Rotating a Box to orient in the same direction as an object
by Steve Lamperti · in Torque Game Engine · 12/08/2006 (10:32 am) · 6 replies
I have what I think is a simple question. My 3D math is quite fuzzy, but I would guess that what I need to do is fairly straightforward for someone with a better grasp of the math.
I have a box, specifically a Box3F variable, and I need to rotate it so it is oriented in the same direction as a 3D object.
I can call createOrientFromDir to get a vector from the object, but I don't know what the next step should be to use the vector to rotate the box.
There may be a function call that I am missing, or perhaps the code to do this is available somewhere.
If someone could point me in the right direction, I would greatly appreciate it.
I have a box, specifically a Box3F variable, and I need to rotate it so it is oriented in the same direction as a 3D object.
I can call createOrientFromDir to get a vector from the object, but I don't know what the next step should be to use the vector to rotate the box.
There may be a function call that I am missing, or perhaps the code to do this is available somewhere.
If someone could point me in the right direction, I would greatly appreciate it.
#2
Thanks for the answer. I tried the code you suggested, and encountered the fact that the box variable type doesn't have a set transform method. The box is not a 3D object, but just basically a bounding box.
12/08/2006 (11:14 am)
@OrionThanks for the answer. I tried the code you suggested, and encountered the fact that the box variable type doesn't have a set transform method. The box is not a 3D object, but just basically a bounding box.
#3
12/08/2006 (6:16 pm)
Even if youre bounding box is not a 3d object, u can cast that object like a normal shapebase and get the method (setTransform) to fix your problem
#4
I don't believe that that works. I tried casting, and am getting an illegal explicit cast error message from my compiler. The box I have is just a Box3F, and I am not sure it makes sense to cast it it be a shapebase. I would be glad to be wrong, and if I am I would appreciate knowing what the code should look like.
12/11/2006 (9:22 am)
@KoRn3Lius,I don't believe that that works. I tried casting, and am getting an illegal explicit cast error message from my compiler. The box I have is just a Box3F, and I am not sure it makes sense to cast it it be a shapebase. I would be glad to be wrong, and if I am I would appreciate knowing what the code should look like.
#5
Why do you need to rotate this box? Is it for rendering (drawing a bounding box) or for collision?
12/11/2006 (10:32 am)
You can't rotate Box3F. It's an Axis Aligned Bounding Box and does not contain rotation information by itself. I strongly suggest you check it's header file and see it's inner workings: it's nothing more than two points: the minimun and maximun points on the box. If you rotate the min and max points, you'll just end up with a re-scaled box, not a rotated box. Why do you need to rotate this box? Is it for rendering (drawing a bounding box) or for collision?
#6
This is for collision. This is during the updatePos code of the object, and the box is calculated to use in the collision code. The code that calcs the box is based on the mObjBox, and is not reflecting the rotation status of the object.
12/11/2006 (10:49 am)
@Manoel,This is for collision. This is during the updatePos code of the object, and the box is calculated to use in the collision code. The code that calcs the box is based on the mObjBox, and is not reflecting the rotation status of the object.
Associate Orion Elenzil
Real Life Plus
pseudo-code: