Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Convert 3dsmax rotation to Unreal Rotation

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Convert 3dsmax rotation to Unreal Rotation

    Hi everyone,

    i'm working on 3dsmax script helping me with unreal works.

    I'm wondering how to convert an object rotation in max to unreal ?

    I think I have to use quaterinion but I don't find the right solution to convert it.
    I know that 90° = 16384 in Unreal

    I'm stuck...

    Thanks everyone

    #2
    I may be wrong, but it's either going to be (65536*(360/YourRotation)) or (-65536*(360/YourRotation))

    I can never remember whether Unreal units work clockwise in every axis but you are already on the right lines.

    Comment


      #3
      No it doesn't work.
      Maybe I did't explain so good.

      I need to convert a rotation of a mesh into 3dsmax to the Pitch, yaw, roll that you can found into the "begin actor" creation:

      Code:
      Begin Map
         Begin Level
            Begin Actor Class=StaticMeshActor Name=StaticMeshActor_1 Archetype=StaticMeshActor'Engine.Default__StaticMeshActor'
               Begin Object Class=StaticMeshComponent Name=StaticMeshComponent0 ObjName=StaticMeshComponent_0 Archetype=StaticMeshComponent'Engine.Default__StaticMeshActor:StaticMeshComponent0'
                  StaticMesh=StaticMesh'ASC_Deco.SM.Mesh.S_ASC_Deco_SM_Trim02'
                  ReplacementPrimitive=None
                  LightingChannels=(bInitialized=True,Static=True)
                  Name="StaticMeshComponent_0"
                  ObjectArchetype=StaticMeshComponent'Engine.Default__StaticMeshActor:StaticMeshComponent0'
               End Object
               StaticMeshComponent=StaticMeshComponent'StaticMeshComponent_0'
               Components(0)=StaticMeshComponent'StaticMeshComponent_0'
               Location=(X=-912.000000,Y=16.000000,Z=464.000000)
               Rotation=(Pitch=-5472,Yaw=6402,Roll=6414)
               DrawScale3D=(X=1.215506,Y=1.215506,Z=1.215506)
               Tag="StaticMeshActor"
               CollisionComponent=StaticMeshComponent'StaticMeshComponent_0'
               Name="StaticMeshActor_1"
               ObjectArchetype=StaticMeshActor'Engine.Default__StaticMeshActor'
            End Actor
         End Level
      Begin Surface
      End Surface
      End Map

      Comment


        #4
        I found those links but did not help me :s or maybe i don't understand:

        http://wiki.beyondunreal.com/Legacy:Quaternion_Rotation

        http://wiki.beyondunreal.com/Legacy:Unreal_Unit

        Comment


          #5
          Post an example rotation from max.

          Comment


            #6
            here is the screenshot:



            I made the same rotation in unreal than 3dsMax (45° horizontal and 45° vertical)

            Comment


              #7
              you can ignore the quaternion bit, that's for if you want to take a rotation and perform quaternion math on it (quaternion math is great for avoiding gimbal lock).

              The rotations are stored in the Rotator though for compactness (it's just 3 short integers). This means that anytime you use a Quat that you have to convert your Rotator to a quat, do the math, then convert the quat back to a Rotator.

              [NOTE - Quaternions don't use RUUs... they are in their own number system where they have a 4 dimensional length of 1... see articles on quaternion rotation for more information about how this works]



              So in 3dsmax you see where it says "euler angles"... that's your 'pitch roll yaw'.

              Now here is the issue, Unreal is an "X forward, Left-handed system"... where as 3dsmax is a "Y forward, right handed system". This means that the direction YAW rotates positively is backwards...

              left is lefthanded, right is right handed


              As you can see left handed coordinate systems rotate clockwise around +Z from +X -> +Y, right handed rotate counter-clockwise around +Z from +X -> +Y.





              So what you need to do is figure out which is your pitch, roll, and yaw in 3ds max... bring them over.

              PITCH - up/down - like nodding head 'yes' - In UnReal rotates positively around Z from X axis -> Z axis
              YAW - left/right - like shanking head 'no' - In UnReal rotates positively around Z from X axis -> Y axis
              ROLL - like doing a barrel roll - In UnReal rotates positively around X from Z axis -> Y axis



              When bringing them over, you pitch and roll will probably swap (going from Y forward to X forward). And your Yaw will be flipped (we went from right-hand to left-hand, so just multiply Yaw by -1)

              [NOTE - I say probably because I don't have 3ds max... I'm basing this on the math of handed coordinate systems and assuming that 3ds max follows the standard RULES of these handed cartesian coord systems. I KNOW that 3ds max is a 'Y Forward Right Handed System', but if they happen to break the rules, I'm sorry, not my fault.]

              so now when you have these values written down go over to unreal

              in unreal if your in the options window in the UDK editor, angles are in degrees. It's this because degrees are easily human readable. Just plug in your values for all three.


              But if you're in code the angles are in RUUs. This is the proprietary units of Unreal based on the 'short int'... instead of 360 degrees, you have 2^16 units of angle... (2^16 == 16 bits == 65536).

              So SCALE your degrees... you do this:

              RUU == degree * RUU_MAX / DEG_MAX
              RUU == degree * 65536 / 360

              Now that you have each value scaled into RUU (think like converting inches to cm, or pounds to kilos, or gallons to liters... it's a new unit system that's all). Just plug them in appropriately in code.

              Comment


                #8
                Thank you for your very interesting answer and to take the time for explanations.

                I tried what you say, do the maths, but it doesn't work, even if there is wrong signs (+/-) I don't find same values...



                I think there is something about a revolution, maybe if you turn your mesh to left or right you won't have the same value of rotation, because it's based on a revolution.

                But I can't find the solution...

                Comment


                  #9
                  You used the translational coordinates to create angles...

                  that highlighted part at the bottom of your image (you have X=30... Y= 30... highlighted by a red box). Those aren't rotations... that is the position.


                  Just draw yourself a shape in 3ds max... forget the numbers right now. Just rotate it in each direction and figure out what is Yaw, what is Roll, and what is Pitch. Then do the same in UDK, figure out what is what.

                  Now go back to 3ds max, watch the rotation values change while you do each.

                  You'll notice a corrolation between the two.

                  Comment


                    #10
                    I tried just to rotate the Sm into unreal by 45° Yaw.

                    This give me that:

                    Code:
                    Begin Map
                       Begin Level
                          Begin Actor Class=StaticMeshActor Name=StaticMeshActor_1 Archetype=StaticMeshActor'Engine.Default__StaticMeshActor'
                             Begin Object Class=StaticMeshComponent Name=StaticMeshComponent0 ObjName=StaticMeshComponent_2 Archetype=StaticMeshComponent'Engine.Default__StaticMeshActor:StaticMeshComponent0'
                                StaticMesh=StaticMesh'ASC_Deco.SM.Mesh.S_ASC_Deco_SM_Trim02'
                                ReplacementPrimitive=None
                                LightingChannels=(bInitialized=True,Static=True)
                                Name="StaticMeshComponent_2"
                                ObjectArchetype=StaticMeshComponent'Engine.Default__StaticMeshActor:StaticMeshComponent0'
                             End Object
                             StaticMeshComponent=StaticMeshComponent'StaticMeshComponent_2'
                             Components(0)=StaticMeshComponent'StaticMeshComponent_2'
                             Rotation=(Pitch=0,Yaw=-8192,Roll=0)
                             Tag="StaticMeshActor"
                             CollisionComponent=StaticMeshComponent'StaticMeshComponent_2'
                             Name="StaticMeshActor_1"
                             ObjectArchetype=StaticMeshActor'Engine.Default__StaticMeshActor'
                          End Actor
                       End Level
                    Begin Surface
                    End Surface
                    End Map
                    And with the math: 45 * (65536 / 360) = 8190

                    So with one axe it works, but when there is more axes, it becomes more difficult :s

                    Comment


                      #11
                      I'm stuck, I tried a lot of things, but didn't work...

                      if somebody can help me

                      Comment

                      Working...
                      X