Package com.jme3.texture

Examples of com.jme3.texture.Texture


        path = split[split.length-1];
       
        String name = new File(path).getName();
        TextureKey texKey = new TextureKey(folderName + name);
        texKey.setGenerateMips(true);
        Texture texture;
        try {
            texture = assetManager.loadTexture(texKey);
            texture.setWrap(WrapMode.Repeat);
        } catch (AssetNotFoundException ex){
            logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[]{texKey, key});
            texture = new Texture2D(PlaceholderAssets.getPlaceholderImage());
            texture.setWrap(WrapMode.Repeat);
            texture.setKey(key);
        }
        return texture;
    }
View Full Code Here


        Material result = new Material(blenderContext.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");

        // copying texture
        MatParam diffuseMap = material.getParam("DiffuseMap");
        if (diffuseMap != null) {
            Texture texture = ((Texture) diffuseMap.getValue()).clone();

            // applying alpha mask to the texture
            Image image = texture.getImage();
            ByteBuffer sourceBB = image.getData(0);
            sourceBB.rewind();
            int w = image.getWidth();
            int h = image.getHeight();
            ByteBuffer bb = BufferUtils.createByteBuffer(w * h * 4);
            IAlphaMask iAlphaMask = alphaMasks.get(alphaMaskIndex);
            iAlphaMask.setImageSize(w, h);

            for (int x = 0; x < w; ++x) {
                for (int y = 0; y < h; ++y) {
                    bb.put(sourceBB.get());
                    bb.put(sourceBB.get());
                    bb.put(sourceBB.get());
                    bb.put(iAlphaMask.getAlpha(x, y));
                }
            }

            image = new Image(Format.RGBA8, w, h, bb);
            texture.setImage(image);

            result.setTextureParam("Texture", VarType.Texture2D, texture);
        }

        // copying glow color
View Full Code Here

        return GL_COLOR_ATTACHMENT0_EXT + attachmentSlot;
    }

    public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) {
        Texture tex = rb.getTexture();
        Image image = tex.getImage();
        if (image.isUpdateNeeded()) {
            updateTexImageData(image, tex.getType(), 0);

            // NOTE: For depth textures, sets nearest/no-mips mode
            // Required to fix "framebuffer unsupported"
            // for old NVIDIA drivers!
            setupTextureParams(tex);
        }

        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
                convertAttachmentSlot(rb.getSlot()),
                convertTextureType(tex.getType(), image.getMultiSamples(), rb.getFace()),
                image.getId(),
                0);
    }
