skylight.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 SKYLIGHT_H
  23. #define SKYLIGHT_H
  24. #ifndef REFLECTIONPROBE_H
  25. #include "T3D/lighting/reflectionProbe.h"
  26. #endif
  27. #ifndef _GFXVERTEXBUFFER_H_
  28. #include "gfx/gfxVertexBuffer.h"
  29. #endif
  30. #ifndef _GFXPRIMITIVEBUFFER_H_
  31. #include "gfx/gfxPrimitiveBuffer.h"
  32. #endif
  33. #ifndef _TSSHAPEINSTANCE_H_
  34. #include "ts/tsShapeInstance.h"
  35. #endif
  36. #include "lighting/lightInfo.h"
  37. #ifndef _RENDERPASSMANAGER_H_
  38. #include "renderInstance/renderPassManager.h"
  39. #endif
  40. class BaseMatInstance;
  41. //-----------------------------------------------------------------------------
  42. // This class implements a basic SceneObject that can exist in the world at a
  43. // 3D position and render itself. There are several valid ways to render an
  44. // object in Torque. This class implements the preferred rendering method which
  45. // is to submit a MeshRenderInst along with a Material, vertex buffer,
  46. // primitive buffer, and transform and allow the RenderMeshMgr handle the
  47. // actual setup and rendering for you.
  48. //-----------------------------------------------------------------------------
  49. class Skylight : public ReflectionProbe
  50. {
  51. typedef ReflectionProbe Parent;
  52. private:
  53. //Debug rendering
  54. static bool smRenderSkylights;
  55. public:
  56. Skylight();
  57. virtual ~Skylight();
  58. // Declare this object as a ConsoleObject so that we can
  59. // instantiate it into the world and network it
  60. DECLARE_CONOBJECT(Skylight);
  61. //--------------------------------------------------------------------------
  62. // Object Editing
  63. // Since there is always a server and a client object in Torque and we
  64. // actually edit the server object we need to implement some basic
  65. // networking functions
  66. //--------------------------------------------------------------------------
  67. // Set up any fields that we want to be editable (like position)
  68. static void initPersistFields();
  69. // Allows the object to update its editable settings
  70. // from the server object to the client
  71. virtual void inspectPostApply();
  72. // Handle when we are added to the scene and removed from the scene
  73. bool onAdd();
  74. void onRemove();
  75. // This function handles sending the relevant data from the server
  76. // object to the client object
  77. U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
  78. // This function handles receiving relevant data from the server
  79. // object and applying it to the client object
  80. void unpackUpdate(NetConnection *conn, BitStream *stream);
  81. //--------------------------------------------------------------------------
  82. // Object Rendering
  83. // Torque utilizes a "batch" rendering system. This means that it builds a
  84. // list of objects that need to render (via RenderInst's) and then renders
  85. // them all in one batch. This allows it to optimized on things like
  86. // minimizing texture, state, and shader switching by grouping objects that
  87. // use the same Materials.
  88. //--------------------------------------------------------------------------
  89. virtual void updateProbeParams();
  90. // This is the function that allows this object to submit itself for rendering
  91. void prepRenderImage(SceneRenderState *state);
  92. void setPreviewMatParameters(SceneRenderState* renderState, BaseMatInstance* mat);
  93. };
  94. #endif // _Skylight_H_