public void MatrixMode(int mode) { if (mode != CurrentMode) { switch (mode) { case MODELVIEW: { ProjectionMatrix = CurrentMatrix; CurrentMatrix = ModelviewMatrix; CurrentMode = MODELVIEW; break; } case PROJECTION: { ModelviewMatrix = CurrentMatrix; CurrentMatrix = ProjectionMatrix; CurrentMode = PROJECTION; break; } default: break; } } }
public static mat4 outerProcuct(vec4 c, vec4 r) { mat4 a = new mat4(); a[0,0] = c.x * r.x; a[1,0] = c.x * r.y; a[2,0] = c.x * r.z; a[3,0] = c.x * r.w; a[0,1] = c.y * r.x; a[1,1] = c.y * r.y; a[2,1] = c.y * r.z; a[3,1] = c.y * r.w; a[0,2] = c.z * r.x; a[1,2] = c.z * r.y; a[2,2] = c.z * r.z; a[3,2] = c.z * r.w; a[0,3] = c.w * r.x; a[1,3] = c.w * r.y; a[2,3] = c.w * r.z; a[3,3] = c.w * r.w; return a; }
public static mat4 inverse(mat4 m) { double[,] i = m.GetInverse(); mat4 r = new mat4(i); return r; }
public static mat4 transpose(mat4 m) { return (mat4)m.Transpose; }
public static mat4 matrixCompMult(mat4 x, mat4 y) { mat4 r = new mat4(MatrixSquare.ComponentMultiply(x, y)); return r; }
public void Frustum(float left, float right, float bottom, float top, float zNear, float zFar) { CurrentMatrix = (mat4)(Matrix4Util.FrustumMatrix(left, right, bottom, top, zNear, zFar) * CurrentMatrix); }
public void Ortho(float left, float right, float bottom, float top, float zNear, float zFar) { CurrentMatrix = (mat4)(Matrix4Util.OrthoMatrix(left, right, bottom, top, zNear, zFar) * CurrentMatrix); }
public void Rotate(float angle, vec3 axis) { CurrentMatrix = (mat4)(Matrix4Util.RotateMatrix(angle, axis) * CurrentMatrix); }
public void Translate(vec3 t) { CurrentMatrix = (mat4)(Matrix4Util.Translate(ref t) * CurrentMatrix); }
public void Scale(vec3 s) { CurrentMatrix = (mat4)(Matrix4Util.ScaleMatrix(ref s) * CurrentMatrix); }
public void MultMatrix(mat4 m) { CurrentMatrix = (mat4)(m * CurrentMatrix); }
public void LoadMatrix(mat4 m) { CurrentMatrix = m; }
public void LoadIdentity() { CurrentMatrix = Matrix4Util.IdentityMatrix(); }