Package com.ardor3d.renderer.state

Examples of com.ardor3d.renderer.state.TextureState


        }

        public void visit(final Spatial spatial) {
            if (spatial instanceof Mesh) {
                final Mesh mesh = (Mesh) spatial;
                final TextureState state = (TextureState) mesh.getWorldRenderState(StateType.Texture);
                if (state != null) {
                    _renderer.applyState(state.getType(), state);
                }
            }
        }
View Full Code Here


        final Camera cam = Camera.getCurrentCamera();
        r.flushGraphics();
        double locationX = cam.getWidth(), locationY = cam.getHeight();
        bQuad.resize(size, (cam.getHeight() / (double) cam.getWidth()) * size);
        if (bQuad.getLocalRenderState(RenderState.StateType.Texture) == null) {
            final TextureState ts = new TextureState();
            bufTexture = new Texture2D();
            ts.setTexture(bufTexture);
            bQuad.setRenderState(ts);
        }

        int width = cam.getWidth();
        if (!MathUtils.isPowerOfTwo(width)) {
View Full Code Here

        tbuf.put(0).put(maxV);
        tbuf.put(maxU).put(maxV);
        tbuf.put(maxU).put(0);
        tbuf.rewind();

        final TextureState texState = new TextureState();
        texState.setTexture(graphTexture);
        quad.setRenderState(texState);

        final BlendState blend = new BlendState();
        blend.setBlendEnabled(true);
        blend.setSourceFunction(SourceFunction.SourceAlpha);
View Full Code Here

        return ret;
    }

    private TextureState readTextureStateFromCurrent() {
        final Element el = _currentElem;
        TextureState ret = null;
        try {
            ret = (TextureState) readSavableFromCurrentElem(null);
            final Savable[] savs = readSavableArray("texture", new Texture[0]);
            for (int i = 0; i < savs.length; i++) {
                Texture t = (Texture) savs[i];
                final TextureKey tKey = t.getTextureKey();
                t = TextureManager.loadFromKey(tKey, null, t);
                ret.setTexture(t, i);
            }
        } catch (final Exception e) {
            Logger.getLogger(DOMInputCapsule.class.getName()).log(Level.SEVERE, null, e);
        }
        _currentElem = el;
View Full Code Here

        float _blendEnabledTestRef = 0.02f;

        boolean _useBlend;

        RenderStateSetter(final Texture texture, final boolean useBlend) {
            textureState = new TextureState();
            textureState.setTexture(texture);

            blendState = new BlendState();
            blendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
            blendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
View Full Code Here

        }
        if (colorCoords != null) {
            bufferSizeBytes += colorCoords.getBufferLimit() * 4;
        }
        if (textureCoords != null) {
            final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture);
            if (ts != null) {
                final int max = caps.isMultitextureSupported() ? Math.min(caps.getNumberOfFragmentTexCoordUnits(),
                        TextureState.MAX_TEXTURES) : 1;
                boolean exists;
                for (int i = 0; i < max; i++) {
                    exists = i < textureCoords.size() && textureCoords.get(i) != null
                            && i <= ts.getMaxTextureIndexUsed();

                    if (!exists) {
                        continue;
                    }

View Full Code Here

        _noLights = new LightState();
        _noLights.setGlobalAmbient(DEFAULT_OUTLINE_COLOR);
        _noLights.setEnabled(true);

        _noTexture = new TextureState();
        _noTexture.setEnabled(true);

        _blendState = new BlendState();
        _blendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
        _blendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
View Full Code Here

        /**
         * Compare opaque items by their texture states - generally the most expensive switch. Later this might expand
         * to comparisons by other states as well, such as lighting or material.
         */
        private int compareByStates(final Mesh mesh1, final Mesh mesh2) {
            final TextureState ts1 = (TextureState) mesh1.getWorldRenderState(RenderState.StateType.Texture);
            final TextureState ts2 = (TextureState) mesh2.getWorldRenderState(RenderState.StateType.Texture);
            if (ts1 == ts2) {
                return 0;
            } else if (ts1 == null && ts2 != null) {
                return -1;
            } else if (ts2 == null && ts1 != null) {
                return 1;
            }

            for (int x = 0, maxIndex = Math.min(ts1.getMaxTextureIndexUsed(), ts2.getMaxTextureIndexUsed()); x <= maxIndex; x++) {

                final TextureKey key1 = ts1.getTextureKey(x);
                final TextureKey key2 = ts2.getTextureKey(x);

                if (key1 == null) {
                    if (key2 == null) {
                        continue;
                    } else {
                        return -1;
                    }
                } else if (key2 == null) {
                    return 1;
                }

                final int tid1 = key1.hashCode();
                final int tid2 = key2.hashCode();

                if (tid1 == tid2) {
                    continue;
                } else if (tid1 < tid2) {
                    return -1;
                } else {
                    return 1;
                }
            }

            if (ts1.getMaxTextureIndexUsed() != ts2.getMaxTextureIndexUsed()) {
                return ts2.getMaxTextureIndexUsed() - ts1.getMaxTextureIndexUsed();
            }

            return 0;
        }
View Full Code Here

        // Validate
        if (face == null) {
            throw new IllegalArgumentException("Face can not be null.");
        }

        TextureState ts = (TextureState) _skyboxQuads[face.ordinal()]
                .getLocalRenderState(RenderState.StateType.Texture);
        if (ts == null) {
            ts = new TextureState();
        }

        // Initialize the texture state
        ts.setTexture(texture, textureUnit);
        ts.setEnabled(true);

        texture.setWrap(WrapMode.EdgeClamp);

        // Set the texture to the quad
        _skyboxQuads[face.ordinal()].setRenderState(ts);
View Full Code Here

    public Quad getFace(final Face face) {
        return _skyboxQuads[face.ordinal()];
    }

    public void preloadTexture(final Face face, final Renderer r) {
        final TextureState ts = (TextureState) _skyboxQuads[face.ordinal()]
                .getLocalRenderState(RenderState.StateType.Texture);
        if (ts != null) {
            r.applyState(StateType.Texture, ts);
        }
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.renderer.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.