AttachedMeshes is empty in SJoint (.x file)

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
wyrmmage
Posts: 204
Joined: Sun Mar 16, 2008 3:12 am
Contact:

AttachedMeshes is empty in SJoint (.x file)

Post by wyrmmage »

Hello everyone :)

I've been working on skinned meshes lately, and I've run into a bit of a problem:

While loading a .x file that I exported from Blender, I noticed that one of my SJoint's AttachedMeshes is empty, even though the SJoint has a mesh attached to it and is not a bone.

Calling getMeshBuffers().size() on the ISkinnedMesh revealed that there is a mesh attached to the ISkinnedMesh, it's just not being associated with any SJoint :\

Here's some code that demonstrates the problem:

Code: Select all

std::cout << "starting\n";
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16, 0, false, false, 0);
assert(device);
IVideoDriver* videoDriver = device->getVideoDriver();
assert(videoDriver);
ISceneManager* sceneManager = device->getSceneManager();
assert(sceneManager);
IGUIEnvironment* guiEnvironment = device->getGUIEnvironment();
assert(guiEnvironment);

std::cout << "init done\n";

IAnimatedMesh* referenceMesh = sceneManager->getMesh("oricon.x");
assert(referenceMesh);

ISkinnedMesh* skinnedMesh = (ISkinnedMesh*)referenceMesh;

std::cout << "meshBuffer length: " << skinnedMesh->getMeshBuffers().size() << "\n";

std::cout << "joint count: " << skinnedMesh->getJointCount() << "\n";
   for(int i=0; i<skinnedMesh->getAllJoints().size(); i++)
   {
   std::cout << "\nname: " << (skinnedMesh->getAllJoints())[i]->Name.c_str() << "\n";
   std::cout << "child children count: " << (skinnedMesh->getAllJoints())[i]->Children.size() << "\n";
   std::cout << "child mesh count: " << (skinnedMesh->getAllJoints())[i]->AttachedMeshes.size() << "\n";
   }
Here's the .x file that demonstrates the problem:

Code: Select all

xof 0303txt 0032


template VertexDuplicationIndices { 
 <b8d65549-d7c9-4995-89cf-53a9a8b031e3>
 DWORD nIndices;
 DWORD nOriginalVertices;
 array DWORD indices[nIndices];
}
template XSkinMeshHeader {
 <3cf169ce-ff7c-44ab-93c0-f78f62d172e2>
 WORD nMaxSkinWeightsPerVertex;
 WORD nMaxSkinWeightsPerFace;
 WORD nBones;
}
template SkinWeights {
 <6f0d123b-bad2-4167-a0d0-80224f25fabb>
 STRING transformNodeName;
 DWORD nWeights;
 array DWORD vertexIndices[nWeights];
 array float weights[nWeights];
 Matrix4x4 matrixOffset;
}

