OpenClonk
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

◆ TransformNormalVector()

StdMeshVector OgreToClonk::TransformNormalVector ( const StdMeshVector vector)

Definition at line 72 of file StdMeshLoader.cpp.

73 {
74  return OgreToClonkInverseTranspose * vector;
75 }

Referenced by TransformVertex().

Here is the caller graph for this function:

◆ TransformPseudoVector()

StdMeshVector OgreToClonk::TransformPseudoVector ( const StdMeshVector vector)

Definition at line 65 of file StdMeshLoader.cpp.

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 }

Referenced by TransformQuaternion().

Here is the caller graph for this function:

◆ TransformQuaternion()

StdMeshQuaternion OgreToClonk::TransformQuaternion ( const StdMeshQuaternion quaternion)

Definition at line 90 of file StdMeshLoader.cpp.

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)

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

Referenced by TransformTransformation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransformScaleVector()

StdMeshVector OgreToClonk::TransformScaleVector ( const StdMeshVector vector)

Definition at line 77 of file StdMeshLoader.cpp.

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 }
static StdMeshMatrix Scale(float sx, float sy, float sz)

References StdMeshMatrix::Scale(), StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

Referenced by TransformTransformation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransformTransformation()

StdMeshTransformation OgreToClonk::TransformTransformation ( const StdMeshTransformation trans)

Definition at line 132 of file StdMeshLoader.cpp.

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 TransformVector(const StdMeshVector &vector)
StdMeshVector TransformScaleVector(const StdMeshVector &vector)
StdMeshQuaternion TransformQuaternion(const StdMeshQuaternion &quaternion)
StdMeshVector translate
Definition: StdMeshMath.h:76
StdMeshQuaternion rotate
Definition: StdMeshMath.h:75
StdMeshVector scale
Definition: StdMeshMath.h:74

References StdMeshTransformation::rotate, StdMeshTransformation::scale, TransformQuaternion(), TransformScaleVector(), TransformVector(), and StdMeshTransformation::translate.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransformVector()

StdMeshVector OgreToClonk::TransformVector ( const StdMeshVector vector)

Definition at line 60 of file StdMeshLoader.cpp.

61 {
62  return OgreToClonkMatrix * vector;
63 }

Referenced by TransformTransformation(), and TransformVertex().

Here is the caller graph for this function:

◆ TransformVertex()

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

Definition at line 108 of file StdMeshLoader.cpp.

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)

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().

Here is the call graph for this function:
Here is the caller graph for this function: