private static void Window_Load(object sender, EventArgs e) { SolidColorMeshShader.Load(); SolidColorMeshShader.SharedInstance.Use(); camera.Projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(40.0f), (float)window.Width / (float)window.Height, 1.0f, 10000.0f); //camera.Projection = Matrix4.CreateOrthographic(10.0f * (float)window.Width / (float)window.Height, 10.0f, 1.0f, 10000.0f); cameraUp = new Vector4(0.0f, 1.0f, 0.0f, 1.0f); cameraRight = new Vector4(1.0f, 0.0f, 0.0f, 1.0f); cameraPos = new Vector4(0.0f, 10.0f, 40.0f, 1.0f); camera.View = Matrix4.LookAt(cameraPos.Xyz, Vector3.Zero, cameraUp.Xyz); //camera.View = Matrix4.Identity; /* * sphere = new ModelMesh() { * Transform = new World3DShaderTransform(Matrix4.CreateScale(8.0f)), * DefaultShader = SolidColorMeshShader.SharedInstance, * DefaultVertexBuffer = new VertexBuffer() { DisposalLevel = ItemDisposalLevel.ModelMesh }, * DefaultMaterial = new SolidColorShaderMaterial(new Vector4(0.0f, 1.0f, 1.0f, 1.0f)), * IndexBuffer = new IndexBuffer() { DisposalLevel = ItemDisposalLevel.ModelMesh } * }; */ sphere = ShapeGenerator.MakeSphere <FirimenticEngine.CustomComponents.Graphics.Vertices.VertexPositioned>( 10, 20, FirimenticEngine.Graphics.Axii.Y, PrimitiveType.Lines, SolidColorMeshShader.SharedInstance, FirimenticEngine.Graphics.VertexFormat.Position ); sphere.Transform = new World3DShaderTransform(Matrix4.CreateScale(8.0f)); sphere.DefaultMaterial = sphere.Parts[0].Material = new SolidColorShaderMaterial(new Vector4(0.0f, 1.0f, 1.0f, 1.0f)); /* * VertexPositioned[] verts = new VertexPositioned[] { * new VertexPositioned( 0.0f, 0.0f, 0.0f), * new VertexPositioned( 1.0f, 0.0f, 0.0f), * new VertexPositioned(-1.0f, 0.0f, 0.0f), * new VertexPositioned( 0.0f, 1.0f, 0.0f), * new VertexPositioned( 0.0f,-1.0f, 0.0f), * new VertexPositioned( 0.0f, 0.0f, 1.0f), * new VertexPositioned( 0.0f, 0.0f,-1.0f) * }; * * ushort[] indcs = new ushort[] { * 2, 0, 4 * }; */ /* * VertexPositioned[] verts = new VertexPositioned[] { * new VertexPositioned(-1.0f, 1.0f, 1.0f), * new VertexPositioned( 1.0f, 1.0f, 1.0f), * new VertexPositioned( 1.0f,-1.0f, 1.0f), * new VertexPositioned(-1.0f,-1.0f, 1.0f), * new VertexPositioned(-1.0f, 1.0f,-1.0f), * new VertexPositioned( 1.0f, 1.0f,-1.0f), * new VertexPositioned( 1.0f,-1.0f,-1.0f), * new VertexPositioned(-1.0f,-1.0f,-1.0f) * }; * * ushort[] indcs = new ushort[] { * 0, 1, 2, 3, 0, * 4, 7, 3, 2, * 6, 7, 6, * 5, 4, 5, * 1, * 3, 2, 0, * 7, 4, 3, * 6, 2, 7, * 5, 6, 4, * 1, 0, 5, * 2, 1, 6 * }; */ /* * VertexPositioned[] verts = new VertexPositioned[19 * 40 + 2]; * * float inc = 9.0f * MathHelper.Pi / 180.0f; * float fullCirc = 2 * MathHelper.Pi - float.Epsilon; * float halfCirc = MathHelper.Pi - float.Epsilon; * float scale = 1.0f; * int ind = 0; * * verts[ind++] = new VertexPositioned(Vector3.UnitY * scale); * verts[ind++] = new VertexPositioned(Vector3.UnitY * -scale); * for (float lng = 0; lng < fullCirc; lng += inc) { * for (float lat = inc; lat < halfCirc; lat += inc) { * Matrix4 rot = Matrix4.CreateRotationZ(lng) * Matrix4.CreateRotationX(lat); * Vector3 pos = (Vector3.UnitY * scale).Transform(ref rot); * verts[ind++] = new VertexPositioned(pos); * } * } * * * ushort[] indcs = new ushort[20 * (2 + 19 + 19) + 1 + 19 * (40 + 1)]; * * ind = 0; * for (ushort lngInd = 0; lngInd < 20; lngInd++) { * indcs[ind++] = 0; * for (ushort latInd = 2; latInd < 21; latInd++) { * indcs[ind++] = (ushort)(lngInd * 19 + latInd); * } * indcs[ind++] = 1; * for (ushort latInd = 20; latInd > 1; latInd--) { * indcs[ind++] = (ushort)((lngInd + 20) * 19 + latInd); * } * } * indcs[ind++] = 0; * for (ushort latInd = 2; latInd < 21; latInd++) { * for (ushort lngInd = 0; lngInd < 40; lngInd++) { * indcs[ind++] = (ushort)(lngInd * 19 + latInd); * } * indcs[ind++] = latInd; * } */ //sphere.DefaultVertexBuffer.SetData(VertexFormat.Position, verts); //sphere.IndexBuffer.SetData(indcs); //new ModelMeshPart(sphere, null, null, null, PrimitiveType.LineStrip, indcs.Length, 0); }