# owc

This topic is 4414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

... [Edited by - WilyCoder on November 5, 2007 1:56:34 PM]

##### Share on other sites
You're right _in principle_ with your 2nd approach. But

(1) there is a little typo:
WorldP2 = P1*matrix should be WorldP2 = P2*matrix, of course.

(2) Don't use OpenGL's getMatrix routine for this job but track the matrices yourself. See that OpenGL has a MODELVIEW matrix there, and that the VIEW portion of that matrix is against of what you want. You want only the MODEL matrix here. You could use getMatrix and consider the VIEW portion specially, but that doesn't makes the things fancier, and you _will_ suffer from it, believe me. The threads here on GDnet are full of problems arised from using getMatrix for such purposes.

(3) You should be aware that OpenGL uses column vectors, while your above pseudo code suggests you're using row vectors. That doesn't need to be a problem but you have to consider that especially in conjunction with point (2).

As for the dimensions of a matrix: With a 3x3 sub-portion you can have rotation and scaling (and shearing) in 3D but no translation. You should always store the full 4x4 matrix but you may deal only with the particular relevant portion on a situation by situation basis (but be aware of what that really means w.r.t. the overall transformation).

##### Share on other sites
...

[Edited by - WilyCoder on November 5, 2007 1:39:50 PM]

##### Share on other sites
As haegarr said in his post: refrain from using glGet. There are dozens of online libraries that perform efficient matrix math, and you should use them instead of OpenGL's (slow) getters. Also, matrix math in itself isn't difficult at all.

Two comments on the last code snippet:

1) glGet( GL_MODELVIEW_MATRIX, ... ) gives you the Model matrix concatenated with the View matrix, which isn't really "right", although in your case it yields correct results. Don't use it.

2) You perform a glLoadIdentity followed by two pairs of glPush/glPop. In this case, you could just as well remove both pairs and replace the second pair with another glLoadIdentity

##### Share on other sites
...

[Edited by - WilyCoder on November 5, 2007 1:33:04 PM]

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013754
×