www.jpct.net

Bones - Skeletal and Pose Animations for jPCT/jPCT-AE => Bones => Topic started by: raft on January 06, 2010, 11:45:01 pm

Title: Bones - Skeletal and Pose animations for jPCT
Post by: raft on January 06, 2010, 11:45:01 pm
Bones is a animation API for jPCT. It supports skeletal and pose animations. It's aimed to be small library with no additional dependencies where possible.

Bones can be found at its home page (http://aptalkarga.com/bones/). The download pack contains the source code, necessary libraries, Eclipse project files and a few demo applications. It's definitely free software with a "Do whatever with it" license.

Note: As the API evolved, following information is not exactly correct anymore. Please refer to Bone's home page (http://aptalkarga.com/bones/) for up to date information.



Bones initially loads skinning information via Ardor3D's (http://www.ardor3d.com/) Collada (http://www.collada.org/) loader. Out of this information, a series of SkinnedObject3D's are constructed. They have mesh data, textures coordinates and skinning information. It's enough to set their textures and call build() to prepare them to be added into a jPCT world.

After this initial loading, they can be saved in a compact form. Saved objects can be later reloaded with loader, with no dependencies to Ardor3D

At the moment, the project is at "Proof of Concept" state. Skinning and mesh deformation works, but skeleton poses can only be created programmatically. Hence it's not really useful for games at the moment. This is so since, Ardor3D's loader only support this much at the moment. As they progress, Bones will progress..

Cheers ;D
r a f t

Edit: Updated the link with some code cleanup and documentation.
Edit2: Updated title and description to reflect changes in the API
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on January 07, 2010, 02:49:05 am
A screen capture (http://www.youtube.com/watch?v=G3MLLsaKKxI) of demo at youtube
Title: Re: Bones - Skeletal animation for jPCT
Post by: EgonOlsen on January 07, 2010, 04:40:46 pm
Very cool. But what exactly does "but skeleton poses can only be created programmatically" mean? That you can't load any pre-edited animations from a file?

A little tool that bundles Ardor and jPCT to load the file, convert it into Bones' format and save it would be cool IMHO, so that one don't have to do this in code everytime.
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on January 07, 2010, 05:27:20 pm
That you can't load any pre-edited animations from a file?
yes, unfortunately it means that at the moment. only bind pose is loaded if you even call it a pose.

i dont know much about collada, so i'm not sure about what will be supported. as written in readme, the seymour file contains an animation but it's not loaded at the moment. Ardor3D is at an early state too, it would evolve. so lets wait and see ;)

btw, i guess Ardor guys got a little pissed of. they think they do the hard work and i copy it. kind of true indeed  ::)

A little tool that bundles Ardor and jPCT to load the file, convert it into Bones' format and save it would be cool IMHO, so that one don't have to do this in code everytime.
yes, i can do that, possibly a command line tool after the projects gets more mature and useful
Title: Re: Bones - Skeletal animation for jPCT
Post by: EgonOlsen on January 07, 2010, 06:23:49 pm
btw, i guess Ardor guys got a little pissed of. they think they do the hard work and i copy it. kind of true indeed  ::)
;D As long as you respect their license, what's the problem with that!? If they can't cope with such things, they shoudn't make it OS.
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on January 07, 2010, 06:29:44 pm
yeah, i think the same ;)
Title: Re: Bones - Skeletal animation for jPCT
Post by: EgonOlsen on January 07, 2010, 09:58:42 pm
The point is, that it doesn't make any difference for Ardor3D's developers if you wait for the animation system to improve to a) use it within Ardor3D, b) port it to jPCT or c) print the source code and use it as a wall paper. So i don't really get this "let us do the hard work" talk. If they don't want to do it, well...nobody forces them to.
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on January 28, 2010, 11:30:18 pm
Ardor guys progressed and so did i ;D Bones is getting closer to be useful. pre-saved animations can be played and multiple animation files can be merged in memory now.

this time i've significantly diverged from their implementation for both simplicity and to match jPCT semantics. for example i have two methods animateSkin(float, int) and animateSkin(float) with same functionality Object3D.animate(float, int) and Object3D.animate(float)

Ardor supports animation blending but i'm undecided about porting it yet..

a new capture:
<removed>

i will soon make a release after some cleanup..

cheers,
r a f t

edit: i removed the video because of licensing issues  :(
Title: Re: Bones - Skeletal animation for jPCT
Post by: paulscode on January 29, 2010, 12:53:54 am
Nice!
Title: Re: Bones - Skeletal animation for jPCT
Post by: EgonOlsen on January 29, 2010, 05:54:50 pm
edit: i removed the video because of licensing issues  :(
Of the model?
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on January 29, 2010, 06:01:39 pm
thanks ;D unfortunately using that skeleton model in demo was against ardor's license. so i removed the video. IMHO, these license things are really a pain in the ass >:( use that,  dont use this, use that but place a license note, bla bla bla..

anyway, if anyone has some nice looking collada models for a demo i will appreciate it ;)
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on February 06, 2010, 08:51:50 pm
well, after this model license thing i've tried to export karga models to collada format. the results weren't nice. my models are skinned with 3dsMax physique modifier which collada exporters (both max's builtin and openCollada) don't support ::) they want skin modifier. i've found this annoying since pyhsique and skin modifiers are essentially equivalent.

i've found a plugin to convert physique modifier to skin and it succesfully f*cked up my models >:( considering most of the ready to buy models are skinned with physique modifier, i've begun to question real world usability of this collada thing..

looking for alternatives, i've figured that Ogre3D plugin for max (ogremax) is very nice. it supports both modifiers and has lots of export options to organize things. it's also nice that options are saved with max file.

i was about to dive into Cyberkilla's Ogre loader and fix it then I found jME has a mature Ogre loader. after some going mad and bumping my head to wall period i've managed to import its data into Bones. it was kind of hard because it's internal working is slightly different from Ardor's. for example, in jME's root joint's rotation is baked into all joint's inverseBindMatrix. anyway, i managed to use it ;D

Bones now can load skins via either Ardor's Collada loader or jME's Ogre3D loader. It's API is beginning to mature. i especially tried to make it match to jPCT semantics. it also have import script files for windows and *nix which convert Collada and Ogre skins to Bones binary format. I've uploaded the new version, it's downloadable

A screen capture of a skin loaded with jME's OgreXml loader:
http://www.youtube.com/watch?v=dGaaxiSwH_Y

cheers ;D

note: hope model license wont be a problem this time. i've wrote to jME forums but couldnt get an answer yet. that model originates from Ogre3D's samples and used in jME's samples. i guess i can use it too  ;)
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on February 07, 2010, 06:03:14 pm
updated the documenation. added support to clone SkinnedGroup. added a version history page.
Title: Re: Bones - Skeletal animation for jPCT
Post by: AGP on February 19, 2010, 05:04:23 pm
Raft, I just saw this. I gotta say, I'm really looking forward to the evolution of your project. This is priceless functionality for jPCT. Please don't let your project go like Cyber's and thanks very much.

BTW, I'm sure you could use Cyber's Ogre3D importer in your project since Cyber's is open source. Ask him, if you feel you need to, but no doubt he would let you.
Title: Re: Bones - Skeletal animation for jPCT
Post by: AGP on February 19, 2010, 05:28:40 pm
Also, do you have the specs to your file format so that one could write a MaxScript to export it?
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on February 19, 2010, 05:39:17 pm
thanks and you are welcome ;D Bones is stable and usable at the moment. you can use it as a replacement of jPCT's mesh animation or with it.

i'm not sure if it will evolve anymore. maybe i can add animation blending, but undecided about it, as very few -if any- people will use it. maybe real life usage will dictate some additions/modifications.

as i said in above posts, my first attempt was to use/fix cyber's ogre3d loader but as jME has a stable loader it seemed easier and more natural to use it.

for exporting, Bones uses java serialization. it doesnt serialize whole objects but parts of it. you can look at the code, it's straightforward. a custom exporter is possible but IMHO there is no need for it. i would suggest collada or even better OgreMax exporter to export from 3ds max. then use the Bones scripts to convert to bones format..

r a f t
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on February 25, 2010, 05:07:36 pm
an experimental facial animation demo:
http://www.youtube.com/watch?v=vemKY9kosvI

the model and animation is loaded via jME's OgreXML loader. in Ogre terminology, it's Pose animation (http://www.ogre3d.org/docs/manual/manual_80.html). it's similar to jPCT's mesh animation but instead of vertex positions, vertex position offsets are stored in animation file. the good thing about this is, as offsets are used, multiple pose animations can be easily blended. it's also possible to blend pose and skeletal animations. it also requires less space as data is only stored for animated vertices.

however i'm not sure how to combine this with skeletal part of Bones. possibly many of classes will be renamed to provide some space for new ones and some restrictions will be relaxed.

these two parts will possibly use two different IVertexController's, so another question is how to make them cooperate in an easy to use manner such that one doesn't destroy other's work.

r a f t
Title: Re: Bones - Skeletal animation for jPCT
Post by: .jayderyu on February 25, 2010, 06:38:18 pm
nice, I didn't imagine that Bone/skeletal animation could have facial animation. That's awesome. Great job to Raft who's doing the porting and the Ardor3d team.
Title: Re: Bones - Skeletal animation for jPCT
Post by: raft on February 25, 2010, 10:00:08 pm
thanks ;D this time it's jME port indeed  ;)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on March 29, 2010, 08:53:24 pm
i've uploaded the new release. quite a lot of changes this time:


Sorry for breaking backward compatibility but as nobody is actively using Bones, this wont differ that much

A capture of animation blending demo (http://www.youtube.com/watch?v=nq5q4NmuQVo)

cheers ;D
r a f t
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on March 30, 2010, 03:49:35 pm
new version:
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on March 30, 2010, 08:17:39 pm
I can't help, but your test object reminds me of some part of the male body that has no bones at all... ;D
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on March 30, 2010, 08:30:33 pm
ehm ::) i agree but it's not intentional ;D
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 01, 2010, 03:08:51 pm
updated the Android sample to show/animate up to 8 ninjas. starting from second model fps seriously drops. below screenshot is taken from G1. 3 models @ 4fps.

i wonder how this will perform in nexus one. maybe dl.zerocool can try this too ;)

(http://img163.imageshack.us/img163/1843/3ninjas.png)
 
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: dl.zerocool on April 01, 2010, 04:36:42 pm
Hello there,

As always I'm proud to test your apps, and here are the results.

Without animation:
(http://img88.imageshack.us/img88/9673/withoutanimation1.png) (http://img88.imageshack.us/i/withoutanimation1.png/)
(http://img339.imageshack.us/img339/5464/withoutanimation2.png) (http://img339.imageshack.us/i/withoutanimation2.png/)

With animation:
(http://img130.imageshack.us/img130/8531/withanimation1.png) (http://img130.imageshack.us/i/withanimation1.png/)
(http://img709.imageshack.us/img709/7686/withanimation2.png) (http://img709.imageshack.us/i/withanimation2.png/)
(http://img130.imageshack.us/img130/6642/withanimation3.png) (http://img130.imageshack.us/i/withanimation3.png/)

Hope it will be helpful.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 01, 2010, 05:10:28 pm
thanks dl, they really help :D

12 fps with 3 models. with some bubbles and a simple gui this will drop to ~8-10 fps. so a very lite karga seems to be barely playable even on nexus one :-\
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 02, 2010, 10:59:25 am
Maybe not when using Bones on Android,  but keyframe animations should run much faster. A simple md2 runs at around 25fps on my phone.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 02, 2010, 01:56:12 pm
how many polygons ?

skeletal animation occupies much less space and possibly loads faster. maybe creating mesh keyframes on the fly is the way to go..
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 02, 2010, 03:49:50 pm
I'm not sure about the polygon count...it's that snork md2 that i used for the first alpha of Robombs. It's a normal md2, i.e.,its polygon count should be similar to most other md2s.

Using a hybrid to generate keyframes from a skeletal animation sounds like a smart and scalable approach.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 02, 2010, 04:17:17 pm
possibly very low polygon, in 200-300 range or similar.. ninja is about 900 + 100 (body and sword are seperate models)

i've tried ninja demo with mesh keyframes. it does run faster as expected, something like %15-20 (hard to measure exactly) but definetely not a boost. skeletal animation does moderately heavy matrix calculations but seems as it's not the bottleneck. pumping mesh data to gpu is. %20 increase is definetely good but the memory cost is also high.

here is the apk if wanna see. you can switch to mesh/skin animation via menu
http://www.aptalkarga.com/bones/Bones-Android-Ninja2.apk

regarding discussion in android board (http://www.jpct.net/forum2/index.php/topic,1542.msg11360.html#msg11360), if we had a JIT this time, it will just allow skeletal animation performance approach to mesh animation. after that we would still be limited to java to native data passing barrier, rigth ? or am i missing something ?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 02, 2010, 05:04:34 pm
I'm not sure what exactly is so slow when transferring data from VM to native memory. This isn't a problem in normal Java, so it should be possible to get it up to speed in Dalvik too and maybe a JIT will help there too.
Right now, optimizing this is all a big trial and error game. I used to do transfers put by put, which was pretty slow. So i changed that to put large float[]-arrays instead in one call, which was faster. When optimizing the blitting, i did this too, i.e. i changed the single puts to normal float[]-access and one final put at the end...and the result was slower!? I then started to use indexed geometry instead and suddenly, the float[]-method was faster again!?
And that's just on my hardware. I've no idea what might be faster on other hardware. 
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: AW999 on April 04, 2010, 07:44:56 pm
At the moment, the project is at "Proof of Concept" state. Skinning and mesh deformation works, but skeleton poses can only be created programmatically. Hence it's not really useful for games at the moment.

  It's strange that you claim it's not useful -  I've been looking for a way to generate this type of thing programmatically so that it's based on context rather than being locked into a small set of stock poses (and so that I don't have to tediously make the poses manually).
I'm hoping you'll retain this feature - this is exactly what I've been looking for, and even the early demos look impressive. 
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 04, 2010, 09:26:03 pm
Quote from: AW999
It's strange that you claim it's not useful -  I've been looking for a way to generate this type of thing programmatically so that it's based on context rather than being locked into a small set of stock poses (and so that I don't have to tediously make the poses manually).
i meant very few people will benefit it. most prefer precanned animations. and to tell the truth making programatic poses look as expected is kind of tedious job.

Quote from: AW999
I'm hoping you'll retain this feature - this is exactly what I've been looking for, and even the early demos look impressive. 
sure, there is no need to remove it. indeed i exposed many more package private constructors and methods to allow programatically create skeletons aniamations etc..

i'm glad you liked it and hope it will be useful ;D at least according to my tests, Bones seems quite stable at the moment
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: zammbi on April 12, 2010, 04:44:58 pm
Testing on "Bones-Android-Ninja2.apk" is this the latest?

8 walking characters:
Skin animation: 8fps
Mesh animation: 16fps
No animation: 31fps

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 12, 2010, 05:02:31 pm
Quote from: zammbi
Testing on "Bones-Android-Ninja2.apk" is this the latest?
yes, i guess so.

thanks for the tests :D similar results with nexus one. bones need a JIT to perform well..

this is kind of expected since it makes moderately heavy matrix calculations. a couple for each skeleton joint to pose them, then up to 4 vector-matrix multiplication for each vertex..



Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 12, 2010, 05:15:11 pm
Does Bones use jPCT's matrix and vector stuff for this or something else?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 12, 2010, 05:21:50 pm
it mostly uses jPCT's matrix and vector class. for rotations it uses quats
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 12, 2010, 05:29:40 pm
So it might help to do some micro optimizing of these methods? Could you provide some data on method usage to know where to look first?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 12, 2010, 05:46:45 pm
sure, i will be glad indeed :D

* SkeletonPose.updateTransforms() updates joint matrices. matrix-matrix multiplication
* JointChannel.applyTo(..) and variants applies precanned animation to skeleton pose. interpolates quats and vectors and sets them on matrix
* Animated.applySkeletonPose() is the method where skeleton pose is applied to mesh. vector-matrix multiplciation and vector addition
* and a few Matrix.setTo(), Matrix.setIdentity(), SimpleVector.set(..) calls to avoid creation of new ones
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 13, 2010, 11:26:17 pm
Updated the jar with a version that includes some micro opts. However, matrix multiplication, as the most complex operation of the ones you mentioned, already has been optimized pretty much to the death and the other methods didn't offer much room for improvement, so you might not notice it at all (except when i broke something by accident...).
I played around with the idea to offload the matrix multiplications to the GL driver, but it was much slower.... :'(
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 13, 2010, 11:57:20 pm
there seems to be a slight increase but hard to measure. it'a a combined effect i suppose. i also made some minor optimizations like assigning static temp fields to method variables. apk (http://www.aptalkarga.com/bones/Bones-Android-Ninja.apk) is up to date
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 14, 2010, 07:53:15 am
Yep, seems to be a tad faster. After all, even those tiny increases will stack up in the end. My demo scene went up from 20 to 31fps during the last few weeks and at least 50% of this increase can be tributed to micro optimizations....Dalvik is very rewarding in this aspect.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: zammbi on April 14, 2010, 04:11:43 pm
Quote
apk is up to date

8fps for walking 8 people. Same as the last demo I ran. But that's probably because of my fpu.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: fir3d on May 10, 2010, 07:05:08 pm
Is it usable in games now? I dont know what most of you all are talking about here  ;D, but I do know how to use a biped in 3ds max and was hoping it would work for games eventually.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 11, 2010, 12:19:13 am
Is it usable in games now?
yes, on desktop definetely it is :D try ogre3d exporter (ogremax (http://www.ogremax.com/)) for max. on Android, Bones suffers performance which is kind of expectable because of dalvik vm and -moderately- heavy matrix calculations :-\
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: fir3d on May 11, 2010, 12:46:07 am
Is it usable in games now?
yes, on desktop definetely it is :D try ogre3d exporter (ogremax (http://www.ogremax.com/)) for max. on Android, Bones suffers performance which is kind of expectable because of dalvik vm and -moderately- heavy matrix calculations :-\

Hopefully they are going to have some major improvements to the dalvik vm with the next android version (froyo).
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 11, 2010, 12:54:23 am
yes, we all hope for a JIT for Android..
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: zammbi on May 11, 2010, 06:17:08 am
Sounds like 2.2 will have JIT and flash :) Oh and maybe install programs on a flash card too!
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: faceb on May 25, 2010, 02:43:14 pm
hey, i have been trying to run samples of bones. all of them running quiete good. but when i try to use another 3d model, some exceptions are thrown.

Code: [Select]
Exception in thread "main" java.lang.IllegalArgumentException: parent index should be less than joint index. o/w a joint array cannot be ordered such that parent comes first
at raft.jpct.bones.Joint.<init>(Joint.java:36)
at raft.jpct.bones.BonesImporter.convertJMEJoint(BonesImporter.java:359)
at raft.jpct.bones.BonesImporter.convertJMESkeleton(BonesImporter.java:332)
at raft.jpct.bones.BonesImporter.importOgre(BonesImporter.java:151)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:93)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:77)
at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:58)
at Converter.main(Converter.java:24)

im using blender to create animations, and ogre mesh export plugin to export them as mesh xmls.
i tried more than 5 different models, but i couldnt succeed.
hope one of you help me. thanks.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 25, 2010, 02:53:54 pm
mm, Bones expect joints to be ordered such that parent always comes before children. all of the models i've seen so far obey this rule. seems as your exporter does not..

can you please post the exported xml file ?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: faceb on May 25, 2010, 04:36:40 pm

these are exported files from blender with orge exporter plugin for blander.

male.mesh.xml
http://www.2shared.com/document/96gHiqlc/malemesh.html

male.skeleton.xml:
http://www.2shared.com/document/--_XAEVM/maleskeleton.html

Scene.material(it seems bones dont user such a file)
http://www.2shared.com/file/frNBp45d/Scene.html

to get files there is a link at the bottom of the page "Save file to your PC: click here".

thanks for your quick response :)

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 25, 2010, 05:41:30 pm
it says :(
Quote
The file link that you requested is not valid. Please contact link publisher or try to make a search
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: faceb on May 25, 2010, 05:47:34 pm
damn upload services  >:(

try this one.
http://rapidshare.com/files/391472693/man-mesh.7z.html

or
http://uploading.com/files/fd9b4488/man-mesh.7z

http://www.sendspace.com/file/oeaiov
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 25, 2010, 06:26:12 pm
ok, i got it. i will have a look at it tonight or tomorrow
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 26, 2010, 01:10:23 am
well, seems as this will take a while :(

the thing is, as i said Bones expects joints ordered such that parent joint comes before child one. this eases a lot of calculations since in skeletal animation each joint's transform is in its parent space. ie: we can process joints in the given order and be sure that parents are processed first.

i tried to sort Ogre joints according to this order but somehow final result got messed up ::) i couldnt figure what is wrong yet ???

sorry for the inconvenience :-\
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 26, 2010, 02:21:56 am
a screenshot of your skeleton in bind pose may help to visualize the problem..
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: faceb on May 26, 2010, 02:16:46 pm
i used blender 3d models at http://www.katorlegaz.com/3d_models/

the one i shared yesterday contains a sample animation which i made.
original model is http://www.katorlegaz.com/3d_models/human_male/0143/male-01-suit.zip.

screenshot of the model in blender is here:http://img707.imageshack.us/img707/1368/manz.jpg

however if i didnt misunderstand , you mean, by sorting bones in following skeleton.xml file, probably, i can resolve the problem ?
i will try it.
Code: [Select]
<skeleton>
<bones>
<bone id="14" name="hip">
<position x="0.000000" y="-0.000000" z="-0.727107"/>
<rotation angle="0.146724">
<axis x="1.000000" y="0.000000" z="0.000000"/>
</rotation>
</bone>
<bone id="81" name="abdomen">
<position x="0.000000" y="0.778774" z="1.265279"/>
<rotation angle="0.213292">
<axis x="-1.000000" y="0.000000" z="0.000000"/>
</rotation>
</bone>
.
.
.

one more thing, is there another way to convert 3d models to mesh xml?

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 26, 2010, 09:34:14 pm
oops, somehow notification mail went to my spam folder :-\

Quote from: faceb
however if i didnt misunderstand , you mean, by sorting bones in following skeleton.xml file, probably, i can resolve the problem ?
yes that will probably solve the issue. but is kind of tedius..

i guess i've solved the problem. my samples and yours loads and plays fine. can you please try it. you can download it here (http://www.aptalkarga.com/bones/bones2.zip). however there are some spike like joints in your skeleton so i couldn't be sure if it's ok. i cant see them in your screenshot since it's taken from front.

Quote from: faceb
one more thing, is there another way to convert 3d models to mesh xml?
if you ask for blender i dont know. if you have 3dsMax OgreMax is a good exporter for it.

hope this helps
r a f t
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: faceb on May 27, 2010, 12:15:56 am
its working, perfectly perfect  :D
thanks.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 27, 2010, 08:41:29 am
cool :D than i'll make that the official release tonight
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 27, 2010, 09:32:19 pm
done. latest updates are in official (whatever it means ;)) version now..
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: stillw on September 20, 2010, 08:25:15 pm
Hi raft,

Can you give a newb some advice pls? My question is really to check with you that I understand what I need to do correctly, so I'm not headed down a blind alley.

Summarising: I am making a 3D animated app for the first time. I realised that I need to give it an armature and use that to move it and so started learning Blender. Then I came across your (frankly) amazing work, and I really think it's the way for me to go. So, I believe I have to now either export Blender models to Ogre or just start anew with Ogre and learn how to do the animation there. Then I'll need to learn JPCT and Bones... so a bit of work for me to do... that's ok, part of the fun, eh!?

Here's what I'm mostly doubtful about: My app will involve a figure moving in time (movements are pre-determined steps) to a beat, and the user will have the ability to vary that beat. I'm imagining that the best way is for me to build my animations in Ogre and load them through Bones and then play them back (I hope) at a speed that corresponds to the beat, (slower/faster). Is it possible to vary the speed of a pre-loaded animation? If not I may have to do it all programatically...

In the future the user may even be able create new steps for the movements, this which could be either by stitching together parts of steps from pre-built animations, or purely programmed, or even by building into my app some kind of interface to Ogre animation... Perhaps you have some ideas about that, but if you feel that this affects how I should be working out the immediate issues I have, please let me know!

Thanks so much for your time, and any help you can lend :)
stillw

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on September 20, 2010, 09:04:44 pm
hi stillw,

Quote
So, I believe I have to now either export Blender models to Ogre or just start anew with Ogre and learn how to do the animation there. Then I'll need to learn JPCT and Bones... so a bit of work for me to do... that's ok, part of the fun, eh!?
basicly true. but an important note, Ogre is not a 3D editor like Blender. it's a 3D engine like jPCT. you dont need to learn it but need some tool which can export to its format (which bones can load). there are many ogre exporters for many 3D tools including blender. but someone tried blender ogre exporter in the past (see the previous pages in this thread) and it turned out exporter is faulty. at least for that specific model and animation. maybe it works for you but no guarantees..

if you somehow have access to 3ds Max, i suggest OgreMax plugin for max. i found it quite successful.

Quote
Is it possible to vary the speed of a pre-loaded animation? If not I may have to do it all programatically...
sure. in deed there is no such thing in Bones (and also in jPCT) to play animation in pre-canned speed. but it's quite simple to do. all you need to do is calculate an index in [0-1] range which maps to a time in an animation sequence. see: Animated3D.animateSkin(index, sequence) (http://www.aptalkarga.com/bones/api/raft/jpct/bones/Animated3D.html#animateSkin(float, int)) have a look at the samples in Bones, you can change the speed with a slider.

Quote
In the future the user may even be able create new steps for the movements, this which could be either by stitching together parts of steps from pre-built animations, or purely programmed, or even by building into my app some kind of interface to Ogre animation... Perhaps you have some ideas about that, but if you feel that this affects how I should be working out the immediate issues I have, please let me know!
both are possible. you can programatically merge animation segments into a new one or virtually merge them (ie: they are not really merged but played one after another to give that felling). you can also create animations programatically from scratch. you dont need to worry about this for now, once other parts are done this wont be hard to add..

Quote
Thanks so much for your time, and any help you can lend :)
np, hope this helps ;)

r a f t
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: stillw on September 20, 2010, 11:00:14 pm
Truly excellent news... I'm getting excited about this now :)

Thanks again, and also for the tip on using Ogre... I installed it on my Ubuntu/Linux system and couldn't find it to run (ie. looking for a gui), but after what you said, now that makes more sense!

Yes, I did read all of the posts in this thread before (actually >1 time). I'm aware I may run into the order of bones problem, but it seems easy enough to sort... and my skeleton is really going to be simple and (hopefully) not updated often, it will be the animations that might get changed.

cheers
stillw
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on September 20, 2010, 11:12:05 pm
I'm aware I may run into the order of bones problem, but it seems easy enough to sort... and my skeleton is really going to be simple and (hopefully) not updated often, it will be the animations that might get changed.
actually the ordering of bones is not a problem anymore. they can be in any order now. the problem i had mentioned is another one. it isnt mentioned in this thread but this one (http://www.jpct.net/forum2/index.php/topic,1641.msg12196.html#msg12196).
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: stillw on September 20, 2010, 11:51:48 pm
Oh, I didn't read that one! Mmm...

I have to travel for a few weeks, during this time I'll get to try out the animations (this is all learning from scratch). When I come back I'll see how this all goes and what options I have. I am not heavily invested in Blender, just that it's the only 3D modelling tool I've used, and I've been through several tutorials with it. Free is best right now... I'm really in proof of concept kinda stage :)

ty Raft!
Title: Ogre scene loading
Post by: Mr.Marbles on September 28, 2010, 12:24:38 am
Raft, thanks for the great ports of the Ogre & Collada loaders!

I've actually been using the Ogre loader for some time in jME and I had all my meshes organized into scene files which was supported by the loader. I noticed your API doesn't support scenes. Do you have any intentions on supporting them?
Title: Re: Ogre scene loading
Post by: raft on September 28, 2010, 12:50:30 am
I noticed your API doesn't support scenes. Do you have any intentions on supporting them?

not really. my primary purpose was an animation library. but porting them from an existing loader wont be that hard, why not create another project yourself ;)
Title: Re: Ogre scene loading
Post by: Mr.Marbles on September 29, 2010, 12:28:55 am
... porting them from an existing loader wont be that hard, why not create another project yourself ;)

If I have time I will definitely look into that.

I have another question, about the Collada loader. I was scratching my head trying to figure out why all my previously working textures didn't map properly until I compared your Seymour texture to the original one in Ardor3D. Also the "_flipped.png" in the texture name hinted something as well  :) I'm just curious as to why the textures need to be vertically flipped from their original positions in order to get them to load properly.
Title: Re: Ogre scene loading
Post by: raft on September 29, 2010, 01:07:58 am
I have another question, about the Collada loader. I was scratching my head trying to figure out why all my previously working textures didn't map properly until I compared your Seymour texture to the original one in Ardor3D. Also the "_flipped.png" in the texture name hinted something as well  :) I'm just curious as to why the textures need to be vertically flipped from their original positions in order to get them to load properly.
well, that's a good question and i'm not sure i have the correct answer ;)

seymour's original texture is in TGA format and Ardor flips TGA textures vertically while loading. so i assumed flipped one is correct and later forgot the matter. what is the format of your textures? how did you export your models? you said you were using JME loader, possibly it shares same loader code with Ardor and maybe flipping your textures too.

i'm not sure which behaviour is correct here ??? i can sure flip UV's while loading but not sure if that fits all cases. AFAIK Ardor passes UV's to OpenGL as they are and jPCT does the same. so the UV's should be correct IMHO

please have a look at the posts below:
http://ardor3d.com/forums/viewtopic.php?f=10&t=501&p=3712#p3712 (http://ardor3d.com/forums/viewtopic.php?f=10&t=501&p=3712#p3712)
http://www.jpct.net/forum2/index.php/topic,1490.0.html (http://www.jpct.net/forum2/index.php/topic,1490.0.html)

sorry for the trouble ::)
Title: Re: Ogre scene loading
Post by: Mr.Marbles on September 29, 2010, 04:23:46 pm
seymour's original texture is in TGA format and Ardor flips TGA textures vertically while loading. so i assumed flipped one is correct and later forgot the matter. what is the format of your textures? how did you export your models? you said you were using JME loader, possibly it shares same loader code with Ardor and maybe flipping your textures too.

My textures are in jpg format. I used jME for Ogre models and Ardor3D for Collada models. In both cases I never needed to flip the textures, but I did need to flip them to have them work with your Bones lib. This seemed strange to me since Bones is using the Ardor3D Collada loader (although it's probably an older version).

I'll take a look at the links you posted. Thanks.
Title: Re: Ogre scene loading
Post by: Mr.Marbles on September 29, 2010, 04:40:59 pm
please have a look at the posts below:
http://ardor3d.com/forums/viewtopic.php?f=10&t=501&p=3712#p3712 (http://ardor3d.com/forums/viewtopic.php?f=10&t=501&p=3712#p3712)
http://www.jpct.net/forum2/index.php/topic,1490.0.html (http://www.jpct.net/forum2/index.php/topic,1490.0.html)

So it appears Ardor3D Collada loader is programmatically flipping the textures when the models are loaded. I noticed that in the jPCT Seymour example you use:

Code: [Select]
ColladaImporter colladaImporter = new ColladaImporter().loadTextures(false);
...
Texture texture = new Texture("./samples/data/seymour/seymour_flipped.png");
TextureManager.getInstance().addTexture("seymour", texture);

for (Animated3D o : skinnedGroup) {
    o.setTexture("seymour");
    o.build();
    o.discardMeshData();
}

And in the Ardor3D example the textures are loaded automatically by the ColladaImporter:

Code: [Select]
final ColladaImporter colladaImporter = new ColladaImporter();

// Load the collada scene
final ColladaStorage storage = colladaImporter.load(source);

So maybe we could avoid the manual texture flipping if Bones ColladaImporter would use the built-in texture flipping of Ardor3D. Just a guess  :-\
Title: Re: Ogre scene loading
Post by: raft on September 29, 2010, 04:55:09 pm
So maybe we could avoid the manual texture flipping if Bones ColladaImporter would use the built-in texture flipping of Ardor3D. Just a guess  :-\
if i got you correctly, this is irrelevant. Bones does not use texture information from Ardor's Collada loader in any way. only the UV's are used.

i've got another look into Ardor's loader code. seems as it flips all Collada textures. this may be because of Collada UV's are flipped compared to OpenGL's. if this is the case, i can flip UV's while loading. i googled for this but couldnt find anything yet. also i wonder, if this is the case, why not Ardor flip UV's instead of textures ???
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on September 29, 2010, 06:35:28 pm
i couldn't find something official but according to this post (http://www.collada.org/public_forum/viewtopic.php?f=12&t=1227) Collada's V's is flipped compared to OpenGL. so flipping V's while loading seems to be the best choice.

please try the flipped version below:
<removed>

edit: removed the obsolute link
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Mr.Marbles on September 29, 2010, 10:35:35 pm
please try the flipped version below:
http://www.aptalkarga.com/bones/bones.flip.zip (http://www.aptalkarga.com/bones/bones.flip.zip)

Thanks for the fix, seems to work fine.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Mr.Marbles on September 29, 2010, 10:37:55 pm
Just hit another issue, I can't get my static, non-animated, collada models to load with Bones. They work fine in Ardor3D. Seems like Bones needs to have an AnimatedGroup in order to load the model in the World. Is this the only way to get a Collada import into jPCT?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on September 29, 2010, 10:51:46 pm
cool ;D i've made that the offical release.

for static models, that's right, you cannot load such models via Bones. this is an animation library afterall. AFAIK there is no Collada loader for jPCT. but you have the options to export them to 3ds or obj format which offer more functionality for such objects. for example there is no way to load multi textured objects via Bones at the moment.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: shadow on October 26, 2010, 10:47:59 pm
Hi,

I try to use Bones for the first time and all the examples work alright! Now I'm trying to get my own model running...
I created a figure in Blender, made some very simple animation with it and explorted it to an Ogre Mesh. Then I modified the OgreSample.java from the samples to load my own model. The frame opens but I cannot see my model at all. Do you have an idea why? Can it have something to do with the "Rotation axis not normalized" warnings? This is the console output:

Code: [Select]
Java version is: 1.6.0_21
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
26.10.2010 22:33:28 com.jme.scene.Node <init>
INFO: Node created.
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNUNG: Rotation axis not normalized
26.10.2010 22:33:28 com.jme.scene.Node attachChild
INFO: Child "CubeMesh000" attached to this node "Cube"
-- total 17 joint(s) --
0 name: Bone, parent:
1 name: Bone.001, parent: 0:Bone
2 name: Bone.004, parent: 0:Bone
3 name: Bone.007, parent: 0:Bone
4 name: Bone.011, parent: 3:Bone.007
5 name: Bone.014, parent: 3:Bone.007
6 name: Bone.008, parent: 3:Bone.007
7 name: Bone.002, parent: 1:Bone.001
8 name: Bone.005, parent: 2:Bone.004
9 name: Bone.006, parent: 8:Bone.005
10 name: Bone.009, parent: 6:Bone.008
11 name: Bone.012, parent: 4:Bone.011
12 name: Bone.003, parent: 7:Bone.002
13 name: Bone.010, parent: 10:Bone.009
14 name: Bone.016, parent: 9:Bone.006
15 name: Bone.013, parent: 11:Bone.012
16 name: Bone.015, parent: 12:Bone.003
-- --
Skeleton created out of jME OGRE skeleton, 17 joints
Created skeleton animation clip: Action
Loading Texture..../data/models/jessica.png

Thanks very much in advance!
Stefan
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on October 27, 2010, 12:00:53 am
i've never experienced a problem related with those warnings. jME's ogre loader prints those warnings for all the models i tested.
can you see the joints or nothing at all? a screenshot may help

i've never used but another user reported Blender's Ogre exporter is faulty. have a look at this thread (http://www.jpct.net/forum2/index.php/topic,1641.msg12196.html#msg12196).

if you have access to 3ds Max, i suggest OgreMax plugin for max. i found it quite successful.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: fireside on October 27, 2010, 05:37:24 am
I've been looking around on this.  One suggestion is to select the mesh and then press cntrl-a before exporting.  Another is to make sure there is only one root bone in the skeleton.  Another is to make sure the path to the material is right in the material file.  If you do get this working, please post how you did it. 
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: shadow on October 29, 2010, 08:10:02 pm
@raft

Heres a screenshot of my problem:

(http://iluzio.de/Screenshot.png)

Unfortunately I see nothing at all, I tried to zoom in and out and rotate, nothing appears :(
BUT: My Animation (called "Action") is in the list. And also in my previous post you can see that the armature is recognized in the file
I do not have max, I definitely want to use Blender... now I updated to the latest exporter script.


@fireside

I applied scale and rotation data to object -> no effect :(
And my armature has only one root...
I'm not sure if it has something to do with the materials because I neither see polygons nor armature. But anyway what does this mean "the material is right in the material file" ?


Thanks for your support but so far I did not get it running. Maybe it helps if you see my files? I created an archive with blender and OGRE mesh files...
http://iluzio.de/models.zip


And another question:
If this does not work, I do not have to use bone animation, although it would be very cool. Do you know an easy way to get my animated models from Blender into JPCT?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: fireside on October 29, 2010, 09:13:57 pm
The material file has to have the right path, I guess.  I just read some things on the internet.  It's apparently a problem for different engines but people appear to be using it.  I might try to do some experimenting, but it would probably be better to just use some of my own models when I do.  I'm in the middle of trying to fix a bunch of code so I don't want to shift right now.

I use 3ds with Jpct.  You can just take snapshots of the model in different poses and use them for frames.  I use low poly models so it's no big deal, but this skeletal deal would still make the files even smaller if I could get it working.  I put a little section in the wiki about it for 3ds and Blender.

I found this guide for exporting to Ogre in Blender it was dated 2009:
conoroneill.comli.com/blenderexportguideforogre.pdf
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on October 29, 2010, 10:45:56 pm
Quote from: shadow
Thanks for your support but so far I did not get it running. Maybe it helps if you see my files? I created an archive with blender and OGRE mesh
boneassignments element is empty in mesh file. there should be vertexboneassignment elements in it which states joint weights over vertices. seems as blender ogre exporter somehow doesnt export those. without weights skeletal animation is not possible.

jME's ogre loader leaves weights as NaN values, as a result vertices are calculated as NaN which in turn results in autoAdjustCamera() method move camera to neverland.

comment the autoAdjustCamera(); in OgreSample.initialize() method and your skeleton will showup.
(http://img139.imageshack.us/img139/1751/screenshotbonessampleso.png)

add the following lines to OgreSample and your model will showup.
Code: [Select]
       @Override
protected void update(long deltaTime) {
cameraController.placeCamera();
}
by doing this we are preventing skeleton pose to be applied to mesh.

(http://img153.imageshack.us/img153/1751/screenshotbonessampleso.png)

as a conclusion, seems as this is blender ogre exporter's fault :(
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on October 30, 2010, 01:10:10 am
here ninja's texture is applied to your model, so it may look different.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: shadow on October 30, 2010, 02:35:03 am
Yes, eeemm.... I forgot to add the right texture to the zip archive, but here I have it and it looks alright!

Thank you very much (!!) for figuring this out, but I really must say, I don't have any clue whats going on here...
With removing (or commenting) the autoAdjustCamera(); the skeleton is visible, and it is animated too! Thats cool so far...

But overriding the update() method it seems to me a lot of animation code is ommited. Why is the model rendered now because of this? And how did you find this out so fast :) ??


/EDIT:
If we could identify whats wrong with the export, maybe the ogre mesh script author could adjust his work....  May be an option.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on October 30, 2010, 03:35:09 am
Quote
But overriding the update() method it seems to me a lot of animation code is ommited. Why is the model rendered now because of this?
right, by overriding the update() method we just omit animation code. animation code applies skeleton pose to mesh and in this case as necessary data is missing we got wrong results.

Quote
And how did you find this out so fast :) ?? 
by debugging and comparing your mesh file a correct one (ninja mesh) ;D

Quote
If we could identify whats wrong with the export, maybe the ogre mesh script author could adjust his work....  May be an option.

as i said, joint weights are missing in mesh file. it should be something like below but vertexboneassignment elements are missing
Code: [Select]
<boneassignments>
                <vertexboneassignment vertexindex="0" boneindex="12" weight="1" />
                <vertexboneassignment vertexindex="1" boneindex="12" weight="1" />
                <vertexboneassignment vertexindex="2" boneindex="12" weight="1" />
...
</boneassignments>
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: shadow on October 30, 2010, 04:43:36 pm
Hey guys! I got it running!
Thank you so very very much for your help!!

Problem was, that I used envelope bones and the exporter wasn't able to convert them to Ogre MESH Xml. Now I  made the same thing with Blenders "Weight Painting" and then the bone weights seem to be exported!

If someone is interested, I did my experiments today with a sample model which I uploaded to this archive:
http://iluzio.de/models2.zip

One thing is still a bit mysterious though, as you can see in the following image. I have arms, legs and head bones but they aren't rendered in the Sample app. But the torso and hip bones are rendered. There must be some difference between them...

(http://iluzio.de/Screenshot-3.png)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on October 30, 2010, 06:32:47 pm
cool. i'm glad you resolved the issue :D
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: AGP on November 07, 2010, 05:45:19 pm
Raft, I have now tried OgreMax on both 3ds max 2009 and 3ds max 2010 (both 64-bit) and neither have worked (both have failed to run and give an error message when Max executes). I'm using the trial version, and I'm not feeling too confident in buying it. Did you have this experience with the trial or did did it run smoothly for you? Do you have a 32- or 64-bit installation of Max?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: AGP on November 07, 2010, 09:09:22 pm
The 64-bit version simply doesn't work, the 32-bit one does. Anyway, how do I load an Ogre model into Bones? Is it as simple as:
Code: [Select]
java.io.FileInputStream inStream = null;
try {

     inStream = new java.io.FileInputStream(objectFileName);
     model = BonesIO.loadObject(inStream);
}
catch (Exception e) {System.err.println("Problem loading file: "+e.getMessage()); return;}
Or is there something more to it?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 07, 2010, 10:20:36 pm
i have a 32 bit windows 7 and didnt experience a similar problem.

BonesIO is used to load/save Bones' native format. to import Ogre, you need to use BonesImporter. have a look at OgreSample for usage.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: AGP on November 08, 2010, 01:30:07 am
What are the dependencies for importing the Ogre files? I usually use a simple programmer's notepad I wrote myself so I can't read the Eclipse project. In other words, what do I pass to the classpath argument (where, for instance, is the OgreLoader class)?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 08, 2010, 01:44:06 am
you need the jME jar (in the zip) to import from Ogre format. you can either programatically or use the spcripts provided to convert to bones' native format. that way you need no external dependencancy..
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: AGP on November 08, 2010, 02:11:43 am
I got it, thanks. I just made a jar with all the necessary JME class files which is about 11% of the three jme jars. If that's at all legal, you should include it in place of the three jars.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 08, 2010, 11:47:00 am
not 100% sure but i guess it's legal. but i dont see it as a necessity. suggested way is to convert to bones' native format and use it. you can of course use your smaller combined jar and load directly from ogre format.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on November 26, 2010, 09:45:09 pm
I've played around a little bit with Bones just for fun...it seems to me, that the normals are never updated with the animation, because when using the rotate-animation of the ninja in combination with a light source, the source seems to move with the model instead of lighting the parts that it's actually facing. Am i missing something?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 26, 2010, 09:54:30 pm
no, you are right, normals arent updated. i've never used a light source in combination with animation so never noticed it.

i guess calling Object3D.calcNormals() each frame is expensive, so any suggestions? maybe i should do some research for this
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on November 26, 2010, 10:07:43 pm
Yes, that would be too expensive...for keyframes, i'm interpolating normals in the same way as i do interpolate vertices, but i guess it's another story here...

Another question: I tried to render three models at a time, which works fine...unless i'm trying to do the animation processing in parallel in three threads. The models are all loaded and created individually (i.e. i've simply loaded the ninja three times), but if i call animateSkin(...) in parallel, all hell breaks loose and they start to look as if they had a severe car accident or something. If i synchronize the animation calls to some common object, all is fine again. Am i doing something wrong? Any ideas?

Here's my hacky test case (with multi threaded animations disabled...enable it with useMultipleThreads=true), if that helps:

Code: [Select]
package bones.samples;

import java.io.FileInputStream;

import org.lwjgl.opengl.Display;

import raft.jpct.bones.Animated3D;
import raft.jpct.bones.AnimatedGroup;
import raft.jpct.bones.BonesIO;

import com.threed.jpct.Camera;
import com.threed.jpct.Config;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IPaintListener;
import com.threed.jpct.IRenderer;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
import com.threed.jpct.threading.WorkLoad;
import com.threed.jpct.threading.Worker;
import com.threed.jpct.util.Light;

public class SimpleBones implements IPaintListener {

private static final long serialVersionUID = 1L;

private Ninja ninja = null;
private Ninja anotherNinja = null;
private Ninja theLastNinja = null;
private FrameBuffer buffer = null;
private World world = null;
private int fps = 0;
private long time = System.currentTimeMillis();
private Worker worker = new Worker(3);
private WorkLoad[] loads = new WorkLoad[3];

private boolean useMultipleThreads = false;
private boolean compile = true;

public static void main(String[] args) {
SimpleBones sb = new SimpleBones();
sb.runIt();
}

public void runIt() {
config();
init();
loop();
}

public void finishedPainting() {
fps++;
if (System.currentTimeMillis() - time >= 1000) {
System.out.println(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
}

public void startPainting() {
}

private void config() {
Config.useMultipleThreads = true;
}

private void loop() {
try {
while (!buffer.isInitialized()) {
Thread.sleep(100);
}

while (!Display.isCloseRequested()) {

if (!useMultipleThreads) {
for (WorkLoad wl : loads) {
wl.doWork();
}
} else {
for (WorkLoad wl : loads) {
worker.add(wl);
}
}

buffer.clear();
if (useMultipleThreads) {
worker.waitForAll();
}
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private void init() {
buffer = new FrameBuffer(1024, 768, FrameBuffer.SAMPLINGMODE_GL_AA_2X);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
buffer.setPaintListener(this);

world = new World();

Texture texture = new Texture("./samples/data/ninja/nskingr.jpg");
TextureManager.getInstance().addTexture("ninja", texture);

ninja = new Ninja();
ninja.addToWorld(world);

anotherNinja = new Ninja();
anotherNinja.addToWorld(world);

theLastNinja = new Ninja();
theLastNinja.addToWorld(world);

if (compile) {
ninja.compile();
anotherNinja.compile();
theLastNinja.compile();
}

WorkLoad w0 = new WorkLoad() {

public void doWork() {
ninja.animate(1);
}

public void done() {
}

public void error(Exception arg0) {
}
};

WorkLoad w1 = new WorkLoad() {

public void doWork() {
anotherNinja.animate(2);
}

public void done() {
}

public void error(Exception arg0) {
}
};

WorkLoad w2 = new WorkLoad() {

public void doWork() {
theLastNinja.animate(5);
}

public void done() {
}

public void error(Exception arg0) {
}
};

loads[0] = w0;
loads[1] = w1;
loads[2] = w2;

anotherNinja.translate(new SimpleVector(-200, 0, 0));
theLastNinja.translate(new SimpleVector(200, 0, 0));

world.getCamera().moveCamera(Camera.CAMERA_MOVEIN, 600);
world.getCamera().moveCamera(Camera.CAMERA_MOVEUP, 200);
world.getCamera().lookAt(new SimpleVector(0, -200, 0));

Light light = new Light(world);
light.setIntensity(255, 255, 255);
light.setPosition(new SimpleVector(800, -400, 0));
light.setAttenuation(-1);
}

private static class Ninja {

private AnimatedGroup animatedGroup = null;
private float index = 0;
private long time = 0;

public Ninja() {
init();
}

public void compile() {
for (Animated3D o : animatedGroup) {
o.compile(true);
}
}

public void translate(SimpleVector trns) {
for (Animated3D o : animatedGroup) {
o.translate(trns);
}
}

public void animate(int seq) {
if (time == 0) {
time = System.nanoTime() / 1000000L;
}

long dt = (System.nanoTime() / 1000000L) - time;
time = dt + time;
index += dt / 1000f;

while (index > 1) {
index -= 1;
}
animatedGroup.animateSkin(index, seq);
}

public void addToWorld(World world) {
animatedGroup.addToWorld(world);
}

private void init() {
try {
FileInputStream fis = new FileInputStream("./samples/data/ninja/ninja.group.bones");
try {
AnimatedGroup skinnedGroup = BonesIO.loadGroup(fis);

for (Animated3D o : skinnedGroup) {
o.setTexture("ninja");
o.build();
o.discardMeshData();
o.setVisibility(true);
}
animatedGroup = skinnedGroup;
} finally {
fis.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

}
}

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on November 26, 2010, 10:12:08 pm
BTW: With a calcNormals() every frame for each model, my frame rate drops from 3100 fps to 400 fps in this test case...still fast enough for this case, but a huge drop nonetheless.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 27, 2010, 12:37:13 am
thanks for the test case. Bones is not thread safe. the case you have discovered happens because JointChannel uses static temporary filler objects. i had made it this way to reduce memory usage. now i re-thinked about it and found it too restrictive. i've made the filler objects instance fields. this will slightly use more memory but i guess the gain worths it. i've uploaded the new version.

instead of loading a new instance from file, you can also clone AnimatedGroup. that will save a lot of memory. below is a sample. here to go multi-threaded there are two ways: either synchronize animation code or make each AnimatedGroup use its own SkeletonPose. the static switch shareSkeletonPose in below example demonstrates this.

a final note, instead of translate/rotate individual objects in a group, you can translate/rotate AnimatedGroup.getRoot(). it's a dummy object that all animated objects are added as child. and its sole purpose is to translate/rotate the whole group easily.

Code: [Select]
import java.io.FileInputStream;

import org.lwjgl.opengl.Display;

import raft.jpct.bones.Animated3D;
import raft.jpct.bones.AnimatedGroup;
import raft.jpct.bones.BonesIO;

import com.threed.jpct.Camera;
import com.threed.jpct.Config;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IPaintListener;
import com.threed.jpct.IRenderer;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
import com.threed.jpct.threading.WorkLoad;
import com.threed.jpct.threading.Worker;
import com.threed.jpct.util.Light;

public class SimpleBones2 implements IPaintListener {

private static final long serialVersionUID = 1L;

private Ninja ninja = null;
private Ninja anotherNinja = null;
private Ninja theLastNinja = null;
private FrameBuffer buffer = null;
private World world = null;
private int fps = 0;
private long time = System.currentTimeMillis();
private Worker worker = new Worker(3);
private WorkLoad[] loads = new WorkLoad[3];

private static boolean shareSkeletonPose = true;
private boolean useMultipleThreads = true;
private boolean compile = true;

public static void main(String[] args) {
SimpleBones2 sb = new SimpleBones2();
sb.runIt();
}

public void runIt() {
config();
init();
loop();
}

public void finishedPainting() {
fps++;
if (System.currentTimeMillis() - time >= 1000) {
System.out.println(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
}

public void startPainting() {
}

private void config() {
Config.useMultipleThreads = true;
}

private void loop() {
try {
while (!buffer.isInitialized()) {
Thread.sleep(100);
}

while (!Display.isCloseRequested()) {

if (!useMultipleThreads) {
for (WorkLoad wl : loads) {
wl.doWork();
}
} else {
for (WorkLoad wl : loads) {
worker.add(wl);
}
}

buffer.clear();
if (useMultipleThreads) {
worker.waitForAll();
}
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private void init() {
buffer = new FrameBuffer(1024, 768, FrameBuffer.SAMPLINGMODE_GL_AA_2X);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
buffer.setPaintListener(this);

world = new World();

Texture texture = new Texture("./samples/data/ninja/nskingr.jpg");
TextureManager.getInstance().addTexture("ninja", texture);

ninja = new Ninja();
ninja.addToWorld(world);

anotherNinja = new Ninja();
anotherNinja.addToWorld(world);

theLastNinja = new Ninja();
theLastNinja.addToWorld(world);

if (compile) {
ninja.compile();
anotherNinja.compile();
theLastNinja.compile();
}

WorkLoad w0 = new WorkLoad() {

public void doWork() {
ninja.animate(1);
}

public void done() {
}

public void error(Exception arg0) {
}
};

WorkLoad w1 = new WorkLoad() {

public void doWork() {
anotherNinja.animate(2);
}

public void done() {
}

public void error(Exception arg0) {
}
};

WorkLoad w2 = new WorkLoad() {

public void doWork() {
theLastNinja.animate(5);
}

public void done() {
}

public void error(Exception arg0) {
}
};

loads[0] = w0;
loads[1] = w1;
loads[2] = w2;

anotherNinja.translate(new SimpleVector(-200, 0, 0));
theLastNinja.translate(new SimpleVector(200, 0, 0));

world.getCamera().moveCamera(Camera.CAMERA_MOVEIN, 600);
world.getCamera().moveCamera(Camera.CAMERA_MOVEUP, 200);
world.getCamera().lookAt(new SimpleVector(0, -200, 0));

Light light = new Light(world);
light.setIntensity(255, 255, 255);
light.setPosition(new SimpleVector(800, -400, 0));
light.setAttenuation(-1);
}

private static class Ninja {

private AnimatedGroup animatedGroup = null;
private float index = 0;
private long time = 0;

public Ninja() {
init();
}

public void compile() {
for (Animated3D o : animatedGroup) {
o.compile(true);
}
}

public void translate(SimpleVector trns) {
animatedGroup.getRoot().translate(trns);
}

public void animate(int seq) {
if (time == 0) {
time = System.nanoTime() / 1000000L;
}

long dt = (System.nanoTime() / 1000000L) - time;
time = dt + time;
index += dt / 1000f;

while (index > 1) {
index -= 1;
}

if (shareSkeletonPose) {
synchronized (ninjaMaster) {
animatedGroup.animateSkin(index, seq);
}
} else {
animatedGroup.animateSkin(index, seq);
}
}

public void addToWorld(World world) {
animatedGroup.addToWorld(world);
}

private void init() {
this.animatedGroup = getNinjaMaster().clone(AnimatedGroup.MESH_DONT_REUSE);
if (!shareSkeletonPose)
animatedGroup.setSkeletonPose(animatedGroup.get(0).getSkeletonPose().clone());
}
}

private static AnimatedGroup ninjaMaster = null;

private static synchronized AnimatedGroup getNinjaMaster() {
if (ninjaMaster == null) {
try {
FileInputStream fis = new FileInputStream("./samples/data/ninja/ninja.group.bones");
try {
AnimatedGroup skinnedGroup = BonesIO.loadGroup(fis);

for (Animated3D o : skinnedGroup) {
o.setTexture("ninja");
o.build();
o.discardMeshData();
o.setVisibility(true);
}
ninjaMaster = skinnedGroup;
} finally {
fis.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return ninjaMaster;
}
}


Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 27, 2010, 04:29:57 pm
after some research, seems as normals are updated similar to vertices but only with rotations (w/o translations) which logically makes sense.

i've implemented it, it seems ok but i'm not sure. @Egon, can u please check the following jar for lighting, my eyes are not as educated as yours ;)

<link removed>
edit: removed obsolute link
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 27, 2010, 05:07:09 pm
normals in Pose animations is another story. seems as even Ogre doesn't do it, since it's too expensive. see this post (http://www.ogre3d.org/forums/viewtopic.php?f=1&t=18829). pose animations are typically used for small deformations (like facial animations) so i guess this wont be a problem for most cases.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on November 28, 2010, 09:52:24 pm
Normals are looking fine now and so does using multiple threads to animate multiple meshes in parallel. Performance has suffered due to the additional normal calculation, but it's really worth it.
The whole point of this test case was to find out how much some simple multi-threading can help with the animations...here are the results on my 3.2Ghz quad core:


So i think that it can be worth it you run animations in different threads. That's all that i wanted to find out for no particular reason.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on November 28, 2010, 10:15:33 pm
cool, thanks for testing ;D i've made the changes official and uploaded the new version.

for performance lost, i think likewise. if it becomes a bottleneck for someone, i can later make updating normals optional. afterall there is no point of updating normals if a light source is not used.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Disastorm on January 11, 2011, 11:54:04 pm
Hello, I havn't tried this yet so I don't know much about it as I've always used keyframe animations, but does this only support premade animations or can we manipulate the bones directly.  I ask this because I just got a kinect the other day, and I think it would be really awesome to allow the player to control a model on the screen with their body.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on January 12, 2011, 12:12:35 am
yes, you can programatically animate skeleton. have a look at ProceduralAnimationSample
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Disastorm on January 12, 2011, 03:29:14 am
Thanks. I'll check it out.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Disastorm on January 15, 2011, 03:25:32 am
Hey for collada when i try to import it it says cannot find file (the .dae file) even though its in the directory.  I've been trying it like the example you have and I know the File = new File part does find it but the cannot find file error comes from colladaImporter.load

do you know why it cant find the file?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on January 15, 2011, 01:24:50 pm
don't know. may it be an uppercase lowercase issue?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Disastorm on January 15, 2011, 09:16:20 pm
its not.  For this code:

File colladaFile = new File("Seymour.dae");
System.out.println(colladaFile.length());
       
        URI uri = colladaFile.toURI();

        final SimpleResourceLocator resLocater = new SimpleResourceLocator(uri.resolve("./"));
        ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, resLocater);

        AnimatedGroup skinnedGroup;
        try {
            ColladaImporter colladaImporter = new ColladaImporter().loadTextures(false);
            ColladaStorage colladaStorage = colladaImporter.load(uri.toString());

            skinnedGroup = BonesImporter.importCollada(colladaStorage, 1f, new Quaternion().rotateX((float) Math.PI));
        } finally {
            ResourceLocatorTool.removeResourceLocator(ResourceLocatorTool.TYPE_MODEL, resLocater);
        }

        Texture texture = new Texture("seymour.png");
        TextureManager.getInstance().addTexture("seymour", texture);

        for (Animated3D o : skinnedGroup) {
            o.setTexture("seymour");
            o.build();
            o.discardMeshData();
        }
        return skinnedGroup;


I get error:

629380
Jan 15, 2011 12:15:18 PM com.ardor3d.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: file:/C:/Users/Disastorm/Documents/NetBeansProjects/KinectTest/Seymour.dae
Exception in thread "main" java.lang.Error: Unable to locate 'file:/C:/Users/Disastorm/Documents/NetBeansProjects/KinectTest/Seymour.dae'
        at com.ardor3d.extension.model.collada.jdom.ColladaImporter.load(ColladaImporter.java:88)
        at kinecttest.Main.createAnimatedGroupCollada(Main.java:104)
        at kinecttest.Main.<init>(Main.java:64)
        at kinecttest.Main.main(Main.java:210)
Java Result: 1


but C:/Users/Disastorm/Documents/NetBeansProjects/KinectTest/Seymour.dae does exist, and as you can see the file = new File part does work because it prints out the filesize.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on January 15, 2011, 10:18:35 pm
well i really dont know what is going on there ??? it's ardor's code. i have added the ardor's and jME's relevant sources to zip file so you can debug yourself.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Disastorm on January 16, 2011, 02:11:44 am
Do you know what this means for Ogre ?

Jan 15, 2011 5:10:06 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Jan 15, 2011 5:10:06 PM com.jme.scene.Node attachChild
INFO: Child "sheepMesh000" attached to this node "sheep"
Jan 15, 2011 5:10:06 PM com.jme.scene.Node attachChild
INFO: Child "sheepMesh001" attached to this node "sheep"
Exception in thread "main" java.lang.IllegalArgumentException: No controller found in OgreEntityNode. Means there is no skeleton or pose animation!
        at raft.jpct.bones.BonesImporter.importOgre(BonesImporter.java:131)
        at kinecttest.Main.createAnimatedGroup(Main.java:131)
        at kinecttest.Main.<init>(Main.java:64)
        at kinecttest.Main.main(Main.java:210)

I exported from Blender and it has a skeleton xml file in the same directory.  Is the Rotation axis not normalized warning related to this error?

It works with the ninja model so it must be something with my model maybe.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on January 16, 2011, 02:15:57 am
no, not related. possibly there is no defined animation so jME didnt load skeleton and attach a controller.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Disastorm on January 16, 2011, 02:17:01 am
Ah ok that must be it I have no animations, I was planning on programmatically trying to manipulate the skeleton.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Disastorm on January 16, 2011, 03:25:00 am
Hey is there any way to have the solid color textures that aren't taken from separate files, like how for example you can have a .obj with different parts of it different colors, but without a jpg or any kind of texture file other than the .mtl (and those colors are loaded automatically by the obj loader), does ogre do that?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on January 16, 2011, 03:34:47 am
i don't know if Ogre or jME Ogre loader support such materials. even if they do, Bones does not load such information. you can achieve the same effect with solid color textures.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 04, 2011, 04:47:41 am
Thank you for the Bones Collada importer. Its a godsend! =)

Now, hopefully you can help me. I'm trying to load some pretty big models (DAZ Victoria) that I exported in Wavefront Collada format. The models import just fine through Bones; however, I can't get the textures...

I've tried
Code: [Select]
ColladaImporter colladaImporter = new ColladaImporter().loadTextures(true);which results in:
WARNING: Unable to read image of type: .jpg
Feb 3, 2011 7:38:08 PM com.ardor3d.image.util.ImageLoaderUtil loadImage
WARNING: loadImage(String, InputStream, boolean): no imageData found.  defaultTexture used.

The textures are in .jpg format, and it seems that the Ardor3d loader can only support TGA and DGA texture formats...

So I guess I have to load the textures manually, so in my code:
Code: [Select]
AnimatedGroup skinnedGroup;
try {
ColladaImporter colladaImporter = new ColladaImporter().loadTextures(false);
ColladaStorage colladaStorage = colladaImporter.load(uri.toString());

skinnedGroup = BonesImporter.importCollada(colladaStorage, 1f, new Quaternion().rotateX((float)Math.PI));
} finally {
ResourceLocatorTool.removeResourceLocator(ResourceLocatorTool.TYPE_MODEL, resLocater);
}
TextureManager tm = TextureManager.getInstance();
tm.addTexture("tex2_SkinHipf_1_Diff", new Texture("/temp/victoria.images/V4SmplTorsoM_NG.jpg"));
tm.addTexture("tex2_SkinTorsof_1_Diff", new Texture("/temp/victoria.images/V4SmplTorsoM_NG.jpg"));
// .... load a bunch more textures here ...

for (Animated3D o : skinnedGroup) {
   o.setTexture(o.getName());  // HOW CAN I GET THE NAME OF THE OBJECT TO ASSOCIATE WITH THE TEXTURE?? o.getName() does not match the texture name!
   o.build();
   o.compileAndStrip();
   o.discardMeshData();
}

Now my problem above is, I've got a TextureManager object full of textures, how can I know which objects correctly associate with which texture?  Unfortunately, the Animated3D object names are generic (ie. Object11), so I don't know which texture to assign to what object.  I'm new to this whole 3d programming stuff, so maybe there is a simple way to solve this problem.

Thanks!
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 04, 2011, 05:34:45 am
Bones does not import texture information from Ardor3d. it only exports the texture (UV) coordinates. that's why samples call ColladaImporter.loadTextures(false), loading textures is only a waste.

regarding your question, there is no simple way of doing this. inspect the Animates3D's in AnimatedGroup visually and set their textures accordingly. but if you have any multi-textured objects practically there is no way to set their textures correctly.

this may seem a bit constraining but keep in mind that Bones is not a Collada -scene- importer. it's an animation library. typically and preferably all Animates3D's in AnimatedGroup use the same texture like in Collada and Ogre samples. this way it's much easier to set textures correctly.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 04, 2011, 07:23:45 am
Thank you for the quick answer.

I have another problem trying to export the base DAZ Victoria 4.2 (http://www.daz3d.com/i/shop/itemdetails/?item=4783) model. I'm using the FREE Daz Studio 3.1, and have been exporting using the Autodesk FBX Collada exporter, and thus far, the V4 models load with Bones just fine (minus the texture issue I reported in the last post); however, the Autodesk FBX Collada exporter on Daz Studio does not save the animation for some reason (even if you check the save animation & poses tab).

So I switched to using the default DAZ Collada Exporter with the following options:
(http://img218.imageshack.us/img218/5398/screenshotcolladaexport.png)

Which results in the following exception:
Code: [Select]
java.lang.RuntimeException: Unable to load collada resource from URL: URLResourceSource [url=file:/home/gene/temp/vicky.dae, type=.dae]
at com.ardor3d.extension.model.collada.jdom.ColladaImporter.load(ColladaImporter.java:154)
at com.ardor3d.extension.model.collada.jdom.ColladaImporter.load(ColladaImporter.java:91)
at bones.samples.SimpleBones2.getModel(SimpleBones2.java:342)
at bones.samples.SimpleBones2.access$4(SimpleBones2.java:329)
at bones.samples.SimpleBones2$Eve.init(SimpleBones2.java:292)
at bones.samples.SimpleBones2$Eve.<init>(SimpleBones2.java:251)
at bones.samples.SimpleBones2.init(SimpleBones2.java:126)
at bones.samples.SimpleBones2.runIt(SimpleBones2.java:57)
at bones.samples.SimpleBones2.main(SimpleBones2.java:52)
Caused by: com.ardor3d.extension.model.collada.jdom.ColladaException: Collada problem for source: [Element: <skin/>]: Unable to find joint with sid: GlamourHairV4_21847
at com.ardor3d.extension.model.collada.jdom.ColladaAnimUtils.buildSkinMeshes(ColladaAnimUtils.java:288)
at com.ardor3d.extension.model.collada.jdom.ColladaAnimUtils.buildController(ColladaAnimUtils.java:157)
at com.ardor3d.extension.model.collada.jdom.ColladaNodeUtils.getVisualScene(ColladaNodeUtils.java:115)
at com.ardor3d.extension.model.collada.jdom.ColladaImporter.load(ColladaImporter.java:134)
... 8 more

If I try unchecking the "Merge Skeletons" checkbox, I get the following:
Code: [Select]
java.lang.IllegalArgumentException: There are more than one skeletons in ColladaStorage.
at raft.jpct.bones.BonesImporter.findUniqueArdorSkeleton(BonesImporter.java:339)
at raft.jpct.bones.BonesImporter.importCollada(BonesImporter.java:63)
at bones.samples.SimpleBones2.getModel(SimpleBones2.java:344)
at bones.samples.SimpleBones2.access$4(SimpleBones2.java:329)
at bones.samples.SimpleBones2$Eve.init(SimpleBones2.java:292)
at bones.samples.SimpleBones2$Eve.<init>(SimpleBones2.java:251)
at bones.samples.SimpleBones2.init(SimpleBones2.java:126)
at bones.samples.SimpleBones2.runIt(SimpleBones2.java:57)
at bones.samples.SimpleBones2.main(SimpleBones2.java:52)

Do you have any suggestions?  
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 04, 2011, 09:55:28 am
I've got one more issue that I hope someone can help me with (sorry to bombard the forum with these)..

I just tried out the the ProceduralAnimationSample and it looks pretty straightforward, all except that it seems the mesh does not follow the bones (as can be seen in this photo), it seems as if the applySkeletonPose() is not working.  Is there something else that needs to be done to get the mesh to follow the skeleton?  Thanks!

(http://img718.imageshack.us/img718/4927/screenshotbonessamplesp.png)

Code: [Select]
protected void update(long deltaTime) {
   totalTime += deltaTime;
   updateBallLocation();
   currentPose.updateTransforms();
   skeletonDebugger.update(currentPose);
   animatedGroup.applySkeletonPose();  // *** This line seems to have no effect.
       
   cameraController.placeCamera();
}
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 04, 2011, 02:52:39 pm
oops. there is a missing call to AnimatedGroup.applyAnimation() in ProceduralAnimationSample, it's working now. please re-download the zip. thanks for the reminder ;D

for exporting: how many skeletons are there in your scene? there should be one. if there are more, try removing others and see if that helps. otherwise send me exported files and let me have a look
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 09, 2011, 09:30:14 pm
Thanks for the response! I have given up on trying to export models from Daz 3d, to trying to use the Collada Models in the Google 3d Warehouse (http://sketchup.google.com/3dwarehouse); however, every time I try to load one of those collada models into Bones, I keep getting the following exception:
Code: [Select]
Exception in thread "main" java.lang.IllegalArgumentException: ColladaStorage contains no skins.
at raft.jpct.bones.BonesImporter.importCollada(BonesImporter.java:49)

I tried the following collada models from Googles 3d Database, and they all resulted in the same exception:
Collada Model 1 (http://sketchup.google.com/3dwarehouse/details?mid=f4c14366e0c3bd1c34ca436481dbdb39&prevstart=0)
Collada Model 2 (http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1&ct=mdrm&prevstart=0)
Collada Model 3 (http://sketchup.google.com/3dwarehouse/details?mid=eee30c6f73284334703a3e27b371a3f1&ct=mdrm&prevstart=0)

Can we not use the Google Collada models in Bones?

Thanks
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 09, 2011, 09:41:29 pm
There are no skeleton and animation in these files. Hence they cannot be imported by Bones. Remember Bones is an animation library, not a collada scene importer.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 09, 2011, 10:32:48 pm
Got it! I guess I need to import these collada models into a 3d program and work on creating a skeleton.

Thanks again for all your help!
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 10, 2011, 11:52:52 pm
Well, I have successfully loaded a collada model into the Desktop JPCT w/Bones. Everything is working great, and I am able to manipulate the skeleton procedurally.

Now, I want to load the same model into JPCT-AE (Android) w/Bones. I noticed, in the Android example with the ninja, you loaded a ninja.group.bones from the /raw/ directory.

In the desktop Jpct/Bones, I load my collada model, then use BonesIO.saveGroup(animatedGroup, output) to save my model to model.group.bones and then imported it into Android. The first time I did this, I got an out of memory error.  After spending hours reducing the number of polygons in the model, I was finally able to get it to load in Android, but with very little memory to spare.. and my model looks quite ugly now due to the low poly count.  I am wondering if the exported file is being serialized??

In Jpct-AE, it is recommended to first serialize the object on the desktop, then load the serialized object into Android.  When I call BonesIO.saveGroup, does it perform this serialization step?  Are there any other optimizations I should perform on the AnimatedGroup before I export it to the bones format to be loaded into Android?  

Thank You
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 11, 2011, 12:15:33 am
no, BonesIO.saveGroup/Object does not use jPCT's serialization. it's indeed slightly customized standard java serialization.

but this shouldn't effect memory usage. jPCT-AE recommends serialization mainly to speed up loading. it also reduces memory usage but only in loading. after loading all objects and making a garbage collection, there is no difference in memory usage.

how many polygons are your model? the ninja model is more than 500 polygons and 8 ninjas run without any memory problems. maybe there is some other thing that consumes memory, big textures maybe?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 11, 2011, 07:55:38 am
how many polygons are your model? the ninja model is more than 500 polygons and 8 ninjas run without any memory problems. maybe there is some other thing that consumes memory, big textures maybe?

I've got complex model.  I currently got it down to about 6000 polygons, and am now able to load it on my Nexus One.  When I had it at about 10,000 polys, it would crash upon loading.  
I also only have one texture at 512x512.  I tried making the texture larger, the desktop version seems to handle 1024x1024 w/o problems, but on Android, it crashed on loading the texture if I have it larger than 512x512, perhaps thats a limit.

Edit: I think I was bumping into the Android Java heap limit (16MB, and 24MB on some phones).  As it stands now, after loading (but before GC), I need about 18MB of heap, which is why it works on my nexus one. Would I be able to use the NDK to allocate space for the AnimatedGroup object to bypass the 16MB heap on older android phones?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 11, 2011, 12:54:35 pm
Would I be able to use the NDK to allocate space for the AnimatedGroup object to bypass the 16MB heap on older android phones?
i'm not aware of such a thing.

after loading AnimatedGroup try calling discardMeshData() on each of Animated3D's and make a GC before loading texture. this will slightly reduce memory usage. but dont expect miracles.

operating near limits of VM memory is not a good idea anyway. 6000 animated polygons sounds high to me. if you wont zoom in to the model very much, 256x256 texture may also look good.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on February 11, 2011, 01:20:25 pm
Would I be able to use the NDK to allocate space for the AnimatedGroup object to bypass the 16MB heap on older android phones?
i'm not aware of such a thing.
There is no such thing. The limit is compiled into the VM by the phone's vendor. You can't even be sure that Android version x.y always supports the same limit...it depends on the vendor's choice.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: gururise on February 11, 2011, 06:54:00 pm
Would I be able to use the NDK to allocate space for the AnimatedGroup object to bypass the 16MB heap on older android phones?
i'm not aware of such a thing.
There is no such thing. The limit is compiled into the VM by the phone's vendor. You can't even be sure that Android version x.y always supports the same limit...it depends on the vendor's choice.

I found an interesting blog post on how to work around the 24mb heap limit (http://blog.javia.org/how-to-work-around-androids-24-mb-memory-limit/) in Android by using the NDK.  Apparently, memory allocations in c/c++ via the NDK are not subject to the java heap limit.  There is also a great thread (http://groups.google.com/group/android-ndk/browse_thread/thread/95c9f0cecceb112a/ab033b9a28d52fcd?lnk=gst&q=heap+limit#ab033b9a28d52fcd) where one of the Google developers chimed in and basically said the same thing, but suggested not going over 32MB via the NDK.

I'm wondering if its possible to declare an AnimatedGroup on the java side, pass it over to the NDK via JNI and then allocate say 24MB via malloc (or new), and then pass it back to Java and instantiate the AnimatedGroup by loading the Bones file... Not sure if that would work or not.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 11, 2011, 08:34:44 pm
interesting blog and thread but that wont work for this case. native memory is outside of java heap, it does not matter how much native memory is allocated. java heap limit will remain the same.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on February 13, 2011, 09:50:43 pm
However, it should be possible to load 10000 polygon object. The models i'm using in the benchmark are much larger. Is the additional skeleton so expensive?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 13, 2011, 10:46:41 pm
here is the math. all these arrays are copied during loading for ensuring encapsulation so x2 applies.

skin data for each vertice:
* short[4]: joint weights = 8 bytes
* float[4]: joint indices = 16 bytes

animated mesh data for each polygon
* source/dest mesh/normals: 4 x SimpleVector = 64 bytes (taken from IVertexController)

constructing mesh data (discarded after Animated3D.discardMeshData() is called)
* indices: int[vertex count] = 4 byte for each vertex
* vertex/uv coordinates 2 x float = number depends on geometry.

in total for a 10.000 object (maximum, assuming all vertices are distinct)
* 240k skin data
* 210k animated mesh data
* 120k constructing mesh data
sum: 470k x2 copying factor = 940k. less than 1m. not that much indeed

skeleton itself does not consume much memory assuming joint (bone) count is reasonable. 2x matrix, 2x int, 1x string for each joint

animation data should not also consume much but it depends on number of keyframes in animation.

edit: multiply with 3. calculated for 10.000 vertex object, not for 10.000 polygon object
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Alexey on February 22, 2011, 01:30:01 pm
Hello!
I try build and install ninja demo on android, but when starting animation i get noSuchMethod exception when call normalTemp.rotate(currentPose.palette[jointIndex]);  - ( Animated3D.rotate(Matrix[]) )
I suspect that this is due to project setting (eclips) . Any one got this exception?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 22, 2011, 01:48:09 pm
seems as jPCT AE version does not have SimpleVector.rotate(Matrix) method. possibly forgotten. Egon can you please add it?
that part is recently added to Animeted3D to animate vertex normals too. since then i had never tested Android demo app.

@Alexey, meanwhile you can comment out the line 435 at Animated3D. the demo will run but normals will not be correct. does not matter if there is no light source in the scene.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Alexey on February 22, 2011, 02:29:11 pm
Animated3D.rotate(Matrix[])
Sorry no in Animated3D - in SimpleVector method rotate;

raft, thanks for reply, yes it work without normalTemp.rotate(currentPose.palette[jointIndex]);  :)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on February 22, 2011, 02:41:04 pm
seems as jPCT AE version does not have SimpleVector.rotate(Matrix) method. possibly forgotten. Egon can you please add it?
Should be available in the latest unofficial version... ???
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 22, 2011, 02:43:41 pm
not really. it's not shown in online javadocs and not in the offical jar (just downloaded the latest version)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on February 22, 2011, 03:06:42 pm
Not the official one...the UNofficial one that i'm linking to in the "new version" thread. I can't try it right now, but it should contain the method.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Alexey on February 22, 2011, 03:27:38 pm
Eclips show only .rotate(SimpleVactor)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 22, 2011, 03:28:47 pm
oops sorry ::) @Alexey you can download the jar from here and replace the jar in the demo project
http://www.jpct.net/jpct-ae/download/alpha/jpct_ae.jar

i will also put that jar into demo app later
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Alexey on February 22, 2011, 04:04:54 pm
Thank you! thats work :)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 22, 2011, 06:55:26 pm
all applies to Android demo:
* updated to use latest (1.23 beta) jPCT AE jar
* added a light demo scene to reflect animation of vertex normals
* added wakelock to make it more look like a game
* cleaned some unnecessary pause-stop code
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Alexey on February 24, 2011, 09:49:31 am
Hello!
What is .bone format ? I could not find it.
And which of formats(animation) has better performance (android devices)?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on February 24, 2011, 09:56:43 am
it's Bones's native format. to save in that format first import with BonesImporter than save with BonesIO. there also scripts wihich makes the same job.

animation performance does not differ, all formats end up with same data representation in memory. but loading times differ. Bones format should load fastests. also by using Bones format, you do not need any other dependency (jME or Ardor3D jars)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: lajidahe on March 08, 2011, 11:22:10 pm
Hi,
    When I am trying to convert the dae file into bones, I got the following error " java.lang.IllegalArgumentException: Transforms that have non-rotational matrices are not supported."
    The workflow is: I used motionBuilder to read in a C3d file that contains a set of animations, and export a skeleton into Maya, then I bind the skeleton with a character that I made, and export it into the dae format.
     Is it because the motionbuilder does the animation without using the rotation matrix?? if so how can I fix it??
Thanks
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on March 08, 2011, 11:36:53 pm
you didnt posted the stack trace (always a good idea) but seems as that exception is thrown by Ardor3d's collada loader. i dont know what causes it (never used Maya), play with export options, maybe it helps.

in general, Ogre3D exporters are more successful IMHO. you can try an Ogre3d importer for Maya. have a look at: http://www.ogre3d.org/tikiwiki/OGRE+Exporters. OgreMax for 3dsMax is quite good so i would expect OgreMax for Maya is good too.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: pages on March 09, 2011, 09:55:44 pm
Hi all ,
I'm probably going to look like an idiot posting this but i am having massive troubles in trying to get my blender animation into bones

I have the .blend file which i want to display
* I can export it with ORGE mesh into
-Mesh.mesh.xml
-Mesh.skeleton.xml
-Mesh.material

* I can also export the .blend into
-Mesh.dae

Now i see in bones.zip  within scripts there is the linux/windows .sh and .bat files for both ardor and ogre but how do i progress from here ??
Is there any tutorials which you can link because quite frankly i'm beyond lost

If you can off any help or advice it would be much appreciated,
Thanks
Pages
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on March 09, 2011, 10:17:06 pm
have a look at the sample applications provided. they should hopefully help ;)

for example, to convert from Ogre3D to Bones format
Code: [Select]
./scripts/jmeOgre2Bones.sh -out /tmp/ninja.group.bones -in samples/data/ninja/ninja.mesh.xml
once you had used scripts to convert from Collada/Ogre3D to Bones' native format, you can load them via BonesIO class. this is the suggested way as it's faster to load and does not depend on Ardor or jME classes.

for testing or quick protoyping you can also directly load Collada and Ogre3D formats via BonesImporter class. this way you also need Ardor or jME jars in your classpath. those scripts actually use BonesImporter to load models and save them in Bones' native format via BonesIO.

note: there was a classpath issue in script files. i've corrected it now. please re-download the zip
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on March 10, 2011, 11:53:51 am
updated the zip. this version uses jME 2.1. i've also changed some piece of jME code to throw a meaningful exception instead of NPE during loading.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on March 31, 2011, 12:01:54 pm
Hi,

I am developing an Android app that needs some 3D skeletal animations.  As I am new to 3D graphics programming, I was delighted to come across JPCT & Bones and hope these fantastic APIs can bail me out.  Thanks a ton to all the people involved!!

I was able to run the Ninja example in my Android emulator and my Android phone (of course using the intermediate release of JPCT that addresses the .rotate issue).  Now I am trying to load some of our own models.  Our artist is using Maya and he has used Ogre3D exporter to generate two files (one for the model and another for the texture).

1. mesh_2_new.ma.mesh (the model)
2. mesh_2_new.ma.material (the texture)

So, I decided to use the BonesImporter to get them to native Bones format.
However, when I analyzed the "OgreSample.java" and "JMEOgreImporter.java", the model file is ".xml" and texture is ".jpg".  I am currently struck here.

I think we're missing something.  Can you please help me out with this?

- Thanks in advance
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on March 31, 2011, 12:40:04 pm
Ogre has two equivalent formats: binary and xml. Bones neeed the xml format. Most possibly there is an option in your Maya exporter to export as xml files. if not, ogre has command line tools (OgreXMLConverter) to convert into either formats.

note, for use with Bones, you also need skeleton file in same directory with mesh file.

Bones does not support complex materials but simple textures. nevermind about material file, tell your artist to provide you the texture (png, jpg, gif whatever) and assign it to Animated3D's as in Ninja demo.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on March 31, 2011, 12:58:10 pm
raft, thanks a lot for your guidance.  I'll try that out and get back to you.  :)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 03, 2011, 02:47:02 pm
Hi raft,

I got the .xml files from our artist.  However, when I tried to convert them to .bones format, I got the following exception.

bash jmeOgre2Bones.sh -in body/body.skeleton.xml body/body.mesh.xml -out fm.group.bones
Exception in thread "main" com.jmex.model.ModelFormatException: Input XML file does not have required root element 'mesh'
   at com.jmex.model.XMLUtil.loadDocument(XMLUtil.java:113)
   at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:225)
   at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:177)
   at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:91)
   at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:81)
   at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:58)
   at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:147)

But the file has the <mesh> root element.  I am not sure what's going wrong.  Can you please help me with this?

The xml files can be obtained from:
https://docs.google.com/leaf?id=0B85w3AW2-YdVYzY1YmZjM2UtNTQzZC00NDE0LWFmNmQtZTkyMDQxNTM4ZDc1&hl=en

- Thanks
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 04, 2011, 12:02:24 am
dont mention about skeloton.xml to script. it's automatically located in same file in mesh.xml

Code: [Select]
jmeOgre2Bones.sh -in body/body.mesh.xml -out fm.group.bones
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 04, 2011, 05:15:29 am
hi raft,
The previous exception doesn't come anymore.  Thanks :)

However, I got the following exception.

Exception in thread "main" java.lang.IllegalArgumentException: No controller found in OgreEntityNode. Means there is no skeleton or pose animation!
   at raft.jpct.bones.BonesImporter.importOgre(BonesImporter.java:131)
   at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:93)
   at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:81)
   at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:58)
   at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:147)

Is there something wrong with the .xml file?  Should I go back to our artist?

Also I got several of the following warnings.

Apr 4, 2011 8:20:56 AM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized

Sorry for troubling you with lot of basic stuff  :-[
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 04, 2011, 11:35:41 am
this happens because there is no animation in your skeleton file. tell your artist export at least one animation.

nevermind about the warnings. jME checks if length of rotation axis is exactly 1.0 and if not prints that warning. due to rounding issues, length cannot be exactly 1.0 most of the time.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: pages on April 04, 2011, 10:02:52 pm
Hi back again :)
I am just wondering about the OrgeLoaderSample.java

If you have two objects both of .mesh.xml and want them to display i presume the code
Code: [Select]

for (Animated3D o : animatedGroup) {
o.setTexture("ninja");
o.build();
o.discardMeshData();
}
return animatedGroup;
Would have to be edited to allow two animated objects but i dont really see how this would be possible in an infinite loop which can only return 1 thing ??
Or is there some way of combining the 2 exports into 1 mesh.xml file ?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 04, 2011, 10:16:09 pm
well, as the name suggests AnimatedGroup is group of animated objects (Animated3D's).

and yes, many objects can be exported to same mesh.xml file. typically they are attached to same skeleton and animated together. have a look at Ogre sample. the ninja model consists of two objects, the sword and the body. they are in the same mesh.xml file.

Code: [Select]
for (Animated3D o : animatedGroup) {
  //..
}

btw, this not an infinite loop. it just iterates over all Animted3D's in the AnimatedGroup
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 05, 2011, 12:10:01 pm
this happens because there is no animation in your skeleton file. tell your artist export at least one animation.

is it not possible to load a model with animation?  Just like the default view of Ninja, before selecting an animation from the options menu?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 05, 2011, 01:22:20 pm
no, not possible. this is simply because Bones is not a model loader but an animation library.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: pages on April 08, 2011, 05:01:34 pm
Just trying to alter the code of this to suit my own needs but i am facing trouble with getting the camera to center on the main target .
I presume in CameraOrbitController.java you set the camera position to look at the x,y,z center of the 'world' through 
Code: [Select]
cameraTarget = new SimpleVector(0, 0, 0);
The only problem is for the NinjaDemoActivity you have it arranged for the circle of 8 ninjas to appear around the (0,0,0) center , now for my project i only require 1 model to appear.
So i guess i need to either
Would you know how to set it this way ?


Also as an aside --
for some reason my models load upside down :)
I'm guessing if i use the
Code: [Select]
jmeOgre2Bones.sh|bat -in ./tmp/Model.mesh.xml -out ./tmp/Model1.group.bones -rotation x180,y0,z0

Would that essentially 'Flip my model around ??
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 08, 2011, 06:17:24 pm
Ninja demo translates each Ninja to a predifened position with the call
Code: [Select]
ninja.getRoot().translate(..)remove that call. if your model is at origin (0, 0, 0) in 3d editor, it will also be in jPCT.

right, CameraOrbitController positions camera such that camera looks at camera target.

your model looks upside down due to difference in coordinate systems of jPCT and 3d editor app. as yoi said, if you pass
Code: [Select]
-rotation x180
to import scripts model and skeleton will be rotated 180 degrees around X axis. no need to specify Y and Z rotation if they are zero.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: pages on April 08, 2011, 11:54:11 pm
your model looks upside down due to difference in coordinate systems of jPCT and 3d editor app. as yoi said, if you pass
Code: [Select]
-rotation x180
to import scripts model and skeleton will be rotated 180 degrees around X axis. no need to specify Y and Z rotation if they are zero.

Cheers that worked perfect just couldn't use the -rotation as the last argument as it fails for some reason ( just in case others try it , use it as the first parameter seemed to work fine for me)

On the second problem of the positioning of the mesh , My model is at x,y,z 0,0,0 in the editor but it still appearing off center . As a test i used the ninja model which you give out but that also appears in the exact same location on start up

(http://img850.imageshack.us/img850/8803/offcenter.png) (http://img850.imageshack.us/i/offcenter.png/)



What might be different is in AndroidManifest.xml i used
Code: [Select]
android:screenOrientation="user"As i want to be able to have a more up close view of the models to fit more of the screen  , could this be the source of the problem ?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 09, 2011, 12:10:13 am
Quote
just couldn't use the -rotation as the last argument as it fails for some reason
ah right, forgot to mention that. -in .. parameter must be last parameter as there may be many in files.

Quote
What might be different is in AndroidManifest.xml i used
Code: [Select]
android:screenOrientation="user"As i want to be able to have a more up close view of the models to fit more of the screen  , could this be the source of the problem ?
no, this cant be. jPCT automatically adjusts aspect ratio.

looking at the screenshot, if you didnt translate ninja to somewhere (NinjaDemoActivity does that), camera is located somewhere where x > 0. maybe there is a call to
Code: [Select]
cameraController.cameraAngle = <angle>in somewhere in your code where angle is non zero. check that please

if cannot find, print ninja's translation and camera position, that might give you a clue

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 11, 2011, 08:04:16 am
this happens because there is no animation in your skeleton file. tell your artist export at least one animation.

Hi raft,
I got the .xml files with a simple animation.  Now I could see that the group is also loaded from the log message below.

Skeleton created out of jME OGRE skeleton, 69 joints
Created skeleton animation clip: leg_test
Loaded ogre file: body_new/body.mesh.xml, scale: 1, rotation: null
   1 sub objects, 1 skin animation(s), 0 pose animation(s)


But after that I get this strange exception.

Exception in thread "main" java.io.FileNotFoundException: /Eng-Repo/Reference/Graphics/Skeletal-Animation/Bones/scripts/-out (No such file or directory)
   at java.io.FileInputStream.open(Native Method)
   at java.io.FileInputStream.<init>(FileInputStream.java:106)
   at java.io.FileInputStream.<init>(FileInputStream.java:66)
   at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
   at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
   at java.net.URL.openStream(URL.java:1010)
   at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:225)
   at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:177)
   at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:91)
   at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:81)
   at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:58)
   at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:147)

I sense that things can't get more basic than this.   :-[.  But I am clueless as to what's going wrong.  I used the following command in the command prompt.
bash jmeOgre2Bones.sh -in body_new/body.mesh.xml -out fm.group.bones

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 11, 2011, 11:17:12 am
the -in parameter should be last. this because there may be more than one in file.

Code: [Select]
jmeOgre2Bones.sh -out fm.group.bones -in body_new/body.mesh.xml
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 11, 2011, 04:48:38 pm
Thanks, raft.  That worked. :)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 12, 2011, 05:34:29 pm
Hi raft,

Finally, I was able to load the model given by my artist.  Thanks a lot for your guidance and support in my first baby step :).
Even my model loaded upside down; but I could use the -rotation parameter to get it loaded properly.

However, I am facing the same problem as pages, i.e. the model is not appearing in the center of the screen, but moved to the left edge of the screen.  I am using the same code that is used in the Ninja demo.  I just changed the resource names for the model and the texture.  Based on your advice to pages, I scanned through the code to see the assignment of a camera angle that is greater than 0.  I couldn't see any such code in NinjaDemoActivity.  But I found that the default value of the camera angle was "PI" as initialized in the cameraorbitor class.  I even changed that to 0.  But I couldn't succeed in getting my model to the center.

Am I missing something here?  I'll anyway continue to analyze this by putting more log messages into the app.

Thanks a lot...
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 12, 2011, 06:46:18 pm
you are welcome. i'm glad if it helped ;D

Ninja demo does not place ninja's to origin. if you use the same code, that is probably your problem. have a look at addNinja() method. it translates the ninja to some distance from origin.

Code: [Select]
ninja.getRoot().translate(..);
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 12, 2011, 08:58:50 pm
Yeah, I was analyzing camera angle and camera position and was planning to analyze the translation part there after. 
Thanks for pointing out the code, I just commented that statement and model appears in the center.  Great  ;D
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 14, 2011, 07:34:19 am
hi raft,

I am back again  :).  The model that I succeeded in loading is a human model.  When the model is loaded with default human-skin-texture, it was all fine.  But when I tried to use separate textures for shirt and pants, whichever texture that I apply last, covers the complete the model. 
Simple solution could be to go back to our artist and ask for the single texture file that includes all: skin, shirt and pants.  But my app requires that the end user should be able to change dresses (shirt, pant etc) on the fly.  So I think having separate texture files is the way to go.  But I am struck with the above problem.

Can you please throw some light or point me to some docs on the texture mapping techniques to be used in JPCT/Bones?

Thanks,
Babu
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 14, 2011, 12:27:05 pm
Bones cannot handle multiple textures per model. you can of course use PolygonManager to assign different textures to different parts but you need polygon id's. i would forget about this

have a look at karga thread (http://www.jpct.net/forum2/index.php/topic,252.0.html). i did clothing thing by creating textures on the fly. pick a panths texture and draw it on top of skin texture, pick a tshirt texture and draw it on top of skin texture too, draw other parts (neckless, glove etc) on top of these and finally apply the resulting texture to the model.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 14, 2011, 01:59:56 pm
thanks, raft.  :)

I'll will start exploring the karga and the PolygonManager...
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 15, 2011, 12:51:41 pm
hi raft,
I went through the mesh.xml files to check for the polygons.  I think that the polygons are listed under <faces>.  Am I right?
If so, getting the right polygon id will be a big guess work   ???.

Then went through the karga thread and even registered myself in aptalkarga.com  :).  It is great  8)  Unfortunately, when I logged in there wasn't anyone except the beauty-bot Alice and I couldn't even kiss her due to lack of money  ;D.  I will log-in again after some time, anyway.  Great work! Keep it up!!

I am thinking about your suggestion of the creating the textures on the fly.  I couldn't figure out how to do it, at least till now  :-[.  I couldn't find any sample code in the karga thread as well.  :(  Any hints??
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 15, 2011, 01:05:30 pm
right, you need to wild guess polygon id's. that's why i said i would forget about it ;)

there is no sample code about this kind of texture generation. it's something like this: you have skin texture of body, panth texture, tshirt texture. you draw these on top of each other and get the final texture. then apply it to your model.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 15, 2011, 05:33:37 pm
hi raft,
I've some new questions... ???
1) Is it possible to have multiple meshes for the same skeleton?  Something like, separate meshes for head, upper-body and lower-body built around the same skeleton?  If so, then I guess that all these meshes to be passed as -in parameters to the ogre2Bones converter script?

2) If the above one is feasible, then is it possible to link each of these meshes to different textures??

3) If the meshes to be changed on the fly, (i.e. from thin-upper-body to fat-upper-body) then I think I have to rebuild the entire ".bones" group programmatically. Is my understanding correct?  If so, then I think it will be performance issue.  Is there a performance friendly way to get over with that?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 15, 2011, 05:51:18 pm
1. yes possible. for example ninja model consists of two meshes. no need to import them from seperate files. your exporter should export them to same file.

2. yes of course, they are seperate objects

3. no. just build them once while initializing them make proper parts visible/invisible
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 15, 2011, 08:38:31 pm
I tried number 1.  Everything seemed to go fine, but at the end, I got this exception...  ???
Code: [Select]
bash jmeOgre2Bones.sh -out fm.group.bones -rotation x180,y180 -in body_new/body.mesh.xml body_new/top.mesh.xml body_new/shorts.mesh.xml
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:07 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
-- total 69 joint(s) --
0 name: joint6, parent:
1 name: joint7, parent: 0:joint6
2 name: joint8, parent: 1:joint7
3 name: left_hip_joint, parent: 1:joint7
4 name: right_hip_joint, parent: 1:joint7
5 name: joint9, parent: 2:joint8
6 name: left_knee_joint, parent: 3:left_hip_joint
7 name: right_knee_joint, parent: 4:right_hip_joint
8 name: joint10, parent: 5:joint9
9 name: left_ankle_joint, parent: 6:left_knee_joint
10 name: right_ankle_joint, parent: 7:right_knee_joint
11 name: joint11, parent: 8:joint10
12 name: left_ball_joint, parent: 9:left_ankle_joint
13 name: right_ball_joint, parent: 10:right_ankle_joint
14 name: joint12, parent: 11:joint11
15 name: left_clavicle_joint, parent: 11:joint11
16 name: right_clavicle_joint, parent: 11:joint11
17 name: left_toe_joint, parent: 12:left_ball_joint
18 name: right_toe_joint, parent: 13:right_ball_joint
19 name: joint13, parent: 14:joint12
20 name: left_shoulder_joint, parent: 15:left_clavicle_joint
21 name: right_shoulder_joint, parent: 16:right_clavicle_joint
22 name: joint14, parent: 19:joint13
23 name: left_elbow_joint, parent: 20:left_shoulder_joint
24 name: right_elbow_joint, parent: 21:right_shoulder_joint
25 name: joint15, parent: 22:joint14
26 name: left_wrist_joint, parent: 23:left_elbow_joint
27 name: right_wrist_joint, parent: 24:right_elbow_joint
28 name: joint16, parent: 25:joint15
29 name: left_thumb_joint, parent: 26:left_wrist_joint
30 name: left_wrist1_joint, parent: 26:left_wrist_joint
31 name: right_thumb_joint, parent: 27:right_wrist_joint
32 name: right_wrist1_joint, parent: 27:right_wrist_joint
33 name: left_thumb1_joint, parent: 29:left_thumb_joint
34 name: left_index_joint, parent: 30:left_wrist1_joint
35 name: left_little_joint, parent: 30:left_wrist1_joint
36 name: left_middle_joint, parent: 30:left_wrist1_joint
37 name: left_ring_joint, parent: 30:left_wrist1_joint
38 name: right_thumb1_joint, parent: 31:right_thumb_joint
39 name: right_index_joint, parent: 32:right_wrist1_joint
40 name: right_little_joint, parent: 32:right_wrist1_joint
41 name: right_middle_joint, parent: 32:right_wrist1_joint
42 name: right_ring_joint, parent: 32:right_wrist1_joint
43 name: left_thumb2_joint, parent: 33:left_thumb1_joint
44 name: left_index1_joint, parent: 34:left_index_joint
45 name: left_little1_joint, parent: 35:left_little_joint
46 name: left_middle1_joint, parent: 36:left_middle_joint
47 name: left_ring1_joint, parent: 37:left_ring_joint
48 name: right_thumb2_joint, parent: 38:right_thumb1_joint
49 name: right_index1_joint, parent: 39:right_index_joint
50 name: right_little1_joint, parent: 40:right_little_joint
51 name: right_middle1_joint, parent: 41:right_middle_joint
52 name: right_ring1_joint, parent: 42:right_ring_joint
53 name: left_index2_joint, parent: 44:left_index1_joint
54 name: left_little2_joint, parent: 45:left_little1_joint
55 name: left_middle2_joint, parent: 46:left_middle1_joint
56 name: left_ring2_joint, parent: 47:left_ring1_joint
57 name: right_index2_joint, parent: 49:right_index1_joint
58 name: right_little2_joint, parent: 50:right_little1_joint
59 name: right_middle2_joint, parent: 51:right_middle1_joint
60 name: right_ring2_joint, parent: 52:right_ring1_joint
61 name: left_index3_joint, parent: 53:left_index2_joint
62 name: left_little3_joint, parent: 54:left_little2_joint
63 name: left_middle3_joint, parent: 55:left_middle2_joint
64 name: left_ring3_joint, parent: 56:left_ring2_joint
65 name: right_index3_joint, parent: 57:right_index2_joint
66 name: right_little3_joint, parent: 58:right_little2_joint
67 name: right_middle3_joint, parent: 59:right_middle2_joint
68 name: right_ring3_joint, parent: 60:right_ring2_joint
-- --
Skeleton created out of jME OGRE skeleton, 69 joints
Created skeleton animation clip: leg_test
Loaded ogre file: body_new/body.mesh.xml, scale: 1, rotation: Quaternion [X=-6.123234E-17, Y=6.123234E-17, Z=1.0, W=3.7493998E-33]
1 sub objects, 1 skin animation(s), 0 pose animation(s)
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
-- total 69 joint(s) --
0 name: joint6, parent:
1 name: joint7, parent: 0:joint6
2 name: joint8, parent: 1:joint7
3 name: left_hip_joint, parent: 1:joint7
4 name: right_hip_joint, parent: 1:joint7
5 name: joint9, parent: 2:joint8
6 name: left_knee_joint, parent: 3:left_hip_joint
7 name: right_knee_joint, parent: 4:right_hip_joint
8 name: joint10, parent: 5:joint9
9 name: left_ankle_joint, parent: 6:left_knee_joint
10 name: right_ankle_joint, parent: 7:right_knee_joint
11 name: joint11, parent: 8:joint10
12 name: left_ball_joint, parent: 9:left_ankle_joint
13 name: right_ball_joint, parent: 10:right_ankle_joint
14 name: joint12, parent: 11:joint11
15 name: left_clavicle_joint, parent: 11:joint11
16 name: right_clavicle_joint, parent: 11:joint11
17 name: left_toe_joint, parent: 12:left_ball_joint
18 name: right_toe_joint, parent: 13:right_ball_joint
19 name: joint13, parent: 14:joint12
20 name: left_shoulder_joint, parent: 15:left_clavicle_joint
21 name: right_shoulder_joint, parent: 16:right_clavicle_joint
22 name: joint14, parent: 19:joint13
23 name: left_elbow_joint, parent: 20:left_shoulder_joint
24 name: right_elbow_joint, parent: 21:right_shoulder_joint
25 name: joint15, parent: 22:joint14
26 name: left_wrist_joint, parent: 23:left_elbow_joint
27 name: right_wrist_joint, parent: 24:right_elbow_joint
28 name: joint16, parent: 25:joint15
29 name: left_thumb_joint, parent: 26:left_wrist_joint
30 name: left_wrist1_joint, parent: 26:left_wrist_joint
31 name: right_thumb_joint, parent: 27:right_wrist_joint
32 name: right_wrist1_joint, parent: 27:right_wrist_joint
33 name: left_thumb1_joint, parent: 29:left_thumb_joint
34 name: left_index_joint, parent: 30:left_wrist1_joint
35 name: left_little_joint, parent: 30:left_wrist1_joint
36 name: left_middle_joint, parent: 30:left_wrist1_joint
37 name: left_ring_joint, parent: 30:left_wrist1_joint
38 name: right_thumb1_joint, parent: 31:right_thumb_joint
39 name: right_index_joint, parent: 32:right_wrist1_joint
40 name: right_little_joint, parent: 32:right_wrist1_joint
41 name: right_middle_joint, parent: 32:right_wrist1_joint
42 name: right_ring_joint, parent: 32:right_wrist1_joint
43 name: left_thumb2_joint, parent: 33:left_thumb1_joint
44 name: left_index1_joint, parent: 34:left_index_joint
45 name: left_little1_joint, parent: 35:left_little_joint
46 name: left_middle1_joint, parent: 36:left_middle_joint
47 name: left_ring1_joint, parent: 37:left_ring_joint
48 name: right_thumb2_joint, parent: 38:right_thumb1_joint
49 name: right_index1_joint, parent: 39:right_index_joint
50 name: right_little1_joint, parent: 40:right_little_joint
51 name: right_middle1_joint, parent: 41:right_middle_joint
52 name: right_ring1_joint, parent: 42:right_ring_joint
53 name: left_index2_joint, parent: 44:left_index1_joint
54 name: left_little2_joint, parent: 45:left_little1_joint
55 name: left_middle2_joint, parent: 46:left_middle1_joint
56 name: left_ring2_joint, parent: 47:left_ring1_joint
57 name: right_index2_joint, parent: 49:right_index1_joint
58 name: right_little2_joint, parent: 50:right_little1_joint
59 name: right_middle2_joint, parent: 51:right_middle1_joint
60 name: right_ring2_joint, parent: 52:right_ring1_joint
61 name: left_index3_joint, parent: 53:left_index2_joint
62 name: left_little3_joint, parent: 54:left_little2_joint
63 name: left_middle3_joint, parent: 55:left_middle2_joint
64 name: left_ring3_joint, parent: 56:left_ring2_joint
65 name: right_index3_joint, parent: 57:right_index2_joint
66 name: right_little3_joint, parent: 58:right_little2_joint
67 name: right_middle3_joint, parent: 59:right_middle2_joint
68 name: right_ring3_joint, parent: 60:right_ring2_joint
-- --
Skeleton created out of jME OGRE skeleton, 69 joints
Created skeleton animation clip: leg_test
Loaded ogre file: body_new/top.mesh.xml, scale: 1, rotation: Quaternion [X=-6.123234E-17, Y=6.123234E-17, Z=1.0, W=3.7493998E-33]
1 sub objects, 1 skin animation(s), 0 pose animation(s)
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Apr 15, 2011 10:38:10 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
-- total 69 joint(s) --
0 name: joint6, parent:
1 name: joint7, parent: 0:joint6
2 name: joint8, parent: 1:joint7
3 name: left_hip_joint, parent: 1:joint7
4 name: right_hip_joint, parent: 1:joint7
5 name: joint9, parent: 2:joint8
6 name: left_knee_joint, parent: 3:left_hip_joint
7 name: right_knee_joint, parent: 4:right_hip_joint
8 name: joint10, parent: 5:joint9
9 name: left_ankle_joint, parent: 6:left_knee_joint
10 name: right_ankle_joint, parent: 7:right_knee_joint
11 name: joint11, parent: 8:joint10
12 name: left_ball_joint, parent: 9:left_ankle_joint
13 name: right_ball_joint, parent: 10:right_ankle_joint
14 name: joint12, parent: 11:joint11
15 name: left_clavicle_joint, parent: 11:joint11
16 name: right_clavicle_joint, parent: 11:joint11
17 name: left_toe_joint, parent: 12:left_ball_joint
18 name: right_toe_joint, parent: 13:right_ball_joint
19 name: joint13, parent: 14:joint12
20 name: left_shoulder_joint, parent: 15:left_clavicle_joint
21 name: right_shoulder_joint, parent: 16:right_clavicle_joint
22 name: joint14, parent: 19:joint13
23 name: left_elbow_joint, parent: 20:left_shoulder_joint
24 name: right_elbow_joint, parent: 21:right_shoulder_joint
25 name: joint15, parent: 22:joint14
26 name: left_wrist_joint, parent: 23:left_elbow_joint
27 name: right_wrist_joint, parent: 24:right_elbow_joint
28 name: joint16, parent: 25:joint15
29 name: left_thumb_joint, parent: 26:left_wrist_joint
30 name: left_wrist1_joint, parent: 26:left_wrist_joint
31 name: right_thumb_joint, parent: 27:right_wrist_joint
32 name: right_wrist1_joint, parent: 27:right_wrist_joint
33 name: left_thumb1_joint, parent: 29:left_thumb_joint
34 name: left_index_joint, parent: 30:left_wrist1_joint
35 name: left_little_joint, parent: 30:left_wrist1_joint
36 name: left_middle_joint, parent: 30:left_wrist1_joint
37 name: left_ring_joint, parent: 30:left_wrist1_joint
38 name: right_thumb1_joint, parent: 31:right_thumb_joint
39 name: right_index_joint, parent: 32:right_wrist1_joint
40 name: right_little_joint, parent: 32:right_wrist1_joint
41 name: right_middle_joint, parent: 32:right_wrist1_joint
42 name: right_ring_joint, parent: 32:right_wrist1_joint
43 name: left_thumb2_joint, parent: 33:left_thumb1_joint
44 name: left_index1_joint, parent: 34:left_index_joint
45 name: left_little1_joint, parent: 35:left_little_joint
46 name: left_middle1_joint, parent: 36:left_middle_joint
47 name: left_ring1_joint, parent: 37:left_ring_joint
48 name: right_thumb2_joint, parent: 38:right_thumb1_joint
49 name: right_index1_joint, parent: 39:right_index_joint
50 name: right_little1_joint, parent: 40:right_little_joint
51 name: right_middle1_joint, parent: 41:right_middle_joint
52 name: right_ring1_joint, parent: 42:right_ring_joint
53 name: left_index2_joint, parent: 44:left_index1_joint
54 name: left_little2_joint, parent: 45:left_little1_joint
55 name: left_middle2_joint, parent: 46:left_middle1_joint
56 name: left_ring2_joint, parent: 47:left_ring1_joint
57 name: right_index2_joint, parent: 49:right_index1_joint
58 name: right_little2_joint, parent: 50:right_little1_joint
59 name: right_middle2_joint, parent: 51:right_middle1_joint
60 name: right_ring2_joint, parent: 52:right_ring1_joint
61 name: left_index3_joint, parent: 53:left_index2_joint
62 name: left_little3_joint, parent: 54:left_little2_joint
63 name: left_middle3_joint, parent: 55:left_middle2_joint
64 name: left_ring3_joint, parent: 56:left_ring2_joint
65 name: right_index3_joint, parent: 57:right_index2_joint
66 name: right_little3_joint, parent: 58:right_little2_joint
67 name: right_middle3_joint, parent: 59:right_middle2_joint
68 name: right_ring3_joint, parent: 60:right_ring2_joint
-- --
Skeleton created out of jME OGRE skeleton, 69 joints
Created skeleton animation clip: leg_test
Loaded ogre file: body_new/shorts.mesh.xml, scale: 1, rotation: Quaternion [X=-6.123234E-17, Y=6.123234E-17, Z=1.0, W=3.7493998E-33]
1 sub objects, 1 skin animation(s), 0 pose animation(s)
Exception in thread "main" java.lang.IllegalArgumentException: Number of vertices differ!
at raft.jpct.bones.SkinData.checkAlmostEqual(SkinData.java:38)
at raft.jpct.bones.Animated3D.mergeSkin(Animated3D.java:475)
at raft.jpct.bones.AnimatedGroup.mergeSkin(AnimatedGroup.java:338)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:83)
at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:58)
at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:147)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 15, 2011, 08:55:11 pm
multiple input files are used to merge animations. ie. one animation in this file, one in another. it's basicly done for Collada models as I couldnt find any collada sample with many animations. no need to use this with Ogre. Ogre exporters can export many animations and objects to same file.

in short, tell you artist to export all objects to same file.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 16, 2011, 12:15:11 pm
thanks, raft. :)
I had in fact asked a single file from my artist (based on your previous suggestion) ... just waiting for the file from my artist...  meanwhile thought of trying out the multiple files that I had with me...
I'll check the single file out once I get the file and then get back to you.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 16, 2011, 04:19:54 pm
2) Is it possible to link each of these meshes to different textures??
yes of course, they are seperate objects

I was thinking that each mesh would have got loaded as an Animated3D.  So I thought of iterating through the AnimatedGroup and assign the appropriate textures to corresponding objects using the object names.  But I found that the objects don't have any specific name, but object3, object4 and so on.   :(
Is there a better way to find the object that one's looking for?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 17, 2011, 06:13:13 pm
i see. the names you see is given by jPCT.

looking at Ogre docs, i've found that Ogre supports -optional- submesh names. jME Ogre loader looks for that element in mesh.xml file and sets names of submeshes accordingly. if it cannot find name, its sets a name itself just like jPCT.

I've started importing names from Ogre and Collada. I've added a method to AnimatedGroup to get an Animated3D by name: AnimatedGroup.get(name).

have a look at export options. possibly there is an option to give a name to an object.

i've updated the zip. please re-download
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 17, 2011, 08:05:41 pm
hi raft,
thanks a lot for the new API; that would my save my iteration stuff. ;D

Today, I was working with our artist to get all the meshes exported to a single .xml file.
Our artist is using OgreMax exporter (http://www.ogremax.com/downloads) to export from Maya.  This OgreMax exporter doesn't seem to give an option to export to a single .xml file.
Then we downloaded another Maya Exporter from http://www.ogre3d.org/forums/viewtopic.php?f=8&t=63214.  But with this we could only get the object format and not the xml one.
Then we downloaded OgreXMLConverter from http://www.ogre3d.org/tikiwiki/OgreXmlConverter&structure=Tools.  When tried in our artist's windows machine, it gave some error related to the absence of some serializer.
When tried in my mac, I got the following error
Code: [Select]
dyld: Library not loaded: @executable_path/../Frameworks/Ogre.framework/Versions/A/Ogre
  Referenced from: /Eng-Repo/Reference/Graphics/Skeletal-Animation/Tools/./OgreXMLConverter
  Reason: image not found
Trace/BPT trap
Do you have any idea what's going on??
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 17, 2011, 08:54:26 pm
i'm surprised that OgreMax for Maya doesn't support exporting many objects. OgreMax for 3ds Max is quite successful. what happens if you select many objects and do export selected?

I used Ogre converter at Ubuntu without any problems. don't know about mac.

I'm out now. I will think about this
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 17, 2011, 09:09:44 pm
I once encountered serializer related error with Ogre converter. can't remember windows or Ubuntu.  it turned out to be version mismatch.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 18, 2011, 07:54:37 am
Quote
i'm surprised that OgreMax for Maya doesn't support exporting many objects. OgreMax for 3ds Max is quite successful. what happens if you select many objects and do export selected?

OgreMax, in fact, supports exporting many objects.  Only that it doesn't give an option to export them into a single xml file.  It generates multiple pairs of "mesh.xml and skeleton.xml" files, a pair each for an object.  i.e. for upper-body, it generates upper.mesh.xml and upper.skeleton.xml and for lower-body, it generated lower.mesh.xml and lower.skeleton.xml.

The exporter from ogre3d.org is able to generate a single .mesh file for all the objects; but we ran into problem when trying to convert that .mesh into .xml  ::)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 18, 2011, 11:55:53 am
send me your mesh.xml and skeleton.xml pairs and let me have look what i can do.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 18, 2011, 01:34:07 pm
The files are uploaded here:
https://docs.google.com/?authuser=0#folders/folder.0.0B85w3AW2-YdVYzY1YmZjM2UtNTQzZC00NDE0LWFmNmQtZTkyMDQxNTM4ZDc1 (https://docs.google.com/?authuser=0#folders/folder.0.0B85w3AW2-YdVYzY1YmZjM2UtNTQzZC00NDE0LWFmNmQtZTkyMDQxNTM4ZDc1)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 18, 2011, 01:36:58 pm
i cant see any files in that folder. i've sent you my email. email me the files please
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 18, 2011, 01:44:54 pm
sorry, raft.  My bad  :-[.
By mistake I sent the link for the folder instead of the documents.
The mesh files are really huge and so I wouldn't able to send them in mail attachments.  However I have sent the proper links this time to you by mail.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 18, 2011, 01:59:01 pm
i've written a method to merge Animated3D's in different groups. but to work properly it needs groups have identical skeletons. looking at your files, i see skeletons differ in number of joints.

are you sure, your artist have one skeleton and attach all objects to it? it must be so, otherwise merging groups has no meaning. also this may be the reason you cannot export many objects to same file.

you can still use it this way, but without merging groups. you need to move and animate body, top and shirts together by yourself.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 18, 2011, 02:28:54 pm
yesterday, when I was working with our artist, I got is confirmed that he is using a single skeleton.  But it's the OgreMax exporter that exports multiple skeletons... seems that it picks up the joints corresponding to the mesh its exporting.

we can try one more thing: I will get the single .mesh and .skeleton generated by the other exporter.  If your ogre2XML converter is working fine, may be we can try converting them to .xml files  ???
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 18, 2011, 02:43:02 pm
Quote
yesterday, when I was working with our artist, I got is confirmed that he is using a single skeleton.  But it's the OgreMax exporter that exports multiple skeletons... seems that it picks up the joints corresponding to the mesh its exporting.
maybe there is an option like "export unused joints" ?

Quote
we can try one more thing: I will get the single .mesh and .skeleton generated by the other exporter.  If your ogre2XML converter is working fine, may be we can try converting them to .xml files  ???
we can try this, but only once ;) i cant do it all the time for you.

Ogre also has an OgreMeshUpgrade tool, to upgrade mesh file to latest version. try using that before using OgreXMLConverter. if it doesnt help send me your mesh files.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 18, 2011, 06:54:03 pm
Quote
maybe there is an option like "export unused joints" ?
Ok, I will ask my artist to explore this.

Quote
Ogre also has an OgreMeshUpgrade tool, to upgrade mesh file to latest version. try using that before using OgreXMLConverter. if it doesnt help send me your mesh files
My OgreXMLConverter doesn't even launch.  It doesn't even show usage options.  I will try to explore ogre3d forum.  :(

Quote
we can try this, but only once  i cant do it all the time for you.
Thanks a lot.  Even doing once would be great  ;D.  I've just mailed you the .mesh and the .skeleton files.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 18, 2011, 08:12:27 pm
my OgreXMLConverter failed too to convert your files. giving same serializer error
Code: [Select]
Exception caught: Cannot find serializer implementation for current version [MeshSerializer_v1.41]
this is, as i remember, caused by version mismatch. ie: exporter uses a newer Ogre library than converter. I've upgraded my converter and successfully converted your files. but this time Bones failed to load your files since there is no animation in them. export some animations and send me the files again.

to run converter on your machine, get latest version of converter. seems as precompiled Windows version is not latest, so you can try building from source.

if you have access to an ubuntu machine, you can get latest converter from here:
https://launchpad.net/~ogre-team/+archive/ogre

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 18, 2011, 08:54:32 pm
I've updated the zip. this version saves Animated3D names to stream. This changes stream version, formerly serialized groups should be re-serialized with BonedIO or script files.

i've decided -at least for now- not to publish merging many objects in many groups into a single group. this is because it wont work as the way I expected and will cause more trouble than it solves.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 19, 2011, 08:58:59 am
Quote
to run converter on your machine, get latest version of converter. seems as precompiled Windows version is not latest, so you can try building from source.

I got the source from their SVN.  But when I tried to build, I found that some more files are required.
Code: [Select]
1>Compiling...
1>main.cpp
1>d:\archive\main.cpp(30) : fatal error C1083: Cannot open include file: 'Ogre.h': No such file or directory
1>OgreXMLMeshSerializer.cpp
1>d:\archive\ogrexmlprerequisites.h(32) : fatal error C1083: Cannot open include file: 'OgrePrerequisites.h': No such file or directory
1>OgreXMLSkeletonSerializer.cpp
1>d:\archive\ogrexmlprerequisites.h(32) : fatal error C1083: Cannot open include file: 'OgrePrerequisites.h': No such file or directory
1>tinyxml.cpp
1>d:\archive\tinyxml.h(29) : fatal error C1083: Cannot open include file: 'OgrePrerequisites.h': No such file or directory
1>tinyxmlerror.cpp
1>d:\archive\tinyxml.h(29) : fatal error C1083: Cannot open include file: 'OgrePrerequisites.h': No such file or directory
1>tinyxmlparser.cpp
1>d:\archive\tinyxml.h(29) : fatal error C1083: Cannot open include file: 'OgrePrerequisites.h': No such file or directory
1>Generating Code...

I am searching for these missing files in their SVN, now  :(
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 19, 2011, 11:01:57 am
well, you are on your own for this build process ;)

have tried downloading Ogre SDK? it contains OgreXMLConverter too.
http://www.ogre3d.org/download/sdk/
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: paulscode on April 19, 2011, 11:50:17 am
if you have access to an ubuntu machine, you can get latest converter from here:
https://launchpad.net/~ogre-team/+archive/ogre

Another option if you can't get the Windows version to work, might be to install the free program VirtualBox (http://www.virtualbox.org/), and then create an Ubuntu (http://www.ubuntu.com/) virtual machine to use for compiling and converting.  Sort of a round-about way to do things, but its another option that won't cost anything if all else fails.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 19, 2011, 01:06:45 pm
Quote
have tried downloading Ogre SDK? it contains OgreXMLConverter too.
Done that.  But the mac version of the SDK seems to be having some problem.  However, my artist was able to download the windows version of the converter and he sent the .xml files.

But when I ran them through the BonesImporter, I got the following exception.  Any hints on resolving this exception??
Code: [Select]
Skeleton created out of jME OGRE skeleton, 69 joints
Exception in thread "main" java.lang.NullPointerException
at raft.jpct.bones.BonesImporter.convertJMEMeshData(BonesImporter.java:431)
at raft.jpct.bones.BonesImporter.importOgre(BonesImporter.java:192)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:93)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:77)
at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:58)
at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:147)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 19, 2011, 01:08:21 pm
raft, also I've mailed you the bunch of files..
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 19, 2011, 02:08:24 pm
seems as a bug in jME ogre loader. there are two vertex texture buffers where first is null. I always use the first buffer, that causes the exception. even if I skip that part I run into another jPCT related exception.

@Egon can you please check the below exception. I provide an array of 13278 int's as coordinates, UV's and indices are null. 4426x3 = 13278 so I dont get what is wrong..

Code: [Select]
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4426
at com.threed.jpct.Object3D.<init>(Unknown Source)
at raft.jpct.bones.Animated3D.<init>(Animated3D.java:119)
..

edit:  corrected the typo
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 19, 2011, 02:42:50 pm
@Babu, meanwhile you can tell your artist not to use shared vertices/geometry if there is such an option in exporter.  seems as that troubles jME loader
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 19, 2011, 09:18:10 pm
hi raft,
I got the new files from my artist (not using shared vertices/geometry) and finally, I was able to load the multiple objects with the corresponding textures!!  ;D.  And thanks a ton for all your help and patience  :).  I think, I am off your back for some time  ;)

Note: Mailed u the screenshot as I couldn't figure out how to place an image in this post.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 19, 2011, 09:26:50 pm
you're welcome ;) i'm glad we finally solved your problem.. btw, your screenshot seems quite good
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Monopula on April 20, 2011, 02:49:31 pm
Hello there,

Just downloaded the android example to try. It compiles ok.
But while running I've got the following exception from BonesIO.readHeader:82 :

Version mismatch. Current version: 3, stream version: 2

Would you, please help me?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 20, 2011, 02:59:41 pm
please re-download the android app. it should be ok now
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Monopula on April 20, 2011, 03:03:25 pm
Yeah, thanks. I've already found it in sources ))
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 20, 2011, 07:16:07 pm
hi raft, I am back :)
I read in wiki read that
Quote
current versions of jPCT come with a new class, the DeSerializer. While it can be used within jPCT only, it's main purpose is to be used in combination with AE. The idea is to load the models in jPCT and serialize them into an optimized format that can be loaded by AE very quickly.

Is it possible to use this approach when we are using Bones i.e. is it possible to serialize/deserialize Animated3Ds?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 20, 2011, 07:23:02 pm
no, not possible. jPCT's serializer only writes jPCT related data, texture info polygons etc. Bones need to write animation data that's why it has its own serializer/deserializer (i.e. BonesIO). i guess it's fast enough, isn't it?

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 20, 2011, 07:41:08 pm
yeah, I kind of guessed it that .bones is the equivalent .ser... but now with your reply it is quite clear, thanks :)
Quote
i guess it's fast enough, isn't it?
In Android Emulator, it took more than 20 seconds to load my model.  I still need to check that in my samsung galaxy 3.  However, the total polygon count for my model is more than 8000  :o.  I think I need to work with my artist to bring it down. 
BTW, what do you think should be the ideal range of polygon count for JPCT-AE/Bones combination  ???


Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 20, 2011, 08:03:42 pm
emulator is really slow. the real device should be faster.

optimal polygon count depends on your application (how many of that models will you render? background model? etc) and target device. its hard to say something. but i guess 8000 polygons is high for a phone app.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 20, 2011, 08:27:18 pm
Following are data that I just collected:

Simulator
Load (.bones to AnimatedGroup) - 12 seconds
Oncreate to OnDraw - 18 seconds

Samsung Galaxy 3
Load (.bones to AnimatedGroup) - 6 seconds
Oncreate to OnDrawFrame - 12 seconds
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 20, 2011, 08:53:59 pm
well, lower your polygon count. how does that phone perform with jPCT bencmark app?

i can later try to make it faster but no promises. and expect no miracles.

i guess some siginificant part of loading time goes to building objects. jPCT's serializer saves build information to save building time in Android. i'm afraid there isn't much I can do about it.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 21, 2011, 12:48:46 am
BonesIO uses some kind of flat java serialization. it serializes some arrays and objects as objects. I was suspecting this was slow but I was avoiding replacing it mostly because it will be too error prone and hard to debug in case of failure.

now i tried replacing ObjectOutputStream.writeObject calls with a series of primitive writes like writeInt and writeFloat. surprisingly it didnt help. maybe even performed slightly worse. than I took my changes back.

so in short, seems as there isnt much room to improve here.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: EgonOlsen on April 21, 2011, 07:03:18 am
Just make sure that you wrap all InputStreams into BufferedInputStreams or otherwise, loading on Android will be much slower...i bet you already do that, it just came to my mind while reading this thread.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 21, 2011, 11:47:21 am
no i wasn't doing that. thanks for the reminder. wrapping into BufferedInputStream slightly increases flat serialization loading but still surprisingly primitive reads perform worse. dont know why ???
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 22, 2011, 08:32:07 am
hi raft,
Today, i was trying to load a model that uses pose animations.  But i got the following exception, when i was exporting from xml to bones.
Any idea what's going wrong?
Code: [Select]
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1937)
at com.jmex.model.ogrexml.anim.MeshAnimationLoader.loadPose(MeshAnimationLoader.java:187)
at com.jmex.model.ogrexml.anim.MeshAnimationLoader.loadPoses(MeshAnimationLoader.java:144)
at com.jmex.model.ogrexml.OgreLoader.loadMesh(OgreLoader.java:699)
at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:225)
at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:177)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:110)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:88)
at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:69)
at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:170)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 22, 2011, 08:46:59 am
I'm out.of city now. will look at it next week. meanwhile you can debug it yourself  ;)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 22, 2011, 05:51:06 pm
thanks, raft :)

I am seeing this problem with even "cylinder.mesh.xml" and "facial.mesh.xml".  Seems to be common problem for anything with pose animations  ???

Yeah, I will try my best to debug this  ;D  But it seems to happen in the jme loader for which i don't have the source code.  Any idea, from where I can get the source  ::)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 22, 2011, 07:13:05 pm
facial and cylinder.xml was working fine. maybe jme version update or me screwed something.

bones.zip contains src for jme and ardor
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 23, 2011, 08:27:32 am
Yeah, got the source.  The ".jar" extension had done me in  :-[
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 24, 2011, 09:24:56 pm
please re-download the zip, hopefully i've fixed that.

jME trunk now contains jME-3 alpha, so i cant see history of jME-2. SVN tags dir contain jME-2.0.1 not jME-2. IMHO they had screwed SVN.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 25, 2011, 12:25:07 pm
Thanks, raft.  I will download the zip and check it out.

Yesterday, I had done some changes locally and I was able convert from xml to bones.  And I am able to to load the cylinder model in my Android App.  Basically, the method, "loadPose" of "MeshAnimationLoader" assumes the existence of extension in the submesh names.  I just did the following changes to get around that.
Old Code
Code: [Select]
String cleanName = name.substring(0, name.lastIndexOf('-'));
rootnode.addPose(cleanName, pose);

My Changes
Code: [Select]
String cleanName = name;
int extIndex = name.lastIndexOf('-');
if(extIndex >0 ) cleanName = name.substring(0, extIndex);
rootnode.addPose(cleanName, pose);
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 25, 2011, 12:27:16 pm
i just got rid of clean name, instead used name
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: panthenol on April 28, 2011, 03:42:12 pm
i'm wondering if somebody knows how to implement several animation clips into a single *.dae file , using 3dsmax , or maya
because it could be very tedious to import and serialize each and every animation using a file loader  :-\

Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 28, 2011, 03:59:57 pm
well, i wonder it too ;) i've never seen a DAE file with many animations but as i know it's possible.

but, you can merge several DAE files into one if skeleton and models are identical. the script files accept more than one input file for this purpose.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on April 29, 2011, 08:23:56 am
Hi Raft,

Quote
3) If the meshes to be changed on the fly, (i.e. from thin-upper-body to fat-upper-body) then I think I have to rebuild the entire ".bones" group programmatically. Is my understanding correct?  If so, then I think it will be performance issue.  Is there a performance friendly way to get over with that?

no. just build them once while initializing them make proper parts visible/invisible

we're contemplating about using blend shapes (pose animations) instead of having multiple meshes for body/head shapes.  Is this a feasible and scalable solution.  Can you please let me know your view on this?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 29, 2011, 12:29:06 pm
sounds good to me. worths a try. performance will not be a problem since pose animations are much cheaper than skeleton animations.

* if you plan to use facial pose animations they may not blend well with head scaling pose animations. but not sure, try and see ;)
* if you radically change mesh with pose animations (like making it twice bigger), skeleton animation may not look good enough. but again not sure, try and see ;)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: panthenol on April 29, 2011, 02:46:37 pm
Hello again ! , so , i don't think i did it right , but :

Code: [Select]
skinnedGroup  = loadDAE(filename);
skinnedGroup1 = loadDAE(filename);
skinnedGroup.getPoseClipSequence().addClip(skinnedGroup1.getPoseClipSequence().getClip(0));
skinnedGroup.getskinClipSequence().addClip(skinnedGroup1.getSkinClipSequence().getClip(0));


gives :
Code: [Select]
Exeption in thread "main" java.lang.NUllPointerExeption
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 29, 2011, 02:47:40 pm
i cant say more if you dont post stack trace. possibly pose clip sequence is null for groups. collada does not support pose animations.

anyway, that's not the way to merge animations in groups. use AnimatedGroup.mergeAnimations(..)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: panthenol on April 29, 2011, 03:38:33 pm
Ok , i did'nt thad the the latest Bones version , so i updated and continuing to test  :)

Don't know if it's of any help for anybody , but i found out that maybe some export problems
are coming not from the exporters , but from the character rigs.

On creativecrash.com ,  i found a lot of skeletons with controls inside the bone hierarchy ,
This could be an issue when exporting animation , because the controllers would potentially not be recognised
as bones by  the exporter , while being inside a bone hierarchy , and it would result in breaking bone hierarchy at export.

In ogreMax Xsi , i had several exported controllers set at origin ...

So I think it's a good idea to have the controllers outside the skeleton , controlling it using constraints.
Before export , you can use any utility to bake constraints into animation curves on the bones
( select the bones hierarchy , and go in edit/keys/bake simulation in maya , or plot animation in softimage )
and then , remove everything , but the bones and the meshes before export
 
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: panthenol on April 29, 2011, 03:52:01 pm
ah , with .mergeAnimations(..) , it's working perfectly , thanks a lot  ;D
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on April 30, 2011, 09:40:12 pm
i had missed your post, somehow notificaton mail didnt arrive ??? anyway seems as you've solved your issue ;)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: MrFluff on May 05, 2011, 01:13:53 pm
Hi, awesome library :).

I have a few questions:

What was the original format of the ninja model? when I export an animated collada (dae) model I cannot set names for animations (I am using 3ds max 9) so after converting the model to the binary format and loading it into my android scene i can only select one animation (this works perfectly fine).

Maybe dae does not support animation naming. What about this ogre3D format. Did you use it for the ninja?

When I use the free version of the OgreMax plugin I can only export am OgreMax scene or an OgreMax Mesh.

When using OgreMax exporter, two files are created (%filename%..mesh, %filename%..skeleton), besides the fact that 2 dots are in the filename there is always an exception thrown when trying to convert either of these files into the binary format.

So what's the best way to create an animated model with different (named) animations?

Thx in advance :)
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 05, 2011, 09:54:43 pm
hi,

original format of ninja is Ogre3D. i'm not sure if collada supports names. but ogre does and OgreMax allows naming animations. i prepared model and animation of animation blend demo myself and gave names to animatinons.

i suggest Ogre format and OgreMax for 3d max. but AFAIK you dont need to name animations to have more than one animations in one file.

there are two equivalent forms of Ogre format: binary and xml. *.mesh/skeleton and *.mesh.xml/skeleton.xml files. they can be converted to each other. Bones need xml format thats why you got an exception. OgreMax has an option to export to xml format or alternatively Ogre has command line tools to convert between formats. look at previous posts in this thread for more information.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: MrFluff on May 08, 2011, 12:55:18 pm

Hi raft,

thank you for your reply. I finally got named animations working using the converted binary from an OgreMax exported file, and everything works as expected.

I had some problems converting from a collada file, however. The first animated frame in a loop does not display corretly (it does not matter to me as I use the Ogre3D format now).
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 08, 2011, 03:51:45 pm
I had some problems converting from a collada file, however. The first animated frame in a loop does not display corretly
possibly an issue with exporter.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: panthenol on May 09, 2011, 12:10:17 pm
Quote
I had some problems converting from a collada file, however. The first animated frame in a loop does not display corretly
possibly an issue with exporter.

I got no such problem in Maya , but OgreMax is quite a time savior anyway ^^
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on May 10, 2011, 12:33:46 pm
hi raft,

I am back  ;).  I could load the cylinder model with the pose animations in my Android app and I could have all the pose animations working fine.  I see that the skin-animation, "wave" is also working fine. 

But I am facing a problem when I try to have both skin and pose animations working together :(.  I am able see only that animation which I apply last in the code i.e. if I call animatePose() last then I see only pose animation and if I call animateSkin() last then I see only skin animation.  I am not sure if I am doing some wrong  ???.  Below is the code for onDrawFrame().  I am using Ninja Demo as the base for my app.

Code: [Select]
                public void onDrawFrame(GL10 gl)
{
if (frameBuffer == null) return;

long now = System.currentTimeMillis();
aggregatedTime += (now - frameTime);
frameTime = now;

if (aggregatedTime > 1000)
{
aggregatedTime = 0;
}

while (aggregatedTime > GRANULARITY)
{
aggregatedTime -= GRANULARITY;
skinAnimateSeconds += GRANULARITY * 0.001f * speed;
poseAnimateSeconds += GRANULARITY * 0.001f * speed;
placeCamera();
}

if (poseAnimation > 0 && rockyCylinder.getPoseClipSequence().getSize() >= poseAnimation)
{
float clipTime = rockyCylinder.getPoseClipSequence().getClip(poseAnimation-1).getTime();
if (poseAnimateSeconds > clipTime)
{
poseAnimateSeconds = 0;
}
float index = poseAnimateSeconds / clipTime;

rockyCylinder.animatePose(index, poseAnimation);
}
else
{
poseAnimateSeconds = 0f;
}

////////////////////////// START BLOCK /////////////////////////////////////////
/////// If I move this block above pose animation then "wave" doesn't happen//////////
if (skinAnimation > 0 && rockyCylinder.getSkinClipSequence().getSize() >= skinAnimation)
{
float clipTime = rockyCylinder.getSkinClipSequence().getClip(skinAnimation-1).getTime();
if (skinAnimateSeconds > clipTime)
{
skinAnimateSeconds = 0;
}
float index = skinAnimateSeconds / clipTime;

rockyCylinder.animateSkin(index, skinAnimation);
}
else
{
skinAnimateSeconds = 0f;
}
////////////////////////// END BLOCK /////////////////////////////////////////

rockyCylinder.applyAnimation();

frameBuffer.clear();
world.renderScene(frameBuffer);
world.draw(frameBuffer);

frameBuffer.display();
}
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 10, 2011, 12:48:51 pm
that's because autoApplyAnimation is enabled by default. call AnimatedGroup.setAutoApplyAnimation(false) once after loading group.

first apply pose animations, then skin animation. finally call AnimatedGroup.applyAnimation().
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on May 10, 2011, 01:06:39 pm
thanks, raft.  That worked!!  ;D
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: panthenol on May 10, 2011, 03:04:18 pm
usefull piece of info here also !  thanks guys for sharing this  :D
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: frag-a on May 14, 2011, 12:18:35 pm
Hi raft, first of all thanks for this great lib. I'm playing around with some 3D game dev stuff, but I don't have much experience...yet :)
It was relatively easy to get into jpct and bones but I suck at math, so I wonder if you could help me here with this attempt to do some IK.
The goal is to have some character to grab or to point to some other object. The below code works fine if the rotation starts from the bind pose.
But if it's not from the bind pose, it just get crazy! Could you please help me figure out whats missing? Thanks in advance.

Code: [Select]
private static final void targetJoint(final SimpleVector targetTranslation, final SkeletonPose pose, int handleIndex, int parentIndex) {
final Skeleton skeleton = pose.getSkeleton();
final Joint handleJoint = skeleton.getJoint(handleIndex);
final Joint parentJoint = skeleton.getJoint(parentIndex);
final Matrix parentInverseBindPose = parentJoint.getInverseBindPose();
final Matrix parentBindPose = parentInverseBindPose.invert();

final SimpleVector handleTranslation = pose.getGlobal(handleIndex).getTranslation();
final SimpleVector parentTranslation = pose.getGlobal(parentIndex).getTranslation();

float distance = handleTranslation.distance(targetTranslation);
if (distance > 0.1) {
SimpleVector parentHandleVector = handleTranslation.calcSub(parentTranslation);
parentHandleVector = parentHandleVector.normalize();
parentHandleVector.rotate(parentInverseBindPose);

SimpleVector parentTargetVector = targetTranslation.calcSub(parentTranslation);
parentTargetVector = parentTargetVector.normalize();
parentTargetVector.rotate(parentInverseBindPose);

float angle = parentHandleVector.calcAngle(parentTargetVector);
if (Math.abs(angle) > 0.1f) {
Quaternion quat = new Quaternion().fromVectorToVector(parentHandleVector, parentTargetVector);
final Matrix rotation = quat.getRotationMatrix();
rotation.matMul(parentBindPose);
rotation.matMul(pose.getSkeleton().getJoint(parentJoint.getParentIndex()).getInverseBindPose());
pose.getLocal(parentIndex).setTo(rotation);
}
}
}
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 14, 2011, 02:44:47 pm
i'm no expert at these calculations either, most of the time they drives me crazy too :-\

but, it's not surprising that it goes crazy if you apply a transform based on bind pose to a pose not in bind pose. the thing you should remember is that each joint's transform is in its parent's space. all calculations depend on this.

although not strictly sure, IMHO you should do something like this:
* store your initial pose somewhere
* on each frame calculate desired world space transform of joints (ProceduralAnimationSample does this)
* then, starting from first joint, remove parent transform (multiply with parent's inverse transform). joints are ordered such that parent always come before child, so it's guaranteed that parents are updated before childs
* set local transform of joint to result of this

ProceduralAnimationSample does this but since it starts from bind pose, it uses bind pose transforms instead of another pose transforms

also have a look at this tutorial, it's one of the best texts i have found describing the subject:
http://www.okino.com/conv/skinning.htm
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: frag-a on May 14, 2011, 03:24:32 pm
Thanks, I'll take a look at your suggestions and do some more tries.
I'll put the code here if I can make it work.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: frag-a on May 15, 2011, 03:14:29 pm
Hi raft, After some head banging I got it working ;D
Solution is to transform all vectors to joint's local space and do the rotation from the bind pose.
Here is the code, maybe it's useful to someone else.

Code: [Select]
private static final void targetJoint(final SimpleVector targetTranslation, final SkeletonPose pose, int handleIndex, int parentIndex) {
final Skeleton skeleton = pose.getSkeleton();
final Joint handleJoint = skeleton.getJoint(handleIndex);
final Joint parentJoint = skeleton.getJoint(parentIndex);
final Matrix parentInverseBindPose = parentJoint.getInverseBindPose();
final Matrix parentBindPose = parentInverseBindPose.invert();

final SimpleVector parentVector = pose.getLocal(parentIndex).getTranslation();
final SimpleVector handleVector = pose.getLocal(handleIndex).getTranslation();
float distance = handleVector.distance(targetTranslation);
if (distance > 0.1) {
final SimpleVector targetVector = new SimpleVector(targetTranslation);
targetVector.matMul(parentInverseBindPose);
float angle = handleVector.calcAngle(targetVector);
if (Math.abs(angle) > 0.1f) {
final SimpleVector bindPoseVector = handleJoint.getBindPose().getTranslation();
bindPoseVector.matMul(parentInverseBindPose);

final Matrix rotation = new Quaternion().fromVectorToVector(bindPoseVector, targetVector).getRotationMatrix();
rotation.matMul(parentBindPose);
rotation.matMul(pose.getSkeleton().getJoint(parentJoint.getParentIndex()).getInverseBindPose());
pose.getLocal(parentIndex).setTo(rotation);
}
}
}

Corrected some bugs.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Babu on May 25, 2011, 12:44:50 pm
hi raft,

I am planning to use a mesh (that sits on the same skeleton as the body) for shirt.  Is it possible to use the same mesh for full-sleeve and half-sleeve shirts.  If that is possible, how do we assign the texture coordinates?

Thanks,
Babu
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on May 25, 2011, 01:09:31 pm
answered in its own thread:
http://www.jpct.net/forum2/index.php/topic,2085.0.html
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: Alexey on June 13, 2011, 02:25:57 pm
Hi!
I tried export mesh + animation from blender (2.57). When i exporting collada and load dae in bones sample, only one animation present. I make 2 animation actions in blender but only one loads. I should make animation actions in some specific way in blender? And another question - i setup http://code.google.com/p/blender2ogre/ blender-ogre exporter and try load exported someMesh.mesh.xml, but then java.nio.BufferOverflowException throw & the same when try convert by .bat . Result .mesh.xml file, i suspicious, is too big 3.2 mb (.dae only ~600kb).  I need another exporter or ?
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on June 13, 2011, 04:12:51 pm
i never used blender. in theory collada files support multiple animations but i never saw such a real file with. play with exporter options, maybe that helps. othwerise you can merge many files with single animation into one. the provided collada import scripts allows many input files for this purpose. for that to work, meshes and skeletons should be identical. you can also programatically do the merge via AnimatedGroup.mergeAnimations(..) method.

for ogre, i dont think it's because of file size. possibly an issue with either exporter or jME's importer. please post the stack trace for more information.
Title: Re: Bones - Skeletal and Pose animations for jPCT
Post by: raft on June 15, 2011, 12:11:36 pm
the discussion is split into a another topic:
http://www.jpct.net/forum2/index.php/topic,2107.0.html