1
0
mirror of https://github.com/Dejvino/roadtrip synced 2024-11-13 04:27:30 +00:00

Map: improved tree placement to look more natural.

This commit is contained in:
Dejvino 2017-01-21 19:06:20 +01:00
parent 4a87dbc674
commit f75fdecf07
3 changed files with 12 additions and 4 deletions

View File

@ -1,4 +1,4 @@
package roadtrip.view.model;
package roadtrip.model;
import roadtrip.model.AbstractProceduralBlock;
import roadtrip.model.ProceduralMapQuadBlock;

View File

@ -179,9 +179,16 @@ public class GameWorldView {
//System.out.println("Grid @ " + terrainGrid.getLocalTranslation() + " s " + terrainGrid.getLocalScale());
//System.out.println("Quad " + quad.getName() + " @ " + quad.getLocalTranslation());
float cellSize = terrainGrid.getPatchSize() * terrainGrid.getLocalScale().x * 2f;
for (int i = 0; i < quadRand.nextInt(1000); i++) {
Vector2f pos = new Vector2f((quadRand.nextFloat() - 0.5f) * cellSize, (quadRand.nextFloat() - 0.5f) * cellSize)
.addLocal(quad.getWorldTranslation().x, quad.getWorldTranslation().z);
Vector2f prevPos = null;
for (int i = 0; i < quadRand.nextInt(10000); i++) {
Vector2f pos;
if (prevPos == null || quadRand.nextFloat() < 0.2f) {
pos = new Vector2f((quadRand.nextFloat() - 0.5f) * cellSize, (quadRand.nextFloat() - 0.5f) * cellSize)
.addLocal(quad.getWorldTranslation().x, quad.getWorldTranslation().z);
} else {
pos = new Vector2f((quadRand.nextFloat() - 0.5f) * 20f, (quadRand.nextFloat() - 0.5f) * 20f).addLocal(prevPos);
}
prevPos = pos;
float height = quad.getHeight(pos);
Vector3f location = new Vector3f(pos.x, height, pos.y)
.addLocal(terrainGrid.getWorldTranslation());

View File

@ -1,5 +1,6 @@
package roadtrip.view.model;
import roadtrip.model.ProceduralMapBlock;
import roadtrip.view.VehicleNode;
import java.util.LinkedList;