Java Code Examples for com.jme3.material.Material#isTransparent()

The following examples show how to use com.jme3.material.Material#isTransparent() . 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: MeshLoader.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void applyMaterial(Geometry geom, String matName) {
    Material mat = null;
    if (matName == null) {
        // no material specified. use placeholder.
        mat = null;
    } else if (matName.endsWith(".j3m")) {
        // load as native jme3 material instance
        try {
            mat = assetManager.loadMaterial(matName);
        } catch (AssetNotFoundException ex) {
            // Warning will be raised (see below)
            if (!ex.getMessage().equals(matName)) {
                throw ex;
            }
        }
    } else {
        if (materialList != null) {
            mat = materialList.get(matName);
        }
    }

    if (mat == null) {
        logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{matName, key});
        mat = PlaceholderAssets.getPlaceholderMaterial(assetManager);
        //mat.setKey(new MaterialKey(matName));
    }

    if (mat.isTransparent()) {
        geom.setQueueBucket(Bucket.Transparent);
    }

    if(mat.isReceivesShadows()){
        geom.setShadowMode(RenderQueue.ShadowMode.Receive);
    }

    geom.setMaterial(mat);
}
 
Example 2
Source File: MeshLoader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void applyMaterial(Geometry geom, String matName) {
    Material mat = null;
    if (matName.endsWith(".j3m")) {
        // load as native jme3 material instance
        try {
            mat = assetManager.loadMaterial(matName);
        } catch (AssetNotFoundException ex) {
            // Warning will be raised (see below)
            if (!ex.getMessage().equals(matName)) {
                throw ex;
            }
        }
    } else {
        if (materialList != null) {
            mat = materialList.get(matName);
        }
    }

    if (mat == null) {
        logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{matName, key});
        mat = PlaceholderAssets.getPlaceholderMaterial(assetManager);
        //mat.setKey(new MaterialKey(matName));
    }

    if (mat.isTransparent()) {
        geom.setQueueBucket(Bucket.Transparent);
    }

    geom.setMaterial(mat);
}