mirror of
https://github.com/Dejvino/roadtrip
synced 2024-11-22 07:52:36 +00:00
Map: improved tree placement to look more natural.
This commit is contained in:
parent
4a87dbc674
commit
f75fdecf07
@ -1,4 +1,4 @@
|
|||||||
package roadtrip.view.model;
|
package roadtrip.model;
|
||||||
|
|
||||||
import roadtrip.model.AbstractProceduralBlock;
|
import roadtrip.model.AbstractProceduralBlock;
|
||||||
import roadtrip.model.ProceduralMapQuadBlock;
|
import roadtrip.model.ProceduralMapQuadBlock;
|
@ -179,9 +179,16 @@ public class GameWorldView {
|
|||||||
//System.out.println("Grid @ " + terrainGrid.getLocalTranslation() + " s " + terrainGrid.getLocalScale());
|
//System.out.println("Grid @ " + terrainGrid.getLocalTranslation() + " s " + terrainGrid.getLocalScale());
|
||||||
//System.out.println("Quad " + quad.getName() + " @ " + quad.getLocalTranslation());
|
//System.out.println("Quad " + quad.getName() + " @ " + quad.getLocalTranslation());
|
||||||
float cellSize = terrainGrid.getPatchSize() * terrainGrid.getLocalScale().x * 2f;
|
float cellSize = terrainGrid.getPatchSize() * terrainGrid.getLocalScale().x * 2f;
|
||||||
for (int i = 0; i < quadRand.nextInt(1000); i++) {
|
Vector2f prevPos = null;
|
||||||
Vector2f pos = new Vector2f((quadRand.nextFloat() - 0.5f) * cellSize, (quadRand.nextFloat() - 0.5f) * cellSize)
|
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);
|
.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);
|
float height = quad.getHeight(pos);
|
||||||
Vector3f location = new Vector3f(pos.x, height, pos.y)
|
Vector3f location = new Vector3f(pos.x, height, pos.y)
|
||||||
.addLocal(terrainGrid.getWorldTranslation());
|
.addLocal(terrainGrid.getWorldTranslation());
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package roadtrip.view.model;
|
package roadtrip.view.model;
|
||||||
|
|
||||||
|
import roadtrip.model.ProceduralMapBlock;
|
||||||
import roadtrip.view.VehicleNode;
|
import roadtrip.view.VehicleNode;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
Loading…
Reference in New Issue
Block a user