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
 40class BaseMatInstance;
 41
 42
 43namespace SimPath
 44{
 45
 46//--------------------------------------------------------------------------
 47/// A path!
 48class Path : public SimGroup
 49{
 50   typedef SimGroup Parent;
 51
 52  public:
 53   enum : <a href="/coding/file/types_8h/#types_8h_1ac3df7cf3c8cb172a588adec881447d68">U32</a>
 54   {
 55      NoPathIndex = 0xFFFFFFFF
 56   };
 57
 58
 59  private:
 60   U32 mPathIndex;
 61   bool mIsLooping;
 62
 63  protected:
 64   bool onAdd();
 65   void onRemove();
 66
 67  public:
 68   Path();
 69   ~Path();
 70
 71   void addObject(SimObject*);
 72   void removeObject(SimObject*);
 73
 74   void sortMarkers();
 75   void updatePath();
 76   bool isLooping() { return mIsLooping; }
 77   U32 getPathIndex() const;
 78
 79   DECLARE_CONOBJECT(Path);
 80   static void initPersistFields();
 81};
 82
 83//--------------------------------------------------------------------------
 84//--------------------------------------------------------------------------
 85inline U32 Path::getPathIndex() const
 86{
 87   return mPathIndex;
 88}
 89
 90} // Namespace
 91
 92
 93//--------------------------------------------------------------------------
 94class Marker : public SceneObject
 95{
 96   typedef SceneObject Parent;
 97   friend class Path;
 98
 99  public:
100   enum SmoothingType
101   {
102      SmoothingTypeLinear,
103      SmoothingTypeSpline,
104      SmoothingTypeAccelerate,
105   };
106
107   enum KnotType
108   {
109      KnotTypeNormal,
110      KnotTypePositionOnly,
111      KnotTypeKink,
112   };
113
114
115   U32   mSeqNum;
116   U32   mSmoothingType;
117   U32   mKnotType;
118
119   U32   mMSToNext;
120
121   // Rendering
122  protected:
123   void prepRenderImage(SceneRenderState *state);
124   void renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance* overrideMat);
125
126  protected:
127   bool onAdd();
128   void onRemove();
129   void onGroupAdd();
130
131   void onEditorEnable();
132   void onEditorDisable();
133   
134   static void initGFXResources();
135
136   static GFXStateBlockRef smStateBlock;
137   static GFXVertexBufferHandle<GFXVertexPCT> smVertexBuffer;
138   static GFXPrimitiveBufferHandle smPrimitiveBuffer;
139
140  public:
141   Marker();
142   ~Marker();
143
144   DECLARE_CONOBJECT(Marker);
145   static void initPersistFields();
146   void inspectPostApply();
147
148   U32  packUpdate  (NetConnection *conn, U32 mask, BitStream *stream);
149   void unpackUpdate(NetConnection *conn,           BitStream *stream);
150};
151
152typedef Marker::SmoothingType MarkerSmoothingType;
153typedef Marker::KnotType MarkerKnotType;
154
155DefineEnumType( MarkerSmoothingType );
156DefineEnumType( MarkerKnotType );
157
158#endif // _H_PATH
159
160