Skip to content

daBlesr/jme-mesh-to-heightmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

jme-mesh-to-heightmap

jMonkeyEngine Mesh to Heightmap Util

usage

float scale = 0.052f;
int sizeMap = 256;
int patchSize = 65;

Geometry terrain = ((Geometry) ModelLoader.loadModel(
    assetManager,
    new File("terrain/map2.j3o"))
);

terrain.scale(scale);

MeshBasedHeightMap meshBasedHeightMap = new MeshBasedHeightMap(terrain.getMesh(), sizeMap);
meshBasedHeightMap.load();
meshBasedHeightMap.setHeightScale(scale);

terrainNode = new Node("terrain");

RigidBodyControl mapRigidBody = new RigidBodyControl(
    new HeightfieldCollisionShape(
        new TerrainQuad("my terrain", patchSize, sizeMap + 1, meshBasedHeightMap.getScaledHeightMap()),
        Vector3f.UNIT_XYZ
    ),
    0
);

terrainNode.addControl(mapRigidBody);
getPhysicsSpace().add(mapRigidBody);

terrainNode.attachChild(terrain);


About

jMonkeyEngine Mesh to Heightmap Util

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages