PDA

View Full Version : Pretty Basic Object Orientation Question... hopefully

Aumnayan
05-15-2014, 04:03 PM
So I have an objected loaded into a VBO, and am trying to put said object in multiple places in my scene, each with it's own orientation in the world space defined by (up, right, and forward) normal vectors.

NOTE: For the moment I've broken the translation step out into a seperate glTranslated call while I isolate the problem.

My fairly loose undertanding of this is that I should be able to get the oppropriate rotation from the object by calling glLoadMatrixd() pssing in the matrix:

right.x, up.x, forward.x, 0
right.y, up.y, forward.y, 0
right.z, up.z, forward.z, 0
0, 0, 0, 1

However, when I perform the above steps the object that is on the screen with an incorrect orientation (before the rotation is applied) is no longer displayed once I start calling glLoadMatrixd.

Is the process I'm attempting correct? Which would indicate the problem is with the math. Or is there a fundamenal problem with the approach I'm taking?

dorbie
05-15-2014, 11:48 PM
So I have an objected loaded into a VBO, and am trying to put said object in multiple places in my scene, each with it's own orientation in the world space defined by (up, right, and forward) normal vectors.

NOTE: For the moment I've broken the translation step out into a seperate glTranslated call while I isolate the problem.

My fairly loose undertanding of this is that I should be able to get the oppropriate rotation from the object by calling glLoadMatrixd() pssing in the matrix:

right.x, up.x, forward.x, 0
right.y, up.y, forward.y, 0
right.z, up.z, forward.z, 0
0, 0, 0, 1

However, when I perform the above steps the object that is on the screen with an incorrect orientation (before the rotation is applied) is no longer displayed once I start calling glLoadMatrixd.

Is the process I'm attempting correct? Which would indicate the problem is with the math. Or is there a fundamenal problem with the approach I'm taking?

Well you have the object at the origin there, and with a loadmatrix you've blown away your viewing matrix (and/or translate) if you had one, so depending on what else you do the eye will probably be inside it.

Try multmatrix instead of load, that way you won't blow away your viewing matrix with the model matrix or your translate. Ultimately translate can be handled by writing x, y, z to 3 zeros (bottom left I think in your example (try the column if the row doesn't behave well). You will still need to multmatrix for your viewing to work.

Aumnayan
05-16-2014, 07:57 AM
Thank you. That was the peice I was missing. Though it's not quite behaving right at the moment, the problem now is more likely my numbers then my process.