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 3.8KB

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