Hi,
I want to do a 3D remake of the game AdvanceWars, see here: http://img.brothersoft.com/screenshots/softimage/a/advance_wars_2_-_black_hole_rising-171684-1.jpeg
So I want to create a terrain, wich is divided into (invisible) squares. If the player wants to move a tank, then the reachable squares should be highlighted. To visualise this, I basically need to add a texture for a highlighted square and then paint this texture for each reachable square on the texture of the terrain. How can I do that?
Thanks in advance!
Ok, after 6 hours of trying I figured it out myself
Here is the code if somebody needs it:
Box b = new Box("Box", new Vector3f(), 100, 100, 100);
b.setLocalTranslation(new Vector3f(0, 0, -500));
b.setModelBound(new BoundingBox());
b.updateModelBound();
// CREATE TEXTURESTATE
ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
// LOAD AND SET FIRST TEXTURE
Texture t1 = TextureManager.loadTexture(Test.class.getClassLoader()
.getResource("jmetest/data/images/Monkey.jpg"),
Texture.MinificationFilter.BilinearNearestMipMap,
Texture.MagnificationFilter.Bilinear);
ts.setTexture(t1, 0);
// LOAD AND SET SECOND TEXTURE
Texture t2 = TextureManager.loadTexture(Test.class.getClassLoader()
.getResource("jmetest/data/texture/dirt.jpg"),
Texture.MinificationFilter.BilinearNearestMipMap,
Texture.MagnificationFilter.Bilinear);
ts.setTexture(t2, 1);
t2.setWrap(WrapMode.BorderClamp);
t2.setTranslation(new Vector3f(-0.0f, -3.0f, 0.0f));
t2.setApply(Texture.ApplyMode.Blend);
// IMPORTANT:
b.copyTextureCoordinates(0, 1, 5.0f);
b.setRenderState(ts);
b.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
scene.attachChild(b);
The trick was to call b.copyTextureCoordinates(0, 1, 5.0f), wich scales the second texture. If you want to have for example 5 * 5 squares, the third parameter has to be set to 5.0f. Then you can move the square with t2.setTranslation(new Vector3f(-1.0f, -3.0f, 0.0f)) to it's desired position on the playfield.
Would this work to paint roads onto a 3d Terrain?
@TastyLemons said: Would this work to paint roads onto a 3d Terrain?
Given the age of this thread, that code won’t even work in JME3.