void AddCustomGeometry() { engine.Geometry.Clear(); // This clears any meshes created by the Engine using (MeshFactory factory = new MeshFactory()) { Mesh mesh1 = factory.CreateGrid(4, 4, 4, 4,false); Mesh mesh2 = factory.CreateGrid(4, 4, 4, 4, false); mesh2.Translation = new Vector3(2, 0, 2); MeshOptimiser.AddMesh(mesh1, mesh2); engine.BindMesh(mesh1, 2); } }
protected virtual void CreateRegularGrid(int xTiles, int yTiles) { using (MeshFactory fact = new MeshFactory()) { Mesh grid = fact.CreateGrid(15, 15, xTiles, yTiles, true); CopyFromMesh(grid); } }
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); } }