This topic is now archived and is closed to further replies.


Matrix modify seperately

Recommended Posts

nullmind    152
Ok, I have a matrix. I''m using D3DX, because I don''t want to code my own again :o The matrix is rotated, scaled and translated at any time, so it can be anything. I want to simply set either rotation, scaling or translation, independent of the others. Say I modify the matrix, then I want to make the rotation 0.0f,0.0f,0.0f. But not resetting the Translation or Scaling. Is it possible? My first guess was to get the rotation, and multiply the matrix opposite of that. Any ideas? Cheers!

Share this post

Link to post
Share on other sites
Dreamforger    122
I''d rather store all the parameters of the matrix seperately and only update the matrix if needed. this of course assumes you don''t allow direct write access to the matrix itself, but only through the functions.

Something like this:

class Matrix
ScaleType scl;
RotationType rot;
TranslationsType trans;

int isDirty;

CalcMatrix(); // does your maultiplications and sets isDirty to 0

float m[4][4];
Matrix(){isDirty = 1; }

const float **Access(){ if (isDirty) CalcMatrix(); return m; }
void Set...(...); // write Methods for all scl, rot, and trans members

This code probably is not without errors but I trust you get the idea. A nice way to substitute the Access method would be some operator overloading.

Share this post

Link to post
Share on other sites
nullmind    152
Well, I suppose that works fine.

Also, without starting another thread. Does anyone have any tips on ''moving'' an object? Not translating it, but moving it base on it''s rotation.

Cheeers, and thanks for the feedback.

Share this post

Link to post
Share on other sites