Skip to content

3D coordinate and heightmap #49

Answered by fabmax
Protoxy22 asked this question in Q&A
Discussion options

You must be logged in to vote

If it's only for rendering simply setting the size within the grid block should do the trick:

addColorMesh {
    generate {
        grid {
            sizeX = 2048f
            sizeY = 2048f
            useHeightMap(heightMap)
        }
    }
}

In case you also want to use physics you can create your terrain body and then generate the mesh from the physics geometry somewhat like this:

    val hfGeom = HeightFieldGeometry(HeightField(heightMap, 1f, 1f))
    terrainBody = RigidStatic()
    terrainBody.attachShape(Shape(hfGeom, Physics.defaultMaterial))

    addColorMesh {
        generate {
            hfGeom.generateMesh(this)
        }
        // ... shader and stuff
    }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Protoxy22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants