make the cube from getting started guide move

31 views
Skip to first unread message

Leonardo Paiva

unread,
Dec 26, 2015, 6:46:26 PM12/26/15
to turbulenz-engine-users
Hello, 

- i`m just starting with turbulenz and made the http://docs.turbulenz.com/starter/getting_started_guide.html guide, now i have a cube rotating, i want to move the cube and place other cubes, how can i do that?

thanks

David Fooks

unread,
Jan 4, 2016, 5:54:26 AM1/4/16
to turbulenz-engine-users
From step 4 do this instead:

if (technique)
{
    var angle = (TurbulenzEngine.time / (4 * Math.PI));
    angle = (angle - Math.floor(angle)) * (2 * Math.PI);
    
    var rotation = md.quatFromAxisRotation(upVector, angle);
    // make the cube wobble left and right
    var translation = md.v3Build(Math.sin(TurbulenzEngine.time), 0.0, 0.0);
    var scale = md.v3Build(1.0, 1.0, 1.0);
    var modelTransform = md.m43FromRTS(rotation, translation, scale);

    techniqueParameters.worldViewProjection =
        md.m43MulM44(modelTransform,
                     camera.viewProjectionMatrix,
                     techniqueParameters.worldViewProjection);

    gd.setTechnique(technique);
    gd.setTechniqueParameters(techniqueParameters);

    gd.setStream(vertexBuffer, semantics);
    gd.draw(gd.PRIMITIVE_TRIANGLES, numVerts, 0);
}

To make more cubes just copy and paste the above code twice (or use a loop) with a different translation.
Reply all
Reply to author
Forward
0 new messages