Skip to content

Commit

Permalink
added meshreduce param
Browse files Browse the repository at this point in the history
  • Loading branch information
xfischer committed Aug 12, 2021
1 parent 018dae0 commit b26675e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions DEM.Net.glTF/gtlfSharp/SharpGltfService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ModelRoot CreateNewModel()

return model;
}
public ModelRoot CreateTerrainMesh(HeightMap heightMap, GenOptions options = GenOptions.None, Matrix4x4 vectorTransform = default, bool doubleSided = true)
public ModelRoot CreateTerrainMesh(HeightMap heightMap, GenOptions options = GenOptions.None, Matrix4x4 vectorTransform = default, bool doubleSided = true, float meshReduceFactor = 0.5f)
{
Triangulation triangulation = default;
if (options.HasFlag(GenOptions.BoxedBaseElevation0))
Expand All @@ -58,7 +58,7 @@ public ModelRoot CreateTerrainMesh(HeightMap heightMap, GenOptions options = Gen
triangulation = _meshService.TriangulateHeightMap(heightMap);
}

triangulation = _meshReducer.Decimate(triangulation);
triangulation = _meshReducer.Decimate(triangulation, meshReduceFactor);

// create a basic scene
var model = CreateNewModel();
Expand Down Expand Up @@ -134,13 +134,13 @@ public ModelRoot CloneGlbWithMesh(SharpGLTF.Schema2.ModelRoot inputModel, Triang
return outputModel;
}

public ModelRoot CreateTerrainMesh(HeightMap heightMap, PBRTexture textures)
{ return AddTerrainMesh(CreateNewModel(), heightMap, textures); }
public ModelRoot AddTerrainMesh(ModelRoot model, HeightMap heightMap, PBRTexture textures)
public ModelRoot CreateTerrainMesh(HeightMap heightMap, PBRTexture textures, float reduceFactor)
{ return AddTerrainMesh(CreateNewModel(), heightMap, textures, reduceFactor); }
public ModelRoot AddTerrainMesh(ModelRoot model, HeightMap heightMap, PBRTexture textures, float reduceFactor)
{
Triangulation triangulation = _meshService.TriangulateHeightMap(heightMap);

triangulation = _meshReducer.Decimate(triangulation);
triangulation = _meshReducer.Decimate(triangulation, reduceFactor);

model = AddTerrainMesh(model, triangulation, textures);

Expand Down

0 comments on commit b26675e

Please sign in to comment.