View Full Code Here

        // generate mipmaps for last FB if needed
        if (lastFb != null) {
            for (int i = 0; i < lastFb.getNumColorBuffers(); i++) {
                RenderBuffer rb = lastFb.getColorBuffer(i);
                Texture tex = rb.getTexture();
                if (tex != null
                        && tex.getMinFilter().usesMipMapLevels()) {
                    setTexture(0, rb.getTexture());

                    int textureType = convertTextureType(tex.getType(), tex.getImage().getMultiSamples(), rb.getFace());
                    glEnable(textureType);
                    glGenerateMipmapEXT(textureType);
                    glDisable(textureType);
                }
            }
View Full Code Here

  /**
   * This function is for legacy support only.
   */
  @Deprecated
  public static Spatial createSimpleSkyBox(AssetManager assetManager) {
    Texture west = assetManager.loadTexture("skybox/milkyway/left.png");
    Texture east = assetManager.loadTexture("skybox/milkyway/right.png");
    Texture north = assetManager.loadTexture("skybox/milkyway/front.png");
    Texture south = assetManager.loadTexture("skybox/milkyway/back.png");
    Texture up = assetManager.loadTexture("skybox/milkyway/top.png");
    Texture down = assetManager.loadTexture("skybox/milkyway/bottom.png");

    Spatial skySpatial = SkyFactory.createSky(assetManager, west, east, north, south, up, down);

    return skySpatial;
  }
View Full Code Here

  }

  private static Spatial createSimpleSkyBox() {
    AssetManager assetManager = GlobalObjectStore
        .<AssetManager> getObject(AssetManager.class);
    Texture west = assetManager.loadTexture("skybox/milkyway/left.png");
    Texture east = assetManager.loadTexture("skybox/milkyway/right.png");
    Texture north = assetManager.loadTexture("skybox/milkyway/front.png");
    Texture south = assetManager.loadTexture("skybox/milkyway/back.png");
    Texture up = assetManager.loadTexture("skybox/milkyway/top.png");
    Texture down = assetManager.loadTexture("skybox/milkyway/bottom.png");

    Spatial skySpatial = SkyFactory.createSky(assetManager, west, east,
        north, south, up, down);

    return skySpatial;
View Full Code Here

        Sphere bullet = new Sphere(32, 32, 0.4f, true, false);
        bullet.setTextureMode(TextureMode.Projected);
        Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
        TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
        key2.setGenerateMips(true);
        Texture tex2 = app.getAssetManager().loadTexture(key2);
        mat2.setTexture("ColorMap", tex2);
        if (name.equals("shoot") && !keyPressed) {
          Geometry bulletg = new Geometry("bullet", bullet);
          bulletg.setMaterial(mat2);
          bulletg.setShadowMode(ShadowMode.CastAndReceive);
View Full Code Here

        // worldState.am = assetManager;

        /*
         * load heightMap
         */
        Texture heightMapImage =
                // assetManager.loadTexture("textures/terrain/heightMaps/heightMap4x4_01.gif");
                // assetManager.loadTexture("textures/terrain/heightMaps/heightMap8x8_01.gif");
                                 assetManager.loadTexture("textures/terrain/heightMaps/heightMap16x16_02.gif");
        // assetManager.loadTexture("textures/terrain/heightMaps/heightMap32x32_02.gif");
        // assetManager.loadTexture("textures/terrain/heightMaps/heightMap64x64_01.gif");
        // assetManager.loadTexture("textures/terrain/heightMaps/heightMap128x128_02.gif");
        // assetManager.loadTexture("textures/terrain/heightMaps/heightMap256x256_01.gif");
        // assetManager.loadTexture("textures/terrain/heightMaps/heightMap512x512_02.gif");

        ImageBasedHeightMap heightMap;
        heightMap = new ImageBasedHeightMap(heightMapImage.getImage());
        heightMap.load(false, false);

        float[][][] data = VoxelState.loadFromHeightMap(heightMap, VoxelMode.LINE_2D);

        /*
 
View Full Code Here

        //make terrain material and load 4 textures into it
        mat_terrain = new Material(mgr, "Textures/Terrain/Terrain.j3md");
        //add alpha map
        mat_terrain.setTexture("Alpha", mgr.loadTexture("Textures/Terrain/alphamap3.png"));
        //add grass
        Texture grass = mgr.loadTexture("Textures/Terrain/grass.jpg");
        grass.setWrap(WrapMode.Repeat);
        mat_terrain.setTexture("Tex1", grass);
        mat_terrain.setFloat("Tex1Scale", 64f);
        //add the snow
        Texture snow = mgr.loadTexture("Textures/Terrain/snow.jpg");
        snow.setWrap(WrapMode.Repeat);
        mat_terrain.setTexture("Tex2", snow);
        mat_terrain.setFloat("Tex2Scale", 8f);
        //make a dirt road
        Texture dirt = mgr.loadTexture("Textures/Terrain/dirt.jpg");
        dirt.setWrap(WrapMode.Repeat);
        mat_terrain.setTexture("Tex3", dirt);
        mat_terrain.setFloat("Tex3Scale", 128f);
        //create height map
        HillHeightMap heightMap = null;
        try {
View Full Code Here

        this.EAST = EAST;
        this.SOUTH = SOUTH;
        this.WEST = WEST;
        this.TOP = TOP;
        this.BOTTOM = BOTTOM;
        Texture t;
    }
View Full Code Here

TOP

Related Classes of com.jme3.texture.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.