Bones - Skeletal and Pose animations for jPCT

Started by raft, January 06, 2010, 11:45:01 PM

Previous topic - Next topic

raft

yes, you can programatically animate skeleton. have a look at ProceduralAnimationSample

Disastorm


Disastorm

#107
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?

raft

don't know. may it be an uppercase lowercase issue?

Disastorm

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.

raft

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.

Disastorm

#111
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.

raft

no, not related. possibly there is no defined animation so jME didnt load skeleton and attach a controller.

Disastorm

Ah ok that must be it I have no animations, I was planning on programmatically trying to manipulate the skeleton.

Disastorm

#114
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?

raft

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.

gururise

#116
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
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:

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!

raft

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.

gururise

#118
Thank you for the quick answer.

I have another problem trying to export the base DAZ Victoria 4.2 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:


Which results in the following exception:
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:
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?  

gururise

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!



protected void update(long deltaTime) {
   totalTime += deltaTime;
   updateBallLocation();
   currentPose.updateTransforms();
   skeletonDebugger.update(currentPose);
   animatedGroup.applySkeletonPose();  // *** This line seems to have no effect.
       
   cameraController.placeCamera();
}