Hi people,
i'v been trying to change the materials of the models that i have imported from 3dsmax (using 3ds).
The model looks okey but is to shiny, has some transparacy in it, etc.
i'v been trying to change the materials when i load them in and have tried to locate a node and then change it materials. both not working…
So heres my code:
part of "loadModel function" fond on the great forum :
try {
formatConverter.convert(modelURL.openStream(), BO);
loadedModel = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
if (modelFormat.equals("3ds")) {
//3ds from max gets exporter in wrong direction
Quaternion rotate = new Quaternion();
rotate.fromAngleAxis(FastMath.PI / 2, new Vector3f(-1, 0, 0));
loadedModel.setLocalRotation(rotate);
//set material stuff // testing....
MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
ms.setEnabled(true);
ms.setShininess(0);
ms.setDiffuse(ColorRGBA.red);
ms.setAmbient(new ColorRGBA(0,0,0,0));
ms.setSpecular(new ColorRGBA(0,0,0,0));
ms.setEmissive(new ColorRGBA(0,0,0,0));
loadedModel.setRenderState(ms);
loadedModel.updateRenderState();
}
and a other function "setWater" (when finished this function set a water material.. i hope):
private void setWater() {
System.out.println("Try to locate a water object and change its material... pfieuwww");
Spatial wNode = rootNode.getChild("Plane01");
MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
ms.setDiffuse(new ColorRGBA(1,0,0,1));
ms.setEnabled(true);
ms.setColorMaterial(ColorMaterial.Diffuse);
wNode.setRenderState(ms);
wNode.updateRenderState();
//System.out.println(wNode.getName());
}
both of them seem to have no effect, so i'm guessing i'm doing something wrong.
But i have yet not found an working method on this forum/wiki/javadocs
Perhaps you can show me how to do this. but als important how to find the information that i need to solve this problem. for example the javadocs have a list of sorta functions but i kinda lacks on usefull examples or howto use... perhaps this is something to work on.. ?
Best regards!