#### Archived

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

# Matrix modify seperately

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

## 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 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{private:  ScaleType scl;  RotationType rot;  TranslationsType trans;  int isDirty;  CalcMatrix(); // does your maultiplications and sets isDirty to 0  float m[4][4];public:  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 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.

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632934
• Total Posts
3009302
• ### Who's Online (See full list)

There are no registered users currently online

×