public Matrix4f InitRotation(float x, float y, float z) { Matrix4f rx = new Matrix4f(); Matrix4f ry = new Matrix4f(); Matrix4f rz = new Matrix4f(); rz.m[0, 0] = (float)Math.Cos(z); rz.m[0, 1] = -(float)Math.Sin(z); rz.m[0, 2] = 0; rz.m[0, 3] = 0; rz.m[1, 0] = (float)Math.Sin(z); rz.m[1, 1] = (float)Math.Cos(z); rz.m[1, 2] = 0; rz.m[1, 3] = 0; rz.m[2, 0] = 0; rz.m[2, 1] = 0; rz.m[2, 2] = 1; rz.m[2, 3] = 0; rz.m[3, 0] = 0; rz.m[3, 1] = 0; rz.m[3, 2] = 0; rz.m[3, 3] = 1; rx.m[0, 0] = 1; rx.m[0, 1] = 0; rx.m[0, 2] = 0; rx.m[0, 3] = 0; rx.m[1, 0] = 0; rx.m[1, 1] = (float)Math.Cos(x); rx.m[1, 2] = -(float)Math.Sin(x); rx.m[1, 3] = 0; rx.m[2, 0] = 0; rx.m[2, 1] = (float)Math.Sin(x); rx.m[2, 2] = (float)Math.Cos(x); rx.m[2, 3] = 0; rx.m[3, 0] = 0; rx.m[3, 1] = 0; rx.m[3, 2] = 0; rx.m[3, 3] = 1; ry.m[0, 0] = (float)Math.Cos(y); ry.m[0, 1] = 0; ry.m[0, 2] = -(float)Math.Sin(y); ry.m[0, 3] = 0; ry.m[1, 0] = 0; ry.m[1, 1] = 1; ry.m[1, 2] = 0; ry.m[1, 3] = 0; ry.m[2, 0] = (float)Math.Sin(y); ry.m[2, 1] = 0; ry.m[2, 2] = (float)Math.Cos(y); ry.m[2, 3] = 0; ry.m[3, 0] = 0; ry.m[3, 1] = 0; ry.m[3, 2] = 0; ry.m[3, 3] = 1; m = rz.Mul(ry.Mul(rx)).GetM(); return(this); }
private void RenderGame() { target.BeginRender(); target.Clear(); rotCounter += (float)timeDelta; Matrix4f translation = new Matrix4f().InitTranslation(0.0f, 0.0f, 3.0f); Matrix4f rotation = new Matrix4f().InitRotation(0.0f, rotCounter, 0.0f); Matrix4f transform = projection.Mul(translation.Mul(rotation)); target.FillTriangle(maxYVert.Transform(transform), midYVert.Transform(transform), minYVert.Transform(transform)); target.EndRender(); Refresh(); }
public Matrix4f InitRotation(float x, float y, float z) { Matrix4f rx = new Matrix4f(); Matrix4f ry = new Matrix4f(); Matrix4f rz = new Matrix4f(); rz.m[0, 0] = (float)Math.Cos(z);rz.m[0, 1] = -(float)Math.Sin(z);rz.m[0, 2] = 0; rz.m[0, 3] = 0; rz.m[1, 0] = (float)Math.Sin(z);rz.m[1, 1] = (float)Math.Cos(z);rz.m[1, 2] = 0; rz.m[1, 3] = 0; rz.m[2, 0] = 0; rz.m[2, 1] = 0; rz.m[2, 2] = 1; rz.m[2, 3] = 0; rz.m[3, 0] = 0; rz.m[3, 1] = 0; rz.m[3, 2] = 0; rz.m[3, 3] = 1; rx.m[0, 0] = 1; rx.m[0, 1] = 0; rx.m[0, 2] = 0; rx.m[0, 3] = 0; rx.m[1, 0] = 0; rx.m[1, 1] = (float)Math.Cos(x);rx.m[1, 2] = -(float)Math.Sin(x);rx.m[1, 3] = 0; rx.m[2, 0] = 0; rx.m[2, 1] = (float)Math.Sin(x);rx.m[2, 2] = (float)Math.Cos(x);rx.m[2, 3] = 0; rx.m[3, 0] = 0; rx.m[3, 1] = 0; rx.m[3, 2] = 0; rx.m[3, 3] = 1; ry.m[0, 0] = (float)Math.Cos(y);ry.m[0, 1] = 0; ry.m[0, 2] = -(float)Math.Sin(y);ry.m[0, 3] = 0; ry.m[1, 0] = 0; ry.m[1, 1] = 1; ry.m[1, 2] = 0; ry.m[1, 3] = 0; ry.m[2, 0] = (float)Math.Sin(y);ry.m[2, 1] = 0; ry.m[2, 2] = (float)Math.Cos(y);ry.m[2, 3] = 0; ry.m[3, 0] = 0; ry.m[3, 1] = 0; ry.m[3, 2] = 0; ry.m[3, 3] = 1; m = rz.Mul(ry.Mul(rx)).GetM(); return this; }