[Solved] Adding weights to an joint of an iskinnedmesh

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

[Solved] Adding weights to an joint of an iskinnedmesh

Post 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?
Last edited by porcus on Sat Jul 31, 2010 11:33 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Post 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 ?
eye776
Posts: 94
Joined: Sun Dec 28, 2008 11:07 pm

Post 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.
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Post by porcus »

Interesting. And how did you apply the animation?
With useAnimationFrom ?

Btw: Thanks for all replies!
Post Reply