public void CopyFrom(VertexGrid sourceGrid) { xLength = sourceGrid.XLength; yLength = sourceGrid.YLength; zLength = sourceGrid.ZLength; cellSize = sourceGrid.CellSize; grid = new VertexGrid(sourceGrid); }
public VertexGrid(VertexGrid from) : this(from.xLength, from.yLength, from.zLength, from.cellSize) { if (from.vertices.Length != vertices.Length) { Debug.LogError("source vertices length mismatch!"); } System.Array.Copy(from.vertices, vertices, vertices.Length); }
public void ResizeGrid(int x, int y, int z) { xLength = x; yLength = y; zLength = z; xLength = Mathf.Clamp(xLength, 2, MaxVertexLength); yLength = Mathf.Clamp(yLength, 2, MaxVertexLength); zLength = Mathf.Clamp(zLength, 2, MaxVertexLength); if (grid == null || grid.Vertices == null || (xLength != grid.XLength || yLength != grid.YLength || zLength != grid.ZLength)) { grid = new VertexGrid(xLength, yLength, zLength, cellSize); } grid.PlaceVertices(CellSize); ClearSnapshot(); }
public void CookClothFabric() { using (var physics = CreatePhysicsAndScene()) { // Create a grid of triangles to be our cloth var clothGrid = new VertexGrid(25, 25); using (Cooking cooking = physics.Physics.CreateCooking()) { ClothMeshDesc clothMeshDesc = new ClothMeshDesc() { Points = clothGrid.Points, Triangles = ArrayUtil.ToByteArray(clothGrid.Indices) }; var stream = new MemoryStream(); cooking.CookClothFabric(clothMeshDesc, new Vector3(0, -9.81f, 0), stream); } } }
public void CookTriangleMesh() { using (var physics = CreatePhysicsAndScene()) { // Create a grid of triangles to be our cloth var clothGrid = new VertexGrid(25, 25); var cooking = physics.Physics.CreateCooking(); var desc = new TriangleMeshDesc() { Points = clothGrid.Points, Triangles = clothGrid.Indices }; var stream = new MemoryStream(); bool result = cooking.CookTriangleMesh(desc, stream); Assert.IsTrue(result); } }
public void CookClothFabric() { using (var physics = CreatePhysicsAndScene()) { // Create a grid of triangles to be our cloth var clothGrid = new VertexGrid(25, 25); Cooking cooking = physics.Physics.CreateCooking(); ClothMeshDesc clothMeshDesc = new ClothMeshDesc() { Points = clothGrid.Points, Triangles = clothGrid.Indices }; var stream = new MemoryStream(); bool result = cooking.CookClothFabric(clothMeshDesc, new Vector3(0, -9.81f, 0), stream); Assert.IsTrue(result); } }