Hello, they are light in terrainQuad, in the tuto “hello terrain” ? because i can’t put this
(Sorry i’m not english)
Use TerrainLighting.j3md as material.
Thanks, I have change my code but i have a another Problem
my code:
[java]mat_terrain = new Material(assetManager, "MatDefs/Terrain/TerrainLighting.j3md");
mat_terrain.setTexture("m_AlphaMap",assetManager.loadTexture("Textures/Terrain/splat/dre.png"));
//texture 1
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("m_DiffuseMap", grass);
mat_terrain.setFloat("m_DiffuseMap_0_scale", 64f);
//texture 2
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("m_DiffuseMap_1", dirt);
mat_terrain.setFloat("m_DiffuseMap_1_scale", 32f);
//texture 3
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
rock.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("m_DiffuseMap_2", rock);
mat_terrain.setFloat("m_DiffuseMap_2_scale", 128f);
final Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/Modele/"+nbrCase+".png");
final AbstractHeightMap heightmap =new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0));
heightmap.load();
//terrain
terrain = new TerrainQuad("my terrain", 65, nbrCase+1, heightmap.getHeightMap());
terrain.setMaterial(mat_terrain);
//terrain.setMaterial(mat_terrain2);
terrain.setLocalTranslation(x,-1 , z);
terrain.setLocalScale(1f, 1f, 1f);
rootNode.attachChild(terrain);
/DirectionalLight sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(0,0,0).normalizeLocal());
terrain.addLight(sun);/[/java]
The terrain was created but i seen nothing. already is black
Well did you add a light? Why don’t you just use the Terrain Editor?
because i want create a world editor
[java]DirectionalLight soleil = nouvelle DirectionalLight ();
sun.setColor (ColorRGBA.White);
sun.setDirection (. Vector3f nouvelles (0,0,0) normalizeLocal ());
terrain.addLight (soleil); [/java]
this code change nothing
Add the light to the rootNode, not to the terrain. (french I see, I’m french too )
Ok but we are in a english forum sooo … ^^
i have the same, but i can see my terrain because i have change my background in blue ! but my terrain is black
Ok aleardy is good !!
My problem was in the light. but i don’t understand ! can you explain me why don’t can write
light.setDirection((new Vector3f(0,0,0)).normalize());
but this
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
???
thanks
A directional light obviously requires a direction Vector.
(0,0,0) doesn’t provide a direction.
When you try to normalize this 0.0f Vector, you try to set its length to 1.0f. It will most certainly give you a division by zero Exception.
You should read this document to understand Vectors better :
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies
Thanks
this topic is OK
I have a other problem
If i put 2 terrainQuad, just the first have light effect
ozonegrif said:
Add the light to the rootNode, not to the terrain.
i have already do this
Can you share a screenshot ?
:o
it’s strange… no it’s good thanks xD