Package com.ardor3d.renderer.state

Examples of com.ardor3d.renderer.state.MaterialState


        final TextureState ts = new TextureState();
        ts.setEnabled(true);
        ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true));
        _root.setRenderState(ts);

        final MaterialState ms = new MaterialState();
        ms.setColorMaterial(ColorMaterial.Diffuse);
        _root.setRenderState(ms);

        _passManager = new BasicPassManager();

        // setup some quads for debug viewing.
View Full Code Here


        final CullState cs = new CullState();
        cs.setCullFace(CullState.Face.Back);
        cs.setEnabled(true);
        _root.setRenderState(cs);

        final MaterialState ms = new MaterialState();
        ms.setColorMaterial(ColorMaterial.Diffuse);
        _root.setRenderState(ms);

        final TextureState ts = new TextureState();
        ts.setEnabled(true);
        ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear,
View Full Code Here

                            ts.setTexture(t, 1);
                            ts.setTexture(specular, 2);
                            skinnedMesh.setRenderState(ts);
                        }

                        final MaterialState ms = new MaterialState();
                        ms.setAmbient(MaterialState.MaterialFace.FrontAndBack, ColorRGBA.WHITE);
                        ms.setDiffuse(MaterialState.MaterialFace.FrontAndBack, ColorRGBA.WHITE);
                        ms.setSpecular(MaterialState.MaterialFace.FrontAndBack, ColorRGBA.WHITE);
                        ms.setShininess(32);
                        skinnedMesh.setRenderState(ms);

                        skinnedMesh.setGpuAttributeSize(3);
                        skinnedMesh.setGpuUseMatrixAttribute(true);
                        skinnedMesh.setUseGPU(true);
View Full Code Here

        final TextureState ts = new TextureState();
        ts.setEnabled(true);
        ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true));
        _root.setRenderState(ts);

        final MaterialState ms = new MaterialState();
        ms.setColorMaterial(ColorMaterial.Diffuse);
        _root.setRenderState(ms);

        _root.setTranslation(0, -1, 0);
    }
View Full Code Here

        }

        mesh.setRenderState(ts);

        // Add a material to the mesh, to show both vertex color and lighting/shading.
        final MaterialState ms = new MaterialState();
        ms.setColorMaterial(ColorMaterial.Diffuse);
        mesh.setRenderState(ms);
    }
View Full Code Here

                }
                final Element blinnPhongLambert = technique.getChild(type);
                if (mInfo != null) {
                    mInfo.setTechnique(type);
                }
                final MaterialState mState = new MaterialState();

                // TODO: implement proper transparency handling
                Texture diffuseTexture = null;
                ColorRGBA transparent = new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f);
                float transparency = 1.0f;
                boolean useTransparency = false;
                String opaqueMode = "A_ONE";

                /*
                 * place holder for current property, we import material properties in fixed order (for texture order)
                 */
                Element property = null;
                /* Diffuse property */
                property = blinnPhongLambert.getChild("diffuse");
                if (property != null) {
                    final Element propertyValue = property.getChildren().get(0);
                    if ("color".equals(propertyValue.getName())) {
                        final ColorRGBA color = _colladaDOMUtil.getColor(propertyValue.getText());
                        mState.setDiffuse(MaterialFace.FrontAndBack, color);
                    } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                        diffuseTexture = populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo,
                                "diffuse");
                    }
                }
                /* Ambient property */
                property = blinnPhongLambert.getChild("ambient");
                if (property != null) {
                    final Element propertyValue = property.getChildren().get(0);
                    if ("color".equals(propertyValue.getName())) {
                        final ColorRGBA color = _colladaDOMUtil.getColor(propertyValue.getText());
                        mState.setAmbient(MaterialFace.FrontAndBack, color);
                    } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                        populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "ambient");
                    }
                }
                /* Transparent property */
                property = blinnPhongLambert.getChild("transparent");
                if (property != null) {
                    final Element propertyValue = property.getChildren().get(0);
                    if ("color".equals(propertyValue.getName())) {
                        transparent = _colladaDOMUtil.getColor(propertyValue.getText());
                        // TODO: use this
                        useTransparency = true;
                    } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                        populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "transparent");
                    }
                    opaqueMode = property.getAttributeValue("opaque", "A_ONE");
                }
                /* Transparency property */
                property = blinnPhongLambert.getChild("transparency");
                if (property != null) {
                    final Element propertyValue = property.getChildren().get(0);
                    if ("float".equals(propertyValue.getName())) {
                        transparency = Float.parseFloat(propertyValue.getText().replace(",", "."));
                        // TODO: use this
                        if (_flipTransparency) {
                            transparency = 1f - transparency;
                        }
                        useTransparency = true;
                    } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                        populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "transparency");
                    }
                }
                /* Emission property */
                property = blinnPhongLambert.getChild("emission");
                if (property != null) {
                    final Element propertyValue = property.getChildren().get(0);
                    if ("color".equals(propertyValue.getName())) {
                        mState.setEmissive(MaterialFace.FrontAndBack, _colladaDOMUtil.getColor(propertyValue.getText()));
                    } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                        populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "emissive");
                    }
                }
                /* Specular property */
                property = blinnPhongLambert.getChild("specular");
                if (property != null) {
                    final Element propertyValue = property.getChildren().get(0);
                    if ("color".equals(propertyValue.getName())) {
                        mState.setSpecular(MaterialFace.FrontAndBack, _colladaDOMUtil.getColor(propertyValue.getText()));
                    } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                        populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "specular");
                    }
                }
                /* Shininess property */
                property = blinnPhongLambert.getChild("shininess");
                if (property != null) {
                    final Element propertyValue = property.getChildren().get(0);
                    if ("float".equals(propertyValue.getName())) {
                        float shininess = Float.parseFloat(propertyValue.getText().replace(",", "."));
                        if (shininess >= 0.0f && shininess <= 1.0f) {
                            final float oldShininess = shininess;
                            shininess *= 128;
                            logger.finest("Shininess - " + oldShininess
                                    + " - was in the [0,1] range. Scaling to [0, 128] - " + shininess);
                        } else if (shininess < 0 || shininess > 128) {
                            final float oldShininess = shininess;
                            shininess = MathUtils.clamp(shininess, 0, 128);
                            logger.warning("Shininess must be between 0 and 128. Shininess " + oldShininess
                                    + " was clamped to " + shininess);
                        }
                        mState.setShininess(MaterialFace.FrontAndBack, shininess);
                    } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                        populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "shininess");
                    }
                }
                /* Reflectivity property */
 
View Full Code Here

TOP

Related Classes of com.ardor3d.renderer.state.MaterialState

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.