Hi,
I've having a *small* problem with a small simulation/game I'm trying
to write in C++ using OpenGL. I'm not sure if I need to include code
yet, as it might just make things more complicated, but I can do so if
necessary.
Basically what I'm writing involves a simple sprite fielder trying to
catch a thrown ball. The ball and the fielder are each in their
respective coordinate frames, and I'm using the matrix stack to keep
track of these. I'm also using a camera with gluLookAt(). The user
picks some initial settings like power and release angle, and the balls
trajectory and landing position is calculated. I can plot this landing
spot correctly as long as I stay within the ball's coordinate frame.
What I would like to do is have my fielder go to the position that the
ball will land to catch it. However, I can't seem to get this to work
right. I have the coordinates that the ball is going to land, and I
need to somehow transform them into coordinates that the fielder "can
understand". I would like the fielder to be able to calculate a path
to the ball using several different algorithms. So basically I just
want to make sense of the ball's landings coordinates. I try saving
the model_view matrix of the ball and then loading it back, but somehow
when I plot the point it's not int he right location. It seems to me
to be just simple matrix multiplication, but I'm having a problem
somewhere. Does the camera need to be considered in these
calculations? I've also had a couple of futile efforts at using
gluUnproject + project, but to no avail. Can anyone give me any info,
or refer me some where where I can see some examples? Any help or
advice is welcomed. Thanks.
-Matt