Ejemplo n.º 1
0
NzBoxf NzBaseGeom::ComputeAABB(const NzMatrix4f& offsetMatrix) const
{
	NzVector3f min, max;
	NewtonCollisionCalculateAABB(m_collision, offsetMatrix, min, max);

	return NzBoxf(min, max);
}
Ejemplo n.º 2
0
NzBoxf NzBaseGeom::ComputeAABB(const NzVector3f& translation, const NzQuaternionf& rotation, const NzVector3f& scale) const
{
	NzVector3f min, max;
	NewtonCollisionCalculateAABB(m_collision, NzMatrix4f::Transform(translation, rotation), min, max);

	// Et on applique le scale à la fin
	return NzBoxf(scale*min, scale*max);
}
Ejemplo n.º 3
0
SCENARIO("Frustum", "[MATH][FRUSTUM]")
{
	GIVEN("One frustum (90, 1, 1, 1000, (0, 0, 0), (1, 0, 0))")
	{
		NzFrustumf frustum;
		frustum.Build(NzFromDegrees(90.f), 1.f, 1.f, 1000.f, NzVector3f::Zero(), NzVector3f::UnitX());

		WHEN("We ask for intersection with objects outside the frustum")
		{
			THEN("These results are expected")
			{
				NzBoundingVolumef bv(NzVector3f::Zero(), NzVector3f::Unit());
				bv.Update(NzMatrix4f::Identity());
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(bv));
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(NzBoxf(NzVector3f::Zero(), NzVector3f::Unit() * 0.9f)));
				NzOrientedBoxf obb(NzVector3f::Zero(), NzVector3f::Unit() * 0.9f);
				obb.Update(NzMatrix4f::Identity());
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(obb));
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(NzSpheref(NzVector3f::Zero(), 0.5f)));
				NzVector3f tmp = NzVector3f::Zero();
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(&tmp, 1));
				tmp = NzVector3f::UnitX() * -10.f;
				REQUIRE(nzIntersectionSide_Outside == frustum.Intersect(&tmp, 1));
			}
		}

		WHEN("We ask for intersection with objects inside the frustum")
		{
			THEN("These results are expected")
			{