tried to figure this out like forever now. Cant get a Box transparent when Using Lighting/Light Material.
My Code:
`
Box b = new Box(1, .5f, 1);
Geometry device = new Geometry("Device", b);
Material mat = new Material(assets, "Common/MatDefs/Light/Lighting.j3md");
mat.setParam("Ambient", VarType.Vector4, new ColorRGBA(1, 1, 1, .5f));
mat.setBoolean("UseAlpha",true);
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
device.setMaterial(mat);
device.setQueueBucket(Bucket.Transparent);
`
I added light sources and aded it to the root node. With the Unshaded Material it is visible and transparent
Glad it helped.
but about the new problem I really have no clue of what may cause it.sorry !
I did test with two boxes (1-one is behind the other 2- one is inside the other) and it worked correctly for me for all sides.
Hope guys here can help.
Thanks for your tip, but unforunately that didn’t work either. Still white.
`
public Node createNetworkDevice(Vector3f position, NodeType nt) {
Node deviceNode = new Node("Device Node");
Box b = new Box(1, .5f, 1);
Geometry device = new Geometry("Device", b);
Material mat = new Material(assets, "Common/MatDefs/Light/Lighting.j3md");
mat.setParam("Ambient", VarType.Vector4, new ColorRGBA(1, 1, 1, .5f));
mat.setBoolean("UseAlpha",true);
mat.setColor("Diffuse", new ColorRGBA(1, 1, 1, 0.5f));
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Specular", new ColorRGBA(1, 1, 1, 0.5f));
device.setMaterial(mat);
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
device.setQueueBucket(Bucket.Transparent);
// Calculate Translation
// set pipe to correct position by translating it right between start and end
device.setLocalTranslation(position);
deviceNode.attachChild(device);
return deviceNode;
}
perhaps the issue is not with the box, but with the other objects… are they in the transparent bucket also, how are they defined? can you make a super simple test case with only the box that doesnt render correctly, one light and one other object ?
Which version you are using ?
I am using jme 3.1 alpha 5
and get run time error in this line : mat.setParam("Ambient", VarType.Vector4, new ColorRGBA(1, 1, 1, .5f));
also tried it with mat.setColor(“Ambient”, ColorRGBA.White);
java.lang.ClassCastException: com.jme3.math.Vector4f cannot be cast to com.jme3.math.ColorRGBA
at com.jme3.shader.Uniform.setValue(Uniform.java:323)
at com.jme3.material.Material.updateShaderMaterialParameters(Material.java:804)
...
If you are seeing an exception from that other line then it is a different exception or you are rebuilding improperly or something. Put some System.out.println(“Kilroy was here”) lines or something.
Yeah, I forgot that VarType is a representation of the shader types… but anyway setColor() is better. (There is a now-fixed bug in JME that was causing the exception before.)