Game Development Community

Issues with node indexes.

by Lukas Joergensen · in Torque 3D Professional · 03/10/2013 (8:07 am) · 3 replies

Hey guys, I'm having an issue with node indexes. Where the node index on the shape is different from the one in the mesh.

Doing this:
S32 node = shape->findNode("Bip01_Head");
S32 tnode = shape->findNode("Bip01_L_Finger02");
Gives me:
node = 7;
tnode = 15

However getting all vertices based on those indexes like this:
Vector<S32> vertIDX;
				TSSkinMesh* sMesh = dynamic_cast<TSSkinMesh*>(mesh);
				
				S32 * curVtx = sMesh->vertexIndex.begin();
				S32 * curBone = sMesh->boneIndex.begin();
				
				// Build the batch operations
				for(U32 i = 0; i < sMesh->vertexIndex.size(); i++)
				{
					const S32 vidx = *curVtx;
					++curVtx;

					const S32 midx = *curBone;
					++curBone;

					if(midx == node)
						vertIDX.push_back(vidx);
				}
Gives the wrong vertices. For example node which hold the index for the head, gives the vertices for the thumb. While the tnode which held the index for the thumb gives me the vertices of the ring finger. Any ideas as to why the indexes is not the same?

#1
03/11/2013 (10:26 am)
A thought, perhaps it's because nodes without any associated vertices isn't included in the skinmesh?
#2
03/27/2013 (3:14 pm)
Update:
Apparently it is because that if a node doesn't have any associated vertices, then it isn't included in the boneIndex list.

I have found that the boneIndex list is set in tsMesh::assemble
ptr32 = getSharedData32( parentMesh, sz, (S32**)smBoneIndexList.address(), skip );
   boneIndex.set( ptr32, sz );
But I have not found where smBoneIndexList is set.

Furthermore in colladaAppMesh::lookupSkinData I found this:
// Ignore empty weights
if ( bIndex < 0 || bWeight == 0 )
   continue;
Which is probably where the empty weighted bones is left out, however this only applies to .dae files. I don't know where something similar happens for dts files.
#3
09/09/2013 (11:25 am)
Bump!
I've now discovered that apparently in the boneIndex array, all bones without associated vertices have been moved from whatever position they had in the list to the end of the list.

Whats the reason for this`? And where does it happen?