diff -r 98191d5d5af6 -r fba447c2485c scripts/machine.js --- a/scripts/machine.js Sat Apr 16 23:34:31 2011 +0200 +++ b/scripts/machine.js Sun Apr 17 01:27:49 2011 +0200 @@ -65,8 +65,10 @@ this.speed = speed; this.rotMatrix = mat4.create(); this.transMatrix = mat4.create(); + this.matrix = mat4.create(); mat4.identity(this.rotMatrix); mat4.identity(this.transMatrix); + mat4.identity(this.matrix); } Camera.prototype.moveLeft = function() { @@ -98,10 +100,14 @@ } Camera.prototype.update = function() { - mat4.rotate(this.rotMatrix, -this.pitch, [1, 0, 0]); - mat4.rotate(this.rotMatrix, -this.yaw, [0, 1, 0]); - mat4.translate(this.transMatrix, [-this.x, -this.y, -this.z]); - //mat4.multiply(this.matrix, newMatrix); + //mat4.rotate(this.rotMatrix, -this.pitch, [1, 0, 0]); + //mat4.rotate(this.rotMatrix, -this.yaw, [0, 1, 0]); + //mat4.translate(this.transMatrix, [-this.x, -this.y, -this.z]); + mat4.translate(this.matrix, [-this.x, -this.y, -this.z]); + //mat4.rotate(this.matrix, -this.pitch, [1, 0, 0]); + //mat4.rotate(this.matrix, -this.yaw, [0, 1, 0]); + + this.clear(); //mat4.rotate(mvMatrix, -camera.pitch, [1, 0, 0]); //mat4.rotate(mvMatrix, -camera.yaw, [0, 1, 0]); @@ -109,7 +115,8 @@ } Camera.prototype.clear = function() { - this.pitch = this.yaw = this.x = this.y = this.z = 0; + this.x = this.y = this.z = 0; + //this.pitch = this.yaw = 0; } function Controller(keyActionMap, mouseActionMap, camera, machine, renderer) @@ -244,10 +251,16 @@ mat4.perspective(45, viewport.width / viewport.height, 0.1, 100.0, pMatrix); mat4.identity(mvMatrix); - mat4.multiply(mvMatrix, camera.transMatrix); - mat4.multiply(mvMatrix, camera.rotMatrix); + //mat4.multiply(mvMatrix, camera.rotMatrix); + //mat4.multiply(mvMatrix, camera.transMatrix); + mat4.rotate(mvMatrix, -camera.pitch, [1, 0, 0]); + mat4.rotate(mvMatrix, -camera.yaw, [0, 1, 0]); + mat4.multiply(mvMatrix, camera.matrix); + //mat4.rotate(camera.matrix, -camera.pitch, [1, 0, 0]); + //mat4.rotate(camera.matrix, -camera.yaw, [0, 1, 0]); + //camera.yaw = camera.pitch = 0; + - this.pushMatrix(mvMatrix); mat4.rotate(mvMatrix, scene.rotation.x, [1, 0, 0]);