Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Render.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*!
  2. * \file include/Render.h
  3. * \brief OpenRaider Renderer class
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _RENDER_H_
  9. #define _RENDER_H_
  10. #include <vector>
  11. #include "config.h"
  12. #include "math/Matrix.h"
  13. #include "ViewVolume.h"
  14. #include "World.h"
  15. #include "Mesh.h"
  16. #include "Texture.h"
  17. #include "Camera.h"
  18. #include "RoomData.h"
  19. /*!
  20. * \brief OpenRaider Renderer class
  21. */
  22. class Render {
  23. public:
  24. typedef enum {
  25. modeDisabled,
  26. modeLoadScreen,
  27. modeVertexLight,
  28. modeSolid,
  29. modeWireframe,
  30. modeTexture
  31. } RenderMode;
  32. typedef enum {
  33. fRoomAlpha = (1 << 0),
  34. fViewModel = (1 << 1),
  35. fEntityModels = (1 << 2),
  36. fFog = (1 << 3),
  37. fUsePortals = (1 << 4),
  38. fGL_Lights = (1 << 5),
  39. fOneRoom = (1 << 6),
  40. fRenderPonytail = (1 << 7),
  41. // fMultiTexture = (1 << 8), //! \todo Whats up with Multitexture stuff? Where is it needed?
  42. fUpdateRoomListPerFrame = (1 << 9),
  43. fAnimateAllModels = (1 << 10),
  44. fAllRooms = (1 << 11)
  45. } RenderFlags;
  46. /*!
  47. * \brief Constructs an object of Render
  48. */
  49. Render();
  50. /*!
  51. * \brief Deconstructs an object of Render
  52. */
  53. ~Render();
  54. /*!
  55. * \brief Makes a screenshot, writes to disk
  56. * \param filenameBase basename of file to be written
  57. */
  58. void screenShot(char *filenameBase);
  59. /*!
  60. * \brief Gets current rendering mode
  61. * \returns current RenderMode
  62. * \fixme Don't return enum as int?!
  63. */
  64. int getMode();
  65. /*!
  66. * \brief Loads textures in a certain id slot
  67. * \param image Image to load
  68. * \param width width of image
  69. * \param height height of image
  70. * \param id id for texture
  71. * \sa Texture::loadBufferSlot()
  72. */
  73. void loadTexture(unsigned char *image,
  74. unsigned int width, unsigned int height,
  75. unsigned int id);
  76. /*!
  77. * \brief Sets up textures for OpenRaider
  78. * \param textureDir Is valid and exists with textures
  79. * \returns number of loaded textures
  80. */
  81. int initTextures(char *textureDir);
  82. /*!
  83. * Removes current world/entity/etc geometry
  84. */
  85. void ClearWorld();
  86. /*!
  87. * \brief Clears bitflags, changes state of renderer in some way
  88. * \param flags RenderFlags to clear (ORed)
  89. * \fixme use enum not integer as parameter?!
  90. */
  91. void clearFlags(unsigned int flags);
  92. /*!
  93. * \brief Sets bitflags, changes state of renderer in some way
  94. * \param flags RenderFlags to set (ORed)
  95. * \fixme use enum not integer as parameter?!
  96. */
  97. void setFlags(unsigned int flags);
  98. void setMode(int n);
  99. /*!
  100. * \brief Renders a single game frame
  101. */
  102. void display();
  103. void setSkyMesh(int index, bool rot);
  104. unsigned int getFlags();
  105. /*!
  106. * \brief Check if a point is in the View Volume
  107. * \param x X coordinate
  108. * \param y Y coordinate
  109. * \param z Z coordinate
  110. * \returns true if point is visible
  111. */
  112. bool isVisible(float x, float y, float z);
  113. /*!
  114. * \brief Check if a sphere is in the View Volume
  115. * \param x X coordinate of center of sphere
  116. * \param y Y coordinate of center of sphere
  117. * \param z Z coordinate of center of sphere
  118. * \param radius radius of sphere
  119. * \returns true if sphere is visible
  120. */
  121. bool isVisible(float x, float y, float z, float radius);
  122. bool isVisible(BoundingBox &box);
  123. /*!
  124. * \brief Renders a mesh.
  125. *
  126. * Texture must be initialized.
  127. * \param r_mesh Mesh to render.
  128. */
  129. void drawModelMesh(model_mesh_t *r_mesh);
  130. //! \fixme should be private
  131. ViewVolume mViewVolume; //!< View Volume for frustum culling
  132. Texture mTexture; //!< Texture subsystem
  133. private:
  134. void drawLoadScreen();
  135. /*!
  136. * \brief Build a visible room list starting at index
  137. * \param index valid room index where to start the list
  138. */
  139. void newRoomRenderList(int index);
  140. /*!
  141. * \brief Build a visible room list starting from room and
  142. * only considers its linked rooms and their linked rooms.
  143. * \param room First room in list
  144. */
  145. void buildRoomRenderList(Room &room);
  146. /*!
  147. * \brief Renders visible world object.
  148. *
  149. * Texture must be initialized.
  150. */
  151. void drawObjects();
  152. /*!
  153. * \brief Renders Sky domes/boxes/etc by scaling factor.
  154. *
  155. * Texture must be initialized.
  156. * \param scale correct scale for map size
  157. */
  158. void drawSkyMesh(float scale);
  159. /*!
  160. * \brief Renders a skeletal model.
  161. *
  162. * Texture must be initialized!
  163. * \param model model to render
  164. */
  165. void drawModel(SkeletalModel *model);
  166. /*!
  167. * \brief Updates View Volume. Call once per render frame.
  168. */
  169. void updateViewVolume();
  170. //! \fixme Let them eat cake...? O.o
  171. void tmpRenderModelMesh(model_mesh_t *r_mesh, texture_tri_t *ttri);
  172. std::vector<Room *> mRoomRenderList;
  173. unsigned int mFlags; //!< Rendering flags
  174. unsigned int mMode; //!< Rendering mode
  175. int mLock;
  176. int mSkyMesh; //!< Skymesh model id
  177. bool mSkyMeshRotation; //!< Should Skymesh be rotated?
  178. };
  179. #endif