Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


How to get the same euler angles in Direct3D as in max


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 lucky6969b   Members   -  Reputation: 624

Like
0Likes
Like

Posted 25 February 2013 - 04:53 AM

Let's say the Direct3D Matrix is D3DXMATRIX

and max Matrix is Matrix3

 

I tried to decompose Matrix3 into head, pitch, bank first, then combine them again using yaw, pitch, roll,

 

void SimExporter::ConvertMatrix3ToEuler()
{
    double sp = elements[1][2];  
    if (sp <= -1.0f) {
        p = -1.570796f;
    } else if (sp >= 1.0f) {
        p = 1.5707096f;
    } else {
        p = asin(sp);
    }
        
    if (sp > 0.9999f) {
        b = 0.0f;
        h = atan2(elements[2][0], elements[0][0]); // m31 and m11
    }
    else
    {
        h = atan2(elements[0][2], elements[2][2]); // m13 and m33
        b = atan2(elements[1][0], elements[1][1]); // m21 and m22
    }

}

 

Then swap b,h

 

D3DXMatrixRotationYawPitchRoll(&yawpitchroll, b, p, h);

 

And convert the D3DXMATRIX back to euler to check

What I expected was something like

Original Euler

x: 30, y: 0, z:180

would become

x:30, y:180, z:0

But in fact, it isn't.

What is the general approach to convert a Matrix3 Matrix into a D3DXMATRIX affine matrix?

Thanks

Jack
 


Edited by lucky6969b, 25 February 2013 - 05:02 AM.


Sponsor:

#2 Alundra   Members   -  Reputation: 885

Like
0Likes
Like

Posted 25 February 2013 - 09:10 AM

3DSMAX uses Z as up-axis. When you export your scene you get the same coordinate system.

You need to convert that to have the correct coordinate system who is Y as up-axis.

You need to use this conversion matrix :

[ 1 0 0 ]
[ 0 0 1 ]
[ 0 1 0 ]
 

Edited by Alundra, 25 February 2013 - 09:18 AM.


#3 BornToCode   Members   -  Reputation: 935

Like
0Likes
Like

Posted 25 February 2013 - 12:59 PM

To convert your matrix to max matrix, you can just apply an rotation of 90 degress around your X. which will point your Y Axis Upward and your Z in and out. Max by default has Z up and Y in and out.


Edited by BornToCode, 25 February 2013 - 01:00 PM.


#4 lucky6969b   Members   -  Reputation: 624

Like
0Likes
Like

Posted 25 February 2013 - 09:26 PM

I couldn't get the y-axis up to work by just multiplying the 3ds max transformation to that one.

I got z-up.

Let me know

Thanks

Jack



#5 BornToCode   Members   -  Reputation: 935

Like
0Likes
Like

Posted 25 February 2013 - 09:32 PM

I notice i had a type in my previous post. This is what you want to do .You want to multiply the 3D max transformation with a rotation of 90 degrees around the X to put it in the same space as DX where Y will be Up and Z will be in and out. Currently right now when you render your mesh using the max coordinate as is. You end up seeing your mesh been updside down correct. If that is the case then you need to do the transformation i said which is multiply it with a 90 degree value around the X


Edited by BornToCode, 25 February 2013 - 09:34 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS