Ready to use models with animations

Discuss Urho3D art-related topics (creation, import, export, troubleshooting) and share your free art.
Forum rules
Please only share free art (eg. public domain or open source-licensed such as Creative Commons) that you own the copyright to. Do not advertise for-pay content.

Re: Ready to use models with animations

PostPosted by Lumak » 02 Aug 2016, 17:51

rku wrote:That indeed would be great so we could replicate the process ourselves. Lumak either seems to not be interested in telling us how to do that or we are having some miscommunication here since i already asked for same thing in my previous post.
Btw Lumak arent all mixamo models using same skeleton?


On the contrary, I have shared my process on how I did it and are described in my reply to you in this post and in http://urho3d.prophpbb.com/topic2092.html. I will reiterate it here but in a step-by-step manner for clarity. But before I do, let me clarify/answer a couple of things:
1) As jenge himself realized, mixamo license prohibits distribution of character/animation file in editable format. And this restriction is the only reason I cannot provide model.fbx or animation.fbx files in the repository.
2) "Do models use same skeleton?" - They are not the same. While the base joint names are the same, i.e. named as "Hip", "Neck", etc., some models have different prefix added to the base, e.g. "mixamorig:Head", "swat:Head", "Mutant:Head", etc.

Mixamo character/animation port process using Maya
As I mentioned numerous times in my posts, I use Maya LT for the porting process. I will describe this process first then will describe what I discovered just using the animation mapping process in mixamo.com.

0) prerequisite: have Maya or Maya LT installed
1) goto mixamo.com and download your model.fbx (t-pose) and animation set (or single animation) in .fbx format.
2) open your model.fbx in maya, open HumanIK editor, choose Create Character Definition, map all joints of your model to the character definition until it becomes "green" lit -> save your model file (maya format) -> export as fbx format with animation box unchecked.
*note1* clear any non-zero pivot rotation - the values found "jointOrientation" needs to be elevated to the parent transform, i.e. add it to the transfrom field for the same joing.
*note2* even doing note1 sometimes result in wonky animation. If this happens, you'll need to reskin the model or replace the rig(skeleton) with a known working rig and re-skin.

3) for each animation that you want to port, open the animation.fbx file in maya, goto frame -1 (negative 1) and set it to t-pose (frame -1 because animations typically start at frame 0), key all your joints in frame -1, open HumanIK editor, select Create Character Definition, map all joints -> save the file (maya format).
4) open your saved maya model file,
from the file explorer drag in your saved animation file into maya,
in the HumanIK editor- character control panel, select "Character:" as your model's character, select "Source:" as the animation's character
set the key frame range of the animation
in HumanIK, choose Bake > Bake To Skeleton
delete the animation rig
save the file as model_animation or w/e
export to .fbx file format, w/ the animation box checked

5) using AssetImporter and arguments:
for model - AssetImporter model your_model.fbx output_file.mdl
for animation - AssetImporter anim your_model_animation.fbx output_animation_file.anim
*note* output file will contain something like "Take-00" or w/e, remove that and rename it as ouput_animfile.anim
*note2* you may have to use an additional option -t to Generate tangents for models with normal bump map

-------------------------------------------------------------------------------------------

Porting character/animation right out of mixamo.com
I have not done this process until just a few minutes ago, and it seemed to work.
1) goto mixamo.com -> Browse Animation -> select "Creature Pack" as an example
2) At the right of the window, it shows "19 animation in Creature Pack on X Bot" (for me at least), click on "Change Character" and select the Mutant character.
3) click on the "Add To My Assets" button, once it completes the button changes to "View/Download" -> click it
4) on the left side of the window there's a check box next to the trash can, selecting it will select your animation(s) -> click Queue Download -> pop up confirmation : .fbx, t-pose , and every other option as default
5) once the progress completes, check your animation, click download.
6) unzip your In_Progress.zip (following the creature pack/mutant example got me this file)
7) using AssetImporter and arguments:
for model - AssetImporter model Mutant.fbx output_file.mdl
for animation - AssetImporter anim mutant_idle.fbx Mutant_Idle.anim
*note* the output file will contain a string "_mixamo.com.ani", just remove the "_mixamo.com"
*note2* you may have to use an additional option -t ->Generate tangents for models with normal bump map

**things to do outside of assetImporter**
1) you'll need to extract the textures using something like Blender. I did this once but I think it was: choose geom > material > output texture (can't remember exactly)
2) the model in Urho3D is huge - scaled by 100 from the looks of it - fix this in Blender or scale the node by 0.01f (this works properly)
3) some animations have root motion - fix it in Blender

I hope this wall of text helps.

Edit: clearing pivot rotation needs to happen in Maya step 2, not 3
Edit: added scaling info in *problems 2)
Edit: added info about additional option -t using the assetImporter for normal bump map
Last edited by Lumak on 06 Aug 2016, 16:42, edited 5 times in total.
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

Re: Ready to use models with animations

PostPosted by Lumak » 02 Aug 2016, 18:06

No one asked how to spin your model by 180 in code. I guess everyone already knows how to do this, but here is how-to for some who don't know.

Using 18_CharacterDemo, snippets of relevant sections.

Spinning your model by 180 in code
CharacterDemo.cpp

Code: Select all
void CharacterDemo::CreateCharacter()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();

    Node* objectNode = scene_->CreateChild("Jack");
    objectNode->SetPosition(Vector3(0.0f, 1.0f, 0.0f));

    // rotate model by 180 ****************************
    Node* adjustNode = objectNode->CreateChild("AdjNode");
    Quaternion qAdjRot(180, Vector3(0,1,0) ); // rotate it by 180
    adjustNode->SetRotation( qAdjRot );

    // Create the rendering component + animation controller
    AnimatedModel* object = adjustNode->CreateComponent<AnimatedModel>();

    //********************* change the model and material name
    object->SetModel(cache->GetResource<Model>("Models/Jack.mdl"));
    object->SetMaterial(cache->GetResource<Material>("Materials/Jack.xml"));
    object->SetCastShadows(true);

    adjustNode->CreateComponent<AnimationController>();

      // ******************** rename it to proper head joint name // Set the head bone for manual control
    object->GetSkeleton().GetBone("Bip01_Head")->animated_ = false;

. . .
}


Code: Select all
void CharacterDemo::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
{
    if (!character_)
        return;

    Node* characterNode = character_->GetNode();

    // Get camera lookat dir from character yaw + pitch
    Quaternion rot = characterNode->GetRotation();
    Quaternion dir = rot * Quaternion(character_->controls_.pitch_, Vector3::RIGHT);

    // ************* rename it to proper head joint name // Turn head to camera pitch, but limit to avoid unnatural animation
    Node* headNode = characterNode->GetChild("Bip01_Head", true);
    float limitPitch = Clamp(character_->controls_.pitch_, -45.0f, 45.0f);
    Quaternion headDir = rot * Quaternion(limitPitch, Vector3(1.0f, 0.0f, 0.0f));
    // This could be expanded to look at an arbitrary target, now just look at a point in front
    Vector3 headWorldTarget = headNode->GetWorldPosition() + headDir * Vector3(0.0f, 0.0f, -1.0f); // -z direction ****************************
    headNode->LookAt(headWorldTarget, Vector3(0.0f, 1.0f, 0.0f));
    // Correct head orientation because LookAt assumes Z = forward, but the bone has been authored differently (Y = forward)
//    headNode->Rotate(Quaternion(0.0f, 90.0f, 90.0f)); //************************* dont need this

. . .
}


Character.cpp
Code: Select all
void Character::FixedUpdate(float timeStep)
{
    /// \todo Could cache the components for faster access instead of finding them each frame
    RigidBody* body = GetComponent<RigidBody>();
    AnimationController* animCtrl = node_->GetComponent<AnimationController>(true); //********** recursive get

. . .
}


Edit: changed comment to "recursive get"
Last edited by Lumak on 06 Aug 2016, 16:44, edited 1 time in total.
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

Re: Ready to use models with animations

PostPosted by jenge » 03 Aug 2016, 16:19

Wow, great docs on the model import process! High quality 3D models have always been one of the most challenging assets for projects. This is really awesome. thanks for the models and trailblazing the process :D
User avatar
jenge
Some active
Some active
 
Posts: 72
Joined: 27 Apr 2014, 15:42
Location: United States

Re: Ready to use models with animations

PostPosted by Lumak » 03 Aug 2016, 22:28

jenge wrote:Wow, great docs on the model import process! High quality 3D models have always been one of the most challenging assets for projects. This is really awesome. thanks for the models and trailblazing the process :D


