checking the binding 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 binding box and check that if i’m inside this binding box. But now i don’t know that how i should use from my posConvertor function to check the boundries of my binding box. Any suggestion?

I guess you meant bounding box, not binding box. Didn’t you ?

A bounding box is a box that surrounds all the object. I don’t know what a binding box could be.

Simply draw your bounding box without the transformations, and them apply the same transformations to your bounding box than your object, that turns out. But maybe I didn’t really understood what you meant.

Also, I don’t understand your ‘360 - x’ you use. Almost when used inside sine and cosines functions. Did you rewrite those functions for them expecting degrees instead of radians ? :confused:

This can get complex, because you’re talking about a bounding box which can presumably have a completely arbitrary value of rotation.

You first need to write a function which actually calculates the coordinates of your bounding box from the object’s list of vertices (i.e., take the smallest and largest x, y, z values in your list of vertices and construct the boundaries of your box from these).

You then need to work out where your box will be after any rotations you’re applying to it, using the routine you posted above.

And finally, you then need to test if your own position resides within the boundaries of this box - which is the tricky part. :slight_smile:

I suggest you post on the Advanced Forum for that part, as it’s not that straightforward. :slight_smile:

Yes Jide. I mean bounding box :rolleyes: I want to detect that if i’m inside a specified bounding box. I’ll write this question in the advanced forum.

I just guess this is not so advanced like that, countrary to what Danny told you. This is even not from GL, but only related to 3D programming.

We’ll see what the moderators will say.