BVH to Blitz (MoCap) [RESOLVED]

Blitz3D Forums/Blitz3D Beginners Area/BVH to Blitz (MoCap) [RESOLVED]

Mikorians(Posted 2015) [#1]
I wanted to better understand how the BVH matrices are applied to a skeleton.
I've had some marginal success reading the angles and just turning bones on my skinned mesh in blitz3d.
Yes. I know I can just LOAD it outright.

The zip package includes:
My WORKING Max5 Importer MaxScript
My ALMOST-WORKING Blitz3d Playback program.
Actual Capture_0000.bvh from kinnect Brekel Windows Application
The Just Walkin' .avi file to see the max result.
A note I've made about basic matrix rotations and multiplication
based on a mathematics website and a smart Japanese fellow's
website.

Link:
https://sites.google.com/site/mikorians/BVH%20Playback.zip

Anyone expert who can enlighten us all about the matrix transformations I'm doing wrong will be appreciated.
The WORLD needs this.

Thanks to all in advance!


RemiD(Posted 2015) [#2]
Not really the answer you are looking for, but know that you can merge a bhv skeleton with animations with a ugh/b3d skeleton if the corresponding joints have the same name (with Fragmotion). It works well, i have done it. You can then export your rigged skinned animated mesh in b3d and then load it in blitz3d with loadanimmesh.


Mikorians(Posted 2015) [#3]
Thank you very much, RemiD (You're always so helpful).
I DO actually have Fragmotion! I wasn't aware it could do that.
But this program will also address a solution for multiple animations.

I've noticed the different axis orders. I tried swapping them around (nothing different happened)

UPDATE:I can already export skinned meshes with the .bvh import macroscript posted here!


Mikorians(Posted 2015) [#4]
It occurred to me-
Has anybody seen the supposed BVH skeleton loader for Blitz?
Does anybody have the source or a valid link to it?

IT WOULD BE A HANDY THING TO HAVE RIGHT NOW!


Mikorians(Posted 2015) [#5]
Working BVH Import MaxScript:




Mikorians(Posted 2015) [#6]
HERE is a REALLY GOOD Maxscript to start with.
(I adapted it to max 5)
http://zigncreations.com/shared/max_import_bvh.txt
It's by Markus Bliem 12/31/2007.

I would have posted the capture_0000.bvh file, but it was too large.
It's in the .zip file I mention throughout this discussion.


Rick Nasher(Posted 2015) [#7]
Cool. This may come in handy.


Mikorians(Posted 2015) [#8]
(Removed my pointless yacking about stuff that's now fixed)


Mikorians(Posted 2015) [#9]
(Removed more pointless blathering about answers I now have)


Mikorians(Posted 2015) [#10]
Hm. Not much response. Guess it's the Independece Day stuff.
I will be posting the vastly improved Maxscript!

I now see the unrotated skeleton in Blitz also.

I got the matrix arithmetic library from the codearc.
So now it's just a matter of transposing from max to blitz.
Nearly there. Anyone know more about receiving/setting
Xforms for entities properly? I just fiddle till I find the correct permutation...


Floyd(Posted 2015) [#11]
Not much response. Guess it's the Independece Day stuff.

And I guess it's because nobody knows anything.

If I understand this correctly bvh is motion capture data. Some human being has his movements recorded. The same motions will then be applied a 3d model of a person, or robot or King Kong or something.

It sounds like you want to use the motion data in Blitz3D. I would think the simplest way to get started is by experimenting with a model loaded into Blitz3D. Initially it would have to be in whatever state the bvh data expects. I suppose this is something like: standing up straight, arms hanging at sides etc.

The .bvh file tells you how to turn the various parts such as RightWrist, LeftHip...

In Blitz3D this can be done with TurnEntity, applied three times in the bvh order of Z,X,Y The turns can be global or relative to the parent. I assume bvh is doing relative turns.

One thing to watch out for is handedness. Blitz3D uses left handed coordinates, like Direct3D, and the bvh system is right handed. Typically that means Y is up, X is right, Z is into the screen for left handed and out of the screen for right handed. That probably means you need to turn the opposite direction for Z.

If you figure out how all of this works you can then get the matrices directly from Blitz3D with GetMatElement. I suppose you need them to build a .b3d file, or similar.


Mikorians(Posted 2015) [#12]
(He was actually RIGHT about it being super easy!)


Mikorians(Posted 2015) [#13]
https://sites.google.com/site/mikorians/BVH%20Playback.zip


Floyd(Posted 2015) [#14]
It's very hard to understand all of those matrix calculations, and I still don't know why they are needed.

Here is my view on what is happening. I will accept all the skeleton building and setup code as correct and just try to figure out the movements.

I have added a function at the beginning of the code, bvhRotateEntity. This mimics the bvh style of z,x,y order.

Look at the code starting at line 205. Three angles have been used in elaborate matrix calculations which are then used with RotateEntity. I have commented out the RotateEntity and instead use bvhRotateEntity with the three angles. It seems to accomplish the same thing.

I don't know what, if anything, is wrong with the rest of the code.




Mikorians(Posted 2015) [#15]
Thank's Floyd!
I will examine the difference, and perhaps the bug will be revealed. Blitz does things a bit differently from Max (or perhaps in a different order). Certainly Blitz is a bit more true to the parent/child relationship than Max is.

UPDATE: Both the codearc entry and a posted source listing touted as working were mathematically inappropriate. I now have a CORRECTED set of matrix arithmetic functions.

UPDATE2: Floyd's probably right about the tranformation matrices not being needed, but I'll include them for everyone anyway.


Mikorians(Posted 2015) [#16]
OK, I've updated ALL my previous postings.
It all works now.


Floyd(Posted 2015) [#17]
I looked at some of my earliest backup CDs and found a note and some code. Maybe you can make something of it.

From Halo, 12/27/2001

When creating an animation sequence with a hierarchal entity, you must set the animation key for each 
entity in the hierarchy. You may then add the animseq to any entity in the hierarchy, and all children will
be included. This wasn't easy to figure out. Please make it public knowledge.





Mikorians(Posted 2015) [#18]
Thanks a bunch, Floyd!
This IS the answer- it had an infinite loop bug and I had to update the text parser, and the floats from the file were being passed as ints.
But it plays the animation correctly!
It IS essentially CORRECT.
I may bother to post a more flexible, live-action thing much later.

(Here ya go Rick Nasher! Heh.)
I've updated my zip file posting also.

NOW you can watch it play AS the animation loads if you set inPlace=1 and CamAng=2 Ha! SSD drives be praised!



And here's MY version- Thanks to all who contributed to it and its components!
I wanted to make an ugly one that is easier to read without all of
the elegant bank work that the original program by Halo and TechLord had.
(It's in the .zip file:)




Rick Nasher(Posted 2015) [#19]
Pretty cool Mikorians ! (bit of delayed response)
This should pave the way for people who want to capture real live motion to incorporate in a game.


Mikorians(Posted 2015) [#20]
I was glad it turned out to be real simple after all.
Thanks to Floyd and all contributors to the archive, posts, and any codearc submissions, who's code mine is a derivative/compilation of!
I just wanted to ENSURE blitz users would be able to easily use this type of file and reap the rewards of motion capture.
(Max 5 users too! THAT was tricky!)

If you see your work in my code- just post here "I helped" !!!