DirectX8Exporter bug with Armatures

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
wyrmmage
Posts: 3
Joined: Tue Dec 09, 2008 4:11 am
Location: Boise, ID

DirectX8Exporter bug with Armatures

Post by wyrmmage » Tue Dec 09, 2008 4:53 am

Hello :) This is my first post here, so please forgive me if I make any dumb mistakes XD

Anyway: I think I've discovered a bug in the DirectX8Exporter found in Blender V2.48a

I have an armature and a bone and then another bone extruded from that first bone (we'll call them boneOne and boneTwo). I then have two cubes; one cube is parented to boneOne and has all of its vertices assigned to boneOne, the other cube is likewise parented and assigned to boneTwo. Now, when I export my creation, the bones are only applied to boneOne, but not boneTwo :\

In my model I have quite a few more bones and meshes than in the above example, but the idea is the same. Here is the resulting .x file I get when I've exported my object (I've replaced stuff that's not really relevant with '...'):

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 {...}
    Frame spineBone {

      FrameTransformMatrix {...}
      Frame rightCollarBone {

        FrameTransformMatrix {...}
        Frame rightShoulderBone {

          FrameTransformMatrix {...}
          Frame rightArmBone {

            FrameTransformMatrix {...}
            Frame rightGunBone {

              FrameTransformMatrix {...}
            }
          }
        }
      }
      Frame leftCollarBone {

        FrameTransformMatrix {...}
        Frame leftShoulderBone {

          FrameTransformMatrix {...}
          Frame leftArmBone {

            FrameTransformMatrix {...}
            Frame leftGunBone {

              FrameTransformMatrix {...}
            }
          }
        }
      }
      Frame rightHipBone {

        FrameTransformMatrix {...}
        Frame rightLegBone {

          FrameTransformMatrix {...}
        }
      }
      Frame leftHipBone {

        FrameTransformMatrix {...}
        Frame leftLegBone {

          FrameTransformMatrix {...}
        }
      }
      Frame cameraFPSBone {

        FrameTransformMatrix {...}
      }
  }  // End of the Bone spineBone 
      Frame cameraFPS {

        FrameTransformMatrix {...}
Mesh {
...
  MeshMaterialList {...}  //End of MeshMaterialList
  MeshNormals {...}  //End of MeshNormals
  XSkinMeshHeader {
    1; 
    3; 
    14; 
  }
  SkinWeights {
    "cameraFPSBone"; 
     36; 
    1, 
    18, 
    30, 
    33, 
    12, 
    20, 
    23, 
    31, 
    6, 
    9, 
    14, 
    17, 
    32, 
    34, 
    2, 
    4, 
    11, 
    35, 
    0, 
    3, 
    19, 
    21, 
    24, 
    13, 
    15, 
    22, 
    26, 
    29, 
    7, 
    16, 
    28, 
    5, 
    8, 
    10, 
    25, 
    27; 
    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, 
    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,-0.999800,-0.022300,0.000000,
          -0.000000,0.022300,-0.999800,0.000000,
          0.000000,0.034300,0.769700,1.000000;;
        }
  } // End of XSkinMeshHeader
  }  // End of the Object cameraFPS 
      Frame rightGun {

        FrameTransformMatrix {...}
Mesh {
...
  MeshMaterialList {...}  //End of MeshMaterialList
  MeshNormals {...}  //End of MeshNormals
  }  // End of the Mesh rightGun 
      Frame leftGun {

        FrameTransformMatrix ...}
Mesh {...}  // End of the Mesh leftGun 
      Frame leftArm {

        FrameTransformMatrix {...}
Mesh {...}  // End of the Mesh leftArm 
      Frame rightArm {

        FrameTransformMatrix {...}
Mesh {...}  // End of the Mesh rightArm 
      Frame leftShoulder {

        FrameTransformMatrix {...}
Mesh {...}  // End of the Mesh leftShoulder 
      Frame rightShoulder {

        FrameTransformMatrix {...}
Mesh {...}  // End of the Mesh rightShoulder 
      Frame leftLeg {

        FrameTransformMatrix {...}
Mesh {...}  // End of the Mesh leftLeg 
      Frame rightLeg {

        FrameTransformMatrix {...}
Mesh {...}  // End of the Mesh rightLeg 
      Frame spine {

        FrameTransformMatrix {...}
Mesh {...}  // End of the Mesh spine 
}  // End of the Root Frame

As you can see, both an XSkinMeshHeader and a SkinWeights structure are present under the definition of the Mesh of cameraFPS, but neither of these exist under the definition of the Mesh of rightGun :\

If you'd like to download the blend file I'm using, you can find it here. I'll try and look into this and see if I can fix it, but I've already been trying for a couple of days without much success, so if someone else could come up with a patch, that would be great too ^_^

Thanks :)
-wyrmmage

wyrmmage
Posts: 3
Joined: Tue Dec 09, 2008 4:11 am
Location: Boise, ID

Post by wyrmmage » Wed Dec 10, 2008 3:57 am

Well, that was more simple than I would have thought :)

Below is the svn patch for DirectX8Exporter.py:

Code: Select all

Index: DirectX8Exporter.py
===================================================================
--- DirectX8Exporter.py	(revision 17767)
+++ DirectX8Exporter.py	(working copy)
@@ -319,10 +319,12 @@
 		obs = Blender.Scene.GetCurrent().objects
 		return [ ob for ob in obs if ob.parent == obj ]
 	
-	def getArmChildren(self,obj):		
+	def getArmChildren(self,obj):
+		resultingObjects = []
 		for ob in Blender.Scene.GetCurrent().objects: #Object.Get():
-			if ob.parent == obj :
-				return ob
+			if ob.parent == obj:
+				resultingObjects.append(ob)
+		return resultingObjects
 	
 	def getLocMat(self, obj):
 		pare = obj.parent
@@ -348,7 +350,7 @@
 		if type(mesh) == Types.ArmatureType :
 			Child_obj = self.getArmChildren(obj)
 			chld_obj = obj
-			ch_list.append(Child_obj)
+			ch_list += Child_obj
 			self.writeRootBone(obj, Child_obj)	
 		if obj.type == 'Mesh' and obj not in ch_list:
 			self.exportMesh(obj)
@@ -399,7 +401,7 @@
 				if ch and ch.type == "Armature":
 					ch_list.append(ch)
 					self.writeObjFrames(ch)
-				else :	
+				else :
 					self.writeChildObj(ch_l)
 			if obj.type != "Armature":
 				self.file.write("  }  // SI End of the Object %s \n" % (obj.name))	
@@ -483,16 +485,17 @@
 	#Export Mesh with Armature
 	#***********************************************
 	def exportMeshArm(self,arm,arm_ob,ch_obj):
-		tex = []
-		mesh = ch_obj.getData()
-		self.writeTextures(ch_obj, tex)		
-		self.writeMeshcoordArm(ch_obj ,arm_ob)
-		self.writeMeshMaterialList(ch_obj, mesh, tex)
-		self.writeMeshNormals(ch_obj, mesh)
-		self.writeMeshTextureCoords(ch_obj, mesh)
-		self.writeSkinWeights(arm,mesh)
-		#self.file.write("  }  // End of the Frame %s \n" % (ch_obj.name))
-		self.file.write("  }  // End of the Object %s \n" % (ch_obj.name))
+		for co in ch_obj:
+			tex = []
+			mesh = co.getData()
+			self.writeTextures(co, tex)		
+			self.writeMeshcoordArm(co, arm_ob)
+			self.writeMeshMaterialList(co, mesh, tex)
+			self.writeMeshNormals(co, mesh)
+			self.writeMeshTextureCoords(co, mesh)
+			self.writeSkinWeights(arm,mesh)
+			#self.file.write("  }  // End of the Frame %s \n" % (ch_obj.name))
+			self.file.write("  }  // End of the Object %s \n" % (co.name))
 				
 	#***********************************************
 	#Export Root Bone
Any chance of this making it into the next Blender release? Do I need to submit the patch anywhere?

Thanks :)
-wyrmmage

stiv
Posts: 3645
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv » Wed Dec 10, 2008 5:02 am

Best thing to do is submit the patch to the patch tracker at
https://projects.blender.org/tracker/?a ... unc=browse

You will need to create an account.

Here is an general info page on patches.
http://www.blender.org/development/submit-a-patch/

wyrmmage
Posts: 3
Joined: Tue Dec 09, 2008 4:11 am
Location: Boise, ID

Post by wyrmmage » Wed Dec 10, 2008 5:37 am

stiv wrote:Best thing to do is submit the patch to the patch tracker at
https://projects.blender.org/tracker/?a ... unc=browse

You will need to create an account.

Here is an general info page on patches.
http://www.blender.org/development/submit-a-patch/
I've posted the patch to the tracker.

Thanks for the help :)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests