Hello guys,
I'm working in a Blender->Irrlicht format. Static meshes with textures are working and now I'm trying the armatures.
I'm confused now by the concept of the bones and joints in Irrlicht.
What's exactly are them?
Thanks guys!
Correct way to work with bones and joints
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Correct way to work with bones and joints
Professional Software Developer and Amateur Game Designer
Re: Correct way to work with bones and joints
You might have to check out sources. Files involved are SkinnedMesh, BoneSceneNode, AnimatedMeshSceneNode. And one format using it already is B3D. Sadly the author (completely coded by Luke Hoschke to my knowledge) hasn't been active in a long time.
Concept should be similar to weight painted animations in Blender.
I just spend a few minutes trying to understand it, but I would need a bit more time to really get it all, so take the following with a grain of salt:
Bones are likely some helper to access & control joints. So you won't have to care about them in a loader. They are some kind of interface connecting joints and the scenegraph so you can attach nodes to joints. Once you create bones it seems to create them all - aka one bone per joint and also same hierarchy with parent/children as joints have. And then you control what the connection between bone and joint is by setting E_JOINT_UPDATE_ON_RENDER. So EJUOR_READ would update the bones from the joints each frame. And EJUOR_CONTROL probably other way round - joints updated from bones. EJUOR_READ useful to attach nodes (like adding gun to a hand bone) and EJUOR_CONTROL useful to override animations. Not quite sure about what EJUOR_CONTROL does exactly. If you get full control or if it's mixed with animation somehow (both sound useful, maybe could need one more state?).
Skinning the mesh (modifying all vertices according to position, rotation, scale keys each frame) only seems to need the joints. Each joint having an array of attached meshes which it influences (just indices to the meshbuffers in the skinned mesh). And weights for how much it influences each meshbuffer.
So loader likely has to set PositionKeys, ScaleKeys, RotationKeys, Weights + affected meshbuffer (those kinda belong together). Find out parent/child relations (Joints have Children). Setting name (just to be nice). And the rest should hopefully be calculated.
But maybe check B3D loader - it's the one using this system.
Concept should be similar to weight painted animations in Blender.
I just spend a few minutes trying to understand it, but I would need a bit more time to really get it all, so take the following with a grain of salt:
Bones are likely some helper to access & control joints. So you won't have to care about them in a loader. They are some kind of interface connecting joints and the scenegraph so you can attach nodes to joints. Once you create bones it seems to create them all - aka one bone per joint and also same hierarchy with parent/children as joints have. And then you control what the connection between bone and joint is by setting E_JOINT_UPDATE_ON_RENDER. So EJUOR_READ would update the bones from the joints each frame. And EJUOR_CONTROL probably other way round - joints updated from bones. EJUOR_READ useful to attach nodes (like adding gun to a hand bone) and EJUOR_CONTROL useful to override animations. Not quite sure about what EJUOR_CONTROL does exactly. If you get full control or if it's mixed with animation somehow (both sound useful, maybe could need one more state?).
Skinning the mesh (modifying all vertices according to position, rotation, scale keys each frame) only seems to need the joints. Each joint having an array of attached meshes which it influences (just indices to the meshbuffers in the skinned mesh). And weights for how much it influences each meshbuffer.
So loader likely has to set PositionKeys, ScaleKeys, RotationKeys, Weights + affected meshbuffer (those kinda belong together). Find out parent/child relations (Joints have Children). Setting name (just to be nice). And the rest should hopefully be calculated.
But maybe check B3D loader - it's the one using this system.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Re: Correct way to work with bones and joints
Aha Master Alien!
I checked the B3D and made my own format based on it, but my researches doesn't make sense... till now!
I successfully loaded the joints, and now I'll go for the weight maps. Let's see what I get!
Thanks for your quick reply!
Regards!
I checked the B3D and made my own format based on it, but my researches doesn't make sense... till now!
I successfully loaded the joints, and now I'll go for the weight maps. Let's see what I get!
Thanks for your quick reply!
Regards!
Professional Software Developer and Amateur Game Designer
Re: Correct way to work with bones and joints
Np and good luck. Having a nicer Blender->Irrlicht pipeline would be incredible!
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Correct way to work with bones and joints
Hi!
Maybe I should open a new topic about this, in that case, I am sorry for writing here.
My question would be, is there any feature to blend two skeletal animations together (EDIT: I mean blending a running animation into a walking animation on a given character, for example)? I think I saw this feature in Coppercube a few months back, but I am not sure.
I checked the tutorial codes, and in the Collision tutorial there is a dwarf which has two animations with blending, but as far as I can tell, those animations are both coming from the same file, and the blending itself wasn't handled by the engine/code, but by the animator himself/herself. Correct me if I am wrong.
I am quite new to c++. I tried to find the answer in the API, but I couldn't. However, it is very possible that it is there.
Thank you for your answer.
Maybe I should open a new topic about this, in that case, I am sorry for writing here.
My question would be, is there any feature to blend two skeletal animations together (EDIT: I mean blending a running animation into a walking animation on a given character, for example)? I think I saw this feature in Coppercube a few months back, but I am not sure.
I checked the tutorial codes, and in the Collision tutorial there is a dwarf which has two animations with blending, but as far as I can tell, those animations are both coming from the same file, and the blending itself wasn't handled by the engine/code, but by the animator himself/herself. Correct me if I am wrong.
I am quite new to c++. I tried to find the answer in the API, but I couldn't. However, it is very possible that it is there.
Thank you for your answer.
Re: Correct way to work with bones and joints
I think not. It looks like the animation system was partly prepared for that, but not finished.
Like there is animateMesh which takes a blend parameter, but then it's always set to 1.0
But not sure if that was really about animation blending.
ISkinnedMesh has useAnimationFrom which allows using another animation. Replacement somewhat slow as it seems to do name lookups per joint (but using short names and avoiding having too many joints it should be fine). That allows at least to replace parts of the animation with another animations it seems (thought not sure right now - what it does with joints it doesn't find - nearly looks like it resets those to 0 so those don't use any animation). But hard cut I think - no soft interpolation.
Maybe there are some hacks like animating things twice with 2 ISkinnedMesh'es and then interpolating yourself between them somehow. But nothing that looks easy.
So it seems blending has to be handled by blend animations (which obviously makes blends in the middle of an animation super tricky). Unless I'm missing it.
Like there is animateMesh which takes a blend parameter, but then it's always set to 1.0
But not sure if that was really about animation blending.
ISkinnedMesh has useAnimationFrom which allows using another animation. Replacement somewhat slow as it seems to do name lookups per joint (but using short names and avoiding having too many joints it should be fine). That allows at least to replace parts of the animation with another animations it seems (thought not sure right now - what it does with joints it doesn't find - nearly looks like it resets those to 0 so those don't use any animation). But hard cut I think - no soft interpolation.
Maybe there are some hacks like animating things twice with 2 ISkinnedMesh'es and then interpolating yourself between them somehow. But nothing that looks easy.
So it seems blending has to be handled by blend animations (which obviously makes blends in the middle of an animation super tricky). Unless I'm missing it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Correct way to work with bones and joints
Thank you for the answer, I really appreciate it.
I took a short peek into the source code, and actually, this can be a very interesting little private project for me, to make at least a linear blending between two animations.
Of course, there is the old way where we make handmade blending animations. In that case, we must let the current animation play until the end, then play the relevant blending animation, and after we can play the new animation. This could work in certain game genres, where fast responsiveness to the player's action is not crucial. But one of the caveats of this method is, that the more animations we have, the more blending animation we need.
I took a short peek into the source code, and actually, this can be a very interesting little private project for me, to make at least a linear blending between two animations.
Of course, there is the old way where we make handmade blending animations. In that case, we must let the current animation play until the end, then play the relevant blending animation, and after we can play the new animation. This could work in certain game genres, where fast responsiveness to the player's action is not crucial. But one of the caveats of this method is, that the more animations we have, the more blending animation we need.