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

#include <PhysicsFrameSpline.h>

Public Member Functions

 PhysicsFrameSpline ()
 
 PhysicsFrameSpline (const Any &any)
 
bool operator== (const PhysicsFrameSpline &a) const
 
bool operator!= (const PhysicsFrameSpline &a) const
 
void scaleControlPoints (float scaleFactor)
 
virtual void correct (PhysicsFrame &frame) const
 
virtual void ensureShortestPath (PhysicsFrame *A, int N) const
 
virtual Any toAny (const std::string &myName) const override
 
Any toAny () const
 
- Public Member Functions inherited from G3D::Spline< PhysicsFrame >
 Spline ()
 
 Spline (const Any &any)
 
void append (float t, const PhysicsFrame &c)
 
void append (const PhysicsFrame &c)
 
void clear ()
 
int size () const
 
void getControl (int i, float &t, PhysicsFrame &c) const
 
PhysicsFrame 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
 

Additional Inherited Members

- Static Public Member Functions inherited from G3D::SplineBase
static Matrix4 computeBasis ()
 
- Public Attributes inherited from G3D::Spline< PhysicsFrame >
Array< PhysicsFramecontrol
 
- Public Attributes inherited from G3D::SplineBase
Array< float > time
 
SplineExtrapolationMode extrapolationMode
 
float finalInterval
 
SplineInterpolationMode interpolationMode
 
- Protected Member Functions inherited from G3D::Spline< PhysicsFrame >
void getControls (int i, float *T, PhysicsFrame *A, int N) const
 
virtual void init (AnyTableReader &propertyTable)
 
- Protected Member Functions inherited from G3D::SplineBase
void computeIndexInBounds (float s, int &i, float &u) const
 
- Protected Attributes inherited from G3D::Spline< PhysicsFrame >
PhysicsFrame zero
 

Detailed Description

A subclass of Spline that keeps the rotation field of a PhysicsFrame normalized and rotating the short direction.

See also
UprightFrameSpline

Constructor & Destructor Documentation

G3D::PhysicsFrameSpline::PhysicsFrameSpline ( )
13 {}
G3D::PhysicsFrameSpline::PhysicsFrameSpline ( const Any any)

Accepts a table of properties, or any valid PhysicsFrame specification for a single control

16  {
17  if (beginsWith(any.name(), "PFrameSpline") ||
18  beginsWith(any.name(), "PhysicsFrameSpline") ||
19  beginsWith(any.name(), "CFrameSpline") ||
20  beginsWith(any.name(), "CoordinateFrameSpline") ||
21  beginsWith(any.name(), "UprightSpline") ||
22  beginsWith(any.name(), "UprightFrameSpline")) {
23  AnyTableReader t(any);
24  init(t);
25  t.verifyDone();
26  } else {
27  // Must be a single control point
29  time.append(0);
30  }
31 }
bool beginsWith(const std::string &test, const std::string &pattern)
Returns true if the test string begins with the pattern string.
Definition: stringutils.cpp:81
bool any(float x)
Definition: g3dmath.h:424
Array< float > time
Definition: Spline.h:26
virtual void init(AnyTableReader &propertyTable)
Definition: Spline.h:303
Array< PhysicsFrame > control
Definition: Spline.h:124
void append(const T &value)
Definition: Array.h:583

+ Here is the call graph for this function:

Member Function Documentation

void G3D::PhysicsFrameSpline::correct ( PhysicsFrame A) const
virtual

Normalize or otherwise adjust this interpolated Control.

Reimplemented from G3D::Spline< PhysicsFrame >.

59  {
60  frame.rotation.unitize();
61 }

+ Here is the call graph for this function:

void G3D::PhysicsFrameSpline::ensureShortestPath ( PhysicsFrame A,
int  N 
) const
virtual

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< PhysicsFrame >.

69  {
70  for (int i = 1; i < N; ++i) {
71  const Quat& p = A[i - 1].rotation;
72  Quat& q = A[i].rotation;
73 
74  float cosphi = p.dot(q);
75 
76  if (cosphi < 0) {
77  // Going the long way, so change the order
78  q = -q;
79  }
80  }
81 }

+ Here is the call graph for this function:

bool G3D::PhysicsFrameSpline::operator!= ( const PhysicsFrameSpline a) const
inline
31  {
32  return ! ((*this) == a);
33  }
bool G3D::PhysicsFrameSpline::operator== ( const PhysicsFrameSpline a) const
34  {
35  if ((extrapolationMode == other.extrapolationMode) &&
36  (time.size() == other.size()) &&
37  (finalInterval == other.finalInterval) &&
38  (control.size() == other.control.size())) {
39  // Check actual values
40  for (int i = 0; i < time.size(); ++i) {
41  if (time[i] != other.time[i]) {
42  return false;
43  }
44  }
45 
46  for (int i = 0; i < control.size(); ++i) {
47  if (control[i] != other.control[i]) {
48  return false;
49  }
50  }
51 
52  return true;
53  } else {
54  return false;
55  }
56 }
SplineExtrapolationMode extrapolationMode
Definition: Spline.h:33
float finalInterval
Definition: Spline.h:42
Array< float > time
Definition: Spline.h:26
int size() const
Definition: Array.h:430
Array< PhysicsFrame > control
Definition: Spline.h:124

+ Here is the call graph for this function:

void G3D::PhysicsFrameSpline::scaleControlPoints ( float  scaleFactor)

Mutates all underlying PhysicsFrames by scaling their translation by

Parameters
scaleFactor
63  {
64  for (int i = 0; i < control.size(); ++i) {
65  control[i].translation *= scaleFactor;
66  }
67 }
int size() const
Definition: Array.h:430
Array< PhysicsFrame > control
Definition: Spline.h:124

+ Here is the call graph for this function:

virtual Any G3D::PhysicsFrameSpline::toAny ( const std::string &  myName) const
inlineoverridevirtual

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

Reimplemented from G3D::Spline< PhysicsFrame >.

41  {
42  return Spline<PhysicsFrame>::toAny(myName);
43  }
virtual Any toAny(const std::string &myName) const
Definition: Spline.h:331

+ Here is the call graph for this function:

Any G3D::PhysicsFrameSpline::toAny ( ) const
inline
45  {
46  return toAny("PFrameSpline");
47  }
Any toAny() const
Definition: PhysicsFrameSpline.h:45

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