Java Code Examples for com.jme3.asset.TextureKey#setAsCube()

The following examples show how to use com.jme3.asset.TextureKey#setAsCube() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderImageJme.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public RenderImageJme(String filename, boolean linear, NiftyJmeDisplay display){
    TextureKey key = new TextureKey(filename, true);

    key.setAnisotropy(0);
    key.setAsCube(false);
    key.setGenerateMips(false);
    
    texture = (Texture2D) display.getAssetManager().loadTexture(key);
    texture.setMagFilter(linear ? MagFilter.Bilinear : MagFilter.Nearest);
    texture.setMinFilter(linear ? MinFilter.BilinearNoMipMaps : MinFilter.NearestNoMipMaps);
    image = texture.getImage();

    width = image.getWidth();
    height = image.getHeight();
}
 
Example 2
Source File: TestEnvironmentMapping.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    final Node buggy = (Node) assetManager.loadModel("Models/Buggy/Buggy.j3o");

    TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true);
    key.setGenerateMips(true);
    key.setAsCube(true);
    final Texture tex = assetManager.loadTexture(key);

    for (Spatial geom : buggy.getChildren()) {
        if (geom instanceof Geometry) {
            Material m = ((Geometry) geom).getMaterial();
            m.setTexture("EnvMap", tex);
            m.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f));
        }
    }

    flyCam.setEnabled(false);

    ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
    chaseCam.setLookAtOffset(new Vector3f(0,0.5f,-1.0f));
    buggy.addControl(chaseCam);
    rootNode.attachChild(buggy);
    rootNode.attachChild(SkyFactory.createSky(assetManager, tex, false));

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
    bf.setBloomIntensity(2.3f);
    bf.setExposurePower(0.6f);
    
    fpp.addFilter(bf);
    
    viewPort.addProcessor(fpp);
}
 
Example 3
Source File: SkyFactory.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Spatial createSky(AssetManager assetManager, String textureName, boolean sphereMap) {
    TextureKey key = new TextureKey(textureName, true);
    key.setGenerateMips(true);
    key.setAsCube(!sphereMap);
    Texture tex = assetManager.loadTexture(key);
    return createSky(assetManager, tex, sphereMap);
}
 
Example 4
Source File: J3MLoader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private Object readValue(VarType type, String value) throws IOException{
        if (type.isTextureType()){
//            String texturePath = readString("[\n;(//)(\\})]");
            String texturePath = value.trim();
            boolean flipY = false;
            boolean repeat = false;
            if (texturePath.startsWith("Flip Repeat ")){
                texturePath = texturePath.substring(12).trim();
                flipY = true;
                repeat = true;
            }else if (texturePath.startsWith("Flip ")){
                texturePath = texturePath.substring(5).trim();
                flipY = true;
            }else if (texturePath.startsWith("Repeat ")){
                texturePath = texturePath.substring(7).trim();
                repeat = true;
            }

            TextureKey key = new TextureKey(texturePath, flipY);
            key.setAsCube(type == VarType.TextureCubeMap);
            key.setGenerateMips(true);

            Texture tex = owner.loadTexture(key);
            if (tex != null){
                if (repeat)
                    tex.setWrap(WrapMode.Repeat);
            }
            return tex;
        }else{
            String[] split = value.trim().split(whitespacePattern);
            switch (type){
                case Float:
                    if (split.length != 1){
                        throw new IOException("Float value parameter must have 1 entry: " + value);
                    }
                     return Float.parseFloat(split[0]);
                case Vector2:
                    if (split.length != 2){
                        throw new IOException("Vector2 value parameter must have 2 entries: " + value);
                    }
                    return new Vector2f(Float.parseFloat(split[0]),
                                                               Float.parseFloat(split[1]));
                case Vector3:
                    if (split.length != 3){
                        throw new IOException("Vector3 value parameter must have 3 entries: " + value);
                    }
                    return new Vector3f(Float.parseFloat(split[0]),
                                                               Float.parseFloat(split[1]),
                                                               Float.parseFloat(split[2]));
                case Vector4:
                    if (split.length != 4){
                        throw new IOException("Vector4 value parameter must have 4 entries: " + value);
                    }
                    return new ColorRGBA(Float.parseFloat(split[0]),
                                                                Float.parseFloat(split[1]),
                                                                Float.parseFloat(split[2]),
                                                                Float.parseFloat(split[3]));
                case Int:
                    if (split.length != 1){
                        throw new IOException("Int value parameter must have 1 entry: " + value);
                    }
                    return Integer.parseInt(split[0]);
                case Boolean:
                    if (split.length != 1){
                        throw new IOException("Boolean value parameter must have 1 entry: " + value);
                    }
                    return Boolean.parseBoolean(split[0]);
                default:
                    throw new UnsupportedOperationException("Unknown type: "+type);
            }
        }
    }