Page 1 of 1

[Solved] Adding weights to an joint of an iskinnedmesh

Posted: Sat Jul 24, 2010 12:26 am
by porcus
Hi,

I wanted to add some weights to a existing joint of a iskinnedmesh.
Adding the vertices and triangles worked fine but when I tried
to add weights with the following function it either had no effect
at all or I received an error (depends on the amount of added weights).

Code: Select all

void AddWeight(IAnimatedMesh* mesh, int i, int wv, u32 vertex, u16 buffer, f32 strength)
{
if(mesh->getMeshType()==EAMT_SKINNED){
ISkinnedMesh* m = (ISkinnedMesh*)mesh;
irr::scene::ISkinnedMesh::SWeight* weight = m->addWeight(m->getAllJoints()[i]);
weight->strength=strength;
weight->buffer_id=buffer;
weight->vertex_id=vertex;
}
}
I'm sure that all parameters were set up correctly.
I also had a look into the source of the b3d loader but this also uses
the addWeight method so I have no idea what's going on.

Can anybody help me?

Posted: Sat Jul 24, 2010 9:43 am
by hybrid
There might be the need to call some finalize() method after altering the weights. Please look through the b3d code, maybe you find some. The interface of the ISkinnedMesh is still a little cluttered, which is why I'm also always wondering what needs to be done, and what happens automatically.

Posted: Sun Jul 25, 2010 4:08 am
by porcus
When I use finalize() at the end the whole animation disappears.
Even if I don't modify the mesh and call finalize() it disappears.
(I tried also to play it with a faster speed but the animation is just gone.)
I also had a look again at the b3dloader source but I couldn't find
a hint that would help me. finalize() is called by the b3dloader at the
end of the loading and it's also called only one time. I suspect that
maybe it's not possible to call finalize() more than one time for each mesh.
Could that be true ?

Posted: Mon Jul 26, 2010 8:17 am
by eye776
Store the animation somewhere else, and not in the model. (That's what I did anyway). Apply the animation after finalizing the model.

Posted: Tue Jul 27, 2010 8:01 pm
by porcus
Interesting. And how did you apply the animation?
With useAnimationFrom ?

Btw: Thanks for all replies!