Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Render.h 5.3KB

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