Soundbomber's picture

3D extents

Does anyone know of a method to calculate the extents for all 3D objects in a scene?
So I want x_min,x_max........z_max calculated by comparing each solid after any transformations.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

@Soundbomber

Why do you want AABBs?

the Fiddler's picture

I'm not Soundbomber, but one advantage of AABBs is dead-simple collision detection.

objarni's picture

.. I know :)

But he does seem to want AABBs, and I ask because this topic was started because of the extents3d computation, which is simple in both OBB and AABB case. OBB is simpler/faster if only thing needed is extents.

For collision detecion AABBs are simpler/faster.

Soundbomber's picture

I only want to calculate the physical extents of my objects so I can fit my scene into the OpenGL control correctly.
(No collision detection needed)
So really I just need to know the minimum and maximum x,y and z values. (After transforms)

the Fiddler's picture

The aforementioned gamasutra articale describes how to calculate the correct AABBs (go to second page).

Soundbomber's picture

As I am applying my transforms to each object as it is rendered, presumably I would have to carry out this calculation at render time also?

the Fiddler's picture

Yes, you have to recalculate AABBs at render time, but only if you rotate an object. Fortunately this is fairly fast.

Soundbomber's picture

Cool. Does OpenTK have a function to multiply a vector by a matrix?

the Fiddler's picture

Yes, Vector3.Transform(). It is a static method.

Use the overload tat takes 3 parameters by reference, as it is much faster.

Soundbomber's picture

Off topic: Is there a way to setup email notification for forum topics?