Hi guys!
I have a big problem with transparency…I have imported a 3ds model made of subcomponents; what I'll like to do is to make transparent some of this component. For doing that I've created my own MousePick with a method that returns the picked TriMesh. Assuming that the parent of the picked mesh hold the whole component geometry, I've set the parent node render state to achieve transparency (setting material state and alpha state). The problem is that this doesn't work! So I've tried another way…once I've got the parent node I "manually" apply material state and alpha state to the children with a for cycle. This second way works well, but I think it's a bad way to do things.
Can anyone help me to do things in the right way?
This is the code that doesn't work.
protected void simpleUpdate(){
Node p=pick.getPickedParent();
if(p!=null){
if(p.getRenderState(StateType.Material)!=materialState){
p.setRenderState(materialState);
p.setRenderState(alphaState);
p.updateRenderState();
p.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
}
}
}
And this is the code that works.
protected void simpleUpdate(){
Node p=pick.getPickedParent();
if(p!=null){
if(p.getRenderState(StateType.Material)!=materialState){
p.setRenderState(materialState);
p.setRenderState(alphaState);
p.updateRenderState();
for(int i=0;i<p.getQuantity();i++){
p.getChild(i).setRenderState(materialState);
p.getChild(i).setRenderState(alphaState);
p.getChild(i).updateRenderState();
}
System.out.println(p.getQuantity());
p.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
}
}
}