Jump to content

Animation driven character movement


Niosop
 Share

Recommended Posts

When animating complex non-linear movements it can be hard to adjust the model position to match the animation if you use a normalized animation (at least that's what I call it when a model doesn't move off the origin and just runs or whatever in the same spot). Often it's a lot easier to visualize the proper translation if you do it in your animation package. Or maybe you have motion capture data that contains the movement already. It would be a shame to discard it by normalizing, then have to recreate it in code. So I've been working on a way to have the animation drive the model's movement.

 

Here's the basic idea:

 

Pick the highest level bone that contains movement. For some animations this might be the root bone, for others one bone further down the chain.

Keep track of the last frame you animated.

Each update, first animate the last frame and record the position of the chosen bone.

Then animate to the current frame and record the position of the chosen bone again.

Store the difference (I just use the X and Z components right now)

Move your model by that amount.

Move the chosen bone to the location of the model.

 

I'll post code here once I clean it up, but here's a video of how it works right now (please forgive the programmer art, my ZBrush-Fu isn't up to par yet):

 

 

 

I've tried pre-calculating and caching the movement between frames so you don't have to animate twice, but the math gets a lot more complicated and I lost any performance I might have gained due to Lua not being blazing fast at math. I'll try this approach again if I rewrite it in C++. I may also try to just use the results of the last update's animation and translation to avoid animating twice, but I'm not sure if I'll gain much.

 

This doesn't take rotation of the root bone into account, I've still got to get that working.

 

It doesn't seem to affect speed that much, getting about 110 fps with a single character on screen and about 60 when I zoom out to all of them. FRAPS drops it by 1/2 to 2/3 when it's recording so ignore the FPS counter on it ;)

 

Any feedback/suggestions are welcome.

  • Upvote 1

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

I am confused how this is good, the character's physics mesh is never aligned with the animation?

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

not every animated character has to be used for interaction with physics objects... this can be used for any animated model that you would have in a scene that doesn't need any physics interaction... its just another thing that people can use...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Well, what I mean is, I didn't mean physics exactly.

 

Is the animation actually MOVING the mesh and the entity's position in terms of what Leadwerks interacts with? Because if not, it is pointless.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Nevermind, I read the list of how it works, and that seems to be how it works.

 

This sounds good.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

I'm confused. Can't you just move your model in your animating program and then just play it in LE like normal and it'll do the same thing?

 

It will DISPLAY the same thing, but the actual TModel won't move, so his collision shape won't move with him (I should have enabled physics so you can see his collision cylinder follows him around) and at the end of the animation it will pop back to where he started since his start and end positions are very different.

 

I am confused how this is good, the character's physics mesh is never aligned with the animation?

 

The red thing that's displayed isn't his collision shape, it's just the starting mesh shape that LE Sandbox displays. I didn't enable physics visualization, his actual collision shape is a cylinder and it follows along with him as he moves. You'll notice the movement gizmo follows him around, that's the center of the model and where the collision is located.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

hmm, it looked like you did display physics for a second in the video. I saw a red mesh but it wasn't exactly at the location of the model.

 

So what would you use this for? In your example I can see a use for NPC's doing more complicated things but I wouldn't think the physics would really matter at that point. I mean what would happen if you put a wall in the path of that characters dancing?

 

[EDIT]

Ah you edited your post above for my second question. Is this cylinder the LE controller or your own collision model?

Link to comment
Share on other sites

hmm, it looked like you did display physics for a second in the video. I saw a red mesh but it wasn't exactly at the location of the model.

 

So what would you use this for? In your example I can see a use for NPC's doing more complicated things but I wouldn't think the physics would really matter at that point. I mean what would happen if you put a wall in the path of that characters dancing?

 

[EDIT]

Ah you edited your post above for my second question. Is this cylinder the LE controller or your own collision model?

 

