private void CreateHeightField(Scene scene, Material material) { const int rows = 25, columns = 25; const float scale = 3; var samples = CreateSampleGrid(rows, columns); var heightFieldDesc = new HeightFieldDesc() { NumberOfRows = rows, NumberOfColumns = columns, Samples = samples }; var cooking = scene.Physics.CreateCooking(); var stream = new MemoryStream(); bool cookResult = cooking.CookHeightField(heightFieldDesc, stream); stream.Position = 0; HeightField heightField = scene.Physics.CreateHeightField(stream); // var rigidActor = scene.Physics.CreateRigidStatic(); var heightFieldGeom = new HeightFieldGeometry(heightField, MeshGeometryFlag.DoubleSided, 1, scale, scale); rigidActor.CreateShape(heightFieldGeom, material); rigidActor.GlobalPose = Matrix4x4.CreateTranslation(30, 30, -32.5f); scene.AddActor(rigidActor); }
private void CreateHeightField(Scene scene, Material material) { const int rows = 25, columns = 25; const float scale = 3; var samples = CreateSampleGrid(rows, columns); var heightFieldDesc = new HeightFieldDesc() { NumberOfRows = rows, NumberOfColumns = columns, Samples = samples }; HeightField heightField = scene.Physics.CreateHeightField(heightFieldDesc); // var rigidActor = scene.Physics.CreateRigidStatic(); var heightFieldGeom = new HeightFieldGeometry(heightField, MeshGeometryFlag.DoubleSided, 1, scale, scale); rigidActor.CreateShape(heightFieldGeom, material); rigidActor.GlobalPose = Matrix.Translation(30, 30, -32.5f); scene.AddActor(rigidActor); }
public void GetHeightFieldGeometry() { var material = _physics.Physics.CreateMaterial(0.5f, 0.5f, 0.1f); const int rows = 25, columns = 25; var samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns); var heightFieldDesc = new HeightFieldDesc() { NumberOfRows = rows, NumberOfColumns = columns, Samples = samples }; var cooking = _physics.Physics.CreateCooking(); var stream = new MemoryStream(); bool cookResult = cooking.CookHeightField(heightFieldDesc, stream); stream.Position = 0; var heightField = _physics.Physics.CreateHeightField(stream); Assert.IsNotNull(heightField); var heightFieldGeometry = new HeightFieldGeometry ( heightField: heightField, flags: MeshGeometryFlag.DoubleSided, heightFieldScale: 2.3f, rowScale: 1.2f, columnScale: 1.9f ); var shape = _actor.CreateShape(heightFieldGeometry, material); // var retrievedHeightfieldGeom = shape.GetHeightFieldGeometry(); Assert.IsNotNull(retrievedHeightfieldGeom); Assert.AreEqual(heightField, retrievedHeightfieldGeom.HeightField); Assert.AreEqual(retrievedHeightfieldGeom.ColumnScale, 1.9f); Assert.AreEqual(retrievedHeightfieldGeom.RowScale, 1.2f); Assert.AreEqual(retrievedHeightfieldGeom.HeightFieldFlags, MeshGeometryFlag.DoubleSided); }
public void GetHeightFieldGeometry() { var material = _physics.Physics.CreateMaterial(0.5f, 0.5f, 0.1f); const int rows = 25, columns = 25; var samples = HeightFieldTestUtil.CreateSampleGrid(rows, columns); var heightFieldDesc = new HeightFieldDesc() { NumberOfRows = rows, NumberOfColumns = columns, Samples = samples }; var heightField = _physics.Physics.CreateHeightField(heightFieldDesc); Assert.IsNotNull(heightField); var heightFieldGeometry = new HeightFieldGeometry ( heightField: heightField, flags: MeshGeometryFlag.DoubleSided, heightFieldScale: 2.3f, rowScale: 1.2f, columnScale: 1.9f ); var shape = _actor.CreateShape(heightFieldGeometry, material); // var retrievedHeightfieldGeom = shape.GetHeightFieldGeometry(); Assert.IsNotNull(retrievedHeightfieldGeom); Assert.AreEqual(heightField, retrievedHeightfieldGeom.HeightField); Assert.AreEqual(retrievedHeightfieldGeom.ColumnScale, 1.9f); Assert.AreEqual(retrievedHeightfieldGeom.RowScale, 1.2f); Assert.AreEqual(retrievedHeightfieldGeom.HeightFieldFlags, MeshGeometryFlag.DoubleSided); }