OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
OgreToClonk Namespace Reference

Functions

StdMeshVector TransformVector (const StdMeshVector &vector)
 
StdMeshVector TransformPseudoVector (const StdMeshVector &vector)
 
StdMeshVector TransformNormalVector (const StdMeshVector &vector)
 
StdMeshVector TransformScaleVector (const StdMeshVector &vector)
 
StdMeshQuaternion TransformQuaternion (const StdMeshQuaternion &quaternion)
 
StdSubMesh::Vertex TransformVertex (const StdSubMesh::Vertex &vertex)
 
StdMeshTransformation TransformTransformation (const StdMeshTransformation &trans)
 

Function Documentation

StdMeshVector OgreToClonk::TransformNormalVector ( const StdMeshVector vector)

Definition at line 73 of file StdMeshLoader.cpp.

Referenced by TransformVertex().

74 {
75  return OgreToClonkInverseTranspose * vector;
76 }

Here is the caller graph for this function:

StdMeshVector OgreToClonk::TransformPseudoVector ( const StdMeshVector vector)

Definition at line 66 of file StdMeshLoader.cpp.

Referenced by TransformQuaternion().

67 {
68  // TODO: This works only for improper rotations... otherwise it might be better
69  // to write vector as an antisymmetric tensor and do the matrix transform.
70  return OgreToClonkDeterminant * (OgreToClonkMatrix * vector);
71 }

Here is the caller graph for this function:

StdMeshQuaternion OgreToClonk::TransformQuaternion ( const StdMeshQuaternion &  quaternion)

Definition at line 91 of file StdMeshLoader.cpp.

References TransformPseudoVector(), StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

Referenced by TransformTransformation().

92 {
93  StdMeshVector axis;
94  axis.x = quaternion.x;
95  axis.y = quaternion.y;
96  axis.z = quaternion.z;
97 
98  StdMeshVector transformed = TransformPseudoVector(axis);
99 
100  StdMeshQuaternion result;
101  result.w = quaternion.w;
102  result.x = transformed.x;
103  result.y = transformed.y;
104  result.z = transformed.z;
105 
106  return result;
107 }
StdMeshVector TransformPseudoVector(const StdMeshVector &vector)

Here is the call graph for this function:

Here is the caller graph for this function:

StdMeshVector OgreToClonk::TransformScaleVector ( const StdMeshVector vector)

Definition at line 78 of file StdMeshLoader.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

Referenced by TransformTransformation().

79 {
80  // TODO: Check we didn't introduce shear components
81  StdMeshMatrix scale = StdMeshMatrix::Scale(vector.x, vector.y, vector.z);
82  StdMeshMatrix transformed = OgreToClonkMatrix * scale * OgreToClonkInverse;
83 
84  StdMeshVector result;
85  result.x = transformed(0,0);
86  result.y = transformed(1,1);
87  result.z = transformed(2,2);
88  return result;
89 }

Here is the caller graph for this function:

StdMeshTransformation OgreToClonk::TransformTransformation ( const StdMeshTransformation &  trans)

Definition at line 133 of file StdMeshLoader.cpp.

References TransformQuaternion(), TransformScaleVector(), and TransformVector().

Referenced by StdMeshSkeletonLoader::LoadSkeletonBinary(), and StdMeshSkeletonLoader::LoadSkeletonXml().

134 {
135  StdMeshTransformation result;
136  result.scale = TransformScaleVector(trans.scale);
137  result.rotate = TransformQuaternion(trans.rotate);
138  result.translate = TransformVector(trans.translate);
139 
140  // Consistency check:
141  /*StdMeshMatrix matrix = StdMeshMatrix::Transform(trans);
142  matrix = OgreToClonk * matrix * OgreToClonkInverse;
143 
144  StdMeshMatrix matrix2 = StdMeshMatrix::Transform(result);
145  for(int i = 0; i < 3; ++i)
146  for(int j = 0; j < 4; ++j)
147  assert(fabs(matrix(i,j) - matrix2(i,j)) < 1e-3);*/
148 
149  return result;
150 }
StdMeshVector TransformScaleVector(const StdMeshVector &vector)
StdMeshQuaternion TransformQuaternion(const StdMeshQuaternion &quaternion)
StdMeshVector TransformVector(const StdMeshVector &vector)

Here is the call graph for this function:

Here is the caller graph for this function:

StdMeshVector OgreToClonk::TransformVector ( const StdMeshVector vector)

Definition at line 61 of file StdMeshLoader.cpp.

Referenced by TransformTransformation(), and TransformVertex().

62 {
63  return OgreToClonkMatrix * vector;
64 }

Here is the caller graph for this function:

StdSubMesh::Vertex OgreToClonk::TransformVertex ( const StdSubMesh::Vertex vertex)

Definition at line 109 of file StdMeshLoader.cpp.

References StdMeshVertex::nx, StdMeshVertex::ny, StdMeshVertex::nz, TransformNormalVector(), TransformVector(), StdMeshVector::x, StdMeshVertex::x, StdMeshVector::y, StdMeshVertex::y, StdMeshVector::z, and StdMeshVertex::z.

Referenced by StdMeshLoader::StdMeshXML::LoadGeometry().

110 {
111  StdMeshVector pos, normal;
112  pos.x = vertex.x;
113  pos.y = vertex.y;
114  pos.z = vertex.z;
115  normal.x = vertex.nx;
116  normal.y = vertex.ny;
117  normal.z = vertex.nz;
118 
119  pos = TransformVector(pos);
120  normal = TransformNormalVector(normal);
121 
122  StdSubMesh::Vertex result = vertex;
123  result.x = pos.x;
124  result.y = pos.y;
125  result.z = pos.z;
126  result.nx = normal.x;
127  result.ny = normal.y;
128  result.nz = normal.z;
129 
130  return result;
131 }
StdMeshVector TransformNormalVector(const StdMeshVector &vector)
StdMeshVector TransformVector(const StdMeshVector &vector)

Here is the call graph for this function:

Here is the caller graph for this function: