Hello,
till yesterday I had run my project with a old jme3 alpha version from march or april. After the update to the beta version I get a transparency problem.
My purpose is to draw a transparent box with a wirebox around and a plane (a box with z-Size zero) inside the box. It is important to see the plane inside the box. This is already fine with the old jme3 version: http://i.imgur.com/ZEKXK.png
With the new beta version the same code creates the following image: http://i.imgur.com/Ox3YF.png
Here is my program code simplified in a small class which shows only the relevant code:
[java]
import com.jme3.app.SimpleApplication;
import com.jme3.bounding.BoundingBox;
import com.jme3.bounding.BoundingVolume;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.Geometry;
import com.jme3.scene.debug.WireBox;
import com.jme3.scene.shape.Box;
public class InsertionContextTest extends SimpleApplication {
Vector3f size = new Vector3f(5, 5, 5);
Vector3f position = new Vector3f(0, 0, 0);
public static void main(String[] args) {
InsertionContextTest app = new InsertionContextTest();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(100f);
cam.setLocation(new Vector3f(0, 20, 10));
Box b = new Box(size.x, size.y, size.z);
Geometry insertionContextBox = new Geometry(“inputArea”, b);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, new ColorRGBA(246, 255, 0, 0.3f));
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
insertionContextBox.setMaterial(mat);
insertionContextBox.setQueueBucket(Bucket.Transparent);
insertionContextBox.setLocalTranslation(position);
insertionContextBox.setModelBound(new BoundingBox());
rootNode.attachChild(insertionContextBox);
BoundingVolume bound = insertionContextBox.getModelBound();
BoundingBox bbox = (BoundingBox) bound;
WireBox wireBox = new WireBox();
wireBox.fromBoundingBox(bbox);
wireBox.setLineWidth(3f);
Geometry insertAreaWireBox = new Geometry(“selectedGeometry”, wireBox);
mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, new ColorRGBA(246, 255, 0, 0.3f));
insertAreaWireBox.setMaterial(mat);
insertAreaWireBox.setLocalTransform(insertionContextBox.getWorldTransform());
rootNode.attachChild(insertAreaWireBox);
Box p = new Box(size.x, size.y, 0);
Geometry insertionContextPlane = new Geometry(“helperPlane”, p);
Material material = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
material.setColor(“Color”, new ColorRGBA(255, 255, 255, 0.8f));
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
insertionContextPlane.setMaterial(material);
insertionContextPlane.setQueueBucket(Bucket.Transparent);
insertionContextPlane.setLocalTranslation(position);
rootNode.attachChild(insertionContextPlane);
}
}
[/java]
For the new jme3 version I used Unshaded material instead of SolidColor, elsewhere the code is exactly the same.
Has anybody an idea, why the plane is not visible with jme3 beta version?
I solved the problem. If a call updateModelBound() for the insertionContextBox geometry then is already fine. But that’s a little bit strange, because the jMonkeyEngine SDK says: “Updating is not needed in jME3, check your update order if you need to call this”. Nevertheless, it looks like that the updateModelBound method is important. Without calling this method I can’t see the inner plane. Is this approach ok, or is there any problem with calling updateModelBound?
Just don’t set a BoundingBox for it, it gets one by default. But you’re right it should get updated in the update loop.