I’m trying to create triangles with following function.
[java]
void setupMat(){
redMat = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);
blueMat = assetManager.loadMaterial(“Textures/Terrain/Pond/Pond.j3m”);
redMat.setColor(“m_Color”, ColorRGBA.Red);
}
public Geometry createTri(float[] arr, int c) {
Mesh m = new Mesh();
m.setMode(Mesh.Mode.Triangles);
Vector2f[] texCoord = new Vector2f[3];
texCoord[0] = new Vector2f(0, 0);
texCoord[1] = new Vector2f(0, 1);
texCoord[2] = new Vector2f(1, 1);
int[] indexes = {2, 0, 1, 1, 0, 2};
m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(arr));
m.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));
m.setBuffer(Type.Index, 1, BufferUtils.createIntBuffer(indexes));
m.updateBound();
m.updateCounts();
Geometry geom = new Geometry(“Triangle”, m);
if (c == 0) {
geom.setMaterial(blueMat);
} else {
geom.setMaterial(redMat);
}
return geom;
}
[/java]
It work’s well with c!=0 aka solid color. But for lightning texture the triangles only shows in special cases like when your close and almost allways only one at a time. I’ve both a point light which follows the camera and a directional light.
Anyone have any idea?
You’re missing a normal buffer on the mesh
Thanks. That led me to this thread which explains how normals and textcoords are used by the engine. How to set texture coordinate indices
Edit: Fixed spelling