notesObject.h

Engine/source/T3D/notesObject.h

More...

Classes:

Detailed Description

  1
  2#pragma once
  3
  4#ifndef _SCENEOBJECT_H_
  5#include "scene/sceneObject.h"
  6#endif
  7#ifndef _GFXSTATEBLOCK_H_
  8#include "gfx/gfxStateBlock.h"
  9#endif
 10#ifndef _GFXVERTEXBUFFER_H_
 11#include "gfx/gfxVertexBuffer.h"
 12#endif
 13#ifndef _GFXPRIMITIVEBUFFER_H_
 14#include "gfx/gfxPrimitiveBuffer.h"
 15#endif
 16
 17//-----------------------------------------------------------------------------
 18// This class implements a basic SceneObject that can exist in the world at a
 19// 3D position and render itself. Note that NotesObject handles its own
 20// rendering by submitting itself as an ObjectRenderInst (see
 21// renderInstance\renderPassmanager.h) along with a delegate for its render()
 22// function. However, the preffered rendering method in the engine is to submit
 23// a MeshRenderInst along with a Material, vertex buffer, primitive buffer, and
 24// transform and allow the RenderMeshMgr handle the actual rendering. You can
 25// see this implemented in RenderMeshExample.
 26//-----------------------------------------------------------------------------
 27
 28class NotesObject : public SceneObject
 29{
 30   typedef SceneObject Parent;
 31
 32   String mNote;
 33   bool mShowArrow;
 34   F32 mArrowLength;
 35   F32 mArrowRadius;
 36
 37   LinearColorF mArrowColor;
 38
 39   // Networking masks
 40   // We need to implement at least one of these to allow
 41   // the client version of the object to receive updates
 42   // from the server version (like if it has been moved
 43   // or edited)
 44   enum MaskBits
 45   {
 46      TransformMask = Parent::NextFreeMask << 0,
 47      NextFreeMask = Parent::NextFreeMask << 1
 48   };
 49
 50   //--------------------------------------------------------------------------
 51   // Rendering variables
 52   //--------------------------------------------------------------------------
 53   // Define our vertex format here so we don't have to
 54   // change it in multiple spots later
 55   typedef GFXVertexPCN VertexType;
 56
 57   // The handles for our StateBlocks
 58   GFXStateBlockRef mNormalSB;
 59   GFXStateBlockRef mReflectSB;
 60
 61   // The GFX vertex and primitive buffers
 62   GFXVertexBufferHandle< VertexType> mVertexBuffer;
 63
 64public:
 65   NotesObject();
 66   virtual ~NotesObject();
 67
 68   // Declare this object as a ConsoleObject so that we can
 69   // instantiate it into the world and network it
 70   DECLARE_CONOBJECT(NotesObject);
 71
 72   //--------------------------------------------------------------------------
 73   // Object Editing
 74   // Since there is always a server and a client object in Torque and we
 75   // actually edit the server object we need to implement some basic
 76   // networking functions
 77   //--------------------------------------------------------------------------
 78   // Set up any fields that we want to be editable (like position)
 79   static void initPersistFields();
 80
 81   void inspectPostApply();
 82
 83   // Handle when we are added to the scene and removed from the scene
 84   bool onAdd();
 85   void onRemove();
 86
 87   // Override this so that we can dirty the network flag when it is called
 88   void setTransform(const MatrixF& mat);
 89
 90   // This function handles sending the relevant data from the server
 91   // object to the client object
 92   U32 packUpdate(NetConnection* conn, U32 mask, BitStream* stream);
 93   // This function handles receiving relevant data from the server
 94   // object and applying it to the client object
 95   void unpackUpdate(NetConnection* conn, BitStream* stream);
 96
 97   // This is the function that allows this object to submit itself for rendering
 98   void prepRenderImage(SceneRenderState* state);
 99
100   void _render(ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat);
101
102   String getNote() { return mNote; }
103   bool showArrow() { return mShowArrow; }
104};
105