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 72 of file StdMeshLoader.cpp.

Referenced by TransformVertex().

73 {
74  return OgreToClonkInverseTranspose * vector;
75 }

Here is the caller graph for this function:

StdMeshVector OgreToClonk::TransformPseudoVector ( const StdMeshVector vector)

Definition at line 65 of file StdMeshLoader.cpp.

Referenced by TransformQuaternion().

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

Here is the caller graph for this function:

StdMeshQuaternion OgreToClonk::TransformQuaternion ( const StdMeshQuaternion &  quaternion)

Definition at line 90 of file StdMeshLoader.cpp.

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

Referenced by TransformTransformation().

91 {
92  StdMeshVector axis;
93  axis.x = quaternion.x;
94  axis.y = quaternion.y;
95  axis.z = quaternion.z;
96 
97  StdMeshVector transformed = TransformPseudoVector(axis);
98 
99  StdMeshQuaternion result;
100  result.w = quaternion.w;
101  result.x = transformed.x;
102  result.y = transformed.y;
103  result.z = transformed.z;
104 
105  return result;
106 }
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 77 of file StdMeshLoader.cpp.

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

Referenced by TransformTransformation().

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

Here is the caller graph for this function:

StdMeshTransformation OgreToClonk::TransformTransformation ( const StdMeshTransformation &  trans)

Definition at line 132 of file StdMeshLoader.cpp.

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

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

133 {
134  StdMeshTransformation result;
135  result.scale = TransformScaleVector(trans.scale);
136  result.rotate = TransformQuaternion(trans.rotate);
137  result.translate = TransformVector(trans.translate);
138 
139  // Consistency check:
140  /*StdMeshMatrix matrix = StdMeshMatrix::Transform(trans);
141  matrix = OgreToClonk * matrix * OgreToClonkInverse;
142 
143  StdMeshMatrix matrix2 = StdMeshMatrix::Transform(result);
144  for(int i = 0; i < 3; ++i)
145  for(int j = 0; j < 4; ++j)
146  assert(fabs(matrix(i,j) - matrix2(i,j)) < 1e-3);*/
147 
148  return result;
149 }
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 60 of file StdMeshLoader.cpp.

Referenced by TransformTransformation(), and TransformVertex().

61 {
62  return OgreToClonkMatrix * vector;
63 }

Here is the caller graph for this function:

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

Definition at line 108 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().

109 {
110  StdMeshVector pos, normal;
111  pos.x = vertex.x;
112  pos.y = vertex.y;
113  pos.z = vertex.z;
114  normal.x = vertex.nx;
115  normal.y = vertex.ny;
116  normal.z = vertex.nz;
117 
118  pos = TransformVector(pos);
119  normal = TransformNormalVector(normal);
120 
121  StdSubMesh::Vertex result = vertex;
122  result.x = pos.x;
123  result.y = pos.y;
124  result.z = pos.z;
125  result.nx = normal.x;
126  result.ny = normal.y;
127  result.nz = normal.z;
128 
129  return result;
130 }
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: