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

  • Profile picture of d3rbastl3r d3rbastl3r said 1 year, 3 months ago:

    Hello,
    sorry for my english :P

    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:

    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);
            }
        }

    MyDefaultRenderer:

    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();
        }

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

    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);

    MyLight:

    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);

    Also, anyone see what make me wrong??

  • Profile picture of sbook sbook255p said 1 year, 3 months ago:

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

  • Profile picture of Core-Dump Core-Dump7p said 1 year, 2 months ago:

    from the video, it looks like you miss a ZBufferstate

  • Profile picture of d3rbastl3r d3rbastl3r said 1 year, 2 months ago:

    @ sbook
    have setting up “updateRenderState() ” but this was´t

    @ Core-Dump
    thx, this was, have setting up the ZBuffer

    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);
        }

    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

  • Profile picture of Core-Dump Core-Dump7p said 1 year, 2 months ago:

    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