MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / computeTransform

Method computeTransform

testbed/common/PhysicsObject.cpp:53–75  ·  view source on GitHub ↗

Compute the new transform matrix

Source from the content-addressed store, hash-verified

51
52// Compute the new transform matrix
53openglframework::Matrix4 PhysicsObject::computeTransform(float interpolationFactor,
54 const openglframework::Matrix4& scalingMatrix) {
55
56 // Get the transform of the rigid body
57 rp3d::Transform transform = mBody->getTransform();
58
59 // Interpolate the transform between the previous one and the new one
60 rp3d::Transform interpolatedTransform = rp3d::Transform::interpolateTransforms(mPreviousTransform,
61 transform,
62 interpolationFactor);
63 mPreviousTransform = transform;
64
65 // Compute the transform used for rendering the box
66 rp3d::decimal matrix[16];
67 interpolatedTransform.getOpenGLMatrix(matrix);
68 openglframework::Matrix4 newMatrix(matrix[0], matrix[4], matrix[8], matrix[12],
69 matrix[1], matrix[5], matrix[9], matrix[13],
70 matrix[2], matrix[6], matrix[10], matrix[14],
71 matrix[3], matrix[7], matrix[11], matrix[15]);
72
73 // Apply the scaling matrix to have the correct box dimensions
74 return newMatrix * scalingMatrix;
75}
76
77// Reset the transform
78void PhysicsObject::setTransform(const rp3d::Transform& transform) {

Callers

nothing calls this directly

Calls 1

getOpenGLMatrixMethod · 0.80

Tested by

no test coverage detected