Search in sources :

Example 1 with Material

use of gaiasky.util.gdx.shader.Material in project gaiasky by langurmonkey.

the class StubModel method setTransparency.

public void setTransparency(float alpha) {
    if (instance != null) {
        int n = instance.materials.size;
        for (int i = 0; i < n; i++) {
            Material mat = instance.materials.get(i);
            BlendingAttribute ba = null;
            if (mat.has(BlendingAttribute.Type)) {
                ba = (BlendingAttribute) mat.get(BlendingAttribute.Type);
            } else {
                ba = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
                mat.set(ba);
            }
            ba.opacity = alpha;
        }
    }
}
Also used : BlendingAttribute(gaiasky.util.gdx.shader.attribute.BlendingAttribute) Material(gaiasky.util.gdx.shader.Material)

Example 2 with Material

use of gaiasky.util.gdx.shader.Material in project gaiasky by langurmonkey.

the class ModelComponent method setTransparency.

public void setTransparency(float alpha, int src, int dst) {
    int n = instance.materials.size;
    for (int i = 0; i < n; i++) {
        Material mat = instance.materials.get(i);
        BlendingAttribute ba;
        if (mat.has(BlendingAttribute.Type)) {
            ba = (BlendingAttribute) mat.get(BlendingAttribute.Type);
            ba.destFunction = dst;
            ba.sourceFunction = src;
        } else {
            ba = new BlendingAttribute(src, dst);
            mat.set(ba);
        }
        ba.opacity = alpha;
    }
}
Also used : Material(gaiasky.util.gdx.shader.Material)

Example 3 with Material

use of gaiasky.util.gdx.shader.Material in project gaiasky by langurmonkey.

the class ModelComponent method addReflectionCubemapAttribute.

public void addReflectionCubemapAttribute(Array<Material> materials) {
    for (Material mat : materials) {
        if (mat.has(ColorAttribute.Reflection) || mat.has(TextureAttribute.Reflection)) {
            MaterialComponent.reflectionCubemap.prepareCubemap(manager);
            mat.set(new CubemapAttribute(CubemapAttribute.ReflectionCubemap, MaterialComponent.reflectionCubemap.cubemap));
        }
    }
}
Also used : Material(gaiasky.util.gdx.shader.Material)

Example 4 with Material

use of gaiasky.util.gdx.shader.Material in project gaiasky by langurmonkey.

the class ModelComponent method setDepthTest.

public void setDepthTest(int func, boolean mask) {
    if (instance != null) {
        int n = instance.materials.size;
        for (int i = 0; i < n; i++) {
            Material mat = instance.materials.get(i);
            DepthTestAttribute dta;
            if (mat.has(DepthTestAttribute.Type)) {
                dta = (DepthTestAttribute) mat.get(DepthTestAttribute.Type);
            } else {
                dta = new DepthTestAttribute();
                mat.set(dta);
            }
            dta.depthFunc = func;
            dta.depthMask = mask;
        }
    }
}
Also used : Material(gaiasky.util.gdx.shader.Material)

Example 5 with Material

use of gaiasky.util.gdx.shader.Material in project gaiasky by langurmonkey.

the class ModelComponent method addColorToMat.

public void addColorToMat() {
    if (cc != null && useColor) {
        // Regular mesh, we use the color
        int n = instance.materials.size;
        for (int i = 0; i < n; i++) {
            Material material = instance.materials.get(i);
            if (material.get(TextureAttribute.Ambient) == null && material.get(TextureAttribute.Diffuse) == null) {
                material.set(new ColorAttribute(ColorAttribute.Diffuse, cc[0], cc[1], cc[2], cc[3]));
                material.set(new ColorAttribute(ColorAttribute.Ambient, cc[0], cc[1], cc[2], cc[3]));
                if (!culling)
                    material.set(new IntAttribute(IntAttribute.CullFace, GL20.GL_NONE));
            }
        }
    }
}
Also used : Material(gaiasky.util.gdx.shader.Material)

Aggregations

Material (gaiasky.util.gdx.shader.Material)22 IntModel (gaiasky.util.gdx.model.IntModel)7 IntModelInstance (gaiasky.util.gdx.model.IntModelInstance)7 Texture (com.badlogic.gdx.graphics.Texture)6 BlendingAttribute (gaiasky.util.gdx.shader.attribute.BlendingAttribute)6 Matrix4 (com.badlogic.gdx.math.Matrix4)5 ColorAttribute (gaiasky.util.gdx.shader.attribute.ColorAttribute)5 ModelComponent (gaiasky.scenegraph.component.ModelComponent)4 Environment (gaiasky.util.gdx.shader.Environment)4 FloatAttribute (gaiasky.util.gdx.shader.attribute.FloatAttribute)4 TextureAttribute (gaiasky.util.gdx.shader.attribute.TextureAttribute)4 Map (java.util.Map)4 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)2 IntModelBuilder (gaiasky.util.gdx.IntModelBuilder)2 Pixmap (com.badlogic.gdx.graphics.Pixmap)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 TextureDescriptor (com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor)1 PixmapTextureData (com.badlogic.gdx.graphics.glutils.PixmapTextureData)1 ExtendViewport (com.badlogic.gdx.utils.viewport.ExtendViewport)1 IntMeshPartBuilder (gaiasky.util.gdx.IntMeshPartBuilder)1