Jump to content
  • Advertisement
Sign in to follow this  
marius1930

AABB/OBB

This topic is 3920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to create a simple bounding box collision detection. Now the initial collision detection was working fine, but when objects gets rotated things go wrong. So i've been reading over at http://www.toymaker.info/Games/html/collisions.html I've tried to implement his way of doing it but i just can't seem to succeed... Mainly what baffles me; Every render loop i'm creating a new matrix, a new array of coordinates, etc.. Everything is done over again. Yet the result of D3DXVec3TransformCoord() increases for every frame. (there are no rotations or movement of any kind, two still objects) How can it possibly keep increasing? I've tried normalizing it but all points gets converted to the same coordinates (given an imprecision of 0.00000006) What am i doing wrong here? Or does anyone have a link to a better way of doing it?

Share this post


Link to post
Share on other sites
Advertisement
If you have any bounding volume, or hierarchy of those, you will need to transform the BV along with your object.

For instance, if you have a sphere encased in AABB and you translate it by a vector V, you should also translate its bounding volume, and each node and leaf, if you have it in a hierarchy structure.

Depending on the application you're dealing with, it's often preferable to translate the collider back to the object's original position to reduce the number of operations each frame.

AABB are nice and easy, but they're very crude and space inefficient.
OBB on the other hand give a very good fit, but they take a lot of math to be built.
Other method you might try is the bounding ellipsoids (look it up).

Hope this helps a bit.

Share this post


Link to post
Share on other sites
Well at this point it's just a sample application until i get it right,
got two squares encased in bounding (works fine with AABB obviously)

And trying to create a third square based on the bounding-volume of square-1, to get more of a visual of whats going on.

Seeing how the collision isnt working, figured it would be the best way.
The only transformation is the location, which i also pass into D3DXVec3TransformCoord.

I'll try to find more articles on OBB to gain a better understanding.
Problem though is that everyone talks in theory and can provide little useful code to show for it, found one for VB but it's just too messy to go trough, i prefer the simplicity of c++ ;)

Share this post


Link to post
Share on other sites
I have collision detection of sphere/aabb and aabb/aabb back at home, but I'm not very keen on waving my source around ;-)

In essence, AABB is a box constructed from a vector anchored at minimal xyz vertex, and pointing towards maximum xyz vertex. It is aligned along the space axes, hence the Axis-Aligned.

OBB is a bounding box oriented in a way which would minimize the size of the box around a given object.

Quote:
And trying to create a third square based on the bounding-volume of square-1, to get more of a visual of whats going on.


What do you mean by that? AABB is simply a box from minimal to maximum point.

Unless the object is modifying its geometry during run time, you should construct the volumes only once, and store them inside the object stucture, or inside a hierarchy, if you want to check more precise collision.

I would advise, as usual, to take a piece of paper, a pen, and draw the whole problem on paper, draw all vectors and coordinates, and try to understand the problem at hand, before attempting to implement it.

You would have to be more specific about what your problem is, and no, don't expect people to do your assignment for you ;-)

Ps. If we're talking about the theory of this mechanism, please omit the d3d parts (since some people, myself included, might not know what they do). Describing what you do with the data in theory would be much more helpful.

Share this post


Link to post
Share on other sites
Well actually it's not two squares, it's two 'bounded boxes' created from an object, although the object itself is never rendered.

Quote:
What do you mean by that? AABB is simply a box from minimal to maximum point.

I mean i'm trying to use the method [at link] to create the OBB and display it as a third visual square. (around a non existing object in this case)

It's not an assignment, i'm reading a DirectX book by frank d. luna and he briefly mentioned bounding boxes and spheres, without going into any details.

My "assignment" is to learn how to create a OOB, or any other kind of bounding box capable of handling a rotation.

[edit:fixed]As for the specifics of the problem, right now i'm just wondering how the coordinates of the (intended)OOB can keep increasing when it's being generated from scratch everytime. [/fixed]

As is i've got an array of 8 points, each containing the AABB's min-max values for the respective corner, then calling D3DXVec3TransformCoord with the world matrix to create the OBB.
(followed by discarding every value of the new vector, aside from the highest and lowest point)

Probably my real problem lies in the lack of understanding of D3DXVec3TransformCoord, and should both keep reading on in the book, and re-read the parts on matrices/vectors.

[Edited by - marius1930 on September 27, 2007 7:51:29 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!