Making a 3d model move by code(user input).

Started by Rhnbmpl, November 07, 2017, 07:35:15 AM

Previous topic - Next topic

Rhnbmpl

Hi,
I am new to JPCT and till now I have displayed a 3D model made in blender in an android app. I have made the model in Blender with the bones attached to the mesh. Earlier I was using libgdx which made the joints of the bone rotate but it wasn't running along properly with my application. The 3d model i have displayed is in the format .3ds. I have not implemented any animations on the model because I don't need them. I need to rotate the joints of my 3d model based on the user input(by variable change). There will be about 5-7 joints in the model which will only rotate.
Thanks for the help.

raft

have a look at ProceduralAnimationSample in samples folder

Rhnbmpl

Do I have to use the Collada(.dae) format to import my models into android?
Also, I'm getting errors trying to open the collada file. I'm storing my model(.dae) in the asset folder in android. I'm passing "file:///android_asset/model.dae" as the URI of the model I want to load. But its showing File not found exception. Do I have to store the model file in the local storage of the android device(other than asset folder)?



ColladaImporter colladaImporter=new ColladaImporter().loadTextures(false);
        ColladaStorage colladaStorage=colladaImporter.load(uri.toString());//<---- File not found exception
        group=BonesImporter.importCollada(colladaStorage, 1f, new Quaternion().rotateX((float)Math.PI));


Thanks.

raft

Quote from: Rhnbmpl on November 09, 2017, 11:21:24 AM
Do I have to use the Collada(.dae) format to import my models into android?
no, you dont have to. also it's not suggested.

the preferred way is converting your model into Bones' native format on desktop (PC) then use that in android. this way;
1. will load much faster
2. have no runtime dependency for Collada/Ogre loader

Rhnbmpl

I am getting the following error while converting the collada file to bones:

abc@xyz:~/Desktop/Bones/scripts$ sudo ./ardorCollada2Bones.sh -in my_model.dae
Nov 13, 2017 5:02:46 PM com.ardor3d.extension.model.collada.jdom.ColladaAnimUtils buildAnimations
WARNING: No element-joint mapping found for element: <node id="Armature_1" name="Armature_1" type="NODE"></node>

Exception in thread "main" java.lang.IllegalArgumentException: ColladaStorage contains no skins.
at raft.jpct.bones.BonesImporter.importCollada(BonesImporter.java:52)
at raft.jpct.bones.util.ArdorColladaImporter.loadGroup(ArdorColladaImporter.java:117)
at raft.jpct.bones.util.ArdorColladaImporter.loadGroup(ArdorColladaImporter.java:89)
at raft.jpct.bones.util.ArdorColladaImporter.run(ArdorColladaImporter.java:70)
at raft.jpct.bones.util.ArdorColladaImporter.main(ArdorColladaImporter.java:176)

Do I have to worry about the warning?
Do I have to put skins on my blender model before exporting to .dae?
And also how to import the resulting .bones generated file into the code taken from ProceduralAnimationsample.java?

Thanks.

raft

not sure about the warning.

the error says, there are no skins in collada file, meaning no animations and hence nothing to import.

once exported to Bones' format, you can use BonesIO class to load it. and that's also the class script files use behind the scenes.

Rhnbmpl

Earlier I was getting the error for the no animations found. But now, I have put animation in the model in Blender and exported it to collada and getting the error that I had posted above. I have even added textures in my model in Blender and am getting the same error.

Rhnbmpl

And one more thing. I have seen the steps in the bones website to export the model to ogre and then to bones and I have questions about this step:

Quote2. Set the rotation and scale of your model as you want it, and then apply (Ctrl+A_key, Select Rotation and Scale). # If your model doesn't have it, create a Root Bone: This is a bone that is parent to every other bone in your armature. You don't need to connect it to the rest though, and can leave the offset. It must have it's head in 0,0,0 and tail in x=0,y=0,z=1

1. Does the root bone have to have its head at 0,0,0 and tail at 0,0,1? (Because mine has tail at 0.179 in z axis)(I am not getting the .skeleton.xml file at export)
2. Can I have the root bone not connected to the rest of my bone structure(Just have it floating in the space)? (Because then I have to scale the model)
3. Do I have to set the root bone as the parent to all my bones even though they are not connected to root?

Thank you.

raft

Quote from: Rhnbmpl on November 14, 2017, 11:09:11 AM
Earlier I was getting the error for the no animations found. But now, I have put animation in the model in Blender and exported it to collada and getting the error that I had posted above. I have even added textures in my model in Blender and am getting the same error.
can you post the previous exception? in Bones code no such exception should be thrown, possibly coming from Ardor's Collada loader.

but in any case, your current exception means no skinning information is found in Collada file, practically means no animation. (actually not sure if exporting only the animation but not the skinning information is possible in Blender, doesnt make any sense though)

Quote from: Rhnbmpl on November 14, 2017, 01:46:53 PM
And one more thing. I have seen the steps in the bones website to export the model to ogre and then to bones and I have questions about this step:
actually I've never used Blender myself, Wiki pages are created and maintained by the community members :)

Rhnbmpl

Sorry, I don't exactly remember the error message, Its said something like "No Animations found". After which I added dummy animation and then got the message which I posted about no skins.
Can you tell me from which software(Blender,3ds max,etc.) you made the model and its skeleton and how you imported it to jpct and bones. I am open to new ways to do this.

raft

during those times, I was using 3dsMax + OgreMax. but as I heard OgreMax is kind of dead nowadays, dont know the details.

Blender is a quite popular 3D editor, Ogre3D is still very popular, so I assume Ogre exporters for Blender should work reasonably well.

I would suggest trying following instructions in Wiki for Blender, if that doesnt help contacting writers of the Wiki page