Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

An update to Anim8or, v1.00b, is available with a few bug fixes. Get your copy HERE. See the "ReadMe" file for details.

Pages: 1 2 [3] 4

Author Topic: BVH File Import into Anim8or  (Read 23086 times)

nemyax

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Re: BVH File Import into Anim8or
« Reply #30 on: June 19, 2015, 04:09:38 pm »

I'll post the code it uses
Have you thought of publishing Anim8or on something like Github?
Logged

SubDrag

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: BVH File Import into Anim8or
« Reply #31 on: July 03, 2015, 01:00:51 pm »

Can you look at this bvh to see why it's not cooperating like your two examples, using your tool.

Here is for sure a valid bvh, I can look at it fine in bvhacker, but it looks off in anim8or after conversion.

http://goldeneyevault.com/priv/animationdamjump.bvh


« Last Edit: July 03, 2015, 01:51:33 pm by SubDrag »
Logged

NickE

  • Full Member
  • ***
  • Posts: 157
    • View Profile
Re: BVH File Import into Anim8or
« Reply #32 on: July 03, 2015, 03:26:30 pm »

SubDrag,

The file from the link is working fine for me.  I have attached the latest version of the program (executable and source) and the an8 file from the conversion.  The latest version is smarter about white space in the bvh file than the previous version.  I found that GoldenEye bvh files tend to use multiple spaces as a separator rather than the single space or tab.  In the previous version, multiple spaces as a separator would cause parsing errors.

The only parameter I changed in BVH2Animator is the scale factor to 0.15, so the figure (originally at 638) would not be so large (more like 100).
Logged

SubDrag

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: BVH File Import into Anim8or
« Reply #33 on: July 03, 2015, 07:00:48 pm »

Hi NickE, that is an improvement to the version I had, but there is still an issue actually in conversion.

This is what the bvh looks like in bvhacker:


In the file you posted, the legs cross or something weird at some point:
« Last Edit: July 03, 2015, 07:01:30 pm by SubDrag »
Logged

Trevor

  • Full Member
  • ***
  • Posts: 156
  • Goldfinger64 Dev OS:10.0.16363 Gfx:RX480 Loc:UK
    • View Profile
    • LS Tech Services
Re: BVH File Import into Anim8or
« Reply #34 on: July 16, 2015, 10:37:34 am »

Ok, so, Ill post our little solution to the problem we found.

First the Problem is that AN8 has Gimble Lock at ZY while most other software has Gimble Lock at XY.
Now, an8 actually proves to be far supirior since the liklyhood of getting GimbleLock is reduced as not many things run the ZY axis.
(It should be noted that an8 uses quaternuions internally which do NOT suffer gimble lock, however this is not the problem)

HOWEVER this proves to be a real problem when directly importing animations made in other software, since as other software approach gimble lock the start to add values to both X and Z which themselves do nothing. An8 however shows these values literally and so you get weird effects.

So, our solution was to move the Gimble Lock back to the XY axis by adding 3 bones at each joint. (originally was 5 as seen in image, however quaternuions do not suffer gimble lock and so the 2 rotations could be combined)



First we take whatever direction the bone is coming from and point it X+
(Image shows z90, this is variable depending on original bone orientation, i.e. had the bone already been pointing X+ then it would rotate 0. If the bone was pointing X- then the bone would rotate 180)

Then we rotate it Y90 (these 2 operations being combined in quaternuions)

Then we add the 'Joint' as a 0 legnth fat bone. (this sets the bone dialoge angles to 0,0,0)

Then we undo all before.

Rotate -Y90

