By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,344 Members | 1,806 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,344 IT Pros & Developers. It's quick & easy.

OpenGL Transforming coordinate frames

P: n/a
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

Nov 16 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

ma**********@gmail.com wrote:
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
You should ask in a relevent news group.
Are you sure you are reversing the projection coordinates? as in z = -z
axis?

Nov 16 '06 #2

P: n/a
ma**********@gmail.com wrote:
Hi,

I've having a *small* problem with a small simulation/game I'm trying
to write in C++ using OpenGL.
It's really hard to help much here except to tell you how I would do it.

To go from one co-ordinate space to another you need to peform the
reverse which usually means multiplication by the inverse matrix. I you
have an unit orthonormal 3x3 matrix, this is just the matrix transpose.
If you have a homogenous 4x4 matrix then I would do a real matrix
invert (which can be quite efficiently done in for a 4x4).

It's mean many many years since I did much opengl so I don't know what
the latest API advances look like but if I were on the opengl committee
I would have added some apis like a 4x4 invert for example.

G
Nov 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.