mirrorSubObject.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _MIRRORSUBOBJECT_H_
  23. #define _MIRRORSUBOBJECT_H_
  24. #ifndef _INTERIORSUBOBJECT_H_
  25. #include "interior/interiorSubObject.h"
  26. #endif
  27. #include "gfx/gfxTextureHandle.h"
  28. class TextureHandle;
  29. class MirrorSubObject : public InteriorSubObject
  30. {
  31. typedef InteriorSubObject Parent;
  32. public:
  33. U32 mDetailLevel;
  34. U32 mZone;
  35. F32 mAlphaLevel;
  36. Point3F mCentroid;
  37. U32 surfaceCount;
  38. U32 surfaceStart;
  39. private:
  40. bool mInitialized;
  41. GFXTexHandle* mWhite;
  42. MatrixF mReflectionMatrix;
  43. bool isInitialized() const { return mInitialized; }
  44. void setupTransforms();
  45. // ISO overrides
  46. protected:
  47. U32 getSubObjectKey() const;
  48. bool _readISO(Stream&);
  49. bool _writeISO(Stream&) const;
  50. // Render control. A sub-object should return false from renderDetailDependant if
  51. // it exists only at the level-0 detail level, ie, doors, elevators, etc., true
  52. // if should only render at the interiors detail, ie, translucencies.
  53. //SubObjectRenderImage* getRenderImage(SceneRenderState*, const Point3F&);
  54. bool renderDetailDependant() const;
  55. U32 getZone() const;
  56. void noteTransformChange();
  57. InteriorSubObject* clone(InteriorInstance*) const;
  58. // Rendering
  59. protected:
  60. //void renderObject(SceneRenderState*, SceneRenderImage*);
  61. void transformModelview(const U32, const MatrixF&, MatrixF*);
  62. void transformPosition(const U32, Point3F&);
  63. bool computeNewFrustum( const U32 portalIndex,
  64. const Frustum &oldFrustum,
  65. const F64 nearPlane,
  66. const F64 farPlane,
  67. const RectI& oldViewport,
  68. F64 *newFrustum,
  69. RectI& newViewport,
  70. const bool flippedMatrix );
  71. void openPortal(const U32 portalIndex,
  72. SceneRenderState* pCurrState,
  73. SceneRenderState* pParentState);
  74. void closePortal(const U32 portalIndex,
  75. SceneRenderState* pCurrState,
  76. SceneRenderState* pParentState);
  77. void getWSPortalPlane(const U32 portalIndex, PlaneF*);
  78. public:
  79. MirrorSubObject();
  80. ~MirrorSubObject();
  81. DECLARE_CONOBJECT(MirrorSubObject);
  82. static void initPersistFields();
  83. };
  84. #endif // _H_MIRRORSUBOBJECT