Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was able to skin my model. Here is what I did:</p> <ol> <li><p>"Sun" is my model's bone. It can translate (in world space) and rotate. "Earth" is a custom point on a model that moves rotated/translated with the model as my goal implies that I can't just pick any point and skin it, I need the latter to move with the model.</p></li> <li><p>I have two methods in my app: one that launches once (Initialize) and another one that launches every frame (Update). In Initialize method my model is always at T-Pose.</p></li> <li><p>In Initialize method I read the position of the Sun and Earth as 2 <code>XNA Matrix</code>.</p></li> <li><p>In Initialize I also compute</p> <pre><code>Vector3 Difference = TPoseEarth.Translation - TPoseSun.Translation; </code></pre></li> <li><p>Finally in Initialize I decompose Sun's Matrix to gain pure Sun's rotation matrix (without translation). I do so because my model's bone Sun apparently has a non-identity matrix assigned to it even at T-Pose. like so:</p> <pre><code>Vector3 scale; Quaternion rotation; Vector3 tra; TPoseSun.Decompose(out scale, out rotation, out tra); BaseSunRot = Matrix.CreateFromQuaternion(rotation); </code></pre></li> <li><p>In Update method I get the current World position of Earth and Sun. I decompose the Sun's Matrix to get the pure rotation (again!).</p> <pre><code>Vector3 scale; Quaternion rotation; Vector3 tra; Sun.Decompose(out scale, out rotation, out tra); Matrix SunRot = Matrix.CreateFromQuaternion(rotation); </code></pre></li> <li><p>I compute the unique bone-Sun rotation by multiplying the inverse of my base rotation by my new rotation:</p> <pre><code>Matrix UniqueRot = Matrix.Invert(BaseSunRot) * SunRot; </code></pre></li> <li><p>I set my Earth's Translation equal to the Difference (Between Sun's T-Pose position and Earth's T-Pose position):</p> <pre><code>Matrix Earth = Matrix.Identity; Earth.Translation = Difference; </code></pre></li> <li><p>I multiply Earth matrix by the unique bone's (Sun's) rotation:</p> <pre><code>Earth *= UniqueRot; </code></pre></li> <li><p>I add Sun's CURRENT position to provide for possible translations between frames:</p> <pre><code>Earth += Sun.Translation; </code></pre></li> <li><p>The End. Earth matrix contains all the necessary info about the skinned vertex.</p></li> </ol> <p>I am not 100% sure but I feel like this is basically a manual on how to skin ANY given point agains ANY bone in the world (i.e rotate/translate keeping the initial offset). The problem is, the code is not optimized :). If anyone have any ideas on how to optimize it I would HUGELY appreciate it.</p> <p>Especially I want to know if I can skip the double matrix decomposition and simply multiply the full ScaleRotationTranslation matrices? I am trying it but without any success.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload