Alphamap howto

Could someone explain how to use an alphamap for the texturesplatt effect?

I have 1 image for the grass texture that should be on the whole terrain and i have a road texture and a .tga file created in photoshop

to use as the alphamap. I have tried to add the images in the texturestate menu but I dont understand how to use the .tga file as alphamap.

Have a look at TestTerrainSplatting and TestIsland

You need to either use a shader or combine modes so that the alphamap is blended with the colormap to produce splatting, see the tests MrCoder mentioned.

I tried to run TestIsland from eclipse and i get this error:

28.okt.2007 01:37:34 class jmetest.terrain.TestIsland start()
SEVERE: Exception in game loop
   at jmetest.terrain.TestIsland.createTerrain(Unknown Source)
   at jmetest.terrain.TestIsland.simpleInitGame(Unknown Source)
   at Source)
   at Source)
   at Source)
   at jmetest.terrain.TestIsland.main(Unknown Source)
28.okt.2007 01:37:34 cleanup
INFO: Cleaning up resources.
28.okt.2007 01:37:34 start
INFO: Application ending.

runs ok here…  my guess is that eclipse is not setup to copy over the .raw file.

I've noticed I had a slight difference in the code for this test on one of my machines that avoided the same error you report.  I've checked that in and hopefully it will now work for you as well.

I reinstalled eclipse and then it suddenly worked. The technique with alphamaps used in TestIsland can be used on a loaded 3d object too right? I have made a terrain in Blender and loading it from a .obj file…

yeah any model…

I tried to create a box and the material then works, but when I use the model that I load from a .obj file it looks like its using

the color of the .obj model and it doesnt show the material i create in jme code.

Maybe theres a way to load the model without any texture or material?

The materials and textures and states are created and applied to the shape/object in a method so the same code is used for the Box as for the loaded .obj file.

Like this: setupTexture(mybox)  or  setupTexture(loadedModel)

The .obj file is just one of those premade box objects in wings3d otherwise untouched and exported as a .obj file. I have also tried to export a file from blender but theres no difference.

When i'm testing with a Box shape I create it like this:

Box boks = new Box("terrenget",new Vector3f(20,20,20),new Vector3f(1,1,1));

When i'm trying to use the .obj file instead of a Box it's done like this:

URL model=TestHillTerreng.class.getClassLoader().getResource("landskap.obj");
// Create something to convert .obj format to .jme
FormatConverter converter=new ObjToJme();

// This byte array will hold my .jme file
        ByteArrayOutputStream BO=new ByteArrayOutputStream();
        try {
            // Use the format converter to convert .obj to .jme
            converter.convert(model.openStream(), BO);
            Spatial maggie=(Spatial)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
            // shrink this baby down some
            maggie.setModelBound(new BoundingSphere());

            //for testing the Box
        } catch (IOException e) {   // Just in case anything happens
            System.out.println("Damn exceptions!" + e);

And i'll show you the setupTexture method too:

private void setupTexture(Spatial model) {
        // create some interesting texturestates for splatting
        TextureState ts1 = createSplatTextureState("baserock.jpg", null);       
        TextureState ts5 = createSplatTextureState("road.jpg","roadalpha.png");
        TextureState ts6 = createLightmapTextureState("lightmap.jpg");
        //alpha used for blending the passnodestates together
        AlphaState as = display.getRenderer().createAlphaState();
     // //////////////////// PASS STUFF START
        // try out a passnode to use for splatting
        PassNode splattingPassNode = new PassNode("SplatPassNode");
        PassNodeState passNodeState = new PassNodeState();
        passNodeState = new PassNodeState();
        // lock some things to increase the performance