public void onEnter() { this.shader = Game.assets.shader("test"); this.camera = new PerspecitveCamera(); this.cameraPosition = new Vector3(0f, 5f, -20f); this.camera.translate(ref cameraPosition); Vector3 target = new Vector3(0f, 0f, 0f); this.camera.lookAt(ref target); float[] vertData = new float[] { -1f, -1f, -1f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f }; uint[] indicedata = new uint[] { //front 0, 7, 3, 0, 4, 7, //back 1, 2, 6, 6, 5, 1, //left 0, 2, 1, 0, 3, 2, //right 4, 5, 6, 6, 7, 4, //top 2, 3, 6, 6, 3, 7, //bottom 0, 1, 5, 0, 5, 4 }; VertexAttributes attrs = new VertexAttributes(VertexAttribute.Position(), VertexAttribute.Color()); this.mesh = new Mesh(true, 8, 7, attrs); this.mesh.setVerticies(ref vertData); this.mesh.setIndicies(ref indicedata); this.posVector = Vector3.Zero; this.mviewdata = Matrix4.CreateTranslation(Vector3.Zero); this.rotationMatrix = Matrix4.CreateRotationX(0f); this.finalMatrix = new Matrix4(); }
public void onEnter() { this.camera = new PerspecitveCamera(MathHelper.PiOver4, Game.shared.width, Game.shared.height); this.shader = Game.assets.shader("test"); VertexAttributes attrs = new VertexAttributes(VertexAttribute.Position(), VertexAttribute.Color()); this.rawMesh = new VertexBufferObject(true, 3, 7, attrs); this.rawIndicies = new IndexBufferObject(true); float[] data = new float[] { -0.8f, -0.8f, 0f, 1f, 0f, 0f, 1.0f, 0.8f, -0.8f, 0f, 0f, 1f, 0f, 1.0f, 0f, 0.8f, 0f, 0f, 0f, 1f, 1.0f, 0.8f, 0.8f, 0f, 1f, 0f, 1f, 1.0f }; uint[] indicies = new uint[] { 0, 1, 2, 1, 2, 3 }; this.rawIndicies.setIndicies(ref indicies); this.rawMesh.setVerticies(ref data); this.mviewdata = Matrix4.Translation(0f, 0f, 0f); Vector3 cameraPosition = new Vector3(5f, 5f, 5f); this.camera.translate(ref cameraPosition); Vector3 target = new Vector3(0f, 0f, 0f); this.camera.lookAt(ref target); }