Package com.ardor3d.image

Examples of com.ardor3d.image.Texture


        if (tkey == null) {
            logger.warning("TextureKey is null, cannot load");
            return TextureState.getDefaultTexture();
        }

        Texture result = store;

        // First look for the texture using the supplied key
        final Texture cache = findCachedTexture(tkey);

        if (cache != null) {
            // look into cache.
            if (result == null) {
                result = cache.createSimpleClone();
                if (result.getTextureKey() == null) {
                    result.setTextureKey(tkey);
                }
                return result;
            }
            cache.createSimpleClone(result);
            return result;
        }

        Image img = imageData;
        if (img == null) {
View Full Code Here


        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);
View Full Code Here

    public boolean removeTexture(final int textureUnit) {
        if (textureUnit < 0 || textureUnit >= MAX_TEXTURES || textureUnit >= _texture.size()) {
            return false;
        }

        final Texture t = _texture.get(textureUnit);
        if (t == null) {
            return false;
        }

        _texture.set(textureUnit, null);
View Full Code Here

                        continue;
                    }

                    foundEnabled = true;
                    for (int i = 0, max = pkTState.getMaxTextureIndexUsed(); i <= max; i++) {
                        final Texture pkText = pkTState.getTexture(i);
                        if (newTState.getTexture(i) == null) {
                            newTState.setTexture(pkText, i);
                        }
                    }
                }
                break;
            case CombineFirst:
                for (int iIndex = 0, max = states.length; iIndex < max; iIndex++) {
                    final TextureState pkTState = (TextureState) states[iIndex];
                    if (!pkTState.isEnabled()) {
                        continue;
                    }

                    foundEnabled = true;
                    for (int i = 0; i < TextureState.MAX_TEXTURES; i++) {
                        final Texture pkText = pkTState.getTexture(i);
                        if (newTState.getTexture(i) == null) {
                            newTState.setTexture(pkText, i);
                        }
                    }
                }
View Full Code Here

                store.getSkinNames().add(name);
            }

            // Apply our texture
            if (isLoadTextures()) {
                Texture tex = null;
                for (final String name : texNames) {
                    tex = loadTexture(name);
                    if (tex != null) {
                        break;
                    }
View Full Code Here

            throw new Error("Unable to load md2 resource from URL: " + resource, e);
        }
    }

    private Texture loadTexture(final String name) {
        Texture tex = null;
        if (_textureLocator == null) {
            tex = TextureManager.load(name, getMinificationFilter(),
                    isUseCompression() ? TextureStoreFormat.GuessCompressedFormat
                            : TextureStoreFormat.GuessNoCompressedFormat, isFlipTextureVertically());
        } else {
View Full Code Here

            final ImageDataFormat fmt = useAlpha ? ImageDataFormat.RGBA : ImageDataFormat.RGB;
            final Image image = new Image(fmt, PixelDataType.UnsignedByte, atlasWidth, atlasHeight, data, null);

            final TextureStoreFormat format = atlasTextureParameter.compress ? TextureStoreFormat.GuessCompressedFormat
                    : TextureStoreFormat.GuessNoCompressedFormat;
            final Texture texture = TextureManager.loadFromImage(image, atlasTextureParameter.minificationFilter,
                    format);
            texture.setMagnificationFilter(atlasTextureParameter.magnificationFilter);

            texture.setWrap(atlasTextureParameter.wrapMode);
            texture.setApply(atlasTextureParameter.applyMode);

            textures.add(texture);
        }

        for (final List<TextureParameter> paramList : cachedAtlases.values()) {
            for (final TextureParameter param : paramList) {
                final Texture texture = textures.get(param.getAtlasIndex());
                final TextureState ts = (TextureState) param.getMesh().getLocalRenderState(StateType.Texture);
                ts.setTexture(texture, param.getTargetTextureIndex());
                ts.setNeedsRefresh(true);
            }
        }
View Full Code Here

        // Add a bloom effect
        final SimpleBloomEffect bloomEffect = new SimpleBloomEffect();
        effectManager.addEffect(bloomEffect);

        // Add a sepia tone post effect
        final Texture sepiaTexture = TextureManager.load(
                new URLResourceSource(ResourceLocatorTool.getClassPathResource(ColorReplaceEffect.class,
                        "com/ardor3d/extension/effect/sepiatone.png")), Texture.MinificationFilter.Trilinear, true);
        final ColorReplaceEffect sepiaEffect = new ColorReplaceEffect(sepiaTexture);
        effectManager.addEffect(sepiaEffect);
View Full Code Here

     */
    private Skybox buildSkyBox() {
        final Skybox skybox = new Skybox("skybox", 10, 10, 10);

        final String dir = "images/skybox/";
        final Texture north = TextureManager
                .load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        final Texture south = TextureManager
                .load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);

        skybox.setTexture(Skybox.Face.North, north);
        skybox.setTexture(Skybox.Face.West, west);
        skybox.setTexture(Skybox.Face.South, south);
        skybox.setTexture(Skybox.Face.East, east);
View Full Code Here

    @Override
    protected void initExample() {
        _canvas.setTitle("Texture3D Example - Ardor3D");

        final TextureState ts = new TextureState();
        final Texture texture = createTexture();
        texture.setEnvironmentalMapMode(EnvironmentalMapMode.ObjectLinear);
        ts.setTexture(texture);
        _root.setRenderState(ts);

        final Sphere sp = new Sphere("sphere", 16, 16, 2);
        _root.attachChild(sp);

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final Texture tex = createTexture();
                tex.setEnvironmentalMapMode(EnvironmentalMapMode.ObjectLinear);
                ts.setTexture(tex);
                ts.setNeedsRefresh(true);
            }
        }));
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.image.Texture

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.