This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Matrix4f Translate/Rotate/Scale

Tags: None
(comma "," separated)
dlbaz
Registered Member
Posts
5
Karma
0

Matrix4f Translate/Rotate/Scale

Sun Jan 23, 2011 7:33 am
I'm currently coding a simple openGL renderer. I've been very confused to what I should be using for my models worldtransform matrix, not sure if I should have an Affine3f or a Matrix4f? ( Is the Affine3f matrix actually an 4x4 matrix with the end column and bollom row set to 0,0,0,1?).

I want to be able to use Eigens built in transform functions like translate/rotate/scale to move my models.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Matrix4f Translate/Rotate/Scale

Sun Jan 23, 2011 8:49 pm
Affine3f is what you need here, and yes internally it's a 4x4 column major matrix. You can access it trough .matrix() for low level manipulations. Not also the unsupported/OpenGLSupport module which provides many convenient methods to interface Eigen with OpenGL.
dlbaz
Registered Member
Posts
5
Karma
0

Re: Matrix4f Translate/Rotate/Scale

Mon Jan 24, 2011 4:11 pm
I thought affine would be the one to use, but I had problems with it.

When I changed everything to use the affine3f. Such as the projection matrix, model transforms and the view matrix it worked.

Just wondering why the following cases work and not work.
The MVP is the model-view-projection matrix and is passed into the shader of my models.

This works and renders all my models at their orgin.
Code: Select all
Eigen::Affine3f VP;
Eigen::Affine3f MVP;   
VP = mCamera->mProjection * mCamera->mCurrViewMatrix;
MVP = VP;


This breaks.
Code: Select all
Eigen::Affine3f VP;
Eigen::Affine3f MVP;   
VP = mCamera->mProjection * mCamera->mCurrViewMatrix;
currModel.mWorldCoordMatrix.setIdentity();
MVP = VP * currModel.mWorldCoordMatrix;


Why would this break?
Code: Select all
Eigen::Affine3f VP;
Eigen::Affine3f MVP;   
VP = mCamera->mProjection * mCamera->mCurrViewMatrix;
currModel.mWorldCoordMatrix.setIdentity();
MVP = VP * Eigen::Matrix4f::Identity();


It confuses me why multiplying by the identity matrix is breaking it.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Matrix4f Translate/Rotate/Scale

Tue Jan 25, 2011 8:22 am
There is a problem here. A projection transformation is not affine, so you should use a Projective3f for VP and MVP, and reserve Affine3f for mCurrViewMatrix and mWorldCoordMatrix.
dlbaz
Registered Member
Posts
5
Karma
0

Re: Matrix4f Translate/Rotate/Scale

Wed Jan 26, 2011 3:48 am
Thanks ggael! Didn't know there was a Projective3f. Was it breaking because the affine3f assumed the last row and last column at 0001?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Matrix4f Translate/Rotate/Scale

Wed Jan 26, 2011 8:44 pm
yes Affine* assumes the last row is 0....01


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft