Advertisement Jump to content


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


Matrix modify seperately

This topic is 5486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!