jME2 – Problem with Transparency ? (3ds-Objects, use MaxToJme())

Hello,

sorry for my english :stuck_out_tongue:



Also, i have a problem with my spatials, spaceship, earth and asteroids are transparency ???

I have loadet and convert all the objects with MaxToJme() and load textures with ResourceLocatorTool.



In Java2-Forum one says i need to set all models to “opaque bucket”

i have done: “mySpatial.setRenderQueueMode(Renderer.QUEUE_OPAQUE);” but this nothing change.



Here youtube-video to see what i mean: Video



MyLoader:

[java]private void load3DSModel(){

URL modelURL;

FormatConverter converter;

ByteArrayOutputStream outStream;

InputStream inputStream;

SimpleResourceLocator location;



System.out.println(“Lade Model " +this.modelPath +this.modelName);



modelURL = getClass().getResource(this.modelPath +this.modelName);

converter = new MaxToJme();

outStream = new ByteArrayOutputStream();



try{

location = new SimpleResourceLocator(getClass().getResource(this.texturePath));

ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, location);

inputStream = modelURL.openStream();

converter.convert(inputStream, outStream);

inputStream.close();

this.objNode = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(outStream.toByteArray()));



System.out.println(“Model " +this.modelPath +this.modelName +” erfolgreich geladen”);

}catch (Exception e){

System.err.println(“Exception @ load3DSModel() in MyObjects!”);

System.err.println(e);

}

}[/java]



MyDefaultRenderer:

[java]public static void setDefaultRenderer(DisplaySystem _display, Node _object, CullState.Face _face){

CullState cs = _display.getRenderer().createCullState();

cs.setEnabled(true);

cs.setCullFace(_face);

_object.setRenderState(cs);

_object.updateRenderState();

}[/java]



StarshipExtractor: // i extract all other objects at same way

[java]

this.starship = super.objNode.getChild(“Starship”);

super.objNode.detachChildNamed(“Starship”);

this.starship.setRenderQueueMode(Renderer.QUEUE_OPAQUE);

setDefaultRenderer(this.display, this.starship, CullState.Face.Front);

super.objNode.attachChild(this.starship);[/java]





MyLight:

[java]Light light = new PointLight();

light.setDiffuse(ColorRGBA.white);

light.setAmbient(ColorRGBA.white);

light.setEnabled(true);



/** Attach the light to a lightState and the lightState to rootNode. */

LightState lightState = display.getRenderer().createLightState();

lightState.detachAll();

lightState.setEnabled(true);

lightState.attach(light);

this.rootNode.setRenderState(lightState);[/java]



Also, anyone see what make me wrong??

Are you calling updateRenderState() after setting up your lighting and model?

from the video, it looks like you miss a ZBufferstate

1 Like

@ sbook

have setting up "updateRenderState() " but this was´t



@ Core-Dump

thx, this was, have setting up the ZBuffer



[java]private void setupZBuffer(){

ZBufferState buf = this.display.getRenderer().createZBufferState();

buf.setEnabled(true);

buf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);

this.rootNode.setRenderState(buf);

this.rootNode.setLightCombineMode(LightCombineMode.CombineFirst);

}[/java]



the problem was corrected at the planet, asteroids and spacestation but this problem to be existing by Starship.

show new youtubevideo to see the problem: Video



thx for help and sorry for bad english xD

like sbook said, make sure to call rootNode.updateRenderState() after setting a render state, and also after adding anything to the scene.

you can also take a look at the stardust code to see how i did set up things.



http://code.google.com/p/jme-demos/source/browse/#svn%2Ftrunk%2Fstardust

1 Like