Yeah, the red mesh isn't the collision, it's just a mesh placeholder LE adds that shows frame 1 of the animation. The cylinder was just a simple cylinder added via phygen. I would like to use a player controller, but it doesn't help much. Since the model is directly moved in very small increments every frame, the PlayerController Update function doesn't work very well with it. In fact, if I enable collision it screws up the movement if he collides with anything. If you put a wall, he'd dance right through it, or possibly over it depending on what type of collision he's checking for when he does his height adjustment calculation. If you enable physics on him, he'd bounce off the wall, but unless you elevate his collision shape he tends to collide with the terrain as well and it makes for some really jerky movement.

 

Speaking of which, anyone know how to mark a body as a kinematic rigid body (it affects other objects, but isn't affected by other objects)?

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

In regards to the kinematic thing, you want to make the player not be affected, but affect other things?

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

In regards to the kinematic thing, you want to make the player not be affected, but affect other things?

 

Correct. I've tried some different Collisions() settings, but maybe I just didn't get them right. That would partially fix the problem and I could use notifications to modify movement of the character. It's not ideal, as the character isn't moved by physics so he tends to send things flying when he collides with them because he's all of a sudden inside of them causing huge forces. But I guess one step at a time.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

I think Enabling swept collision should fix, if not simply aide those problems.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

..im not quite sure for use of this since everything can be done just by animation tool (3dsmax or whatever you use), including moving appropriate collider..

 

Really? Please show me how, it'll save me a lot of work on this.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

..simply create dummy (im talking about 3dsmax), and just keyframe it over already existing character animation(translation/rotation), based on any bone of your character or COG, depending what you want to use...then export it separate from your character and play in parallel with character animation. Character in this case should be positioned in 3dsmax at 0,0,0 with no motion, while motion will came from dummy. so, just parent it to exported dummy(and belonging collider) and stuff works like a charm...i can post some of my cut scenes to see this in action if you want..

 

Link to comment
Share on other sites

Ahh, so basically just do the same thing I'm doing but in 3dsmax. But you still have the looping problem if your dummy doesn't start and end in the exact same position. You can work around it the same way I guess. I'll stick w/ this method for now as my animations already have motion and this saves me from having to first create a dummy that follows the existing motion, then remove the motion from the original animation. But I'll definitely keep it in mind for use in the future, thanks ;)

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

..dummy will start 100% at same location and end 100% at same location as requested because its extracted from original character animation..so it has same number of animated keys as character, and there is no way to start or end before or after..dummy you have to create after your character in motion animation is done. Second problem you may experience if you plain moving character in space is occlusion..it may happen that your character will dissapear from sight in some situations, if camera is between 0,0,0 and your character while character move further and further from 0,0,0...on way i suggested, its all working just fine, with no issues of any kind...give it a go and you will see...quite easy setup basically..

 

Link to comment
Share on other sites

I see what you mean Naughty Alien, I just don't see the point. Why would I want to duplicate then strip out movement information when I can just export the files I have and let the computer do it for me? If you had an already normalized animation I guess it would be helpful. Just different approaches I think ;) You prefer modeling/animating, I prefer coding.

 

Here's a quick test w/ simple one-way physics interactions using a cylinder:

 

  • Upvote 2

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

..nope..its not same animation..dummy contain only translation/rotation keys and nothing else..no skinning and so on..and my point is, instead of running trough code, its way easier to attach it and use just one single call for animate them both..use of such approach you can appreciate A LOT when you try to do audio syncing with your characters as well as lipsync..but i'll let you discover that on your own ;) you will remember meee ;)

 

Link to comment
Share on other sites

I see what you mean Naughty Alien, I just don't see the point. Why would I want to duplicate then strip out movement information when I can just export the files I have and let the computer do it for me? If you had an already normalized animation I guess it would be helpful. Just different approaches I think :) You prefer modeling/animating, I prefer coding.

 

Here's a quick test w/ simple one-way physics interactions using a cylinder:

 

 

 

Nice work Niosop, I will have a small glass of whatever your character has been drinking :)

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...