Open Source Tomb Raider Engine
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 "TextureManager.h"
  13. #include "ViewVolume.h"
  14. /*!
  15. * \brief OpenRaider Renderer class
  16. */
  17. class Render {
  18. public:
  19. typedef enum {
  20. modeDisabled,
  21. modeLoadScreen,
  22. modeVertexLight,
  23. modeSolid,
  24. modeWireframe,
  25. modeTexture
  26. } RenderMode;
  27. typedef enum {
  28. fRoomAlpha = (1 << 0),
  29. fEntityModels = (1 << 1),
  30. fFog = (1 << 2),
  31. fGL_Lights = (1 << 3),
  32. fRenderPonytail = (1 << 4),
  33. fAnimateAllModels = (1 << 5),
  34. // fMultiTexture = (1 << 6), //! \todo Whats up with Multitexture stuff? Where is it needed?
  35. } RenderFlags;
  36. /*!
  37. * \brief Constructs an object of Render
  38. */
  39. Render();
  40. /*!
  41. * \brief Deconstructs an object of Render
  42. */
  43. ~Render();
  44. /*!
  45. * \brief Makes a screenshot, writes to disk
  46. * \param filenameBase basename of file to be written
  47. */
  48. void screenShot(const char* filenameBase);
  49. /*!
  50. * \brief Gets current rendering mode
  51. * \returns current RenderMode
  52. * \fixme Don't return enum as int?!
  53. */
  54. int getMode();
  55. /*!
  56. * Removes current world/entity/etc geometry
  57. */
  58. void ClearWorld();
  59. /*!
  60. * \brief Clears bitflags, changes state of renderer in some way
  61. * \param flags RenderFlags to clear (ORed)
  62. * \fixme use enum not integer as parameter?!
  63. */
  64. void clearFlags(unsigned int flags);
  65. /*!
  66. * \brief Sets bitflags, changes state of renderer in some way
  67. * \param flags RenderFlags to set (ORed)
  68. * \fixme use enum not integer as parameter?!
  69. */
  70. void setFlags(unsigned int flags);
  71. void setMode(int n);
  72. /*!
  73. * \brief Renders a single game frame
  74. */
  75. void display();
  76. void setSkyMesh(int index, bool rot);
  77. unsigned int getFlags();
  78. /*!
  79. * \brief Check if a point is in the View Volume
  80. * \param x X coordinate
  81. * \param y Y coordinate
  82. * \param z Z coordinate
  83. * \returns true if point is visible
  84. */
  85. bool isVisible(float x, float y, float z);
  86. /*!
  87. * \brief Check if a sphere is in the View Volume
  88. * \param x X coordinate of center of sphere
  89. * \param y Y coordinate of center of sphere
  90. * \param z Z coordinate of center of sphere
  91. * \param radius radius of sphere
  92. * \returns true if sphere is visible
  93. */
  94. bool isVisible(float x, float y, float z, float radius);
  95. bool isVisible(BoundingBox& box);
  96. float getDistToSphereFromNear(float x, float y, float z, float radius);
  97. void debugDisplayTexture(int texture = -1,
  98. TextureManager::TextureStorage s = TextureManager::TextureStorage::GAME,
  99. float x = 0.0f, float y = 0.0f, float w = 256.0f, float h = 256.0f);
  100. void debugDisplayTextile(int texture = -1,
  101. float x = 0.0f, float y = 0.0f, float w = 64.0f, float h = 64.0f);
  102. private:
  103. void drawTexture(float x, float y, float w, float h,
  104. unsigned int texture, TextureManager::TextureStorage s);
  105. void drawTextile(float x, float y, float w, float h, unsigned int textile);
  106. static void lightRoom(Room& room);
  107. void drawLoadScreen();
  108. /*!
  109. * \brief Build a visible room list starting at index
  110. * \param index valid room index where to start the list
  111. */
  112. void newRoomRenderList(int index);
  113. /*!
  114. * \brief Build a visible room list starting from room and
  115. * only considers its linked rooms and their linked rooms.
  116. * \param room First room in list
  117. */
  118. void buildRoomRenderList(Room& room);
  119. /*!
  120. * \brief Renders Sky domes/boxes/etc by scaling factor.
  121. *
  122. * Texture must be initialized.
  123. * \param scale correct scale for map size
  124. */
  125. void drawSkyMesh(float scale);
  126. /*!
  127. * \brief Updates View Volume. Call once per render frame.
  128. */
  129. void updateViewVolume();
  130. std::vector<Room*> mRoomRenderList;
  131. ViewVolume mViewVolume; //!< View Volume for frustum culling
  132. unsigned int mFlags; //!< Rendering flags
  133. unsigned int mMode; //!< Rendering mode
  134. int mLock;
  135. int mSkyMesh; //!< Skymesh model id
  136. bool mSkyMeshRotation; //!< Should Skymesh be rotated?
  137. int debugTexture, debugTextile;
  138. TextureManager::TextureStorage debugTextureStorage;
  139. float debugX, debugY, debugW, debugH;
  140. };
  141. Render& getRender();
  142. #endif