I have been working on loading, rendering and lighting 3D models with LWJGL. It works mostly, but there's currently problem with the lighting, I think its the lighting normals but I can't fix it. Here is a picture the problem;
Lighting code:
public class Light {
private Vector4f position;
public Light(Vector3f position)
{
this.position = new Vector4f(position.x, position.y, position.z, 1);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightModel(GL_LIGHT_MODEL_AMBIENT, getFlipedFloatBuffer(new Vector4f(0.05f, 0.05f, 0.05f, 1)));
glLight(GL_LIGHT0, GL_POSITION, getFlipedFloatBuffer(this.position));
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
}
private FloatBuffer getFlipedFloatBuffer(Vector4f values)
{
return (FloatBuffer)BufferUtils.createFloatBuffer(4).put(new float[]{values.x, values.y, values.z, values.w}).flip();
}
public void update() {
glLight(GL_LIGHT0, GL_POSITION, getFlipedFloatBuffer(this.position));
}
}