Problem using MaterialState

Hey guys, last night I was working on my DxsToJme converter to port it to JME 2.0, and also to expand on the different kinds of materials and blending options that I can bring from DeleD into JME (in this case, color materials + transparency). I’ve gotten both working, but there is an unintended effect - it seems the color of the material of one trimesh lights up whatever I put in the scene - so rather than the default lights, it looks like I put in a disco light! When I turn off the lights in the scene, the problem goes away and of course the material as well…so Im assuming it has something to do with the lightstates?

Lights on.

Lights off.

I first noticed it when I was loading test models up that had window meshes that had a light blue color that were transparent, but as you can see its like that without transparency so I don’t think how I set the blendstate is the problem. Here’s a snippet from my code, where I set a material with a specified color (lay.color) to the trimesh (variable tm):

      MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();

Anyone have any ideas what else I'm missing? I left the default emissive/specular/ambiant on purpose also.

Is it possible you are perhaps reusing the lay.color variable?

In this specific case no, but how things are set up, two different meshes that use the same material information would be. Only one of the tanks use a materialstate, the other three use textures. I did try out just creating a new color at the time I create the materialstate for the green tank, but it didn’t affect anything.

How things are set up in the DXS file, each material has an ID, and then up to three layers where each layer has either a texture or a color and a blending option. At the moment I’m only using the first layer. When I first parse through the file, each material is processed into a representational class that contains each layer with the pertinent information, then each material is placed into a HashMap. When each object is finished being built into a trimesh, I then go back to that HashMap and grab the material representation based on its ID, so yeah if two objects use the same material I created in DeleD, then they would be using the same lay.color variable.

I’m throwing up the complete file - I apply the materials within a setMaterial() method in the internal DXSPrim class.

is it not just a missing node.updaterenderstate() after attaching the loaded model to the node?

Well, after I create and apply any material/texture states, I always call an updateRenderState(), although I did try and call it after I attached the mesh to the root node, but it had no impact. Plus, I'm getting this effect on -other- objects I import after I imported the one with the color materialstate, so Im not sure if its just something I didnt do in the converter code, or something else. The only objects that arent affected are the prebuilt meshes like the Teapot mesh…