Search in sources :

Example 6 with Environment

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

the class ShapeObject method initModel.

public void initModel() {
    this.localTransform = new Matrix4();
    if (model == null) {
        Pair<IntModel, Map<String, Material>> m = ModelCache.cache.getModel(modelShape, modelParams, Bits.indexes(Usage.Position), primitiveType);
        model = m.getFirst();
        for (Map.Entry<String, Material> material : m.getSecond().entrySet()) {
            material.getValue().set(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE));
            material.getValue().set(new ColorAttribute(ColorAttribute.Diffuse, cc[0], cc[1], cc[2], cc[3]));
        }
        mc = new ModelComponent(false);
        mc.initialize(null);
        DirectionalLight dLight = new DirectionalLight();
        dLight.set(1, 1, 1, 1, 1, 1);
        mc.env = new Environment();
        mc.env.add(dLight);
        mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1.0f, 1.0f, 1.0f, 1f));
        mc.env.set(new FloatAttribute(FloatAttribute.Shininess, 0.2f));
        mc.instance = new IntModelInstance(model, new Matrix4());
        // Relativistic effects
        if (Settings.settings.runtime.relativisticAberration)
            mc.rec.setUpRelativisticEffectsMaterial(mc.instance.materials);
        // Gravitational waves
        if (Settings.settings.runtime.gravitationalWaves)
            mc.rec.setUpGravitationalWavesMaterial(mc.instance.materials);
    }
}
Also used : IntModelInstance(gaiasky.util.gdx.model.IntModelInstance) BlendingAttribute(gaiasky.util.gdx.shader.attribute.BlendingAttribute) Material(gaiasky.util.gdx.shader.Material) Matrix4(com.badlogic.gdx.math.Matrix4) ModelComponent(gaiasky.scenegraph.component.ModelComponent) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) Environment(gaiasky.util.gdx.shader.Environment) FloatAttribute(gaiasky.util.gdx.shader.attribute.FloatAttribute) IntModel(gaiasky.util.gdx.model.IntModel) ColorAttribute(gaiasky.util.gdx.shader.attribute.ColorAttribute) Map(java.util.Map)

Aggregations

Environment (gaiasky.util.gdx.shader.Environment)6 Matrix4 (com.badlogic.gdx.math.Matrix4)5 ColorAttribute (gaiasky.util.gdx.shader.attribute.ColorAttribute)5 Texture (com.badlogic.gdx.graphics.Texture)4 ModelComponent (gaiasky.scenegraph.component.ModelComponent)4 IntModelInstance (gaiasky.util.gdx.model.IntModelInstance)4 Material (gaiasky.util.gdx.shader.Material)4 BlendingAttribute (gaiasky.util.gdx.shader.attribute.BlendingAttribute)4 FloatAttribute (gaiasky.util.gdx.shader.attribute.FloatAttribute)4 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)3 IntModel (gaiasky.util.gdx.model.IntModel)3 TextureAttribute (gaiasky.util.gdx.shader.attribute.TextureAttribute)2 Map (java.util.Map)2 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 DecalBatch (com.badlogic.gdx.graphics.g3d.decals.DecalBatch)1 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)1 SceneGraphRenderer (gaiasky.render.SceneGraphRenderer)1 ShadowMapImpl (gaiasky.render.ShadowMapImpl)1 IntMeshPartBuilder (gaiasky.util.gdx.IntMeshPartBuilder)1 IntModelBatch (gaiasky.util.gdx.IntModelBatch)1