Bone orientation

shoei321shoei321 Posts: 113
edited March 2016 in Daz Studio Discussion

I need some help understanding how bones in a Daz figure are expressed in terms of orientation/center/endpoint.  

What I'm ultimately trying get to is a local-space quaternion (DzQuat) of a bone's orientation -- e.g. the direction that the bone is pointed in.    Calling bone.getOrientation() does not give me what I'd expect though -- for example, it returns the same value (zero) for both the pelvis and abdomen bones in Genesis3, which are clearly oriented in opposite directions when viewed in the Joint Editor. 

I also tried creating a DzQuat from the bone's rotation order and origin -> endpoint vector :

DzQuat(bone.getRotationOrder(), (bone.getEndpoint() - bone.getOrigin()));

... but this also isn't giving me the expected results.    Unfortunately I'm a bit out of my depth on how the RotationOrder plays into bone orientation and movement. 

Can someone point me in the right direction on this ... pun intended?   

 

Thanks

 

 

 

Post edited by shoei321 on

Comments

  • millighostmillighost Posts: 261
    shoei321 said:

    I need some help understanding how bones in a Daz figure are expressed in terms of orientation/center/endpoint.  

    What I'm ultimately trying get to is a local-space quaternion (DzQuat) of a bone's orientation -- e.g. the direction that the bone is pointed in.    Calling bone.getOrientation() does not give me what I'd expect though -- for example, it returns the same value (zero) for both the pelvis and abdomen bones in Genesis3, which are clearly oriented in opposite directions when viewed in the Joint Editor. 

    The hip and pelvis have the same orientation, so the value returned by getOrientation() is the same. The octaeder-thing that can be seen in the joint-editor shows the endpoint of a bone, which is an additional, independent parameter of the bone and essentially has nothing to do with the orientation. A bone can be aligned (with the context menu in the joint editor), so the endpoint lies in the major axis, but usually it is not.

    shoei321 said:

    I also tried creating a DzQuat from the bone's rotation order and origin -> endpoint vector :

    DzQuat(bone.getRotationOrder(), (bone.getEndpoint() - bone.getOrigin()));

    This will not produce anything useful. endpoint-origin is a (displacement-)vector, the DzQuat constructor needs Euler-angles to produce a quaternion. To get an orientation for the endpoint wrt the origin, you probably need to calculate the Euler-angles by hand (i.e. sin(), cos() and such).

    shoei321 said:

    ... but this also isn't giving me the expected results.    Unfortunately I'm a bit out of my depth on how the RotationOrder plays into bone orientation and movement. 

    The rotation order is used for the rotation of the bone (i.e. when the bone is rotated via parameters which are always euler angles). The orientation is also given in euler angles (as can be seen in the joint editor), but uses always XYZ for rotation order. So the rotation order has no effect on orientation.

    shoei321 said:

    Can someone point me in the right direction on this ... pun intended?   

     

    Thanks

     

     

     

     

  • hphoenixhphoenix Posts: 1,335
    edited March 2016
    shoei321 said:

    I need some help understanding how bones in a Daz figure are expressed in terms of orientation/center/endpoint.  

    What I'm ultimately trying get to is a local-space quaternion (DzQuat) of a bone's orientation -- e.g. the direction that the bone is pointed in.    Calling bone.getOrientation() does not give me what I'd expect though -- for example, it returns the same value (zero) for both the pelvis and abdomen bones in Genesis3, which are clearly oriented in opposite directions when viewed in the Joint Editor. 

    I also tried creating a DzQuat from the bone's rotation order and origin -> endpoint vector :

    DzQuat(bone.getRotationOrder(), (bone.getEndpoint() - bone.getOrigin()));

    ... but this also isn't giving me the expected results.    Unfortunately I'm a bit out of my depth on how the RotationOrder plays into bone orientation and movement. 

    Can someone point me in the right direction on this ... pun intended?   

     

    Thanks

    DzBone elements are (by their nature) part of a skeleton.  Each DzBone has a local orientation (it's rotation from it's parent bone.)  But it sounds like what you are looking for is the World Space orientation (the orientation with respect to the scene origin and axes.)

    You may be able to call DzBone::CalcWSTransform(...) but it is a protected method, so you may have to inherit DzBone in a custom class and expose it.

    You might also be able to call DzBone::GetWSOrientedBox(...) to get the oriented bounding box, which you could then get the orientation from using DzOrientedBox3::GetTransform() to get the transformation matrix.  Getting the Quaternion or the xyz angles of rotation from the transformation matrix is a good bit of math.....

    ETA:  if all you are wanting is to get the direction the bone is pointing in world-space, you can always just get the bone origin and endpoints and calculate the vector, normalize it, and then directly compute the rotation matrix from that.

     

    Post edited by hphoenix on
Sign In or Register to comment.