OgreXML models - how to import as unshaded

Hi All



I am currently writing an Android game. Since the platform is quite limited, I am unable to use models with lighting.



It seems the OgreXML importer by default uses the Lighting.j3md material. I would like to import all models using the Unshaded material. I cannot for the life of me figure out how to do this.



I know that I could manually re-assign a material to the model in my code - but the problem is that some models have multiple geometrys, each with a different texture. Using spatial.setMaterial will set every geometry to the same material.



Any help? The wiki does not seem to mention anything about this. I am using 3ds max if that matters.



Jon

Do a recursive loop trough the models



(if node do this for all childs)

if geometry, get diffuse texture, create new unshaded material and set the texture there

save as j3o for further use (using the exporter)

Thanks for the quick reply, but how do I “get diffuse texture”? I can see no method that returns the texture (or even material) of a geometry.

[java] public void setTextureScale(Spatial spatial, Vector2f vector) {

if (spatial instanceof Node) {

Node findingnode = (Node) spatial;

for (int i = 0; i < findingnode.getQuantity(); i++) {

Spatial child = findingnode.getChild(i);

setTextureScale(child, vector);

}

} else if (spatial instanceof Geometry) {

((Geometry) spatial).getMesh().scaleTextureCoordinates(vector);

}

}[/java]



use this code example. just do a material change(not texture scale) :slight_smile:



edit: about diffuse texture try to get parameter from material “m_Diffuse” or somethin like this

take a look here:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:materials_overview

and here:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:how_to_use_materials

for unshaded: “ColorMap” for lighting: “DiffuseMap” so just try to get this parameters(im not sure but it should be possible)

Thanks a lot.