mirror of
https://github.com/Dejvino/roadtrip
synced 2024-11-21 23:42:35 +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.ProceduralMapQuadBlock;
|
@ -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)
|
||||
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());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package roadtrip.view.model;
|
||||
|
||||
import roadtrip.model.ProceduralMapBlock;
|
||||
import roadtrip.view.VehicleNode;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
Loading…
Reference in New Issue
Block a user