Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I´ve encountered the same problems (seen weird distortions and everything else), my solution based on the <a href="http://developer.android.com/training/graphics/opengl/motion.html" rel="nofollow noreferrer" title="Android Training &gt; Displaying Graphics with OpenGL ES &gt; Adding Motion">Android Training > Displaying Graphics with OpenGL ES > Adding Motion</a> below.</p> <p>(Head over to my detailed post for at if needed: <a href="https://stackoverflow.com/questions/13480043/opengl-es-android-matrix-transformations/17292894#17292894">OpenGL ES Android Matrix Transformations</a>.)</p> <ol> <li><p>Set a <em>mModelMatrix</em> to identity Matrix</p> <pre><code>Matrix.setIdentityM(mModelMatrix, 0); // initialize to identity matrix </code></pre></li> <li><p>Apply translation to the <em>mModelMatrix</em></p> <pre><code>Matrix.translateM(mModelMatrix, 0, -0.5f, 0, 0); // translation to the left </code></pre></li> <li><p>Apply rotation to a <em>mRotationMatrix</em> (angles in degrees)</p> <pre><code>Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, -1.0f); </code></pre></li> <li><p>Combine rotation and translation via <em>Matrix.multiplyMM</em></p> <pre><code>mTempMatrix = mModelMatrix.clone(); Matrix.multiplyMM(mModelMatrix, 0, mTempMatrix, 0, mRotationMatrix, 0); </code></pre></li> <li><p>Combine the model matrix with the projection and camera view</p> <pre><code>mTempMatrix = mMVPMatrix.clone(); Matrix.multiplyMM(mMVPMatrix, 0, mTempMatrix, 0, mModelMatrix, 0); </code></pre></li> </ol>
 

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