View Full Version : accessing vertex data after model transformations

jwlee

10-04-2000, 06:33 PM

Greetings

I'm currently loading a model into memory.

Doing the usual setup routine.

A user can rotate the model with the mouse (using Push and Pop to manage the stack).

Here's my question...

I would like to know where my model is positioned after a rotation. If I set up a vertex array would the rotation update the values there? Could I use this as a temporary set of "last-positioned" coordinates?

Just trying to find the best solution.

thanks

James

The transformation does not affect the data of a vertex array. The data is always the same, but all vertices and normals will be multiplicated with the current modelview matrix in order to position the object in world space and rotate it in the correct direction. So no, you can't look in the array to obtain the latest position.

If you want to know where the object will be placed, you can always obtain the latest modelview matrix with glGetFloatv, and multiply the origin O=(0,0,0,1) with this matrix. Then you will know where your object will be placed in world space. This assumes you store your object data in a local coordinate system, and the resulting vector will tell you where the local origin will be placed in world space.

You can also multiply the default look-at vector L=(0,0,1,1) and the default up-vector U=(0,1,0,1) with this matrix, then you will know in what direction the object is facing, and what direction is up for the object. The look-at direction is the vector from the transformed O to the transformed L. Same with up-vector.

jwlee

10-05-2000, 06:25 PM

The glGetFloatv to obtain the latest modelview matrix sounds like it will do the trick. I was actually preparing myself to write my own rotation routines. I know the OpenGL (redbook) discourages this, but I didn’t know of any other way.

Many thanks! =)

========================================

If you want to know where the object will be placed, you can always obtain the latest modelview matrix with glGetFloatv, and multiply the origin O=(0,0,0,1) with this matrix. Then you will know where your object will be placed in world space. This assumes you store your object data in a local coordinate system, and the resulting vector will tell you where the local origin will be placed in world space.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.