1

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:

  • int smooth: the number of division in one meter
  • int viewDistance: the number of chunk to draw in one axis
  • int chunkSize: the number on meter in one chunk

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 ?

Jonathan Drapeau
  • 2,610
  • 2
  • 26
  • 32
  • At first, there is nothing "infinite" in computer science but you might create huge levels. Secondly, I'm sad to write that but I'm not sure that JBullet is still maintained, why not having a look at the Java Bullet binding of JMonkeyEngine 3 which is actively maintained? – gouessej Aug 11 '15 at 08:50
  • i know infinite isn't real, and for JME3, I'm trying to make my own game engine. I didn't know that JBullet isn't maintained :( I will take a look at JME3... – Hugo Flores - Slaynash Aug 11 '15 at 14:10
  • I don't suggest you to use JMonkeyEngine 3, I suggest you to use only its Java binding for the Bullet API as a replacement of JBullet with JOGL and OSN. If you decide to switch to JMonkeyEngine 3, you can use my JOGL renderer with it. I wrote my own game engine in 2007, keep in mind that it's very time consuming and you have no chance to make something technically "better" than an engine maintained by tens of contributors except if you're a genius. If you want to focus on game programming, don't create your own engine. Finally, the very latest version of JBullet was released in October 2010. – gouessej Aug 11 '15 at 14:38
  • If you want to stick to JBullet, look at some forks on Github including this one: https://github.com/bubblecloud/jbullet – gouessej Aug 11 '15 at 14:42
  • OK, thanks you. Sorry for the late answer i didn't have internet earlier – Hugo Flores - Slaynash Aug 14 '15 at 19:52
  • 1
    I find what i need: https://github.com/bubblecloud/jbullet/commit/a5da8cdc679e998ef3a8605ee9b3cd5f94d71fee – Hugo Flores - Slaynash Aug 14 '15 at 20:44

1 Answers1

1

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 :)

  • You're welcome. Let us know whether this fork is reliable. – gouessej Aug 15 '15 at 06:45
  • I havn't test it yet, but i think i can use "public HeightfieldTerrainShape(int, int, float[], float, float, float, int, boolean)" (line 107 - 108) to create a HeightfieldTerrainShape shape (i will post the code used later, i'm currently working on a lua program) – Hugo Flores - Slaynash Aug 15 '15 at 11:11