CppRenderClassFile.h.template 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef _@_H_
  2. #define _@_H_
  3. #ifndef _SCENEOBJECT_H_
  4. #include "scene/sceneObject.h"
  5. #endif
  6. #ifndef _GFXVERTEXBUFFER_H_
  7. #include "gfx/gfxVertexBuffer.h"
  8. #endif
  9. #ifndef _GFXPRIMITIVEBUFFER_H_
  10. #include "gfx/gfxPrimitiveBuffer.h"
  11. #endif
  12. class BaseMatInstance;
  13. class @ : public SceneObject
  14. {
  15. typedef SceneObject Parent;
  16. // Networking masks
  17. // We need to implement a mask specifically to handle
  18. // updating our transform from the server object to its
  19. // client-side "ghost". We also need to implement a
  20. // maks for handling editor updates to our properties
  21. // (like material).
  22. enum MaskBits
  23. {
  24. TransformMask = Parent::NextFreeMask << 0,
  25. UpdateMask = Parent::NextFreeMask << 1,
  26. NextFreeMask = Parent::NextFreeMask << 2
  27. };
  28. //--------------------------------------------------------------------------
  29. // Rendering variables
  30. //--------------------------------------------------------------------------
  31. // The name of the Material we will use for rendering
  32. String mMaterialName;
  33. // The actual Material instance
  34. BaseMatInstance* mMaterialInst;
  35. // Define our vertex format here so we don't have to
  36. // change it in multiple spots later
  37. typedef GFXVertexPNT VertexType;
  38. // The GFX vertex and primitive buffers
  39. GFXVertexBufferHandle< VertexType > mVertexBuffer;
  40. GFXPrimitiveBufferHandle mPrimitiveBuffer;
  41. public:
  42. @();
  43. virtual ~@();
  44. // Handle when we are added to the scene and removed from the scene
  45. bool onAdd();
  46. void onRemove();
  47. // Declare this object as a ConsoleObject so that we can
  48. // instantiate it into the world and network it
  49. DECLARE_CONOBJECT(@);
  50. //--------------------------------------------------------------------------
  51. // Object Editing
  52. // Since there is always a server and a client object in Torque and we
  53. // actually edit the server object we need to implement some basic
  54. // networking functions
  55. //--------------------------------------------------------------------------
  56. // Set up any fields that we want to be editable (like position)
  57. static void initPersistFields();
  58. // Allows the object to update its editable settings
  59. // from the server object to the client
  60. virtual void inspectPostApply();
  61. // Override this so that we can dirty the network flag when it is called
  62. void setTransform( const MatrixF &mat );
  63. // This function handles sending the relevant data from the server
  64. // object to the client object
  65. U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
  66. // This function handles receiving relevant data from the server
  67. // object and applying it to the client object
  68. void unpackUpdate( NetConnection *conn, BitStream *stream );
  69. //--------------------------------------------------------------------------
  70. // Object Rendering
  71. // Torque utilizes a "batch" rendering system. This means that it builds a
  72. // list of objects that need to render (via RenderInst's) and then renders
  73. // them all in one batch. This allows it to optimized on things like
  74. // minimizing texture, state, and shader switching by grouping objects that
  75. // use the same Materials.
  76. //--------------------------------------------------------------------------
  77. // Create the geometry for rendering
  78. void createGeometry();
  79. // Get the Material instance
  80. void updateMaterial();
  81. // This is the function that allows this object to submit itself for rendering
  82. void prepRenderImage( SceneRenderState *state );
  83. };
  84. #endif // _@_H_