I'm trying to create an infinite playable world with Jogl, Jbullet, and OpenSimplexNoise (OSN). I'm generating the world with OSN, rendering it successfully, but I don't know how to add it to the world/collision system.
I found the btHeightfieldTerrainShape class, but it isn't implemented in Java. I tried to use BvhTriangleMeshShape too, but i don't understand how it work.
I have 3 values of generation:
I'm using this code for generate heightmap:
/**
* Generate all height in the chunk p[cx][cy].
*/
private float[][] genPerlinMap(int[] p) {
float[][] pts = new float[chunkSize*smooth+1][chunkSize*smooth+1];
for(int i1=0;i1<chunkSize*smooth+1;i1++){
for(int i2=0;i2<chunkSize*smooth+1;i2++){
pts[i1][i2] = (float) (osp.eval(
(p[0]*chunkSize+i1/(float)(smooth))/(float) (mapSize),
(p[1]*chunkSize+i2/(float)(smooth))/(float) (mapSize)
)+1)*0.5f*mapSize;
}
}
return pts;
}
Does someone know how to add this ?
I found a solution: use https://github.com/bubblecloud/jbullet (jbullet from github) with the code here: https://github.com/bubblecloud/jbullet/commit/a5da8cdc679e998ef3a8605ee9b3cd5f94d71fee .
Thanks gouessej for the jbullet github link :)