void GraphicsWorld::DebugDrawFloat3x4(const float3x4 &t, float axisLength, float boxSize, const Color &clr, bool depthTest)
{
    AABB aabb(float3::FromScalar(-boxSize/2.f), float3::FromScalar(boxSize/2.f));
    OBB obb = aabb.Transform(t);
    DebugDrawOBB(obb, clr);
    DebugDrawLineSegment(LineSegment(t.TranslatePart(), t.TranslatePart() + axisLength * t.Col(0)), 1, 0, 0, depthTest);
    DebugDrawLineSegment(LineSegment(t.TranslatePart(), t.TranslatePart() + axisLength * t.Col(1)), 0, 1, 0, depthTest);
    DebugDrawLineSegment(LineSegment(t.TranslatePart(), t.TranslatePart() + axisLength * t.Col(2)), 0, 0, 1, depthTest);
}
Beispiel #2
0
/// See Eric Lengyel's Mathematics for 3D Game Programming And Computer Graphics 2nd ed., p.110, chapter 4.2.3.
void Plane::Transform(const float3x4 &transform)
{
    ///\todo Could optimize this function by switching to plane convention ax+by+cz+d=0 instead of ax+by+cz=d.
    float3x3 r = transform.Float3x3Part();
    bool success = r.Inverse(); ///\todo Can optimize the inverse here by assuming orthogonality or orthonormality.
    assume(success);
    d = d + Dot(normal, r * transform.TranslatePart());
    normal = normal * r;
}
Beispiel #3
0
void Frustum::SetWorldMatrix(const float3x4 &worldTransform)
{
	pos = worldTransform.TranslatePart();
	if (handedness == FrustumRightHanded)
		front = -worldTransform.Col(2); // The camera looks towards -Z axis of the given transform.
	else
		front = worldTransform.Col(2); // The camera looks towards +Z axis of the given transform.
	up = worldTransform.Col(1); // The camera up points towards +Y of the given transform.
	assume(pos.IsFinite());
	assume(front.IsNormalized());
	assume(up.IsNormalized());
	assume(worldTransform.IsColOrthogonal3()); // Front and up must be orthogonal to each other.
	assume(EqualAbs(worldTransform.Determinant(), 1.f)); // The matrix cannot contain mirroring.
}