<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MD5 Mesh Reader Troubles in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183235#M16003</link>
    <description>Hello&lt;BR /&gt;&lt;BR /&gt;Could you give me some tips for a simple import of ".md5mesh" files.&lt;BR /&gt;&lt;BR /&gt;Windows 7, 64bit, Maya or 3DSmax 2011.&lt;BR /&gt;&lt;BR /&gt;Cheers, Claude</description>
    <pubDate>Thu, 24 Feb 2011 00:03:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-02-24T00:03:50Z</dc:date>
    <item>
      <title>MD5 Mesh Reader Troubles</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183232#M16000</link>
      <description>Greetings Ladies, Gents, Holograms and turtles&lt;BR /&gt;&lt;BR /&gt;New to the forum, but none the less need some help. &lt;BR /&gt;&lt;BR /&gt;I am writing an MD5Mesh importer in Python for a personal learning project and ive run into a problem with calculating the final vertex positions and its become quite an irritation. All of the example plugins seem to be doing different things and I have come to you all for some assistance. With a single bone influencing any vertex all is well, but as soon as a second bone comes into the situation the waters get turbulent and the vertices jump all over the place. &lt;BR /&gt;&lt;BR /&gt;Attached are two examples, illustrating that the problem is clearly in local rotations, but once i get there all seems to lay out. The character is actually from Maya 2010, the second (What used to be a bird) is from Maya 2011&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt; def calculateVertexPositions(self):&lt;BR /&gt; for mesh in self.Meshes:&lt;BR /&gt; counter = 0&lt;BR /&gt; for v in mesh.Vertices:&lt;BR /&gt; counter += 1&lt;BR /&gt; amount = int(100 * (counter/len(mesh.Vertices)))&lt;BR /&gt; cmds.progressWindow( edit = True, progress = amount, status=('Calculating Final Vertex Positions...' ) )&lt;BR /&gt; &lt;BR /&gt; final = Vector3()&lt;BR /&gt;&lt;BR /&gt; for weightOffset in range(0, v.WeightElements):&lt;BR /&gt;&lt;BR /&gt; vWeight = mesh.Weights&lt;BR /&gt; vJoint = self.Joints&lt;BR /&gt;&lt;BR /&gt; wsq = vJoint.Orientation.w ** 2&lt;BR /&gt;&lt;BR /&gt; var = wsq - vJoint.Orientation.x ** 2 - vJoint.Orientation.y ** 2 - vJoint.Orientation.z ** 2&lt;BR /&gt; var2 = 2 * (vJoint.Orientation.x * vWeight.Position.x + vJoint.Orientation.y * vWeight.Position.y + vJoint.Orientation.z * vWeight.Position.z)&lt;BR /&gt; &lt;BR /&gt; var3 = Vector3(var * vWeight.Position.x + var2 * vJoint.Orientation.x, var * vWeight.Position.y + var2 * vJoint.Orientation.y, var * vWeight.Position.z + var2 * vJoint.Orientation.z)&lt;BR /&gt;&lt;BR /&gt; var3 += Vector3(&lt;BR /&gt; wsq * (vJoint.Orientation.y * vWeight.Position.z - vJoint.Orientation.z * vWeight.Position.y),&lt;BR /&gt; wsq * (vJoint.Orientation.z * vWeight.Position.x - vJoint.Orientation.x * vWeight.Position.z),&lt;BR /&gt; wsq * (vJoint.Orientation.x * vWeight.Position.y - vJoint.Orientation.y * vWeight.Position.x))&lt;BR /&gt; &lt;BR /&gt; final += var3&lt;BR /&gt;&lt;BR /&gt; v.setFinalPosition(final)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;As soon as i get home ill upload a couple more screenshots of a cube i used for reference and you can see its distortion, as well as a stream of the Vertex positions before and after the Quaternion is applied. &lt;BR /&gt;&lt;BR /&gt;Thanks ahead of time for your help!&lt;P&gt;&lt;IMG class="migr-att-link" src="http://area.autodesk.com/userdata/forum/m/maya_20101223_15280520.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migr-att-link" src="http://area.autodesk.com/userdata/forum/m/maya_20101228_20262815.jpg" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 04:32:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183232#M16000</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-12-29T04:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 Mesh Reader Troubles</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183233#M16001</link>
      <description>The Weight class has an Index (int), JointIndex (int), WeightScale (float) and Position (vector3)&lt;BR /&gt;The Joint class has a Bone Name (string), ParentIndex (int), Position (vector3) and an Orientation (quaternion)&lt;BR /&gt;&lt;BR /&gt;The file stores the X, Y, Z components of the Quaternion and you need to calculate the W component from something like the following:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;t = 1.0 - (q.X ** 2) - (q.Y ** 2) - (q.Z ** 2)&lt;BR /&gt;q.W = 0.0 if t &amp;lt; 0.0 else -1.0 * math.sqrt(t)&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt; &lt;BR /&gt;So all is well up to this point. &lt;BR /&gt;&lt;BR /&gt;Executing my script i get everything loaded, and then it tries to render it. Below you will see two reference meshes that i rendered for example. The first two are pre import, the second are post.&lt;P&gt;&lt;IMG class="migr-att-link" src="http://area.autodesk.com/userdata/forum/m/maya_20101229_00181345.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migr-att-link" src="http://area.autodesk.com/userdata/forum/m/maya_20101229_00185383.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migr-att-link" src="http://area.autodesk.com/userdata/forum/m/maya_20101229_00194047.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migr-att-link" src="http://area.autodesk.com/userdata/forum/m/maya_20101229_00211848.jpg" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 08:22:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183233#M16001</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-12-29T08:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 Mesh Reader Troubles</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183234#M16002</link>
      <description>So here is my process for the files up to this point:&lt;BR /&gt;&lt;BR /&gt;1. Create a cube/simple mesh. &lt;BR /&gt;2. Add a single joint at its center and apply full weight to all vertices in the mesh.&lt;BR /&gt;3. Export from Maya into UDK.&lt;BR /&gt;4. Export from UDK into MD5Mesh format (UModel assisted).&lt;BR /&gt;5. Load the exported file into MD5Mesh Viewer and confirm file is not corrupted.&lt;BR /&gt;6. Pass file path into my Maya MD5Mesh importer script and wait for completion. &lt;BR /&gt;&lt;BR /&gt;This works fine. &lt;BR /&gt;&lt;BR /&gt;The trick is that this file format has the positions impacted by multiple weights/joints and you have to calculate the position afterwards. So it makes sense that a single joint would be fine. I then repeated these steps, this time with two and then ten bones, figuring if it worked for two and it worked for ten i could be happy with a process and move it over to a full blown plugin for maya and not need to pass around the Python script. &lt;BR /&gt;&lt;BR /&gt;Attached are two meshes, one a test cube with two linked joints which works and the second a bird which does not with 10 linked bones. (Apparently i cant attach the files, here are links to them)&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://projects.gneu.org/md5mesh/CubeTest.md5mesh" target="_blank"&gt;http://projects.gneu.org/md5mesh/CubeTest.md5mesh&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://projects.gneu.org/md5mesh/Reference_MultipleBones.md5mesh" target="_blank"&gt;http://projects.gneu.org/md5mesh/Reference_MultipleBones.md5mesh&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also attached is the current draft of the script for loading the mesh into Maya. Tested on Maya 2010 and Maya 2011&lt;BR /&gt;&lt;A href="http://projects.gneu.org/md5mesh/draft.php" target="_blank"&gt;http://projects.gneu.org/md5mesh/draft.php&lt;/A&gt;</description>
      <pubDate>Wed, 29 Dec 2010 08:46:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183234#M16002</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-12-29T08:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 Mesh Reader Troubles</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183235#M16003</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;Could you give me some tips for a simple import of ".md5mesh" files.&lt;BR /&gt;&lt;BR /&gt;Windows 7, 64bit, Maya or 3DSmax 2011.&lt;BR /&gt;&lt;BR /&gt;Cheers, Claude</description>
      <pubDate>Thu, 24 Feb 2011 00:03:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183235#M16003</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-02-24T00:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 Mesh Reader Troubles</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183236#M16004</link>
      <description>Sure, but my mesh reader is still broken.&lt;BR /&gt;&lt;BR /&gt;Do you have a certain area you need tips in?</description>
      <pubDate>Thu, 24 Feb 2011 05:05:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/md5-mesh-reader-troubles/m-p/4183236#M16004</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-02-24T05:05:59Z</dc:date>
    </item>
  </channel>
</rss>

