simPath.h

Engine/source/scene/simPath.h

More...

Classes:

class
class

Namespaces:

namespace

Public Typedefs

MarkerKnotType 
MarkerSmoothingType 

Detailed Description

Public Typedefs

typedef Marker::KnotType MarkerKnotType 
typedef Marker::SmoothingType MarkerSmoothingType 

Public Functions

DefineEnumType(MarkerKnotType )

DefineEnumType(MarkerSmoothingType )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _SIMPATH_H_
 25#define _SIMPATH_H_
 26
 27#ifndef _SCENEOBJECT_H_
 28#include "scene/sceneObject.h"
 29#endif
 30#ifndef _GFXSTATEBLOCK_H_
 31#include "gfx/gfxStateBlock.h"
 32#endif
 33#ifndef _GFXVERTEXBUFFER_H_
 34#include "gfx/gfxVertexBuffer.h"
 35#endif
 36#ifndef _GFXPRIMITIVEBUFFER_H_
 37#include "gfx/gfxPrimitiveBuffer.h"
 38#endif
 39
 40#ifndef _STATICSHAPE_H_
 41#include "T3D/staticShape.h"
 42#endif
 43
 44class BaseMatInstance;
 45struct PathShapeData;
 46
 47namespace SimPath
 48{
 49
 50//--------------------------------------------------------------------------
 51/// A path!
 52class Path : public GameBase
 53{
 54   typedef GameBase Parent;
 55
 56  public:
 57   enum : <a href="/coding/file/types_8h/#types_8h_1ac3df7cf3c8cb172a588adec881447d68">U32</a>
 58   {
 59      NoPathIndex = 0xFFFFFFFF
 60   };
 61
 62
 63  private:
 64   U32 mPathIndex;
 65   F32 mPathSpeed;
 66   bool mIsLooping;
 67   PathShapeData* mDataBlock;
 68   S32 mSpawnCount;
 69   S32 mMinDelay;
 70   S32 mMaxDelay;
 71  protected:
 72   bool onAdd();
 73   void onRemove();
 74
 75  public:
 76   Path();
 77   ~Path();
 78
 79   void addObject(SimObject*);
 80   void removeObject(SimObject*);
 81
 82   void sortMarkers();
 83   void updatePath();
 84   bool isLooping() { return mIsLooping; }
 85   U32 getPathIndex() const;
 86
 87   DECLARE_CONOBJECT(Path);
 88   static void initPersistFields();
 89   DECLARE_CALLBACK(void, onAdd, (SimObjectId ID));
 90};
 91
 92//--------------------------------------------------------------------------
 93//--------------------------------------------------------------------------
 94inline U32 Path::getPathIndex() const
 95{
 96   return mPathIndex;
 97}
 98
 99} // Namespace
100
101
102//--------------------------------------------------------------------------
103class Marker : public SceneObject
104{
105   typedef SceneObject Parent;
106   friend class Path;
107
108  public:
109   enum SmoothingType
110   {
111      SmoothingTypeLinear,
112      SmoothingTypeSpline,
113      SmoothingTypeAccelerate,
114   };
115
116   enum KnotType
117   {
118      KnotTypeNormal,
119      KnotTypePositionOnly,
120      KnotTypeKink,
121   };
122
123
124   U32   mSeqNum;
125   U32   mSmoothingType;
126   U32   mKnotType;
127
128   U32   mMSToNext;
129
130   // Rendering
131  protected:
132   void prepRenderImage(SceneRenderState *state);
133   void renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance* overrideMat);
134
135  protected:
136   bool onAdd();
137   void onRemove();
138   void onGroupAdd();
139
140   void onEditorEnable();
141   void onEditorDisable();
142   
143   static void initGFXResources();
144
145   static GFXStateBlockRef smStateBlock;
146   static GFXVertexBufferHandle<GFXVertexPCT> smVertexBuffer;
147   static GFXPrimitiveBufferHandle smPrimitiveBuffer;
148
149  public:
150   Marker();
151   ~Marker();
152
153   DECLARE_CONOBJECT(Marker);
154   static void initPersistFields();
155   void inspectPostApply();
156
157   U32  packUpdate  (NetConnection *conn, U32 mask, BitStream *stream);
158   void unpackUpdate(NetConnection *conn,           BitStream *stream);
159};
160
161typedef Marker::SmoothingType MarkerSmoothingType;
162typedef Marker::KnotType MarkerKnotType;
163
164DefineEnumType( MarkerSmoothingType );
165DefineEnumType( MarkerKnotType );
166
167#endif // _H_PATH
168
169