Oriented Bounding Box
by Daniel Allessi · in Torque Game Engine · 03/31/2005 (3:43 pm) · 13 replies
I recently implemented swimming, which requires me to use a bounding box that has different sizes on X and Y axis. Unfortunately it seems the engine forces player objects to have AABB, which simply won't do. I have looked in depth at buildConvex and buildPolyList for the player class, and even went so far as to make them simply call the shapeBase Parent methods instead. However, no luck.
I need the oriented box as shown in the editor, not the AA version to be the collision volume. Any insights?
I need the oriented box as shown in the editor, not the AA version to be the collision volume. Any insights?
#2
03/31/2005 (4:22 pm)
It's a good idea but I need the oriented box because I'll be having the player character swimming and he's longer than he is wide when swimming, and I also need to not have the box be AA because I will be rotating him on the X axis to pitch him up and down - the collision needs to take that into account as well.
#3
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4348
03/31/2005 (9:08 pm)
Ohh I see you mean like this?http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4348
#4
03/31/2005 (11:35 pm)
That's the resource I implemented, but it suffers from the problem I describe. :(
#5
04/01/2005 (10:53 am)
I need the exact same help.
#6
The demo's player collision code wasn't made with rotations in mind, so you will get bugs while rotating nearby other objects (passing thru them or getting stuck).
Since I *need* non-uniform bounding boxes with rotation support for my game, I'll try to modify the whole player collision stuff to use a rigid instead of a boxConvex.
The rigid class and the collision code in the vehicle classes fully support rotations while solving collisions, so it's just a matter of feeding the rigid a linearVelocity and angularVelocity based on the resulting mVelocity and rotation offset. Maybe I'll also need to remove all that momentum stuff so the player won't bounce around like a vehicle does, and simplify the collision response so the rigid just stops moving/rotating at collision point, with no new forces being applied (to keep the player from probably tripping and falling on the ground - but it would be funny).
04/01/2005 (1:01 pm)
Using an oriented bounding box will give you problems too, sorry.The demo's player collision code wasn't made with rotations in mind, so you will get bugs while rotating nearby other objects (passing thru them or getting stuck).
Since I *need* non-uniform bounding boxes with rotation support for my game, I'll try to modify the whole player collision stuff to use a rigid instead of a boxConvex.
The rigid class and the collision code in the vehicle classes fully support rotations while solving collisions, so it's just a matter of feeding the rigid a linearVelocity and angularVelocity based on the resulting mVelocity and rotation offset. Maybe I'll also need to remove all that momentum stuff so the player won't bounce around like a vehicle does, and simplify the collision response so the rigid just stops moving/rotating at collision point, with no new forces being applied (to keep the player from probably tripping and falling on the ground - but it would be funny).
#7
04/01/2005 (6:11 pm)
Here's another interesting issue: I placed some Con::errorF calls into the first lines of player::buildPolyList and player::buildConvex to try and figure out the exact order of calls, but oddly enough, neither are ever called... yet if you remove them, no more collision.
#8
04/02/2005 (1:47 pm)
They are called - they are the key methods responsible for collision...
#9
04/02/2005 (2:48 pm)
Yeah, as I said, they _have_ to be called, because if you remove them, no more collision. It's just baffling that calls to Con::errorf placed at the very first line of those functions do nothing.
#10
04/02/2005 (3:02 pm)
Btw, Ben, any clue on how I can change the engine to use OBB? It seems like Box3F is hardwired to be AABB only.
#11
Thought I'd ask before I go spend some more time on it. ;)
Edit: You think spelling would be a strong suit for a programmer...
04/03/2005 (5:58 am)
If I create a version of Box3F that stores the actual corner coords instead of a center and min/max, and utilize this new class in Player::buildConvex and Player::buildPolyList, being sure to transform it by the players rotation, would that work?Thought I'd ask before I go spend some more time on it. ;)
Edit: You think spelling would be a strong suit for a programmer...
#12
You can get the corner positions out of Box3F pretty easily. Hmm. Wait, it stores the min/max. You have to do work to get the center/extents out of it. Overall this works pretty well (there's no clear win to be had by changing it to be a center/extent structure, since half the time you want it one way and half the time the other way).
The Convex interface can support a true sphere, while the polylist has to return an approximation if that's what you want. Note that polylist is also used to cast shadows with.
04/03/2005 (9:20 am)
Well, if all you care about is the raycast, you don't have to modify them, right? As for example implementations, I'd suggest checking out, ah, TSStatic, ShapeBase, Interior, and Terrain's implementations.You can get the corner positions out of Box3F pretty easily. Hmm. Wait, it stores the min/max. You have to do work to get the center/extents out of it. Overall this works pretty well (there's no clear win to be had by changing it to be a center/extent structure, since half the time you want it one way and half the time the other way).
The Convex interface can support a true sphere, while the polylist has to return an approximation if that's what you want. Note that polylist is also used to cast shadows with.
#13
04/03/2005 (11:42 am)
Thank you so much Ben. Back to work on the game. :)
Torque Owner Dreamer
Default Studio Name