scripts/machine.js
changeset 16 fba447c2485c
parent 15 98191d5d5af6
child 17 8b187fa957ad
     1.1 --- a/scripts/machine.js	Sat Apr 16 23:34:31 2011 +0200
     1.2 +++ b/scripts/machine.js	Sun Apr 17 01:27:49 2011 +0200
     1.3 @@ -65,8 +65,10 @@
     1.4      this.speed = speed;
     1.5      this.rotMatrix = mat4.create();
     1.6      this.transMatrix = mat4.create();
     1.7 +    this.matrix = mat4.create();
     1.8      mat4.identity(this.rotMatrix);
     1.9      mat4.identity(this.transMatrix);
    1.10 +    mat4.identity(this.matrix);
    1.11  }
    1.12  Camera.prototype.moveLeft = function()
    1.13  {
    1.14 @@ -98,10 +100,14 @@
    1.15  }
    1.16  Camera.prototype.update = function()
    1.17  {
    1.18 -    mat4.rotate(this.rotMatrix, -this.pitch, [1, 0, 0]);
    1.19 -    mat4.rotate(this.rotMatrix, -this.yaw, [0, 1, 0]);
    1.20 -    mat4.translate(this.transMatrix, [-this.x, -this.y, -this.z]);
    1.21 -    //mat4.multiply(this.matrix, newMatrix);
    1.22 +    //mat4.rotate(this.rotMatrix, -this.pitch, [1, 0, 0]);
    1.23 +    //mat4.rotate(this.rotMatrix, -this.yaw, [0, 1, 0]);
    1.24 +    //mat4.translate(this.transMatrix, [-this.x, -this.y, -this.z]);
    1.25 +    mat4.translate(this.matrix, [-this.x, -this.y, -this.z]);
    1.26 +    //mat4.rotate(this.matrix, -this.pitch, [1, 0, 0]);
    1.27 +    //mat4.rotate(this.matrix, -this.yaw, [0, 1, 0]);
    1.28 +    
    1.29 +    
    1.30      this.clear();
    1.31      //mat4.rotate(mvMatrix, -camera.pitch, [1, 0, 0]);
    1.32      //mat4.rotate(mvMatrix, -camera.yaw, [0, 1, 0]);
    1.33 @@ -109,7 +115,8 @@
    1.34  }
    1.35  Camera.prototype.clear = function()
    1.36  {
    1.37 -   this.pitch = this.yaw = this.x = this.y = this.z = 0;
    1.38 +   this.x = this.y = this.z = 0;
    1.39 +   //this.pitch = this.yaw = 0;
    1.40  }
    1.41  
    1.42  function Controller(keyActionMap, mouseActionMap, camera, machine, renderer)
    1.43 @@ -244,10 +251,16 @@
    1.44      mat4.perspective(45, viewport.width / viewport.height, 0.1, 100.0, pMatrix);
    1.45  
    1.46      mat4.identity(mvMatrix);
    1.47 -    mat4.multiply(mvMatrix, camera.transMatrix);
    1.48 -    mat4.multiply(mvMatrix, camera.rotMatrix);
    1.49 +    //mat4.multiply(mvMatrix, camera.rotMatrix);
    1.50 +    //mat4.multiply(mvMatrix, camera.transMatrix);
    1.51 +    mat4.rotate(mvMatrix, -camera.pitch, [1, 0, 0]);
    1.52 +    mat4.rotate(mvMatrix, -camera.yaw, [0, 1, 0]);
    1.53 +    mat4.multiply(mvMatrix, camera.matrix);
    1.54 +    //mat4.rotate(camera.matrix, -camera.pitch, [1, 0, 0]);
    1.55 +    //mat4.rotate(camera.matrix, -camera.yaw, [0, 1, 0]);
    1.56 +    //camera.yaw = camera.pitch = 0;
    1.57 +   
    1.58      
    1.59 -
    1.60      this.pushMatrix(mvMatrix);
    1.61  
    1.62      mat4.rotate(mvMatrix, scene.rotation.x, [1, 0, 0]);