Hey there!
i am working with jmonkey since more than 10 months. each time this forum has an answer to my questions, but now it makes me crazy. so i hope someone has an answer to my current question!
I'm using ColladaImporter to import some Google-Sketch-up models. This works very well for full-textured models.
But: if there are some primitives (or meshes) inside of this model with no textures and they are only colored (e.g. gray or red), this color will not be imported: its just white.
i also call updateRenderState() and checked for the phong-blinn-type (here its lambert)
if i interpret the Collada-Spec right, then the following snippet should show the relevant xml from the dae:
<effect id="material_3_24-effect" name="material_3_24-effect">
<profile_COMMON>
<technique sid="COMMON">
<lambert>
<emission>
<color>0.000000 0.000000 0.000000 1</color>
</emission>
<ambient>
<color>0.000000 0.000000 0.000000 1</color>
</ambient>
<diffuse>
<color>0.549020 0.549020 0.560784 1</color>
</diffuse>
<transparent>
<color>1 1 1 1</color>
</transparent>
<transparency>
<float>0.000000</float>
</transparency>
</lambert>
</technique>
</profile_COMMON>
</effect>
the relevant passage from the colladaimporter.java:
private void processLambert(lambertType lt, ColladaMaterial mat)
throws Exception {
// lambert shading, create a FLAT shade state and material state
// with
// defined colors.
ShadeState ss = DisplaySystem.getDisplaySystem().getRenderer()
.createShadeState();
ss.setShadeMode(ShadeState.ShadeMode.Flat);
mat.setState(ss);
// obtain the colors for the material
MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer()
.createMaterialState();
// set the ambient color value of the material
if (lt.hasambient()) {
ms.setAmbient(getColor(lt.getambient().getcolor()));
}
// set the diffuse color value of the material
if (lt.hasdiffuse()) {
if (lt.getdiffuse().hascolor()) {
ms.setDiffuse(getColor(lt.getdiffuse().getcolor()));
}
if (lt.getdiffuse().hastexture()) {
// create a texturestate, and we will need to make use of
// texcoord to put this texture in the correct "unit"
for (int i = 0; i < lt.getdiffuse().gettextureCount(); i++) {
mat.setState(processTexture(
lt.getdiffuse().gettextureAt(i), mat));
}
}
}
// set the emmission color value of the material
if (lt.hasemission()) {
ms.setEmissive(getColor(lt.getemission().getcolor()));
}
if (lt.hastransparent()) {
if (lt.gettransparent().hascolor()
&& !lt.gettransparency().getfloat2().getValue().toString()
.equals("0")) {
float alpha = lt.gettransparency().getfloat2().getValue()
.floatValue();
ColorRGBA diffuse = ms.getDiffuse();
diffuse.a = 1.0f - alpha;
ms.setDiffuse(diffuse);
BlendState as = DisplaySystem.getDisplaySystem().getRenderer()
.createBlendState();
as.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
as
.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
as.setBlendEnabled(true);
mat.setState(as);
}
}
mat.setState(ms);
// Ignored: reflective attributes, transparent attributes
}
i am missguided, that these snippets are responsible for the color?
thanks! greets!
sorry for my english ;)