<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Can you send more code ? (a paste)<br>
      <br>
      what is your b ? <br>
      <br>
      <br>
      <br>
      Le 27/08/2017 à 10:26, Vsevolod Kremianskii a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CANWL8p+DX4Z0kqmiH-OYPavRE-VEYP6vdBE20otNuV2fPJEK3Q@mail.gmail.com">
      <div dir="ltr"><span style="font-size:12.8px">Alright, it works.
          Sort off. Except for that ugly mesh deformation issue. I
          wonder if somebody could set me in the right direction from
          here.</span>
        <div style="font-size:12.8px"><br>
        </div>
        <div style="font-size:12.8px">Here's how it's done:</div>
        <div style="font-size:12.8px"><br>
        </div>
        <div style="font-size:12.8px">I load position and orientation
          controllers for every animation node, which pretty much does
          it for the skeleton (also heads, since they're attached to the
          headhook).</div>
        <div style="font-size:12.8px">I load bone mapping from skin mesh
          header and per vertex bone data from MDX (as described <a
href="https://github.com/xoreos/xoreos-docs/blob/master/specs/kotor_mdl.html"
            target="_blank" moz-do-not-send="true">here</a>).</div>
        <div style="font-size:12.8px">When animation gets updated I
          iterate through model's skinned nodes and for every vertex do
          the following:</div>
        <div style="font-size:12.8px"><br>
        </div>
        <div style="font-size:12.8px">I iterate over nodes (bones) that
          affect the vertex and create each node's global transformation
          matrix (relative to the root node). Then I multiply initial
          vertex coordinates by the transformation matrix and multiply
          that by the bone weight. Resulting vertex coordinates are
          calculated as a sum of four transformed vertices. There are
          some optimizations in place so it isn't quite as bad as it
          sounds.</div>
        <div style="font-size:12.8px"><br>
        </div>
        <div>
          <div style="font-size:12.8px"> <span style="white-space:pre-wrap">           </span>for
            (uint32 i = 0; i < vertexCount; ++i) {</div>
          <div style="font-size:12.8px">
            <div> <span style="white-space:pre-wrap">                    </span>v[0] = 0;</div>
            <div> <span style="white-space:pre-wrap">                    </span>v[1] = 0;</div>
            <div> <span style="white-space:pre-wrap">                    </span>v[2] = 0;</div>
            <div> <span style="white-space:pre-wrap">                    </span>for
              (uint8 j = 0; j < 4; ++j) {</div>
            <div> <span style="white-space:pre-wrap">                            </span>int
              index = static_cast<int>(b[4 + j]);</div>
            <div> <span style="white-space:pre-wrap">                            </span>if
              (index != -1) {</div>
            <div> <span style="white-space:pre-wrap">                                    </span>float
              rv[3];</div>
            <div> <span style="white-space:pre-wrap">                                    </span>transform
              = transArr + (index * 16);</div>
            <div> <span style="white-space:pre-wrap">                                    </span>transform.multiply(iv,
              rv);</div>
            <div> <span style="white-space:pre-wrap">                                    </span>v[0] +=
              rv[0] * b[j];</div>
            <div> <span style="white-space:pre-wrap">                                    </span>v[1] +=
              rv[1] * b[j];</div>
            <div> <span style="white-space:pre-wrap">                                    </span>v[2] +=
              rv[2] * b[j];</div>
            <div> <span style="white-space:pre-wrap">                            </span>}</div>
            <div> <span style="white-space:pre-wrap">                    </span>}</div>
            <div> <span style="white-space:pre-wrap">                    </span>v +=
              stride;</div>
            <div> <span style="white-space:pre-wrap">                    </span>iv += 3;</div>
            <div> <span style="white-space:pre-wrap">                    </span>b += 8;</div>
            <div> <span style="white-space:pre-wrap">            </span>}</div>
          </div>
          <div style="font-size:12.8px"><br>
          </div>
          <div style="font-size:12.8px">Now, the problem is that weird
            stretching issue. I have no idea what could cause that at
            the moment.</div>
          <div style="font-size:12.8px"><a href="goog_555208919"
              moz-do-not-send="true"><br>
            </a></div>
          <div><span style="font-size:12.8px"><a
                href="https://yadi.sk/i/0hnd2a0M3MMYJR"
                moz-do-not-send="true">https://yadi.sk/i/0hnd2a0M3MMYJR</a></span><br>
          </div>
        </div>
        <div><span style="font-size:12.8px"><a
              href="https://yadi.sk/i/jdiTSrXZ3MMYL3"
              moz-do-not-send="true">https://yadi.sk/i/jdiTSrXZ3MMYL3</a></span><br>
        </div>
        <div><span style="font-size:12.8px"><a
              href="https://yadi.sk/i/Vm3kRTVf3MMYKQ"
              moz-do-not-send="true">https://yadi.sk/i/Vm3kRTVf3MMYKQ</a></span><br>
        </div>
        <div><span style="font-size:12.8px"><br>
          </span></div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
xoreos-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:xoreos-devel@xoreos.org">xoreos-devel@xoreos.org</a>
<a class="moz-txt-link-freetext" href="https://xoreos.org/mailman/listinfo/xoreos-devel">https://xoreos.org/mailman/listinfo/xoreos-devel</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>