com.jme3.material.RenderState.FaceCullMode Java Examples

The following examples show how to use com.jme3.material.RenderState.FaceCullMode. 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: BlenderKey.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void write(JmeExporter e) throws IOException {
    super.write(e);
    OutputCapsule oc = e.getCapsule(this);
    oc.write(fps, "fps", DEFAULT_FPS);
    oc.write(featuresToLoad, "features-to-load", FeaturesToLoad.ALL);
    oc.write(loadUnlinkedAssets, "load-unlinked-assets", false);
    oc.write(assetRootPath, "asset-root-path", null);
    oc.write(fixUpAxis, "fix-up-axis", true);
    oc.write(generatedTexturePPU, "generated-texture-ppu", 128);
    oc.write(usedWorld, "used-world", null);
    oc.write(defaultMaterial, "default-material", null);
    oc.write(faceCullMode, "face-cull-mode", FaceCullMode.Off);
    oc.write(layersToLoad, "layers-to-load", -1);
    oc.write(mipmapGenerationMethod, "mipmap-generation-method", MipmapGenerationMethod.GENERATE_WHEN_NEEDED);
}
 
Example #2
Source File: BlenderKey.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule ic = e.getCapsule(this);
    fps = ic.readInt("fps", DEFAULT_FPS);
    featuresToLoad = ic.readInt("features-to-load", FeaturesToLoad.ALL);
    loadUnlinkedAssets = ic.readBoolean("load-unlinked-assets", false);
    assetRootPath = ic.readString("asset-root-path", null);
    fixUpAxis = ic.readBoolean("fix-up-axis", true);
    generatedTexturePPU = ic.readInt("generated-texture-ppu", 128);
    usedWorld = ic.readString("used-world", null);
    defaultMaterial = (Material) ic.readSavable("default-material", null);
    faceCullMode = ic.readEnum("face-cull-mode", FaceCullMode.class, FaceCullMode.Off);
    layersToLoad = ic.readInt("layers-to=load", -1);
    mipmapGenerationMethod = ic.readEnum("mipmap-generation-method", MipmapGenerationMethod.class, MipmapGenerationMethod.GENERATE_WHEN_NEEDED);
}
 
Example #3
Source File: PreDepthProcessor.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public PreDepthProcessor(AssetManager assetManager){
    this.assetManager = assetManager;
    preDepth = new Material(assetManager, "Common/MatDefs/Shadow/PreShadow.j3md");
    preDepth.getAdditionalRenderState().setPolyOffset(0, 0);
    preDepth.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Back);

    forcedRS = new RenderState();
    forcedRS.setDepthTest(true);
    forcedRS.setDepthWrite(false);
}
 
Example #4
Source File: J3MLoader.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void readRenderStateStatement(Statement statement) throws IOException{
    String[] split = statement.getLine().split(whitespacePattern);
    if (split[0].equals("Wireframe")){
        renderState.setWireframe(parseBoolean(split[1]));
    }else if (split[0].equals("FaceCull")){
        renderState.setFaceCullMode(FaceCullMode.valueOf(split[1]));
    }else if (split[0].equals("DepthWrite")){
        renderState.setDepthWrite(parseBoolean(split[1]));
    }else if (split[0].equals("DepthTest")){
        renderState.setDepthTest(parseBoolean(split[1]));
    }else if (split[0].equals("Blend")){
        renderState.setBlendMode(BlendMode.valueOf(split[1]));
    }else if (split[0].equals("BlendEquation")){
        renderState.setBlendEquation(BlendEquation.valueOf(split[1]));
    }else if (split[0].equals("BlendEquationAlpha")){
        renderState.setBlendEquationAlpha(RenderState.BlendEquationAlpha.valueOf(split[1]));
    }else if (split[0].equals("AlphaTestFalloff")){
        // Ignore for backwards compatbility
    }else if (split[0].equals("PolyOffset")){
        float factor = Float.parseFloat(split[1]);
        float units = Float.parseFloat(split[2]);
        renderState.setPolyOffset(factor, units);
    }else if (split[0].equals("ColorWrite")){
        renderState.setColorWrite(parseBoolean(split[1]));
    }else if (split[0].equals("PointSprite")){
        // Ignore for backwards compatbility
    }else if (split[0].equals("DepthFunc")){
        renderState.setDepthFunc(RenderState.TestFunction.valueOf(split[1]));
    }else if (split[0].equals("AlphaFunc")){
        renderState.setAlphaFunc(RenderState.TestFunction.valueOf(split[1]));
    }else if (split[0].equals("LineWidth")){
        renderState.setLineWidth(Float.parseFloat(split[1]));
    } else {
        throw new MatParseException(null, split[0], statement);
    }
}
 
Example #5
Source File: J3MLoader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void readRenderStateStatement(String statement) throws IOException{
    String[] split = statement.split(whitespacePattern);
    if (split[0].equals("Wireframe")){
        renderState.setWireframe(parseBoolean(split[1]));
    }else if (split[0].equals("FaceCull")){
        renderState.setFaceCullMode(FaceCullMode.valueOf(split[1]));
    }else if (split[0].equals("DepthWrite")){
        renderState.setDepthWrite(parseBoolean(split[1]));
    }else if (split[0].equals("DepthTest")){
        renderState.setDepthTest(parseBoolean(split[1]));
    }else if (split[0].equals("Blend")){
        renderState.setBlendMode(BlendMode.valueOf(split[1]));
    }else if (split[0].equals("AlphaTestFalloff")){
        renderState.setAlphaTest(true);
        renderState.setAlphaFallOff(Float.parseFloat(split[1]));
    }else if (split[0].equals("PolyOffset")){
        float factor = Float.parseFloat(split[1]);
        float units = Float.parseFloat(split[2]);
        renderState.setPolyOffset(factor, units);
    }else if (split[0].equals("ColorWrite")){
        renderState.setColorWrite(parseBoolean(split[1]));
    }else if (split[0].equals("PointSprite")){
        renderState.setPointSprite(parseBoolean(split[1]));
    }else{
        throwIfNequal(null, split[0]);
    }
}
 
Example #6
Source File: PreDepthProcessor.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public PreDepthProcessor(AssetManager assetManager){
    this.assetManager = assetManager;
    preDepth = new Material(assetManager, "Common/MatDefs/Shadow/PreShadow.j3md");
    preDepth.getAdditionalRenderState().setPolyOffset(0, 0);
    preDepth.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Back);

    forcedRS = new RenderState();
    forcedRS.setDepthTest(true);
    forcedRS.setDepthWrite(false);
}
 
Example #7
Source File: SceneEditTool.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
     * Create the axis marker that is selectable
     */
    protected Node createAxisMarker() {
        float size = 2;
        float arrowSize = size;
        float planeSize = size * 0.7f;

        Quaternion YAW090 = new Quaternion().fromAngleAxis(-FastMath.PI / 2, new Vector3f(0, 1, 0));
        Quaternion PITCH090 = new Quaternion().fromAngleAxis(FastMath.PI / 2, new Vector3f(1, 0, 0));

        redMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        redMat.getAdditionalRenderState().setWireframe(true);
        redMat.setColor("Color", ColorRGBA.Red);
        //redMat.getAdditionalRenderState().setDepthTest(false);
        greenMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        greenMat.getAdditionalRenderState().setWireframe(true);
        greenMat.setColor("Color", ColorRGBA.Green);
        //greenMat.getAdditionalRenderState().setDepthTest(false);
        blueMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        blueMat.getAdditionalRenderState().setWireframe(true);
        blueMat.setColor("Color", ColorRGBA.Blue);
        //blueMat.getAdditionalRenderState().setDepthTest(false);
        yellowMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        yellowMat.getAdditionalRenderState().setWireframe(false);
        yellowMat.setColor("Color", new ColorRGBA(1f, 1f, 0f, 0.25f));
        yellowMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
        yellowMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
        //yellowMat.getAdditionalRenderState().setDepthTest(false);
        cyanMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        cyanMat.getAdditionalRenderState().setWireframe(false);
        cyanMat.setColor("Color", new ColorRGBA(0f, 1f, 1f, 0.25f));
        cyanMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
        cyanMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
        //cyanMat.getAdditionalRenderState().setDepthTest(false);
        magentaMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        magentaMat.getAdditionalRenderState().setWireframe(false);
        magentaMat.setColor("Color", new ColorRGBA(1f, 0f, 1f, 0.25f));
        magentaMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
        magentaMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
        //magentaMat.getAdditionalRenderState().setDepthTest(false);

        orangeMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        orangeMat.getAdditionalRenderState().setWireframe(false);
        orangeMat.setColor("Color", new ColorRGBA(251f / 255f, 130f / 255f, 0f, 0.4f));
        orangeMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
        orangeMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);

        Node axis = new Node();

        // create arrows
        Geometry arrowX = new Geometry("arrowX", new Arrow(new Vector3f(arrowSize, 0, 0)));
        Geometry arrowY = new Geometry("arrowY", new Arrow(new Vector3f(0, arrowSize, 0)));
        Geometry arrowZ = new Geometry("arrowZ", new Arrow(new Vector3f(0, 0, arrowSize)));
        axis.attachChild(arrowX);
        axis.attachChild(arrowY);
        axis.attachChild(arrowZ);

        // create planes
        quadXY = new Geometry("quadXY", new Quad(planeSize, planeSize));
        quadXZ = new Geometry("quadXZ", new Quad(planeSize, planeSize));
        quadXZ.setLocalRotation(PITCH090);
        quadYZ = new Geometry("quadYZ", new Quad(planeSize, planeSize));
        quadYZ.setLocalRotation(YAW090);
//        axis.attachChild(quadXY);
//        axis.attachChild(quadXZ);
//        axis.attachChild(quadYZ);

        axis.setModelBound(new BoundingBox());
        return axis;
    }
 
Example #8
Source File: MaterialContext.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * This method sets the face cull mode.
 * @param faceCullMode
 *            the face cull mode
 */
public void setFaceCullMode(FaceCullMode faceCullMode) {
    this.faceCullMode = faceCullMode;
}
 
Example #9
Source File: BlenderKey.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * This method returns the face cull mode.
 * @return the face cull mode
 */
public FaceCullMode getFaceCullMode() {
    return faceCullMode;
}
 
Example #10
Source File: BlenderKey.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * This method sets the face cull mode.
 * @param faceCullMode
 *            the face cull mode
 */
public void setFaceCullMode(FaceCullMode faceCullMode) {
    this.faceCullMode = faceCullMode;
}