I've added an agent to the maze--for now, a simple white arrow. Its intention is to point in the direction that a more complicated model would be facing (i.e. going "forward" will put a force on the agent in the arrow's direction). I've mapped keys for moving forward and backward, and rotating clockwise and counter-clockwise (in the x/y plane).
It's a simple enough matter to use OpenGL to display a rotated arrow. So far, the rendering sequence is:
- Translate the scene according to the camera position.
- Draw the maze in its own coordinate space.
- Translate the scene according to the agent position.
- Rotate the scene according to the agent rotation.
- Draw the agent in its own coordinate space.
So far, I have not been able to determine a standard way in OpenGL to determine the vector resulting from a rotation. It appears I will have to implement my own rotation functionality, which means adding a matrix class (with all the appropriate bells and whistles). With as much math as I'm re-implementing, I'm sure it would be easier to find and use someone else's math library. I'm taking it as a personal challenge, however, to
really understand what I'm doing--and that means I have to understand the math I'm using. I have found that there's no better way to understand a concept than to implement it.
No comments:
Post a Comment