Skip to content

Commit

Permalink
Assign LOD to golf features
Browse files Browse the repository at this point in the history
  • Loading branch information
tordanik committed Nov 13, 2024
1 parent fa2fa3e commit 4cbb35a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/osm2world/core/world/modules/GolfModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.osm2world.core.math.algorithms.TriangulationUtil.triangulationXZtoXYZ;
import static org.osm2world.core.target.common.material.Materials.PLASTIC;
import static org.osm2world.core.target.common.material.Materials.SAND;
import static org.osm2world.core.target.common.mesh.LevelOfDetail.*;
import static org.osm2world.core.target.common.texcoord.NamedTexCoordFunction.GLOBAL_X_Z;
import static org.osm2world.core.target.common.texcoord.NamedTexCoordFunction.STRIP_WALL;
import static org.osm2world.core.target.common.texcoord.TexCoordUtil.texCoordLists;
Expand Down Expand Up @@ -113,12 +114,22 @@ public Collection<PolygonShapeXZ> getRawGroundFootprint() {
@Override
public void buildMeshesAndModels(Target target) {

/* triangulate the bunker's area normally at low LOD */

target.setCurrentLodRange(LOD0, LOD1);

List<TriangleXYZ> basicTriangulation = getTriangulation();
target.drawTriangles(SAND, basicTriangulation,
triangleTexCoordLists(basicTriangulation, SAND, GLOBAL_X_Z));

/* draw the bunker as a depression by shrinking the outline polygon and lowering it at each step.
*
* The first step gets special handling and is primarily intended for bunkers in uneven terrain.
* It involves an almost vertical drop towards the lowest point of the bunker outline
* that is textured with ground, not sand. */

target.setCurrentLodRange(LOD2, LOD4);

List<TriangleXYZ> resultingTriangulation = new ArrayList<>();

double[] dropSteps = {-0.03, -0.07, -0.05, -0.02};
Expand Down Expand Up @@ -279,6 +290,8 @@ public void buildMeshesAndModels(Target target) {

/* render pin */

target.setCurrentLodRange(LOD3, LOD4);

PolygonXYZ upperHoleRing = pinConnectors.getPosXYZ(pinHoleLoop);

drawPin(target, pinPosition, upperHoleRing.vertices());
Expand Down

0 comments on commit 4cbb35a

Please sign in to comment.