Answer the question
In order to leave comments, you need to log in
Building View and Perspective Matrices for OpenGL
I work with WebGL, I don’t want to use any extraneous libraries, because I do it just for experience in mathematics.
I managed to build a working Perpective matrix, but the trouble is with the View.
this.eye = new Vec3(0,0,0);
this.up = new Vec3(0,1,0);
this.at = new Vec3(0,0,1);
this.lookAt = function(){
var zaxis = new Vec3(this.at.v.x-this.eye.v.x,this.at.v.y-this.eye.v.y,this.at.v.z-this.eye.v.z).normal();
var xaxis = this.up.cross(zaxis).normal();
var yaxis = zaxis.cross(xaxis);
return new Mat4([
xaxis.v.x,yaxis.v.x,zaxis.v.x,0,
xaxis.v.y,yaxis.v.y,zaxis.v.y,0,
xaxis.v.z,yaxis.v.z,zaxis.v.z,0,
-xaxis.dot(this.eye),-yaxis.dot(this.eye),-zaxis.dot(this.eye),1
]);
}
Answer the question
In order to leave comments, you need to log in
https://code.google.com/p/gl33lessons/wiki/Lesson03 short and to the point
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question