You're welcome.

I was really surprised by how easy it was to download then import character/animations using the Porting character/animation right out of mixamo.com method.
It was my first attempt and didn't expect to have an animating character in Urho3D following this process**. Can't get any easier than that!

Edit: **rephrased
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

Re: Ready to use models with animations

PostPosted by Bluemoon » 06 Aug 2016, 10:11

Great work Lumark!! This is just what I need

Unfortunately when I import the models into the editor and setup the materials I get an unlit material like shown below Image
When I edited the material's technique from "Techniques/DiffNormalSpec.xml" to "Techniques/DiffNormalSpecEmissive.xml" it seemed to correct but I noticed that it flickers on and off based on camera angle.

I honestly have no idea what is going on and I really need to use these models, most importantly their animations :(
Every complex thing is made up of simple parts
User avatar
Bluemoon
Active user
Active user
 
Posts: 108
Joined: 23 May 2014, 09:42
Location: Nigeria

Re: Ready to use models with animations

PostPosted by NiteLordz » 06 Aug 2016, 14:03

i found that the models from that were in the repo, were not compatible with the latest version of github, as they were missing vertex declarations.

to test, don't supply a material when using, and it will use the default white material.

i had to export the models myself, which given the above process was simple! (GREAT job btw).

Once i got the steps down, it was easy to follow and import.

I now can test a handful of things i have been wanting, but couldn't because of lack of animation skill.
User avatar
NiteLordz
Some active
Some active
 
Posts: 51
Joined: 11 Feb 2014, 12:21
Location: United States

Re: Ready to use models with animations

PostPosted by cadaver » 06 Aug 2016, 15:45

Current Urho runtime code should load both the old & new models, that means without or with vertex declarations.

Where exactly did you run into trouble?
User avatar
cadaver
Urho3D author
Urho3D author
 
Posts: 1802
Joined: 16 Jan 2014, 14:52
Location: Finland

Re: Ready to use models with animations

PostPosted by NiteLordz » 06 Aug 2016, 16:05

If you use the "Mutant" model as an example.

The material provided has a technique of DiffNormal.xml, this will render no model, but the shadow is animated.

If you modified the material to be just Diff.xml, the model will render properly (just not with a normal).

If you enable D3D11_CREATE_DEVICE_DEBUG, you get the following output

Code: Select all
D3D11 WARNING: ID3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'BLENDINDICES'/0 and component(s) of the type 'int32'.  However, the matching entry in the Input Layout declaration, element[6], specifies mismatched format: 'R8G8B8A8_UINT'.  This is not an error, since behavior is well defined: The element format determines what data conversion algorithm gets applied before it shows up in a shader register. Independently, the shader input signature defines how the shader will interpret the data that has been placed in its input registers, with no change in the bits stored.  It is valid for the application to reinterpret data as a different type once it is in the vertex shader, so this warning is issued just in case reinterpretation was not intended by the author. [ STATE_CREATION WARNING #391: CREATEINPUTLAYOUT_TYPE_MISMATCH]
D3D11 WARNING: ID3D11DeviceContext::DrawIndexed: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]


If you run the fbx model provided by mixamo thru the AssetImporter, then the model will just drop right in properly.

Hope this helps
User avatar
NiteLordz
Some active
Some active
 
Posts: 51
Joined: 11 Feb 2014, 12:21
Location: United States

Re: Ready to use models with animations

PostPosted by cadaver » 06 Aug 2016, 16:16

That's probably from missing tangents in the model, which are required for normal mapping techniques. D3D11 is strict in that sense and fails to create the input layout when shader wants data that isn't there in the buffer (resulting in failure to render), while D3D9 and OpenGL would just fetch invalid data, probably zeroes.
User avatar
cadaver
Urho3D author
Urho3D author
 
Posts: 1802
Joined: 16 Jan 2014, 14:52
Location: Finland

Re: Ready to use models with animations

PostPosted by Lumak » 06 Aug 2016, 16:50

@ Bluemoon
Is it possible that it's the same issue Cadaver mentioned with missing tangents? Try using an additional option -t in the assetImporter.

@NiteLordz, the models in my repo didn't work for you? Hmm, I'm using OpenGL renderer and it works for me, although, I also forgot to generate tangents.
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

PreviousNext

Return to Artists

Who is online

Users browsing this forum: No registered users and 1 guest

cron