public void CreateSquare() { using (MeshFactory factory = new MeshFactory()) { Mesh mesh = factory.CreateSquare(2, 2); PrintMesh(mesh); mesh.Dispose(); } }
void AddCustomGeometry() { engine.Geometry.Clear(); // This clears any meshes created by the Engine using (MeshFactory factory = new MeshFactory()) { Mesh mesh = factory.CreateGrid(10, 10, 4, 4, true); mesh.Translation = new Vector3(0, -20, 0); engine.BindMesh(mesh, 2); mesh = factory.CreateBox(0.2f, 0.5f, 1); mesh.BindToPass(engine.D3DDevice, engine.Effect, 2); engine.Geometry.Add(mesh); mesh.Translation = new Vector3(-1, 0, 4); mesh = factory.CreateSquare(5, 5); mesh.Translation = new Vector3(0,1,0); mesh.BindToPass(engine.D3DDevice, engine.Effect, 2); engine.Geometry.Add(mesh); mesh = factory.CreateSphere(2, 50, 50); mesh.BindToPass(engine.D3DDevice, engine.Effect, 2); engine.Geometry.Add(mesh); mesh.Translation = new Vector3(4, 0, -1); //mesh = factory.CreateTeapot(); //mesh.BindToPass(engine.D3DDevice, engine.Effect, "P2"); //engine.Geometry.Add(mesh); mesh = new ExpandedPlane(); (mesh as ExpandedPlane).Segments = new System.Drawing.Size(8, 8); mesh.Translation = new Vector3(0, -1, 0); mesh.Scale = new Vector3(10, 1, 10); engine.BindMesh(mesh, 2); } }