Starting first game

Hi everybody  :smiley:

I’ve decided to start the making of a full 3d game. So far i have fiddled with directX in delphi getting some nice 2d tools but i have never worked 3d before. I have chosen jMonkey because i’m proficient with java and looks quite capable of handling the game i am thinking of. Righto!!! So the game is a Turn Based Hexagon Tiled Multiplayer World War II Skirmish type. Something along the lines of the old “advanced squad leader” table game. It is going to be much simpler in its ruleset of course but the general feel should be similar.

So beign this my first 3d game i am a little confused on where and how to start (already going through the tuts, kuddos to the authors :wink: ) so i thought that i would lay down terrain first and then start adding units and so on. Then turns and actions (and their resolutions) and finally the network code.

So here is a pic done in photoshop of how terrain would be represented within the maps.

Anyone would be so kind as to share how he would go about implementing this kind of map?  :? Actual type of object in java code? Work pipeline? etc… :stuck_out_tongue: Really lost

thanks to everyone.


Well, i wasn’t convinced of going the heightmap way for the terrain and now that i have tried it out i’m still not sure that is the way i wan’t to do it.  I hate the way hexes warp on the altitude changes. :(  But then again, it is a very simple method to implement it and maybe i should explore further to see if i cant get a nicer look to it.  :? :-o Maybe adding trees, houses and roads it won’t bother me as much.

Anyway, here is a pic of what i got so far.

Thankx fpor answering JMEstarter :wink: Any ideas are welcome.



Looks good so far to me!

Would you mind posting the code used to generate the last screen shot?  Like you, I am also new to jme and 3d programming.

Keep up the good work!

Sure, no problem. It's mostly stuff from the flagrush tuts. I only added the hex detail texture and replaced the MidpointHeightMap with a RawImageMap done in photosop.

Here the code

   private void buildTerrain() {
      // Generate a random terrain data
      // MidPointHeightMap heightMap = new MidPointHeightMap(64, 1f);      
      // FaultFractalHeightMap heightMap = new FaultFractalHeightMap(64, 100, 1,100, 0.9f );   
      // FluidSimHeightMap heightMap = new FluidSimHeightMap(64, 100 );   
      // ParticleDepositionHeightMap heightMap = new ParticleDepositionHeightMap(64, 50, 1, 50, 100, 0.4f );   
      RawHeightMap heightMap = new RawHeightMap("media/images/heighmap1.raw", 256 );   
      // Scale the data
      Vector3f terrainScale = new Vector3f(0.5f, 0.5f, 0.28515625f);      
      // create a terrainblock
      tb = new TerrainBlock( "Terrain", heightMap.getSize(), terrainScale,
                               heightMap.getHeightMap(), new Vector3f(0, 0, 0), false );
      tb.setModelBound( new BoundingBox() );
      // generate a terrain texture with 3 textures
      ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
      pt.addTexture(new ImageIcon(TestGame.class.getClassLoader().getResource("jmetest/data/texture/grassb.png")), -128, 0, 128);
      pt.addTexture(new ImageIcon(TestGame.class.getClassLoader().getResource("jmetest/data/texture/dirt.jpg")), 0, 128, 255);
      pt.addTexture(new ImageIcon(TestGame.class.getClassLoader().getResource("jmetest/data/texture/highest.jpg")), 128, 255,   384);

      // assign the texture to the terrain
      ts = display.getRenderer().createTextureState();
      Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),
                    Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
      ts.setTexture(t1, 0);
      Texture t2 = TextureManager.loadTexture(    TestGame.class.getClassLoader().getResource(   "jmetest/data/texture/Detail.jpg" ),
                                                   Texture.FM_LINEAR );
      Texture t3 = TextureManager.loadTexture(    TestGame.class.getClassLoader().getResource(   "media/images/hex.jpg" ),
                                                   Texture.FM_LINEAR );
      ts.setTexture(t2, 1);      
      ts.setTexture(t3, 2);            
      tb.setDetailTexture(1, 16);
      tb.setDetailTexture(2, 16);      
      tb.setRenderState( ts );
      scene.attachChild( tb );      

And this is the image


You could always use this for now, and make some kind of hexes based grid later. Your game logic won't have to change.

llama said:

You could always use this for now, and make some kind of hexes based grid later. Your game logic won't have to change.

Yes, i'll probably do that. But I do want to add some stuff to the map before going any further. A couple of buildings and some woods is the bare minimum. Different kind of terrains are a very basic feature in this type of game. You know, movement hinderance while moving through wood hexes, moving into a house for cover ;) that sort of stuff has to be there or there is not going to be much game logic.


For adding roads/rivers you could look at ProceduralSplatTextureGenerator

Dude, the terrain looks great. Show us the game where its ready yeah.

Okey, about the SplatTextureGenerator. I like the way it looks when used but it could be better if you help me out with the next question 8)  Is there a way to apply a detail texture to a terrainblock but avoid having it drawn in certain areas??

I want this so i can have the hexes detail texture NOT be drawn over the roads. Is it posible with jme as it is or would it need custom opengl coding?

Show us the game where it's ready yeah.

If I do finish it all are invited to the grand opening fragfest :D


almost taking a trip into real texturesplatting land as usual(keeps popping up on the forum, guess it's time to write a tutorial about it)…

one way of doing it is this(which is also the basic technique for texturessplatting):

  • draw the terrain two times(two passes for example)
  • first time draw the terrain with it's base texture and no hex detail texture
  • second time draw the terrain with an inversed road alpha texture and the hex detail texture, and texturesetting somethings like this:

inverseRoadAlpha.setApply( Texture.AM_REPLACE );
textureState.setTexture( inverseRoadAlpha, 0 );

hexTexture.setApply( Texture.AM_COMBINE );
hexTexture.setCombineFuncRGB( Texture.ACF_REPLACE );
hexTexture.setCombineFuncAlpha( Texture.ACF_REPLACE );
hexTexture.setCombineSrc0Alpha( Texture.ACS_PREVIOUS );
hexTexture.setCombineOp0Alpha( Texture.ACO_SRC_ALPHA );
textureState.setTexture( hexTexture, 1 );

for the second pass you also need blending enabled. That is, an alphastate with these settings:

alphaState.setSrcFunction( AlphaState.SB_SRC_ALPHA );
alphaState.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );

ahmmm, sorry for my ignorance in all 3d related but… what do you mean by

- draw the terrain two times(two passes for example) 

Is it a way for describing the process of adding several textures on the texturestate?

Sorry I can't test it out before asking. I'm currently at work over here ;)

I think i figured it out by myself :wink: You’re talking about render passes, this kind of stuff

Am I right? Can i pat myself in the back?  :smiley:

Thanks for the hint, will look into it :wink:


exactly, two renderpasses, or just render the terrain two times with the different settings…

go ahead an pat yourself, just don't do it in front of us s  :smiley:

MrCoder said:

almost taking a trip into real texturesplatting land as usual(keeps popping up on the forum, guess it's time to write a tutorial about it)...

please! :)