Author Topic: Making a 3d model move by code(user input).  (Read 22845 times)

Offline Rhnbmpl

  • byte
  • *
  • Posts: 8
    • View Profile
Making a 3d model move by code(user input).
« on: November 07, 2017, 07:35:15 am »
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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Making a 3d model move by code(user input).
« Reply #1 on: November 07, 2017, 09:24:44 am »
have a look at ProceduralAnimationSample in samples folder

Offline Rhnbmpl

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Making a 3d model move by code(user input).
« Reply #2 on: November 09, 2017, 11:21:24 am »
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)?

Code: [Select]

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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Making a 3d model move by code(user input).
« Reply #3 on: November 09, 2017, 01:51:06 pm »
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

Offline Rhnbmpl

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Making a 3d model move by code(user input).
« Reply #4 on: November 13, 2017, 01:40:27 pm »
I am getting the following error while converting the collada file to bones:

Code: [Select]
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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Making a 3d model move by code(user input).
« Reply #5 on: November 13, 2017, 06:00:58 pm »
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.

Offline Rhnbmpl

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Making a 3d model move by code(user input).
« Reply #6 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.

Offline Rhnbmpl

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Making a 3d model move by code(user input).
« Reply #7 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:

Quote
2. 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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Making a 3d model move by code(user input).
« Reply #8 on: November 14, 2017, 04:13:21 pm »
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)

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 :)

Offline Rhnbmpl

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Making a 3d model move by code(user input).
« Reply #9 on: November 17, 2017, 05:56:38 am »
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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Making a 3d model move by code(user input).
« Reply #10 on: November 19, 2017, 02:49:15 pm »
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