S-S

03-20-2008, 12:42 PM

Hi!

I wrote a BVH exporter for learning purposes. My exporter's "hierarchy parser" part is already done and is working ok and root positions and rotations are written into bvh file, and i can import it back.

However, problem is that biovision stores rotations in angles. IMO It was relatively straightforward to read angles into object rotations (i also wrote importer part).

But for exporting problem seems to be how to convert rotations to angles, in such manner that i can get the exactly same result back (max -> bvh -> max).

Example:

create a point helper

rotate point 45 degrees along it's local x

quatToEuler ($point.rotation) shows: (eulerAngles -45 0 0)

rotate point -45 degrees along it's local z

quatToEuler ($point.rotation) shows: (eulerAngles -45 -1.02453e-005 45)

So far good...

rotate point -45 degrees along it's local y

Now, this is my problem:

quatToEuler ($point.rotation) shows: (eulerAngles -9.73564 30 54.7356)

I no longer can just read then write the actual x,y and z values and then expect those to work later, when importing bvh file back to max.

Result is an "almost there" walkcycle for example, when i compare it to original bvh file imported with my importer.

I have tested results of my importer compared to other importers and it matches, so i think i'm quite sure that the problem is in how i write the rotation values.

And what comes to from where i read the values; i use world oriented points, linked into joints of hierarchy, in setup frame. I read the rotations in "parent space" of each point, which is point linked to bone one level up in hierarchy.

If someone has enlightening thoughts about rotations and how to solve this i would be delighted. I have tried different methods for getting rotations, not just converting quat rotation value to euler. But i seem to be stuck with this... Maybe i'm going into wrong direction.

I wrote a BVH exporter for learning purposes. My exporter's "hierarchy parser" part is already done and is working ok and root positions and rotations are written into bvh file, and i can import it back.

However, problem is that biovision stores rotations in angles. IMO It was relatively straightforward to read angles into object rotations (i also wrote importer part).

But for exporting problem seems to be how to convert rotations to angles, in such manner that i can get the exactly same result back (max -> bvh -> max).

Example:

create a point helper

rotate point 45 degrees along it's local x

quatToEuler ($point.rotation) shows: (eulerAngles -45 0 0)

rotate point -45 degrees along it's local z

quatToEuler ($point.rotation) shows: (eulerAngles -45 -1.02453e-005 45)

So far good...

rotate point -45 degrees along it's local y

Now, this is my problem:

quatToEuler ($point.rotation) shows: (eulerAngles -9.73564 30 54.7356)

I no longer can just read then write the actual x,y and z values and then expect those to work later, when importing bvh file back to max.

Result is an "almost there" walkcycle for example, when i compare it to original bvh file imported with my importer.

I have tested results of my importer compared to other importers and it matches, so i think i'm quite sure that the problem is in how i write the rotation values.

And what comes to from where i read the values; i use world oriented points, linked into joints of hierarchy, in setup frame. I read the rotations in "parent space" of each point, which is point linked to bone one level up in hierarchy.

If someone has enlightening thoughts about rotations and how to solve this i would be delighted. I have tried different methods for getting rotations, not just converting quat rotation value to euler. But i seem to be stuck with this... Maybe i'm going into wrong direction.