So I have a model I’m trying to add animations to. The animations are a separate GLTIF file. I know there is an animation section in the model file, that I thought I could just add an animation section to that points to the animation files, but I have not found a way to do that yet. Is there a way to add an animation in a separate file to the model file?
When you have a model in one side and an skeleton on the other side and you want the model to be animated by the skeleton you need to weight paint the model to the skeleton.
In Object mode:
Select Body > Then Select Armature > Go to Object > Parent (Ctrl + P) > With automatic weights
OP, in case it wasn’t clear… those are instructions for Blender.
Hi @jcrosby10
You can use the AnimUtils.copy(Spatial from, Spatial to)
method available on my GitHub. Use it wisely. Ensure that the model 3D file and the animation file have the same skeleton and structure/bone names; otherwise, you’ll need to use a different technique.
Thanks I will have to look into these. The model and animations I got from an Unreal Engine asset.
I found some tutorials and docs. I found this in the tutorials.
“animations”: [
{
“samplers” : [
{
“input” : 2,
“interpolation” : “LINEAR”,
“output” : 3
},
{
“input” : 2,
“interpolation” : “LINEAR”,
“output” : 4
}
],
“channels” : [
{
“sampler” : 0,
“target” : {
“node” : 0,
“path” : “rotation”
}
},
{
“sampler” : 1,
“target” : {
“node” : 0,
“path” : “translation”
}
}
]
}
],
I was hoping it would be as easy as adding a node like that links a name to an animation file:
{property: animationFileToPlay, name: animationName}
I have yet to find anything that would do this. Since you can add animations to a model in Blender there has to be a way to do this I would have thought. I’m not sure how all this works behind the scenes.
After more investigation I did find that it can be done but its significantly more difficult than I was thinking. Exporting animated models from Unreal always results in having the animations come in a separate file. Does JMonkey have a way to load a model and play animations from separate files? Or does the model have to have all the animations in it for animations to work?
jME supports GLTF. GLTIF doesn’t seem to be any official expansion to it? Just some Unreal stuff? You’ll just have to cook support for GLTIF yourself.
In the hello animation tutorial
Loading an animated model is pretty straight-forward, just as you have learned in the previous chapters. Animated Ogre models come as a set of files: The model is in
Oto.mesh.xml
, and the animation details are inOto.skeleton.xml
, plus the usual files for materials and textures. Check that all files of the model are together in the sameModel
subdirectory.
It would seem that just having the animation file in the same directory as the model file would work. But when I do this and try control.setCurrentAction("animationFileName")
I get
Cannot find clip named animationFileName
Are you using the ogre format or the GLTF format? I’m confused now.
…that works for ogre files because ogre models are split up into a bunch of files.
GLTF is generally only one file (or two files if the binary data is separate).
JME does not currently support GLTIF, only GLTF. If you want to support GLTIF then you will have to add it.
Sorry I mistyped, GLTF. I’m using the text version gltf with a bin file.
Here are my resources I’m using IntelliJ.
What I see in that picture: two separate GLTF files in the same directory.
Whatever magic Unreal does to merge those two things together, JME does not do that magic.
I do not know exactly what the magic is so I can’t really help further, personally.
Ok sorry for all the confusion initially. I could have also added a screenshot in the initial post. I will have to change my process. I’ll see what I can find about loading the model into Blender and adding the animations there so its all in one file.
This might be helpful:
I’ll look into it. I guess Unreal does not support exporting the animations and model into a single model file so I have some thinking to do.