Package com.jme.scene.state

Examples of com.jme.scene.state.TextureState


                public void update(Object arg0) {
                    TreeScan.findNode((Spatial) arg0, new ProcessNodeInterface() {
                        public boolean processNode(Spatial node) {
                            if (node instanceof Geometry) {
                                ((Geometry)node).clearBuffers();
                                TextureState ts = (TextureState) node.getRenderState(RenderState.RS_TEXTURE);
                                // deleteAll is too aggressive, it deletes other copies of the same texture
//                                if (ts!=null)
//                                    ts.deleteAll(false);
                            }
                            return true;
View Full Code Here


        Quad updatedQuad = getQuad();

        if (updatedQuad!=oldQuad) {
            Node tmpParent = oldQuad.getParent();
            oldQuad.removeFromParent();
            TextureState texState = (TextureState) oldQuad.getRenderState(StateType.Texture);
            Texture tex = texState.getTexture();
            TextureManager.releaseTexture(tex);
            tmpParent.attachChild(updatedQuad);
        }
    }
View Full Code Here

        Quad ret;

        if (imgWidth==w && imgHeight==h && imgFactor==factor) {
            // Reuse quad and texture
            ret = quad;
            TextureState texState = (TextureState) quad.getRenderState(StateType.Texture);
            Texture oldtex = texState.getTexture();
            // Not sure why this does not work, instead release the current texture and create a new one.
//            oldtex.setImage(TextureManager.loadImage(img, true));
//            texState.setTexture(oldtex);
            TextureManager.releaseTexture(oldtex);

            Texture tex = TextureManager.loadTexture(img, MinificationFilter.BilinearNoMipMaps, MagnificationFilter.Bilinear, true);

            texState.setTexture(tex);
            //end workaround
        } else {
            ret = new Quad("textLabel2d", w * factor, h * factor);
            TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
            Texture tex = TextureManager.loadTexture(img, MinificationFilter.BilinearNoMipMaps, MagnificationFilter.Bilinear, true);

            ts.setTexture(tex);
            ts.setEnabled(true);
            ret.setRenderState(ts);

            BlendState as = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
            as.setBlendEnabled(false);
            as.setReference(0.5f);
View Full Code Here

    void findTextures(Node root) {
        TreeScan.findNode(root, new ProcessNodeInterface() {

            public boolean processNode(Spatial node) {
                TextureState ts =
                        (TextureState) node.getRenderState(
                        TextureState.RS_TEXTURE);
                if (ts != null) {
                    Texture t = ts.getTexture();
                    if (t != null) {
//                        System.out.println("Texture "+t.getImageLocation());
                    }
                }
                return true;
View Full Code Here

        final HashSet<String> textureSet = new HashSet();

        TreeScan.findNode(bg, Geometry.class, new ProcessNodeInterface() {

            public boolean processNode(Spatial node) {
                TextureState ts =
                        (TextureState) node.getRenderState(
                        TextureState.RS_TEXTURE);
                if (ts == null) {
                    return true;
                }

                Texture t = ts.getTexture();
                if (t != null) {
                    String tFile = t.getImageLocation();
                    if (textureSet.add(tFile)) {
                        model.addRow(new Object[]{new String(tFile),
                                    "not implemented",
View Full Code Here

    public void setData(Vector3f center, float xExtent, float yExtent, float zExtent) {

        for (int i = 0; i < 6; i++) {
      if (faces[i] == null) {
    TriMesh mesh = new TriMesh();
    TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
    ts.setTexture(texture);
    mesh.setRenderState(ts);
    mesh.setModelBound(new BoundingBox());
    mesh.updateModelBound();
    faces[i] = mesh;
    attachChild(mesh);
View Full Code Here

     */
    public void setTexture (Texture texture) {
  this.texture = texture;
        for (int i = 0; i < 6; i++) {
      if (faces[i] != null) {
    TextureState ts = (TextureState) faces[i].getRenderState(RenderState.RS_TEXTURE);
    ts.setTexture(texture);
      }
  }
    }
View Full Code Here

    _groundDetailTexture = TextureManager.loadTexture(ImageIO
        .read(groundDetailTexture), Texture.MM_LINEAR_LINEAR,
        Texture.MM_LINEAR, true);

    TextureState ts = HeightMap.getTextureState();
    /* Now we have to set up our ground texture */
    _groundTexture.setApply(Texture.AM_COMBINE);
    _groundTexture.setCombineFuncRGB(Texture.ACF_MODULATE);
    _groundTexture.setCombineSrc0RGB(Texture.ACS_TEXTURE);
    _groundTexture.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
    _groundTexture.setCombineSrc1RGB(Texture.ACS_PRIMARY_COLOR);
    _groundTexture.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
    _groundTexture.setCombineScaleRGB(1.0f);

    ts.setTexture(_groundTexture, 0);

    _groundDetailTexture.setApply(Texture.AM_COMBINE);
    _groundDetailTexture.setWrap(Texture.WM_WRAP_S_WRAP_T);
    _groundDetailTexture.setCombineFuncRGB(Texture.ACF_ADD_SIGNED);
    _groundDetailTexture.setCombineSrc0RGB(Texture.ACS_TEXTURE);
    _groundDetailTexture.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
    _groundDetailTexture.setCombineSrc1RGB(Texture.ACS_PREVIOUS);
    _groundDetailTexture.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
    _groundDetailTexture.setCombineScaleRGB(1.0f);

    ts.setTexture(_groundDetailTexture, 1);

    _terrain.setRenderState(ts);
    _terrain.setDetailTexture(1, 32);

    /* Load Skybox Texture */
 
View Full Code Here

  private Node createObjects() {
    Node objects = new Node( "objects" );

    Torus torus = new Torus( "Torus", 50, 50, 10, 20 );
    torus.setLocalTranslation( new Vector3f( 50, -5, 20 ) );
    TextureState ts = display.getRenderer().createTextureState();
    Texture t0 = TextureManager.loadTexture(
        TestSimpleQuadWater.class.getClassLoader().getResource(
            "jmetest/data/images/Monkey.jpg" ),
        Texture.MM_LINEAR_LINEAR,
        Texture.FM_LINEAR );
    Texture t1 = TextureManager.loadTexture(
        TestSimpleQuadWater.class.getClassLoader().getResource(
            "jmetest/data/texture/north.jpg" ),
        Texture.MM_LINEAR_LINEAR,
        Texture.FM_LINEAR );
    t1.setEnvironmentalMapMode( Texture.EM_SPHERE );
    ts.setTexture( t0, 0 );
    ts.setTexture( t1, 1 );
    ts.setEnabled( true );
    torus.setRenderState( ts );
    objects.attachChild( torus );

    ts = display.getRenderer().createTextureState();
    t0 = TextureManager.loadTexture(
        TestSimpleQuadWater.class.getClassLoader().getResource(
            "jmetest/data/texture/wall.jpg" ),
        Texture.MM_LINEAR_LINEAR,
        Texture.FM_LINEAR );
    t0.setWrap( Texture.WM_WRAP_S_WRAP_T );
    ts.setTexture( t0 );

    Box box = new Box( "box1", new Vector3f( -10, -10, -10 ), new Vector3f( 10, 10, 10 ) );
    box.setLocalTranslation( new Vector3f( 0, -7, 0 ) );
    box.setRenderState( ts );
    objects.attachChild( box );

    box = new Box( "box2", new Vector3f( -5, -5, -5 ), new Vector3f( 5, 5, 5 ) );
    box.setLocalTranslation( new Vector3f( 15, 10, 0 ) );
    box.setRenderState( ts );
    objects.attachChild( box );

    box = new Box( "box3", new Vector3f( -5, -5, -5 ), new Vector3f( 5, 5, 5 ) );
    box.setLocalTranslation( new Vector3f( 0, -10, 15 ) );
    box.setRenderState( ts );
    objects.attachChild( box );

    box = new Box( "box4", new Vector3f( -5, -5, -5 ), new Vector3f( 5, 5, 5 ) );
    box.setLocalTranslation( new Vector3f( 20, 0, 0 ) );
    box.setRenderState( ts );
    objects.attachChild( box );

    ts = display.getRenderer().createTextureState();
    t0 = TextureManager.loadTexture(
        TestSimpleQuadWater.class.getClassLoader().getResource(
            "jmetest/data/images/Monkey.jpg" ),
        Texture.MM_LINEAR_LINEAR,
        Texture.FM_LINEAR );
    t0.setWrap( Texture.WM_WRAP_S_WRAP_T );
    ts.setTexture( t0 );

    box = new Box( "box5", new Vector3f( -50, -2, -50 ), new Vector3f( 50, 2, 50 ) );
    box.setLocalTranslation( new Vector3f( 0, -15, 0 ) );
    box.setRenderState( ts );
    box.setModelBound( new BoundingBox() );
View Full Code Here

    float quadHeight = display.getWidth() / 8;
    Quad debugQuad = new Quad( "reflectionQuad", quadWidth, quadHeight );
    debugQuad.setRenderQueueMode( Renderer.QUEUE_ORTHO );
    debugQuad.setCullMode( SceneElement.CULL_NEVER );
    debugQuad.setLightCombineMode( LightState.OFF );
    TextureState ts = display.getRenderer().createTextureState();
    ts.setTexture( waterEffectRenderPass.getTextureReflect() );
    debugQuad.setRenderState( ts );
    debugQuad.updateRenderState();
    debugQuad.getLocalTranslation().set( quadWidth * 0.6f, quadHeight * 1.0f, 1.0f );
    debugQuadsNode.attachChild( debugQuad );

    if( waterEffectRenderPass.getTextureRefract() != null ) {
      debugQuad = new Quad( "refractionQuad", quadWidth, quadHeight );
      debugQuad.setRenderQueueMode( Renderer.QUEUE_ORTHO );
      debugQuad.setCullMode( SceneElement.CULL_NEVER );
      debugQuad.setLightCombineMode( LightState.OFF );
      ts = display.getRenderer().createTextureState();
      ts.setTexture( waterEffectRenderPass.getTextureRefract() );
      debugQuad.setRenderState( ts );
      debugQuad.updateRenderState();
      debugQuad.getLocalTranslation().set( quadWidth * 0.6f, quadHeight * 2.1f, 1.0f );
      debugQuadsNode.attachChild( debugQuad );
    }

        if( waterEffectRenderPass.getTextureDepth() != null ) {
            debugQuad = new Quad( "refractionQuad", quadWidth, quadHeight );
            debugQuad.setRenderQueueMode( Renderer.QUEUE_ORTHO );
            debugQuad.setCullMode( SceneElement.CULL_NEVER );
            debugQuad.setLightCombineMode( LightState.OFF );
            ts = display.getRenderer().createTextureState();
            ts.setTexture( waterEffectRenderPass.getTextureDepth() );
            debugQuad.setRenderState( ts );
            debugQuad.updateRenderState();
            debugQuad.getLocalTranslation().set( quadWidth * 0.6f, quadHeight * 3.2f, 1.0f );
            debugQuadsNode.attachChild( debugQuad );
        }
View Full Code Here

TOP

Related Classes of com.jme.scene.state.TextureState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.