Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Blender-Exported Animations Fail #576

Closed
hjmediastudios opened this issue Dec 24, 2014 · 30 comments
Closed

Blender-Exported Animations Fail #576

hjmediastudios opened this issue Dec 24, 2014 · 30 comments
Labels

Comments

@hjmediastudios
Copy link
Contributor

Using the Urho3D-Blender exporter script and Blender 2.72 allows for models to be exported without a problem, but animations do not play. Observing the file size of *.ani files and adding debug-print behavior to the exporter indicates that data is being exported, but the final animations do not play either in the application or in the Urho3D editor when "test" is hit. The model simply stays in its neutral pose.

@hjmediastudios hjmediastudios changed the title Blender-Exported Animations Blender-Exported Animations Fail Dec 24, 2014
@Mike3D
Copy link
Contributor

Mike3D commented Dec 24, 2014

Sorry, cannot reproduce.

@MonkeyFirst
Copy link
Contributor

did you set weight (to 1.0f) for your animation state?

@hjmediastudios
Copy link
Contributor Author

Yes; in the editor I'm setting it to 1.0 and in my tests with straight C++ I'm using the "Play Exclusive" function.

@Mike3D
Copy link
Contributor

Mike3D commented Dec 26, 2014

Are you using the latest revision of the exporter?

@MonkeyFirst
Copy link
Contributor

Maybe you have several layers and highest layer state with 1.0f weight, but you want play lower layer state ?
i'm not work with AnimationController only with AnimationStates and i'm don't known how it PlayExclusive() and what this means in AnimStates terms.

there is the sample of my BotLogic script setup

void Start()
// get components
rigidbody_ = node_->GetComponent();
animModel_ = node_->GetComponent();
animController_ = node_->GetComponent();
boneCenter_ = animModel_->GetSkeleton().GetBone("Center");
//boneCenter_->animated_ = false;

// get animations
animIdle1_ = animModel_->GetAnimationState(StringHash("R2_IDLE_1"));
animIdle2_ = animModel_->GetAnimationState(StringHash("R2_IDLE_2"));
animIdle3_ = animModel_->GetAnimationState(StringHash("R2_IDLE_3"));
animIdle4_ = animModel_->GetAnimationState(StringHash("R2_IDLE_4"));
animIdle5_ = animModel_->GetAnimationState(StringHash("R2_IDLE_5"));
animWalk_ = animModel_->GetAnimationState(StringHash("R2_WALK"));
animFalling_ = animModel_->GetAnimationState(StringHash("R2_FALLING"));
animFire_ = animModel_->GetAnimationState(StringHash("R2_FIRE"));

// setup
animIdle1_->SetLooped(true);
animIdle2_->SetLooped(true);
animIdle3_->SetLooped(true);
animIdle4_->SetLooped(true);
animIdle5_->SetLooped(true);
animWalk_->SetLooped(true);
animFalling_->SetLooped(false);
animFire_->SetLooped(true);

animIdle1_->SetWeight(1.0f);
animIdle2_->SetWeight(0.0f);
animIdle3_->SetWeight(0.0f);
animIdle4_->SetWeight(0.0f);
animIdle5_->SetWeight(0.0f);
animWalk_->SetWeight(0.0f);
animFalling_->SetWeight(0.0f);
animFire_->SetWeight(0.0f);

animIdle1_->SetLayer(1);
animIdle2_->SetLayer(2);
animIdle3_->SetLayer(3);
animIdle4_->SetLayer(4);
animIdle5_->SetLayer(5);
animWalk_->SetLayer(6);
animFalling_->SetLayer(7);
animFire_->SetLayer(8);

and then these animStates just set weights (to 1) and addTime() in same named state of bot.
note: only one state at same time have weight with 1.0 value.

@hjmediastudios
Copy link
Contributor Author

I am using the latest revision of the exporter, and even using the Animation States without a controller produces the same problem. It's not a problem with playing any animations- the default Jack model and Jack_Walk animation plays just fine, but the exported model from Blender and any animations there fail.

@MonkeyFirst
Copy link
Contributor