Rotate back to original cource pointing to next bone. (in image the next bone was directly above the first, so we rotate -Z90. Had the next bone been to the right we would rotate 0, had the bone been to the left slightly then we would rotate 100 etc.


All connecting bones are 0 legnth and 0 diameter.

One final consideration and we are done.

Ignore all lables in the bone Orientation Dialoge, the Order is Z, X, Y, Not P Y R.

Attached is an example of a working animation direct from GoldenEye.



Trev


P.S. can anyone tell me if the atached .an8 shows the guard in scene mode?
He works in sequence mode but in scene mode his model is invisible, all I can see is his skeleton working
If he is invisible then does anyone know why?
(clearly something went wrong since the animation pictured above, which actually shows him)

P.S.S Doesnt matter I found it... Sub put him on the root bone accidently in the latest version.
The root bone is useless grrr


« Last Edit: July 25, 2015, 11:38:11 am by Trevor »
Logged

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 1519
    • View Profile
Re: BVH File Import into Anim8or
« Reply #35 on: July 22, 2015, 02:40:03 am »

What version of Anim8or are you using?  I found a much more robust Rotation Matrix to Quaternion algorithm that the one you see everywhere on the web (and that Anim8or has been using since it's inception).  It's in build 1178 and onwards and may fix the problem that you're seeing.

If you're interested in to algorithm, here's a link:

http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/
Logged

Trevor

  • Full Member
  • ***
  • Posts: 156
  • Goldfinger64 Dev OS:10.0.16363 Gfx:RX480 Loc:UK
    • View Profile
    • LS Tech Services
Re: BVH File Import into Anim8or
« Reply #36 on: July 23, 2015, 04:02:27 pm »

Personally Im using the latest beta. 1179.

As I kinda atated above, its the fact that as other software aproches gimble lock they add values to X and Z (eg, 90 90 -90)
The result in those apps is that nothing changes, the rotation = 0 90 0

However, since an8 does not lock out, it takes the values literally and so rotates the character 'oddly'.

This was the solution we came up with to overcome the limitation from GoldenEye (and xsi and blender etc)

Trev

P.S. Not sure if you saw the images, my PC was off yesterday at 02:40  UTC
Logged

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 1519
    • View Profile
Re: BVH File Import into Anim8or
« Reply #37 on: July 23, 2015, 05:34:53 pm »

OK, thanks. I misread your post and thought Anim8or was locking up.  Before build 1178 it could do that because some tools use rotation matrices internally and occasionally returned a default neutral quaternion.
Logged

SubDrag

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: BVH File Import into Anim8or
« Reply #38 on: July 24, 2015, 02:11:30 pm »

**I should note this working in bvh2anim8or, but I'd like to understand why mine isn't working.

Actually it only works for simpler models though.  More complicated and I can't get the bone orientation correct (nothing to do with actual rotation keyframes, just talking bone structure now).    I am using normalized Quat::RotateFromTo (root bone at 0,1,0) of absolute position of current - absolute position of previous, to go from previous bone to current, and assign that quaternion, but clearly something goes wrong at some point, to go from previous bone to next.  Maybe your logic is slightly different somehow?

The issue seems to be (in my code) that sometimes the quaternion is backwards. 

For example,
orientation { (-0.164697 0.000000 -0.000000 0.986344) } Wrong
vs
orientation { (0.16470 0.00000 0.00000 -0.98634) } Right

When startLink = {x=0.00000000 y=40.600006 z=-532.50000 ...}
And endLink = {x=0.00000000 y=-54.827942 z=-210.49976 ...}

Then Quat RotFromTo startLink to endLink basically

Quat MUST_USE_RESULT Quat::RotateFromTo(const float3 &sourceDirection, const float3 &targetDirection)
{
   assume(sourceDirection.IsNormalized());
   assume(targetDirection.IsNormalized());
   float angle = sourceDirection.AngleBetweenNorm(targetDirection);
   assume(angle >= 0.f);
   // If sourceDirection == targetDirection, the cross product comes out zero, and normalization would fail. In that case, pick an arbitrary axis.
   float3 axis = sourceDirection.Cross(targetDirection);
   float oldLength = axis.Normalize();
   if (oldLength == 0)
      axis = float3(1, 0, 0);
   return Quat(axis, angle);
}

Code is:
if (length > 0)
{
if (realParent == NULL) // From TopJoint
         {
            quat = Quat::RotateFromTo(float3(0,1,0), bone->boneEnd->positionAbsolute.Normalized());

            length = bone->boneEnd->positionAbsolute.Length();
         }
         else
         {
            float3 startLink = realParent->boneEnd->positionAbsolute - ((realParent->boneStart == 0) ? float3(0,0,0) : realParent->boneStart->positionAbsolute);
            float3 endLink = bone->boneEnd->positionAbsolute - bone->boneStart->positionAbsolute;
            
            quat = Quat::RotateFromTo( startLink.Normalized(), endLink.Normalized() );

            length = (bone->boneEnd->positionAbsolute - bone->boneStart->positionAbsolute).Length();
         }
}
else
      {
         quat = Quat(0, 0, 0, 1);
      }


« Last Edit: July 24, 2015, 03:46:04 pm by SubDrag »
Logged

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 1519
    • View Profile
Re: BVH File Import into Anim8or
« Reply #39 on: July 26, 2015, 07:35:57 pm »

SubDrag: There a common problem when generating a series of quaternions to be used as orientations representing positions in an animation:

Q1, Q2, ... Qn-1, Qn.

As you stated there are two possible quaternions for each orientation, which I'll call Q and Q'. As orientations they are equivalent. But when used pairwise to generate rotations they are very different and need to be considered pair-wise..

If you want the animation to rotate using the shortest angle (i.e. from New York to London across the Atlantic) then each pair of consecutive quaternions Qk-1, Qk needs to be the "closest" distance, for lack of a better term. If they aren't, you will go from New York to London via the Pacific and Indian oceans.

So assume that you have generated Q1, ... Qk-1 and you want to add q as the next value. How can you tell which to use, q or q'? Compute the dot product:

dot(Qk-1, q) = Qk-1.x*q.x + Qk-1.y*q.y + Qk-1.z*q.z + Qk-1.w*q.w

If it is > 0 you need to use Qk = q, otherwise use Qk = q'.

If it is = 0 then there is no shortest path - the orientations are exactly opposite so there is not enough information for a solution. There needs to be another data point between those tow orientations.
Logged

SubDrag

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: BVH File Import into Anim8or
« Reply #40 on: July 26, 2015, 08:13:46 pm »

Thanks Steve, that makes sense in terms of why they are different, though I hadn't realized bone definitions used rotations instead of effective orientations.
Logged

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 1519
    • View Profile
Re: BVH File Import into Anim8or
« Reply #41 on: July 26, 2015, 08:59:21 pm »

Well, they are both. An orientation is a particular point in time, a key. A rotation is what happens between two orientations, how motion is generated between two fixed orientations.
Logged

Trevor

  • Full Member
  • ***
  • Posts: 156
  • Goldfinger64 Dev OS:10.0.16363 Gfx:RX480 Loc:UK
    • View Profile
    • LS Tech Services
Re: BVH File Import into Anim8or
« Reply #42 on: August 05, 2015, 01:38:37 pm »

Forgot to update this when sub posted his new version of Obj2an8, it works now.

Here is a Skedar animation direct from Perfect Dark


These work with the gimble lock bones as described above.

Now, for going back into GE/PD im not sure how to do the bones. Since an8 does not suffer gimble lock it seems slightly pointless to do all the rotations.

Actually, I just tested again and this build still locks out in GUI in the YZ plane so I guess I have to make all these bones manually for new objects.

Trev

Trev
Logged

RemiD

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: BVH File Import into Anim8or
« Reply #43 on: January 23, 2016, 06:58:03 pm »

Hello, :)

Can somebody share alink to the last stable version of this tool (BVH2Anim8or) to convert a bhv file to a an8 file (with joints/bones and animation)

Thanks,
Logged

Claude

  • Full Member
  • ***
  • Posts: 244
    • View Profile
Re: BVH File Import into Anim8or
« Reply #44 on: January 23, 2016, 07:40:54 pm »

The file in NickE's post dated July 03, 2015, 03:26:30 pm
is the most recent one.
« Last Edit: January 23, 2016, 07:41:35 pm by Claude »
Logged
Pages: 1 2 [3] 4