We use the chicken egg exporter to export 3d models from Blender. But we have a problem with materials.
Indeed the egg files created define materials at the beginning and polygons refer to it (MRef as you probably know).
The problem is that the color don’t appear in our application under Panda. We have to edit manually the files and set the corresponding RGBA to each vertex.
We read that materials appear with lights in Panda but this is the only way we found to solve our problem.
Does anybody know a better and easier way to do that?
Thanks a lot.
Well, materials make no sense with no lights. Consider the fact that what you’re setting in a material is the diffuse, ambient and specular components. Those are terms of the lighting equation, so without any lights obviously the result will not make much sense.
What you could do if you insist on not using lights is write a script in Blender that fills a vertex color channel with the diffuse (or any other component or combination of them) from your object’s materials and run that script on your model every time you make changes to the materials’ diffuse. If you go that route, consider that each face can have a different material and fill in the vertex colors accordingly.
mesh = object.getmesh()
for face in mesh.faces:
mat = object.materials[face.materialIndex]
for vertex in face.verts:
vertex.color = mat.diffuse
Don’t try to copy/paste that into blender obviously since those are not the actual functions/attributes of the classes involved, only the general idea.
You could also hack code like this into Chicken so it’ll do it automatically each time you export an object.
Thanks for your help. But we finally found that the materials work in our application (but not in pview) without touching the egg files. It must be, as you said, because of the lack of lights.
Note that you can press the “l” key in pview to toggle lights. And, yes, materials are a property of lighting, and do not work without lights.