小编Ran*_*der的帖子

如何在Java中生成森林

我正在创建一个可以完美生成景观的游戏,一个星期前,我已经创建了一个基本的“森林”生成系统,只是一个for循环需要一个大块,并将随机数量的树木放置在随机位置。但这并不能给我带来希望的结果。

for(int t = 0; t <= randomForTrees.nextInt(maxTreesPerChunk); t++){

    // generates random locations for the X, Z positions\\
    // the Y position is the height on the terrain gain with the X, Z coordinates \\
    float TreeX = random.nextInt((int) (Settings.TERRAIN_VERTEX_COUNT + Settings.TERRAIN_SIZE)) + terrain.getX();
    float TreeZ = random.nextInt((int) (Settings.TERRAIN_VERTEX_COUNT + Settings.TERRAIN_SIZE)) + terrain.getZ();
    float TreeY = terrain.getTerrainHeightAtSpot(TreeX, TreeZ);

    // creates a tree entity with the previous generated positions \\
    Entity tree = new Entity(TreeStaticModel, new Vector3f(TreeX, TreeY, TreeZ), 0, …
Run Code Online (Sandbox Code Playgroud)

java opengl landscape lwjgl

5
推荐指数
0
解决办法
143
查看次数

标签 统计

java ×1

landscape ×1

lwjgl ×1

opengl ×1