Advertisement

A couple of questions about cubes

Started by April 09, 2002 10:15 AM
2 comments, last by Feblex 22 years, 10 months ago
I''m currently developing a game that features a spinning cube (texture mapped) and I have a couple questions I can''t seem to find the answer for. 1. I can''t figure out how to make the cube pause for a couple seconds every 90 degree rotation 2. This one is really stumping me. How can I figure what which face of the cube is facing the camera? I need this because I have 4 images on either side of the cube and need to return a value about which picture is facing the camera when the space bar is pushed. Mr Bugg
1. if (rotation_angle%90==0) pause_for_a_couple_seconds();

2. Calculate the angle between the normal vector of the face and a vector opposite to the camera's direction. If the angle is small, the face is facing the camera.


[edited by - circuit on April 9, 2002 11:30:18 AM]
Advertisement
Thanks for the help. I still don''t know how to tell which face is facing the camera, though. Is there a way I could assign identifiers to each face, or something? A theory I have is that the texture binded to the quad might be used to identify it. I could check to see what texture was facing the camera. I just have no clue on how to do this.

Mr Bugg
You probably have a variable for the rotation, so
if(rot>-45 && rot<45)
(side selected is the one at 0 degreesP
etc.

and, depending on how fast you rotate the cube every frame, you might not get a rot%90=0;
use this:
prevrot=0;
if(rot>prevrot+90)
{
rot=prevrot+90;
prevrot=rot;
pauseforafewseconds();
}
or something to that effect. If the rotation angle is the same every frame and is divisible by 90, circuit''s example certainly works and is faster.

______________________________
Pretty guy for a white fly.
______________________________Pretty guy for a white fly.

This topic is closed to new replies.

Advertisement