From e2a9084df152700af8926a6b1ab5b6b374649f58 Mon Sep 17 00:00:00 2001 From: Irlan <-> Date: Sun, 23 Sep 2018 13:20:57 -0300 Subject: [PATCH] convert transform to affine matrix --- include/bounce/common/math/transform.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/bounce/common/math/transform.h b/include/bounce/common/math/transform.h index 7169251..13a9101 100644 --- a/include/bounce/common/math/transform.h +++ b/include/bounce/common/math/transform.h @@ -20,6 +20,7 @@ #define B3_TRANSFORM_H #include +#include #include // A transform represents a rigid frame. @@ -59,6 +60,16 @@ struct b3Transform // Identity transformation extern const b3Transform b3Transform_identity; +// Convert a transform to a 4-by-4 transformation matrix. +inline b3Mat44 b3TransformMat44(const b3Transform& T) +{ + return b3Mat44( + b3Vec4(T.rotation.x.x, T.rotation.x.y, T.rotation.x.z, 0.0f), + b3Vec4(T.rotation.y.x, T.rotation.y.y, T.rotation.y.z, 0.0f), + b3Vec4(T.rotation.z.x, T.rotation.z.y, T.rotation.z.z, 0.0f), + b3Vec4(T.position.x, T.position.y, T.position.z, 1.0f)); +} + // Multiply a transform times a vector. inline b3Vec3 b3Mul(const b3Transform& T, const b3Vec3& v) {