I have a 3D cube that i can move around with my Keys. So if i do that and the Cube reaches the border of the Screen(or Form in window-mode) it doesn’t stop and goes on until its gone.
So how can i set borders for my screen?
Is there a OpenGL-Function to set this?
The short answer to your question is no' - there is not border function such as you describe. This is perhaps a problem withcollision detection’ in that you must check to see whether or not the cube is still within the viewing frustum after you have moved its position.
Do a search on frustum intersections with cube on google or something.
If you want to keep it for going of the screen then setup a boundry like this.
example:
if ( cube_x > x_boundry_right) cube_x = x_boundry_right;
if ( cube_x < x_boundry_left) cube_x = x_boundry_left;
repeat check for y and z.
If you want to just bounce around the screen, then add a direction varible.
if (cube_x > x_boundry_right) cube_direction = Left; // if hit right boundry, move now to the left
hope this helps
Originally posted by Clouddancer:
[b]Hello!
I am programming with Borland C++ Builder5.
I have a 3D cube that i can move around with my Keys. So if i do that and the Cube reaches the border of the Screen(or Form in window-mode) it doesn’t stop and goes on until its gone.
So how can i set borders for my screen?
Is there a OpenGL-Function to set this?