View Full Version : Getting an object's matrix

GameMaker

12-06-2002, 02:44 PM

I want to get an object's matrix when I am about to draw it, but I don't want the camera transform in it. I only want the object's matrix. I thought multiplying by the camera inverse matrix would give me just the object's matrix. I guess not because that didn't work. :-)

Any suggestions?

cbwan

12-07-2002, 01:23 AM

have you tried multiplying it on the left side?

ModelViewMat = CamMat * WhateverMat

-> CamMat^-1 * ModelViewMat = WhateverMat

cb

Jambolo

12-07-2002, 07:41 PM

Multiplying by the inverse of the camera matrix should work. Remember, the order is important.

GameMaker

12-08-2002, 08:46 AM

Can you please tell me if this is the correct way? What I am trying to do is cancel out the object part of the transformation so that when opengl's modelview matrix is applied I just get the camera transform and plane transform. (I have to do it this way because I am auto generating texture coordinates and opengl wants the real transform of the object when it receives the vertices. But the plane that I am drawing the texture on is not part of the object.)

// get the modelview matrix

BMatrix modelViewMatrix;

glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatrix.Mtx);

// get inverse camera matrix

BMatrix objectMatrix;

objectMatrix = gCamera.Matrix; // actually contains inverse camera matrix

// take the camera out of the matrix by

// multiplying inverse camera matrix by modelViewMatrix

objectMatrix.Mul(modelViewMatrix);

// take the inverse of the object's

objectMatrix.Inverse();

// take my cutplane matrix and multiply by object's matrix

drawPlaneMatrix = objectMatrix;

drawPlaneMatrix.Mul(gCutPlane.m_Matrix);

.

.

.

(later on)

glBegin();

multiply points by drawPlaneMatrix

glVertex3f...

glEnd();

Thanks, I really appreciate any help I can get!

GameMaker

12-09-2002, 01:07 PM

I just can't seem to make this work...

glGetFloatv(GL_MODELVIEW, modelViewMatrix);

objectMatrixOnly = myInverseCameraMatrix * modelViewMatrix;

Can someone please point me to a web page or tutorial on how to extract the object's matrix from the current opengl matrix?

Thanks

roffe

12-09-2002, 04:31 PM

Well that seems correct, are you ordering your rows/columns correctly?

Opengl uses column major ordering:

|0 4 8 12|

|1 5 9 13|

|2 6 10 14|

|3 7 11 15|

It gave me some weird results in the beginning.

GameMaker

12-10-2002, 05:42 AM

Yes, my matrix order is column major order just like opengl.

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.