Topic: need help with skinnedmesh

Ok so basically in my game i have a skeleton i exported via b3d, now i need to swap out clothing and or body parts from this mesh. Simply attaching a scenenode to a bone node won't suffice as i need all the weights from the mesh to be applied to the base skeleton.

I have been struggling with this for a few days, but something i am having trouble figuring out is why i cannot append any vertices to a SSkinnedMeshBuffer, seems to work fine with a an SMeshBuffer.

e.g.

Global bodyp:IAnimatedMesh = device.getSceneManager().getMesh("media\avatars\male_torso.b3d")


Global meshy2:ISkinnedMesh = smgr.creatSkinnedMesh()
Global meshy:SSkinMeshBuffer = meshy2.addMeshBuffer()

'just gonna try with the first meshbuffer.. since this mesh only has one
Global bodymeshbuff:IMeshBuffer = bodyp.getMeshBuffer(0)


Global bodyverts:S3DVertex[] = bodymeshbuff.getVertices()
Global bodyindices:Short[] = bodymeshbuff.getIndices()

DebugLog "Vertices to add: "+bodyverts.length+" Indices to add: "+bodyindices.length

meshy.append(bodyverts,bodyindices)
DebugLog "Meshy has: "+meshy.getVertexCount()
'meshy.appendFromOther(bodymeshbuff) <---- didnt work either

I have tried a bunch of other ways to get around this.. like trying to break attach the mesh's bones to the base skeleton's bones, but that causes irrlicht to crash. Anyone have any idea how to do this or what i am doing wrong?

Re: need help with skinnedmesh

the goal was to copy the bodypart i load in to a new SkinnedMesh, then i copy all the joints from a different mesh, then copy my bodyparts weights to this new skinnedmesh. more or less.

Re: need help with skinnedmesh

or better yet simply attach bone from meshA to bone from meshB

Re: need help with skinnedmesh

greetings smile  can you pack up a quick example (with mesh files) i can play with?

Re: need help with skinnedmesh

sure here ya go

http://u15312943.onlinehome-server.com/testskinmesh.zip

there is a skeleton file and a bodypart mesh (which has the skeleton included as well)

basically if there were either a way to attach Mesh A's bones to Mesh B's bones or append the mesh buffer to the skeleton and then assign weights is what i am after.

Re: need help with skinnedmesh

greetings smile  thank you for the test files.  it really helps smile 

looking at the Irrlicht source i think i see the issue.  createSkinnedMesh() underneath returns an instance of CSkinnedMesh.  this is the implementation of ISkinnedMesh.  ISkinnedMesh.addMeshBuffer() returns a direct instance of SSkinMeshBuffer.  looking at SSkinMeshBuffer, the append functions do not have any implementation so im not sure if the Irrlicht developers have completed the SSkinMeshBuffer interface yet.  i searched through the Irrlicht code to find where SSkinMeshBuffer is used and if so how is it populated if not via the append methods.  i found a spot in COgreMeshFileLoader.cpp that directly inserts into the properties of SSkinnedMeshBuffer.  yay.  why not implement the append and just use that?

anyways, i stole the append implementation from CMeshBuffer and updated it to support the dynamic vertex type thing that SSkinnedMesh has going on.  the appendFromOther wasnt implemented in CMeshBuffer either so i didnt do that one.  im not knowledgeable enough to know what you are trying to accomplish but hopefully this will get you on your way.  after implementing append in SSkinMeshbuffer your output is now:

Loaded mesh: testskele.b3d
Could not open file of texture: chestuv.jpg
Loaded mesh: male_torso.b3d
DebugLog:Vertices to add: 391 Indices to add: 1806
DebugLog:vt meshy: 0 vt body: 0
DebugLog:Meshy has: 391
Resizing window (640 480)

meshy now has the 391 verts smile

i have rebuilt the mod and uploaded a new distribution.

Re: need help with skinnedmesh

woohoo!

after reading some techniques done in C++ i saw that you could essentially build an entire mesh and apply bones as well as set the weights within code, which was what i was after. In blitz3d i got around this whole bit simply by passing entityparent from a bone of one mesh tot he bone of another, this way when i animated the skeleton the child meshes would animate with it. In irrlicht trying to attach a bonenode of one mesh to the bonenode of another mesh crashes the system. So instead of that i decided perhaps i could just build a new Skinned mesh made up of meshbuffers from different bodyparts and then use the skeleton of the base skeleton.b3d file i loaded. This way i can swap out parts for changing costume or features.

Re: need help with skinnedmesh

as far as appendfromother that's no big deal as long as i can get the data in there i'm happy. from what i saw apparently in you had to insert the vertices by using SSkinMeshBuffer.Vertices_Standard.pushback( vertice array blah blah in order to get the data into the buffer, so yea i am guessing the append function was not implemented yet.

9 (edited by leondrake 2010-06-26 10:25:20)

Re: need help with skinnedmesh

lol, well it looks like something went goofy, it could be just the nature of the vertices because i havent added the skeleton or set the weights, but after i appended the vertices (thanks again for that!) I proceeded to push the mesh into a scenenode to view its results and it comes out really askewed. Also i notice that i get a memory access violation from
IrrScene_SSkinMeshBuffer_append only when i run irrlicht in either software modes as well as directx 9. Seems to not crash when i run it under Directx 8 and OpenGL.

anyhoo here is the screeny of what it spits out.

http://www.vigilart.com/modelgoof.jpg

if i call finalize() after i append the data, the mesh disappears completely in Dx8 but remains unchanged in OpenGL, i am gonna go ahead and finish adding the bone data to see if perhaps since i transfered vertices that were previously weighted, to a model with no bones or weights that perhaps its causing the mesh to skew.

Re: need help with skinnedmesh

Just an Update, it doesnt seem to crash at all on my work PC, but it is still doing the same thing. I'm not sure what's going on, after looking at some code people used to push verts into SSkinmeshBuffer it should retain its shape regardless if the bones are there or not.