Hello! I am having some problems with this particular problem.
EDIT: I noticed changing the color of the PointLight changes the color displayed on the model. Maybe this plays a role?
I am working on a system to generate models. Obviousely this requires lighting and stuff like that. An important thing is adding colors without having to use custom textures or anything like that. I am working on a simple game that requires no textures at all. Models are existing out of cubes solely. The cube rendering and generation works just fine, but when I try to color them something goes wrong. I get no errors, but the colors I assign in the Type.Color mesh buffer seem to be ignored when using Lighting.j3md, the diffuse color seems to be taken over. When using Unshaded.j3md it seems to be working just fine. The colors are assigned like this:
float r = (float) current.getR()/255;
float g = (float) current.getG()/255;
float b = (float) current.getB()/255;
float a = (float) current.getA()/255;
The model is added like this:
Geometry geom = new Geometry("Custom Mesh", sword.getMesh());
boolean shading = true;
Material mat;
if(shading){
mat = new Material(assetManager,
"Common/MatDefs/Light/Lighting.j3md");
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Diffuse", ColorRGBA.White );
mat.setColor("Ambient", ColorRGBA.White );
}else{
mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
mat.setBoolean("VertexColor",true);
}
geom.setMaterial(mat);
Here’s a screenshot:
Unshaded:
Due to me being a new user I cannot upload an image with the shaders, but with shaders the whole model is gray.
Please note that I have no clear understanding of how the different lighting color values mean, so I would pretty much appreciate any explanation if that is what I have done wrong.
Kind regards and thank you in advance,
Techdaan.