ok, maybe you need to set fakeuser for all yours animations, befor you start doing export ?
123

@hjmediastudios
Copy link
Contributor Author

Nope; the animations I want export just fine regardless of whether the Fake option is selected, and the size of the .ani is proportional to the number of keyframes, so data seems to be getting exported. Nothing happens even if I bake the visual transform of the bones (i.e. to directly manipulate the bones, instead of using the IK handles).

@ghost
Copy link

ghost commented Dec 28, 2014

Are you using a rigify rig? Have you selected the correct bone in the urho editor to play animations from?

@hjmediastudios
Copy link
Contributor Author

No, the rig is one of my own design with IK controls, pole bones, and the like (i.e. several helper bones that are keyframed to control the animation, but not themselves deforming the mesh), and I'm selecting the hip bone (the one all others stem from) in the editor. Using the same settings in code doesn't produce anything different.

@MonkeyFirst
Copy link
Contributor

can you make screenshot of export log ?
and show some code there you: load / setup / play animation states ?

@hjmediastudios
Copy link
Contributor Author

The export log is as follows. I've slightly modified the script to show me the number of frames in the animation, but it's otherwise the most recent update.

----------------------Urho export start----------------------
---- Decomposing Minifig_LOD0 ----
Added as LOD with distance 0.000
Decomposing armature: Minifig Bones (46 bones)
Decomposing action: Run with Rifle.001 (frames 0.0 21.0)
Decomposing mesh: Minifig_LOD0 (3018 vertices)
Object Minifig_LOD0 has no texture with UV2 data. Append _UV2 to the texture slot name
New Geometry0 created for material Marine.001
New LOD0 created for material Marine.001
Maybe these groups have no bone: Thumb.1.L, Thumb.1.R, Finger.1.L, Finger.1.R
Optimizing 3911 indices for Minifig_LOD0 Geometry0
---- Exporting Minifig ----
Creating file /home/.../Minifig.mdl
Creating file /home/.../Run with Rifle.001.ani
Export ended in 5.7781 sec

The code relevant to the animation is here:

// "marine_" is the Node of the character
AnimatedModel* marineModel = marine_->CreateComponent<AnimatedModel>();
marineModel->SetModel(cache->GetResource<Model>("Models/Minifig.mdl"));
marineModel->SetMaterial(cache->GetResource<Material>("Models/Marine_PTSuit.xml"));
marineModel->AddAnimationState(cache->GetResource<Animation>("Animations/RunWhip.ani"));
marineModel->SetCastShadows(true);

// ...
AnimationController* ctrl = marine_->CreateComponent<AnimationController>();

// ... In a separate custom component, called every fixed update
AnimationController* ctrl = marine_->GetNode()->GetComponent<AnimationController>();
ctrl->PlayExclusive("Animations/RunWhip.ani", 0, true, 0.2f);
ctrl->DrawDebugGeometry(GetScene()->GetComponent<DebugRenderer>(), false);

All this works with the default Jack model and Jack's walk animation- he continuously walks. The model itself appears correct, but not the animation. I have also inserted a line to print the quaternion rotation of the bones in the animation, and it appears they are moving correctly in the decomposition portion of the exporter, from observing the changing values and plugging a few of them into a copy of the rig to verify that they're at the correct position. This leads me to believe it's a problem with the export portion of the exporter or with the playback in-engine.

@MonkeyFirst
Copy link
Contributor

Ok i'm find something maybe it's exporter bug
later i'm try to make video on my youtube how to solve this.

but now...
It's all about empty *.ani files (or tiny sized) then you try export complex model with several armatures (in my case)
( mb joined separate objects may also produse this issue, i'm don't know exacly, example: character and separated object - sword joined to some bone of character armature )

bug for example :
in my case i'm have character on the big bird, and with guns on this bird.
there is 3 armatures and 3 objects:
main armature is - bird's(1st), and two others arms the children's of bird. Character(2-nd) and guns (3-rd).

And for this all armatures i'm made 3 animations for big bird(flying action), for character (idle on bird action) for guns (overlap motion action). Actually this one complex animation ( 0 - 20 frames) for separeted armatures in separated strips.

In this case then i'm try to export all this complex model exporter write only one valid ani file for one of this armatures, other ani files broken or emply.

How to solve:
manualy select only one obj (mesh) and his armature, setup exporter, press export, then go to bin\data\model\ and copy all *.ani files to temp dir
(note: copy files that only for this obj (mesh).

do same with other parts

after all copy anims from temp dir to bin\data\model\
and these anims must to be valid for playing.

123

@hjmediastudios
Copy link
Contributor Author

The problem is, I have selected only one object and its armature, with only one action to be exported, and it still does nothing. The problem isn't in the exporter script recognizing that the bones are moving, as my printing the output will show correct poses on each frame, nor in the overall animation-playing code, as Jack works, but somewhere between exporting the data into the *.ani file and reading it for playback (inclusive).

@MonkeyFirst
Copy link
Contributor

hmm, ok try to change path from your "animation" folder to std model path and set speed
Like in 18 CharacterDemo
'''
animCtrl->PlayExclusive("Models/Jack_Walk.ani", 0, true, 0.2f);
animCtrl->SetSpeed("Models/Jack_Walk.ani", planeVelocity.Length() * 0.3f);
'''
mb animation loads only from this folder and not from other
and comment this in your code:
'''
marineModel->AddAnimationState(cache->GetResource("Animations/RunWhip.ani"));
'''
i don's see it in example 18 mb it's not needed

at last if you share your model (blend file) (or simular your example) i'm try to check it for playing by my self.

@hjmediastudios
Copy link
Contributor Author

I've tried all of these. With our without adding the animation state, it doesn't work (but does either way with the Jack animation.) Placing the Jack_Walk animation in the same folder still plays, so it's not a path issue. Setting the speed makes no change.

@reattiva
Copy link
Contributor

@hjmediastudios, I'm late but have you solved your problem? If not, can you reproduce it with a simple cube?

@hjmediastudios
Copy link
Contributor Author

Nope; the problem remains unsolved. I can't reproduce it with a simple cube by definition, as the model itself exports correctly- it's the animation that's the problem.

@reattiva
Copy link
Contributor

Can you send me at gmail.com the .blend file?

@hjmediastudios
Copy link
Contributor Author

Sure thing; I just did.

@hjmediastudios
Copy link
Contributor Author

After some more testing, the animation exports but does so incorrectly. I'll attempt to determine if this is an engine or exporter problem.

@gabdab
Copy link

gabdab commented Oct 10, 2015

Same problem .

@reattiva
Copy link
Contributor

This was my reply to hj, maybe it suits you too:
"I've looked into it and it seems to work in the Urho editor. The only thing I had to do is setting the "Start Bone" to "Root". It was set to "Leg R", and this is due the fact that your skeleton has three bones at the root level, you'd better have only one."

@gabdab
Copy link

gabdab commented Oct 12, 2015

Where do you set 'Start Bone' from ? Didn't find such field in Editor ..

@Mike3D
Copy link
Contributor

Mike3D commented Oct 12, 2015

It is available only after you have set "Animation Count" to at least 1.

In code, you can use Skeleton::SetRootBoneIndex()

@gabdab
Copy link

gabdab commented Oct 13, 2015

..they actually work flawlessly inside the editor . Must be my code ..
urho_anim
Many thanks to all who helped .

@christianclavet
Copy link
Contributor

Hi, I'm not sure it the issue, but it's not a good practice. If you look at your export log:
---- Exporting Minifig ----
Creating file /home/.../Minifig.mdl
Creating file /home/.../Run with Rifle.001.ani

Please don't use spaces in names (meshes, animation names, and folder names). This could cause issues.
So the animation name should be written like this:
Run_with_Rifle.001.ani

@JimSEOW
Copy link

JimSEOW commented Jun 8, 2016

A good source to learn from others on how to export Blender to Orho3D

@weitjong
Copy link
Contributor

Although I believe you meant good but I have to say that this is an English-speaking community!

@github-actions
Copy link

Marking this stale since there has been no activity for 30 days.
It will be closed if there is no activity for another 15 days.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

9 participants