Collision Detection in a rotating world (glRotate)

Started by
1 comment, last by Blackkata 18 years ago
Hello, In the current project Im working on current I am making a computer version of this physical (not video game) labyrinth. Its a small maze that a person would hold in their hand. There was a little ball in the maze and the goal of the game was/is to tilt to the board around until you can navigate the ball into a hole in the board. If it helps this ia link to something i think resembles the old physical game: http://www.growingtreetoys.com/product/5239 in that picture you rotate the dark brown nobs to rotate the board inside of the box and you have to try to navigate the ball to the right hole. Im using Opengl and I have the maze drawn in 3d and the maze rotates around the x and z axies when the user presses the up/down or left/right keys repsectivly. my code is something like this ... glPushMatrix(); glRotate3f(current_angle); drawMaze(maze_vertices); glPopMatrix(); ... this works well visualy but now Ive come to the problem that I need to do collision detection. Ive done collision detection in a world that doesnt move but now the board is rotating. The ball is stored in the same coordinate system as the maze but once you rotate using glRotate() the coordiantes in maze_vertices array no long are the actually coordinates of where its drawn on screen. I tried to transform the actual coordinates instead of using glRotate3f() , something along the lines of ... transformed_maze_vertices.x = maze_vertices.x transformed_maze_vertices.y = maze_vertices.y * sin + maze_vertices.z * cos ... but tranforming the vertices every frame seemed to drop the frame rate noticably. So in short Im asking: How do you do collision detection in a world that moves around using glRotate()? Just so more informatin in case it helps: I am moving the ball using Runga Kutta, Im trying to simulate real physics for the ball moving around in the maze. The ball is contained in the maze (so theres a bottom and a cover on it) so it cant bounce out or anything) Thank you for your time
Advertisement
Using normal vector math, rotate the direction of gravity inverse to the rotation of the maze, and do collision as normal.
Thank you very much your idea worked great

This topic is closed to new replies.

Advertisement