Jump to content
  • Advertisement
Sign in to follow this  
rocklobster

Collada pivot node

This topic is 1829 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

What is jointOrientX? Why is it there? Why is there a sub-node with the suffix -pivot?

 

Can someone please explain this to me, here is part of the .dae file:

<node name="Box012" id="Box012" sid="Box012">
        <translate sid="translate">91.838813 42.641855 -53.673642</translate>
        <rotate sid="jointOrientX">1 0 0 -90.000000</rotate>
        <scale sid="scale">2.540000 2.540000 2.540000</scale>
        <node id="Box012-Pivot" name="Box012-Pivot">
          <translate>0.000000 -13.999999 -0.128876</translate>
          <rotate>0.000000 0.000000 0.000000 0.000000</rotate>
          <instance_geometry url="#Box012-lib">
            <bind_material>
              <technique_common>
                <instance_material symbol="_04 - Default" target="#_04 - Default"/>
              </technique_common>
            </bind_material>
          </instance_geometry>
        </node>
        <extra>
          <technique profile="FCOLLADA">
            <visibility>1.000000</visibility>
          </technique>
        </extra>
      </node>

The object "Box012" is not rendered in the correct place, and I think it is because it doesn't have the transform of "Box012-Pivot". But pivot is a sub node, and it doesn't reference any mesh? I'm a bit confused why it's even there. I don't remember having a pivot when I exported from 3ds max. 

Edited by rocklobster

Share this post


Link to post
Share on other sites
Advertisement
Hey, I happened to be looking at 3ds max's DAE exporter recently and came across a couple of these issues you're having.

Box012-pivot refers to the 'pivot point' of your object in 3ds max. That's the point on the object that it rotates around when you use the rotate tool in 3dsmax. It only shows up as a node in the DAE (collada) exporter for me if the pivot point has been moved in 3dsmax from it's original position, typically using the rightside menu (where object modifier stack etc is), via the Hierarchy tab (3rd from left), and clicking the Affect Pivot Only button.

If you want to remove only the pivot point entry for the object from your collada file from within 3dsmax, you can either click Reset Pivot on that same Hierarchy tab for the object, or alternatively use Reset XForm on the Utilities tab (far right). The pivot point is essentially the origin around which an object's vertex positions are described, so if you Reset Pivot it will simply undo the Pivot translation and remove the -Pivot node from the collada file. However if you instead use Reset XForm, it will apply the current Pivot translation to your individual vertices instead (meaning you keep the effective pivot translation). The main difference between the two is how you want the object to respond to local rotations, since rotations are around the origin, using Reset XForm after moving the pivot point will move the object origin to the new pivot point, whereas Reset Pivot will return the pivot to the original object origin.

Lastly if you select Single Matrix in the collada section of the exporter, it'll combine the pivot and object translations into a single matrix node rather than seperate nodes. This will also have the effect of making the 3dsmax Pivot for the object behave as the origin in terms of vertex positions, the same as using Reset XForm within max as mentioned above.

Using a Single Matrix will also combine the rotations for pivot and object into that single matrix, which leads to your other question...

JointOrientX, I believe it describes the Y=up axis rotation that I assume you selected in the exporter options (Axis Conversion), since 3dsmax uses a Z-up coordinate system (while 3D engines generally use Y-up). That means in 3dsmax, the world Z axis is upwards, as opposed to say directx/opengl where world Y points up. I believe basically the JointOrientX rotation is just an axis-angle format rotation, saying rotate your box -90 degrees through the X axis (x=1, y=0, z=0, as in along a vector directly pointing in the X axis, -90.0000, as in clockwise 90 degrees).

If it helps to visualize that rotation, go into 3dsmax, and rotate your perspective viewport around your box012 object so you're looking down it's local red X-axis along the direction of it's arrow (viewport cube should read LEFT), select the rotate tool, then imagine rotating the cube's axis 90 degrees to the right (clockwise) around the red X-axis, you'd see it's local Y axis now points up and it's local Z now points forward.

You might also notice that although Y now points up, the Z axis is pointing in the opposite direction compared to the Y axis, before the rotation. Basically the new Z axis now also has to be negated, made opposite, so that it's in the same direction that the old Y axis was in. If you just export with the Single Matrix option it'll place the rotation and Z axis negation in the column-major format Single Matrix element of the object in your collada file. The matrix will look like:
 
1  0  0  0
0  0  1  0
0 -1  0  0
0  0  0  1
That rotation matrix, the first 3x3 cells, essentially performs Y = Z, Z = -Y. That's the axis rotation and also the Z-axis negation that was needed, however it requires you apply that matrix to your vertex position-array in whatever software/engine is going to use the collada file, so...

If you want to pre-apply the rotation described by JointOrientX (so that it's removed from the collada file, but also not included in the matrix node), then in 3dsmax on the Hierarchy tab select Affect Pivot Only, and rotate by 90 degrees through X, so that the green Y axis points upwards and the blue Z axis points 'front' (according to the viewport cube). Now export with the Axis Conversion set to Y-up and also Single Matrix selected.

In combination with the Single Matrix option, this should have the effect of applying the pivot rotation directly to your vertex position-array data for your object in your collada file, rather than in the single matrix for your object (although I think technically it's being applied then negated in the matrix). If you don't rotate the pivot in 3dsmax, then for me at least, the collada file object's vertex position-array is given as Z=up, with the axis-angle conversion applied via the single matrix as mentioned earlier.

So to sum up, if you want to convert max's Z = up coordinates to Y = up in your collada file, and without any extra pivot-point elements, or any matrix rotations, you can just rotate the Pivot Only in 3ds max to point Y (green axis) upwards, then export to collada with Axis Conversion set to Y-up, and Advanced->Collada to set to Single Matrix. This'll give you a direct vertex position-array for the object in y=up format with the 3dsmax pivot point as your object origin. Assuming you haven't rotated the actual object, the Single Matrix in your .DAE will read as:



1  0  0  0
0  1  0  0
0  0  1  0
0  0  0  1
If you've moved the object, or the pivot point isn't at the world origin in 3ds max, the bottom row will have the position info, which in the collada matrix element would be: position X = 4th value, position Y = 8th, position Z = 12th. If you've also rotated the object itself in 3dsmax then those rotations will be in the matrix also, in which case it'd be simpler to just transform the vertex-array by the entire matrix in your engine/software when you load the file, rather than rotating the Pivot Only in 3dsmax.

All this assumes your intended engine/software uses right-handed coordinates (opengl or D3DX with RH projection/winding, etc). If you need the vertices to also be in left handed coords, then, I think, you need to firstly negate position Z again, negate texture V, and negate normal Z for each vertice. To reverse the face winding, read in the <triangles> <p> section 3 vertices at a time, and reverse their order (swap first and third), then read 3 more and reverse their order, and so on all the way through to </p>. I suspect google will give plenty of results for right-hand to left-hand examples, and possibly a collada converter someone has made somewhere, no doubt.

I haven't done a lot with my 3dsmax collada exports yet, aside from check the normals and UVs were valid in right handed coords, so there might be other issues I'm unaware of. Also I'm not super experienced by any means, so if anyone notices something I have wrong here, please do correct me. Edited by backstep

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!