Frame RootFrame {

  FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,
    0.000000,-0.000000,1.000000,0.000000,
    0.000000,1.000000,0.000000,0.000000,
    0.000000,0.000000,0.000000,1.000000;;
  }
      Frame cameraFPSBone {

        FrameTransformMatrix {
          -1.000000,0.000000,0.000000,0.000000,
          0.000000,0.000000,1.000000,0.000000,
          0.000000,1.000000,-0.000000,0.000000,
          0.000000,1.000000,0.000000,1.000000;;
        }
      }
      Frame cameraFPS {

        FrameTransformMatrix {
          0.300000,0.000000,0.000000,0.000000,
          0.000000,0.300000,0.000000,0.000000,
          0.000000,0.000000,0.300000,0.000000,
          -0.005500,-1.943100,-0.072000,1.000000;;
        }
Mesh {
24;
0.294500; -1.643100; -0.372000;,
0.294500; -2.243100; -0.372000;,
-0.305500; -2.243100; -0.372000;,
-0.305500; -1.643100; -0.372000;,
0.294500; -1.643100; 0.228000;,
-0.305500; -1.643100; 0.228000;,
-0.305500; -2.243100; 0.228000;,
0.294500; -2.243100; 0.228000;,
0.294500; -1.643100; -0.372000;,
0.294500; -1.643100; 0.228000;,
0.294500; -2.243100; 0.228000;,
0.294500; -2.243100; -0.372000;,
0.294500; -2.243100; -0.372000;,
0.294500; -2.243100; 0.228000;,
-0.305500; -2.243100; 0.228000;,
-0.305500; -2.243100; -0.372000;,
-0.305500; -2.243100; -0.372000;,
-0.305500; -2.243100; 0.228000;,
-0.305500; -1.643100; 0.228000;,
-0.305500; -1.643100; -0.372000;,
0.294500; -1.643100; 0.228000;,
0.294500; -1.643100; -0.372000;,
-0.305500; -1.643100; -0.372000;,
-0.305500; -1.643100; 0.228000;;
6;
4; 0, 3, 2, 1;,
4; 4, 7, 6, 5;,
4; 8, 11, 10, 9;,
4; 12, 15, 14, 13;,
4; 16, 19, 18, 17;,
4; 20, 23, 22, 21;;
  MeshMaterialList {
    0;
    6;
    0,
    0,
    0,
    0,
    0,
    0;;
    }  //End of MeshMaterialList
  MeshNormals {
24;
    0.577349; 0.577349; -0.577349;,
    0.577349; -0.577349; -0.577349;,
    -0.577349; -0.577349; -0.577349;,
    -0.577349; 0.577349; -0.577349;,
    0.577349; 0.577349; 0.577349;,
    -0.577349; 0.577349; 0.577349;,
    -0.577349; -0.577349; 0.577349;,
    0.577349; -0.577349; 0.577349;,
    0.577349; 0.577349; -0.577349;,
    0.577349; 0.577349; 0.577349;,
    0.577349; -0.577349; 0.577349;,
    0.577349; -0.577349; -0.577349;,
    0.577349; -0.577349; -0.577349;,
    0.577349; -0.577349; 0.577349;,
    -0.577349; -0.577349; 0.577349;,
    -0.577349; -0.577349; -0.577349;,
    -0.577349; -0.577349; -0.577349;,
    -0.577349; -0.577349; 0.577349;,
    -0.577349; 0.577349; 0.577349;,
    -0.577349; 0.577349; -0.577349;,
    0.577349; 0.577349; 0.577349;,
    0.577349; 0.577349; -0.577349;,
    -0.577349; 0.577349; -0.577349;,
    -0.577349; 0.577349; 0.577349;;
6;
4; 0, 3, 2, 1;,
4; 4, 7, 6, 5;,
4; 8, 11, 10, 9;,
4; 12, 15, 14, 13;,
4; 16, 19, 18, 17;,
4; 20, 23, 22, 21;;
}  //End of MeshNormals
  XSkinMeshHeader {
    1; 
    3; 
    1; 
  }
  SkinWeights {
    "cameraFPSBone"; 
     24; 
    0, 
    8, 
    21, 
    1, 
    11, 
    12, 
    2, 
    15, 
    16, 
    3, 
    19, 
    22, 
    4, 
    9, 
    20, 
    7, 
    10, 
    13, 
    6, 
    14, 
    17, 
    5, 
    18, 
    23; 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000, 
    1.000000; 
          -1.000000,0.000000,0.000000,0.000000,
          0.000000,-1.000000,0.000000,0.000000,
          0.000000,0.000000,1.000000,0.000000,
          -0.000000,0.000000,-0.000000,1.000000;;
        }
  } // End of XSkinMeshHeader
  }  // End of the Object cameraFPS 
}  // End of the Root Frame
As you can see, there is a bone (named cameraFPSBone), and a mesh attached to that bone (named cameraFPS), yet none of the SJoints have any AttachedMeshes :\

Removing the SkinWeights { ... } part of the file fixes the problem: the cameraFPS SJoint now has an AttachedMesh :)

I'll look into this and see if I can create a patch, or if someone else could, that would be cool :)

*EDIT*
I guess I should've mentioned that I'm using the Irrlicht trunk....sorry XD

Thanks,
-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
wyrmmage
Posts: 204
Joined: Sun Mar 16, 2008 3:12 am
Contact:

Post by wyrmmage »

UPDATE:
Here's a patch for the problem:

Code: Select all

Index: CXMeshFileLoader.cpp
===================================================================
--- CXMeshFileLoader.cpp	(revision 1913)
+++ CXMeshFileLoader.cpp	(working copy)
@@ -129,14 +129,14 @@
 			mesh->Buffers.push_back( AnimatedMesh->createBuffer() );
 			mesh->Buffers.getLast()->Material = mesh->Materials[i];
 
-			if (!mesh->HasSkinning)
-			{
+			//if (!mesh->HasSkinning)
+			//{
 				//Set up rigid animation
 				if (mesh->AttachedJointID!=-1)
 				{
 					AnimatedMesh->getAllJoints()[mesh->AttachedJointID]->AttachedMeshes.push_back( AnimatedMesh->getMeshBuffers().size()-1 );
 				}
-			}
+			//}
 		}
This works for me, but a quick look through the one other place that AttachedMeshes is used suggests that this fix is going to trash skinned meshes with animation.

Unfortunately with the current system there's no way to know what some of the meshes found in getMeshBuffers() are, which is a problem for me because I need to modify the vertices after the mesh is already loaded.

I'll try and create a better patch, I just didn't want this thread to completely die :P
-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
wyrmmage
Posts: 204
Joined: Sun Mar 16, 2008 3:12 am
Contact:

Post by wyrmmage »

Ok, looks like this boils down to a bug in Blender (which I wasn't expecting at all)...sorry I blamed Irrlicht first :oops: Anyway, if people are having problems with bones, attachedMesh's, etc. (or even SkinWeights, for that matter...I found another bug in the exporter that affected that >.>) when using the .x format from Blender, I've made a patch that might help you out :)
-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
Post Reply