checking the bounding box with my transformations...

I have used from the following transformations to move my environment:

glRotatef( 360 - yrot, 0,1,0 );
glTranslatef( -xpos, -walkbias - 6.0f + beeHeight, -zpos );

In my environment, i have some points that should check their positions. So i have written a function to simulate the above OpenGL transformations:
void PosConvertor(float x, float y, float z)
{

xx=(float)cos(( 360.0 - yrot )* piover180 ) * ( x-xpos) + (float)sin(( 360.0 - yrot )* piover180 )(z -zpos );
yy=y- walkbias - 2;
zz=-(float)sin( ( 360.0 - yrot )
piover180 )* (x -xpos ) + (float)cos( ( 360.0 - yrot )* piover180 ) * ( z -zpos );

}

The function posConvertor is like the OpenGL transformations that i have used in my code. I can check the position of my objects with the function posConvertor. But now i want to create a bounding box and check that if i’m inside this bounding box. But now i don’t know that how i should use from my posConvertor function to check the boundries of my bounding box. Any suggestion?
-Ehsan-

As I just asked you in the beginner forum, could you please tell me if you rewrote the sine and cosine function so that they expect degrees instead of radians ?? If not, what you’ve done is totally wrong, I’m sorry.

Hi Jide
My posConvertor function has no problem. We have used from this function to compute the position of our sounds–Since we have used from the DirectSound to play our 3D sounds. As you know, sin and cos functions accept the radians, not degrees. My problem is about the bounding box.
Note: Are there any OpenGL extensions to find the boundries of the bounding boxes?
Regards
-Ehsan-

Oups sorry, didn’t see that piover180, I should read your topics more slowly in the future. I fill like dumb… I’m sorry again then, forgive me.

No as far as I know there aren’t any GL functions to detect the bounding box of an object.

It is not difficult as long as your object is centered around its origin and the box is axis aligned. Simply get the maximum distance between each axis of your object when it has not rotated at all, so the bounding box will be axis aligned (AABB).

After that, you’ll have to rotate the box according to the angles you have, then translate it. You’ll have to do some maths to detect if you’re inside the BB when it has rotated.

If you talk about collision detection, then the easiest thing for that is to detect how near you’re from each segment of the box. If you need to detect if you’re inside (as you stippled), then you can get the sign of the equation of 2 opposite segments: if they are not the same, then you are between those 2 segments. Do the same for all the other segment-couples.

Hope that helps.

You want to check whether a point is inside a bounding volume or not? If this is the problem then it has got nothing to do with OpenGL, or am i missing something here :confused: ?
Btw, is your bounding box axis-aligned or not? In case its an AABB then there is a very simple test to check this. In an OBB case the check is essentially the same, except that you now have to transform your point to a coordinate space in which OBB will become an AABB. Needless to say, this would be the orientation matrix of the OBB.

… Or you can model the OBB as a set of six planes, so that you can test points against it without having to do another transformation.

Either way, this has nothing to do with OpenGL.