TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::UprightSpline Class Reference

Shortest-path linear velocity spline for camera positions. Always keeps the camera from rolling. More...

#include <UprightFrame.h>

Public Member Functions

 UprightSpline ()
 
 UprightSpline (const Any &any)
 
virtual Any toAny (const std::string &myName) const override
 
Any toAny () const
 
UprightSplineoperator= (const Any &any)
 
void serialize (class BinaryOutput &b) const
 
void deserialize (class BinaryInput &b)
 
- Public Member Functions inherited from G3D::Spline< UprightFrame >
 Spline ()
 
 Spline (const Any &any)
 
void append (float t, const UprightFrame &c)
 
void append (const UprightFrame &c)
 
void clear ()
 
int size () const
 
void getControl (int i, float &t, UprightFrame &c) const
 
UprightFrame evaluate (float s) const
 
- Public Member Functions inherited from G3D::SplineBase
 SplineBase ()
 
virtual ~SplineBase ()
 
float getFinalInterval () const
 
float duration () const
 
void computeIndex (float s, int &i, float &u) const
 

Protected Member Functions

virtual void ensureShortestPath (UprightFrame *A, int N) const
 
- Protected Member Functions inherited from G3D::Spline< UprightFrame >
void getControls (int i, float *T, UprightFrame *A, int N) const
 
virtual void correct (UprightFrame &A) const
 
virtual void init (AnyTableReader &propertyTable)
 
- Protected Member Functions inherited from G3D::SplineBase
void computeIndexInBounds (float s, int &i, float &u) const
 

Additional Inherited Members

- Static Public Member Functions inherited from G3D::SplineBase
static Matrix4 computeBasis ()
 
- Public Attributes inherited from G3D::Spline< UprightFrame >
Array< UprightFramecontrol
 
- Public Attributes inherited from G3D::SplineBase
Array< float > time
 
SplineExtrapolationMode extrapolationMode
 
float finalInterval
 
SplineInterpolationMode interpolationMode
 
- Protected Attributes inherited from G3D::Spline< UprightFrame >
UprightFrame zero
 

Detailed Description

Shortest-path linear velocity spline for camera positions. Always keeps the camera from rolling.

See also
G3D::UprightSplineManipulator, G3D::UprightFrame

Constructor & Destructor Documentation

G3D::UprightSpline::UprightSpline ( )
117  : Spline<UprightFrame>() {
118 }

+ Here is the caller graph for this function:

G3D::UprightSpline::UprightSpline ( const Any any)
explicit

Constructs an UprightSpline from an Any object.

The Any format for UprightSpline is:

controls = (UprightFrame, ...), times = (##, ...), cyclic = bool

The controls and times arrays must have the same length.

121  {
122  any.verifyName("UprightSpline");
123  any.verifyType(Any::TABLE);
124 
125  extrapolationMode = any["extrapolationMode"];
126 
127  const Any& controlsAny = any["control"];
128  controlsAny.verifyType(Any::ARRAY);
129 
130  control.resize(controlsAny.length());
131  for (int controlIndex = 0; controlIndex < control.length(); ++controlIndex) {
132  control[controlIndex] = controlsAny[controlIndex];
133  }
134 
135  const Any& timesAny = any["time"];
136  timesAny.verifyType(Any::ARRAY);
137 
138  time.resize(timesAny.length());
139  for (int timeIndex = 0; timeIndex < time.length(); ++timeIndex) {
140  time[timeIndex] = timesAny[timeIndex];
141  }
142 }
Definition: Any.h:187
SplineExtrapolationMode extrapolationMode
Definition: Spline.h:33
void resize(size_t n, bool shrinkIfNecessary=true)
Definition: Array.h:490
bool any(float x)
Definition: g3dmath.h:424
Definition: Any.h:187
int length() const
Definition: Array.h:438
Array< float > time
Definition: Spline.h:26
Array< UprightFrame > control
Definition: Spline.h:124

+ Here is the call graph for this function:

Member Function Documentation

void G3D::UprightSpline::deserialize ( class BinaryInput b)
191  {
192  extrapolationMode = SplineExtrapolationMode(b.readInt32());
193 
194  control.resize(b.readInt32());
195  for (int i = 0; i < control.size(); ++i) {
196  control[i].deserialize(b);
197  }
198 
199  if (b.hasMore()) {
200  time.resize(b.readInt32());
201  for (int i = 0; i < time.size(); ++i) {
202  time[i] = b.readFloat32();
203  }
204  debugAssert(time.size() == control.size());
205  } else {
206  // Import legacy path
207  time.resize(control.size());
208  for (int i = 0; i < time.size(); ++i) {
209  time[i] = (float)i;
210  }
211  }
212 }
SplineExtrapolationMode extrapolationMode
Definition: Spline.h:33
void resize(size_t n, bool shrinkIfNecessary=true)
Definition: Array.h:490
Array< float > time
Definition: Spline.h:26
#define debugAssert(exp)
Definition: debugAssert.h:160
int size() const
Definition: Array.h:430
Array< UprightFrame > control
Definition: Spline.h:124

+ Here is the call graph for this function:

virtual void G3D::UprightSpline::ensureShortestPath ( UprightFrame A,
int  N 
) const
inlineprotectedvirtual

Mutates the array of N control points that begins at A. It is useful to override this method by one that wraps the values if they are angles or quaternions for which "shortest path" interpolation is significant.

Reimplemented from G3D::Spline< UprightFrame >.

85  {
87  }
static void unwrapYaw(UprightFrame *a, int N)
Definition: UprightFrame.cpp:72

+ Here is the call graph for this function:

UprightSpline & G3D::UprightSpline::operator= ( const Any any)
171  {
172  *this = UprightSpline(any);
173  return *this;
174 }
bool any(float x)
Definition: g3dmath.h:424
UprightSpline()
Definition: UprightFrame.cpp:117

+ Here is the call graph for this function:

void G3D::UprightSpline::serialize ( class BinaryOutput b) const
177  {
178  b.writeInt32(extrapolationMode);
179 
180  b.writeInt32(control.size());
181  for (int i = 0; i < control.size(); ++i) {
182  control[i].serialize(b);
183  }
184  b.writeInt32(time.size());
185  for (int i = 0; i < time.size(); ++i) {
186  b.writeFloat32(time[i]);
187  }
188 }
SplineExtrapolationMode extrapolationMode
Definition: Spline.h:33
Array< float > time
Definition: Spline.h:26
int size() const
Definition: Array.h:430
Array< UprightFrame > control
Definition: Spline.h:124

+ Here is the call graph for this function:

Any G3D::UprightSpline::toAny ( const std::string &  myName) const
overridevirtual

Note that invoking classes can call setName on the returned value instead of passing a name in.

Reimplemented from G3D::Spline< UprightFrame >.

145  {
146  Any any(Any::TABLE, myName);
147 
148  any["extrapolationMode"] = extrapolationMode;
149 
150  Any controlsAny(Any::ARRAY);
151  for (int controlIndex = 0; controlIndex < control.length(); ++controlIndex) {
152  controlsAny.append(control[controlIndex]);
153  }
154  any["control"] = controlsAny;
155 
156  Any timesAny(Any::ARRAY);
157  for (int timeIndex = 0; timeIndex < time.length(); ++timeIndex) {
158  timesAny.append(Any(time[timeIndex]));
159  }
160  any["time"] = timesAny;
161 
162  return any;
163 }
Definition: Any.h:187
SplineExtrapolationMode extrapolationMode
Definition: Spline.h:33
bool any(float x)
Definition: g3dmath.h:424
Definition: Any.h:187
int length() const
Definition: Array.h:438
Array< float > time
Definition: Spline.h:26
Array< UprightFrame > control
Definition: Spline.h:124

+ Here is the call graph for this function:

Any G3D::UprightSpline::toAny ( ) const
166  {
167  return toAny("UprightSpline");
168 }
Any toAny() const
Definition: UprightFrame.cpp:166

The documentation for this class was generated from the following files: