Advertisement

X file issue

Started by June 18, 2009 01:28 PM
1 comment, last by MrDoDo 15 years, 6 months ago
Hi I'm a student-programmer so I hope you don't take offense with me being here. My problem is uniquely artsy though. I'm experiencing a terrible offset in my game engine when I use skinned meshes. It increases in size the further the model gets from a point (not quite the origin, seems a little further down the z-axis). So this has the effect of making the model appear offset from where it should be. Now I'm torn between it being an engine-error, or a modelling error. I found one skinned-mesh .x file (bones_all.x in example on http://www.toymaker.info/Games/html/load_x_hierarchy.html) where the engine works fine: the model appears where it should. But any models I make (and export via kwxport exporter in max) suffer this offset problem. And then several other models I've tried also suffer this (such as tiny.x from the DX SDK). For example:
xof 0303txt 0032
template KeyValuePair {
 <26e6b1c3-3d4d-4a1d-a437-b33668ffa1c2>
 STRING key;
 STRING value;
}

template Frame {
 <3d82ab46-62da-11cf-ab39-0020af71e433>
 [...]
}

template Matrix4x4 {
 <f6f23f45-7686-11cf-8f52-0040333594a3>
 array FLOAT matrix[16];
}

template FrameTransformMatrix {
 <f6f23f41-7686-11cf-8f52-0040333594a3>
 Matrix4x4 frameMatrix;
}

template ObjectMatrixComment {
 <95a48e28-7ef4-4419-a16a-ba9dbdf0d2bc>
 Matrix4x4 objectMatrix;
}

template Vector {
 <3d82ab5e-62da-11cf-ab39-0020af71e433>
 FLOAT x;
 FLOAT y;
 FLOAT z;
}

template MeshFace {
 <3d82ab5f-62da-11cf-ab39-0020af71e433>
 DWORD nFaceVertexIndices;
 array DWORD faceVertexIndices[nFaceVertexIndices];
}

template Mesh {
 <3d82ab44-62da-11cf-ab39-0020af71e433>
 DWORD nVertices;
 array Vector vertices[nVertices];
 DWORD nFaces;
 array MeshFace faces[nFaces];
 [...]
}

template MeshNormals {
 <f6f23f43-7686-11cf-8f52-0040333594a3>
 DWORD nNormals;
 array Vector normals[nNormals];
 DWORD nFaceNormals;
 array MeshFace faceNormals[nFaceNormals];
}

template Coords2d {
 <f6f23f44-7686-11cf-8f52-0040333594a3>
 FLOAT u;
 FLOAT v;
}

template MeshTextureCoords {
 <f6f23f40-7686-11cf-8f52-0040333594a3>
 DWORD nTextureCoords;
 array Coords2d textureCoords[nTextureCoords];
}

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;
}

template ColorRGBA {
 <35ff44e0-6c7c-11cf-8f52-0040333594a3>
 FLOAT red;
 FLOAT green;
 FLOAT blue;
 FLOAT alpha;
}

template ColorRGB {
 <d3e16e81-7835-11cf-8f52-0040333594a3>
 FLOAT red;
 FLOAT green;
 FLOAT blue;
}

template Material {
 <3d82ab4d-62da-11cf-ab39-0020af71e433>
 ColorRGBA faceColor;
 FLOAT power;
 ColorRGB specularColor;
 ColorRGB emissiveColor;
 [...]
}

template MeshMaterialList {
 <f6f23f42-7686-11cf-8f52-0040333594a3>
 DWORD nMaterials;
 DWORD nFaceIndexes;
 array DWORD faceIndexes[nFaceIndexes];
 [Material <3d82ab4d-62da-11cf-ab39-0020af71e433>]
}

template TextureFilename {
 <a42790e1-7810-11cf-8f52-0040333594a3>
 STRING filename;
}

template AnimTicksPerSecond {
 <9e415a43-7ba6-4a73-8743-b73d47e88476>
 DWORD AnimTicksPerSecond;
}

template Animation {
 <3d82ab4f-62da-11cf-ab39-0020af71e433>
 [...]
}

template AnimationSet {
 <3d82ab50-62da-11cf-ab39-0020af71e433>
 [Animation <3d82ab4f-62da-11cf-ab39-0020af71e433>]
}

template AnimationOptions {
 <e2bf56c0-840f-11cf-8f52-0040333594a3>
 DWORD openclosed;
 DWORD positionquality;
}

template FloatKeys {
 <10dd46a9-775b-11cf-8f52-0040333594a3>
 DWORD nValues;
 array FLOAT values[nValues];
}

template TimedFloatKeys {
 <f406b180-7b3b-11cf-8f52-0040333594a3>
 DWORD time;
 FloatKeys tfkeys;
}

template AnimationKey {
 <10dd46a8-775b-11cf-8f52-0040333594a3>
 DWORD keyType;
 DWORD nKeys;
 array TimedFloatKeys keys[nKeys];
}


KeyValuePair {
 "Date";
 "2009-06-17 20:19:21";
}

KeyValuePair {
 "File";
 "";
}

KeyValuePair {
 "User";
 "DoDo";
}

KeyValuePair {
 "CoreTime";
 "0";
}

Frame Box01 {
 

 FrameTransformMatrix relative {
  0.000000,0.000000,0.000000,0.000000,0.000000,0.00000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000;;
 }

 ObjectMatrixComment object {
  0.0000000,0.000000,0.000000,0.000000,0.000000,0.0000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000;;
 }

 Mesh mesh_Box01 {
  24;
  -0.532122;0.000000;-0.532122;,
  -0.532122;0.000000;0.532122;,
  0.532122;0.000000;0.532122;,
  0.532122;0.000000;-0.532122;,
  -0.532122;2.837986;-0.532122;,
  0.532122;2.837986;-0.532122;,
  0.532122;2.837986;0.532122;,
  -0.532122;2.837986;0.532122;,
  -0.532122;0.000000;-0.532122;,
  0.532122;0.000000;-0.532122;,
  0.532122;2.837986;-0.532122;,
  -0.532122;2.837986;-0.532122;,
  0.532122;0.000000;-0.532122;,
  0.532122;0.000000;0.532122;,
  0.532122;2.837986;0.532122;,
  0.532122;2.837986;-0.532122;,
  0.532122;0.000000;0.532122;,
  -0.532122;0.000000;0.532122;,
  -0.532122;2.837986;0.532122;,
  0.532122;2.837986;0.532122;,
  -0.532122;0.000000;0.532122;,
  -0.532122;0.000000;-0.532122;,
  -0.532122;2.837986;-0.532122;,
  -0.532122;2.837986;0.532122;;
  12;
  3;0,2,1;,
  3;2,0,3;,
  3;4,6,5;,
  3;6,4,7;,
  3;8,10,9;,
  3;10,8,11;,
  3;12,14,13;,
  3;14,12,15;,
  3;16,18,17;,
  3;18,16,19;,
  3;20,22,21;,
  3;22,20,23;;

  MeshNormals normals {
   24;
   0.000000;-1.000000;0.000000;,
   0.000000;-1.000000;0.000000;,
   0.000000;-1.000000;0.000000;,
   0.000000;-1.000000;0.000000;,
   0.000000;1.000000;0.000000;,
   0.000000;1.000000;0.000000;,
   0.000000;1.000000;0.000000;,
   0.000000;1.000000;0.000000;,
   0.000000;0.000000;-1.000000;,
   0.000000;0.000000;-1.000000;,
   0.000000;0.000000;-1.000000;,
   0.000000;0.000000;-1.000000;,
   1.000000;0.000000;0.000000;,
   1.000000;0.000000;0.000000;,
   1.000000;0.000000;0.000000;,
   1.000000;0.000000;0.000000;,
   0.000000;0.000000;1.000000;,
   0.000000;0.000000;1.000000;,
   0.000000;0.000000;1.000000;,
   0.000000;0.000000;1.000000;,
   -1.000000;0.000000;0.000000;,
   -1.000000;0.000000;0.000000;,
   -1.000000;0.000000;0.000000;,
   -1.000000;0.000000;0.000000;;
   12;
   3;0,2,1;,
   3;2,0,3;,
   3;4,6,5;,
   3;6,4,7;,
   3;8,10,9;,
   3;10,8,11;,
   3;12,14,13;,
   3;14,12,15;,
   3;16,18,17;,
   3;18,16,19;,
   3;20,22,21;,
   3;22,20,23;;
  }

  MeshTextureCoords tc0 {
   24;
   1.000000;1.000000;,
   1.000000;0.000000;,
   0.000000;0.000000;,
   0.000000;1.000000;,
   0.000000;1.000000;,
   1.000000;1.000000;,
   1.000000;0.000000;,
   0.000000;0.000000;,
   0.000000;1.000000;,
   1.000000;1.000000;,
   1.000000;0.000000;,
   0.000000;0.000000;,
   0.000000;1.000000;,
   1.000000;1.000000;,
   1.000000;0.000000;,
   0.000000;0.000000;,
   0.000000;1.000000;,
   1.000000;1.000000;,
   1.000000;0.000000;,
   0.000000;0.000000;,
   0.000000;1.000000;,
   1.000000;1.000000;,
   1.000000;0.000000;,
   0.000000;0.000000;;
  }

  XSkinMeshHeader {
   1;
   0;
   2;
  }

  SkinWeights W-Bone01 {
   "Bone01";
   12;
   0,
   8,
   21,
   3,
   9,
   12,
   1,
   17,
   20,
   2,
   13,
   16;
   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.015624,-0.000002,-0.999878,0.000000,0.999878,-0.000000,-0.015624,0.000000,0.000000,-1.000000,0.000002,0.000000,-0.011325,0.000000,0.009593,1.000000;;
  }

  SkinWeights W-Bone04 {
   "Bone04";
   12;
   4,
   11,
   22,
   5,
   10,
   15,
   7,
   18,
   23,
   6,
   14,
   19;
   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.000253,0.000000,-1.000000,0.000000,1.000000,-0.000000,0.000253,0.000000,-0.000000,-1.000000,-0.000000,0.000000,-2.814689,-0.000000,-0.009066,1.000000;;
  }

  MeshMaterialList mtls {
   1;
   12;
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0;

   Material _01___Default {
    0.588235;0.588235;0.588235;1.000000;;
    9.999999;
    0.900000;0.900000;0.900000;;
    0.000000;0.000000;0.000000;;

    TextureFilename Diffuse {
     "C:\\Documents and Settings\\DoDo\\My Documents\\Visual Studio Projects\\DirectXSamples\\Attempt1\\metal_mangledpaint-01_df_.dds";
    }
   }
  }
 }
}

Frame Bone01 {
 

 FrameTransformMatrix relative {
  -0.015624,0.999878,0.000000,0.000000,-0.000002,-0.000000,-1.000000,0.000000,-0.999878,-0.015624,0.000002,0.000000,0.009415,0.011474,-0.000000,1.000000;;
 }

 ObjectMatrixComment object {
  0.999994,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;;
 }

 Frame Bone02 {
  

  FrameTransformMatrix relative {
   0.999878,-0.000000,-0.015625,0.000000,-0.000000,1.000000,-0.000002,0.000000,0.015625,0.000002,0.999878,0.000000,1.150150,0.000000,-0.000000,1.000000;;
  }

  ObjectMatrixComment object {
   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;;
  }

  Frame Bone03 {
   

   FrameTransformMatrix relative {
    1.000000,0.000000,-0.000252,0.000000,-0.000000,1.000000,-0.000000,0.000000,0.000252,0.000000,1.000000,0.000000,0.862520,0.000000,0.000000,1.000000;;
   }

   ObjectMatrixComment object {
    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;;
   }

   Frame Bone04 {
    

    FrameTransformMatrix relative {
     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.790688,0.000000,0.000000,1.000000;;
    }

    ObjectMatrixComment object {
     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;;
    }
   }
  }
 }
}

AnimTicksPerSecond fps {
 4800;
}

AnimationSet IdleShake {
 

 Animation Anim-IdleShake-Box01 {
  
  { Box01 }

  AnimationOptions {
   1;
   0;
  }

  AnimationKey rot {
   0;
   1;
   0;4;1.000000,0.000000,0.000000,0.000000;;;
  }

  AnimationKey scale {
   1;
   1;
   0;3;1.000000,1.000000,1.000000;;;
  }

  AnimationKey pos {
   2;
   1;
   0;3;0.000000,0.000000,0.000000;;;
  }
 }

 Animation Anim-IdleShake-Bone01 {
  
  { Bone01 }

  AnimationOptions {
   1;
   0;
  }

  AnimationKey rot {
   0;
   1;
   0;4;0.496079,0.496078,0.503890,-0.503891;;;
  }

  AnimationKey scale {
   1;
   1;
   0;3;1.000000,1.000000,1.000000;;;
  }

  AnimationKey pos {
   2;
   1;
   0;3;0.009415,0.011474,-0.000000;;;
  }
 }

 Animation Anim-IdleShake-Bone02 {
  
  { Bone02 }

  AnimationOptions {
   1;
   0;
  }

  AnimationKey rot {
   0;
   26;
   0;4;0.999969,0.000001,-0.007813,-0.000000;;,
   800;4;0.999969,0.000001,-0.007813,-0.000000;;,
   960;4;0.999702,-0.000180,-0.007811,-0.023143;;,
   1120;4;0.996903,-0.000610,-0.007789,-0.078257;;,
   1280;4;0.989589,-0.001122,-0.007731,-0.143712;;,
   1440;4;0.980154,-0.001547,-0.007658,-0.198084;;,
   1600;4;0.975307,-0.001723,-0.007620,-0.220715;;,
   1760;4;0.978604,-0.001605,-0.007646,-0.205604;;,
   1920;4;0.986371,-0.001283,-0.007706,-0.164352;;,
   2080;4;0.994645,-0.000804,-0.007771,-0.103052;;,
   2240;4;0.999574,-0.000219,-0.007810,-0.028110;;,
   2400;4;0.998531,0.000420,-0.007801,0.053612;;,
   2560;4;0.990818,0.001056,-0.007741,0.134975;;,
   2720;4;0.977893,0.001634,-0.007640,0.208959;;,
   2880;4;0.963103,0.002103,-0.007525,0.269021;;,
   3040;4;0.950964,0.002417,-0.007430,0.309204;;,
   3200;4;0.946068,0.002531,-0.007392,0.323875;;,
   3360;4;0.956819,0.002271,-0.007476,0.290581;;,
   3520;4;0.977707,0.001640,-0.007639,0.209828;;,
   3680;4;0.993724,0.000873,-0.007764,0.111582;;,
   3840;4;0.999567,0.000223,-0.007810,0.028376;;,
   4000;4;0.999948,-0.000051,-0.007812,-0.006609;;,
   4160;4;0.999952,-0.000045,-0.007813,-0.005921;;,
   4320;4;0.999960,-0.000032,-0.007813,-0.004282;;,
   4480;4;0.999967,-0.000017,-0.007813,-0.002326;;,
   4640;4;0.999969,-0.000004,-0.007813,-0.000687;;;
  }

  AnimationKey scale {
   1;
   1;
   0;3;1.000000,1.000000,1.000000;;;
  }

  AnimationKey pos {
   2;
   1;
   0;3;1.150150,0.000000,-0.000000;;;
  }
 }

 Animation Anim-IdleShake-Bone03 {
  
  { Bone03 }

  AnimationOptions {
   1;
   0;
  }

  AnimationKey rot {
   0;
   26;
   0;4;1.000000,0.000000,-0.000126,-0.000000;;,
   800;4;1.000000,0.000000,-0.000126,-0.000000;;,
   960;4;0.999654,-0.000003,-0.000126,-0.026316;;,
   1120;4;0.996035,-0.000011,-0.000125,-0.088962;;,
   1280;4;0.986584,-0.000021,-0.000124,-0.163255;;,
   1440;4;0.974402,-0.000028,-0.000123,-0.224812;;,
   1600;4;0.968149,-0.000032,-0.000122,-0.250376;;,
   1760;4;0.970774,-0.000030,-0.000122,-0.239996;;,
   1920;4;0.977338,-0.000027,-0.000123,-0.211685;;,
   2080;4;0.985505,-0.000021,-0.000124,-0.169645;;,
   2240;4;0.992991,-0.000015,-0.000125,-0.118186;;,
   2400;4;0.998087,-0.000008,-0.000126,-0.061828;;,
   2560;4;0.999986,-0.000001,-0.000126,-0.005271;;,
   2720;4;0.998908,0.000006,-0.000126,0.046718;;,
   2880;4;0.995992,0.000011,-0.000125,0.089445;;,
   3040;4;0.992972,0.000015,-0.000125,0.118349;;,
   3200;4;0.991648,0.000016,-0.000125,0.128974;;,
   3360;4;0.993090,0.000015,-0.000125,0.117359;;,
   3520;4;0.996005,0.000011,-0.000125,0.089295;;,
   3680;4;0.998486,0.000007,-0.000126,0.055002;;,
   3840;4;0.999692,0.000003,-0.000126,0.024820;;,
   4000;4;0.999958,0.000001,-0.000126,0.009136;;,
   4160;4;0.999987,0.000001,-0.000126,0.005001;;,
   4320;4;0.999997,0.000000,-0.000126,0.002337;;,
   4480;4;1.000000,0.000000,-0.000126,0.000827;;,
   4640;4;1.000000,0.000000,-0.000126,0.000154;;;
  }

  AnimationKey scale {
   1;
   1;
   0;3;1.000000,1.000000,1.000000;;;
  }

  AnimationKey pos {
   2;
   1;
   0;3;0.862520,0.000000,0.000000;;;
  }
 }

 Animation Anim-IdleShake-Bone04 {
  
  { Bone04 }

  AnimationOptions {
   1;
   0;
  }

  AnimationKey rot {
   0;
   1;
   0;4;1.000000,-0.000000,-0.000000,0.000000;;;
  }

  AnimationKey scale {
   1;
   1;
   0;3;1.000000,1.000000,1.000000;;;
  }

  AnimationKey pos {
   2;
   1;
   0;3;0.790688,0.000000,0.000000;;;
  }
 }
}
which is just a simple dancing block suffers the offset. So the bones_all.x file indicates it is not my engine... but tiny.x makes me feel like it is. I was wondering if anybody here can offer any help in depth, or rather at the least, whether anybody can send me some skinned-mesh .x files that they know have rendered correctly in a game they use. I thank you for your time and any assistance you can give. Matt K.
There's many a source for .x models. The DirectX SDK has quite a few, our you might want to check out Assimp's repository of test files. The latter one also has a working skinning engine in place and provides source with it, albeit a bit mixed up.

Oh, and please put a download link to your model file. There's no need to paste 20+ pages of text into your posting.
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
Advertisement
Thanks for the direction Schrompf. Apologies for the many pages of code, I was in a rush and half expected some automated script to crop the code into a scroll-barred box.

I'm out of town for the next couple of days, after which I will check out Assimps repository of files and update with my results.

God speed.

This topic is closed to new replies.

Advertisement