Hello everybody, i am a total beginner in JME and have a Problem with Materials based on …Lighting.j3md.
The following Codes works fine and results in the following Output
… vertices = new Vector3f[4];
System.out.println("i = " + i);
vertices[0] = new Vector3f(100,100,100);
vertices[0] = new Vector3f((float)punkte[i].getX(),(float)punkte[i].getY(),(float)punkte[i].getZ());
vertices[1] = new Vector3f((float)punkte[i+1].getX(),(float)punkte[i+1].getY(),(float)punkte[i+1].getZ());
vertices[2] = new Vector3f((float)punkte[i].getX(),(float)punkte[i].getY(),(float)(punkte[i].getZ()+profil.getLaenge()));
vertices[3] = new Vector3f((float)punkte[i+1].getX(),(float)punkte[i+1].getY(),(float)(punkte[i+1].getZ()+profil.getLaenge()));
m = new Mesh();
Vector2f [] texCoord = new Vector2f[4];
texCoord[0] = new Vector2f(0,0);
texCoord[1] = new Vector2f(1,0);
texCoord[2] = new Vector2f(0,1);
texCoord[3] = new Vector2f(1,1);
// Setting buffers
m.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
m.setBuffer(VertexBuffer.Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));
m.setBuffer(VertexBuffer.Type.Index, 3, BufferUtils.createShortBuffer(indexes));
m.updateBound();
// I think the interesting part starts here
// Creating a geometry, and apply a single color material to it
Geometry geom = new Geometry(“MeshProfil”, m);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor("Color", Profil.getFarbe());
geom.setMaterial(mat);
nodeProfil.attachChild(geom);
See Pic 1
But when i want to use Lighting the following Code results in an Error
Geometry geom = new Geometry("MeshProfil", m);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setBoolean("UseMaterialColors",true);
mat.setColor("Ambient", ColorRGBA.White);
mat.setColor("Diffuse", ColorRGBA.White);
mat.setColor("Color", Profil.getFarbe());
geom.setMaterial(mat);
nodeProfil.attachChild(geom);
See Pic2
When i do it without the line “mat.setColor(“Color”, Profil.getFarbe()); " the output looks like this (just Focus on the “invisible” parts”)
See Pic3
What am i doing wrong? i have set ambient light an 4 Point Lights around the objects.