Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can have a float variable for rotation and create rotation matrix from it once then store it. Every frame you should have the world matrix updated like this: modelToWorldTransform = rotationTransform * modelToWorldTransform; See wikipedia for creating the rotation matrix around y: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations" rel="nofollow">http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations</a></p> <p>EDIT: I suppose your having trouble with affine transformations. To move (no matter how - translate, rotate) an object in the world, you have to apply a transformation to it. Currently, you are applying one transformation, which is translation to the position 0, 0, 3. So far, so good. But your triangle is static(it doesn't move). So to rotate it, you need to apply another transformation (represented by a matrix, again). But if you always apply one and the same rotation, the triangle will be rotated against its original transform but it won't move once again. So you need to apply a rotation every frame, store the result in the modeltoworldtransform and then on next frame repeat the step. e.g in the renderCallback:</p> <pre><code>static mat4 modelToWorldTransform = mat4(1.0f); static mat4 rotationTransform = &lt;rotation by the described in wiki way&gt;; modelToWorldTransform = rotationTransform * modelToWorldTransform; </code></pre> <p>Also, order of multiplying matrices matters, because their multiplication (which we use to get transform from object to camera space) is not commutative and A * B is different from B * A. I highly recommend you to read more about linear algebra and it will help you understand what happens "behind the scenes". Many books about graphics for game devs explain it in a pretty good and understandable way. "Mathematics for 3D Game Programming and Computer Graphics" by Eric Lengyel kicks ass. It even helped me when I studied maths in university ;).</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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