Search in sources :

Example 6 with ColorAttribute

use of gaiasky.util.gdx.shader.attribute.ColorAttribute in project gaiasky by langurmonkey.

the class BackgroundModel method initialize.

@Override
public void initialize() {
    // Force texture loading
    mc.forceInit = true;
    mc.initialize(null);
    mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, cc[0], cc[1], cc[2], 1));
}
Also used : ColorAttribute(gaiasky.util.gdx.shader.attribute.ColorAttribute)

Example 7 with ColorAttribute

use of gaiasky.util.gdx.shader.attribute.ColorAttribute 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)

Example 8 with ColorAttribute

use of gaiasky.util.gdx.shader.attribute.ColorAttribute in project gaiasky by langurmonkey.

the class SpacecraftGui method doneLoading.

/**
 * Constructs the interface
 */
public void doneLoading(AssetManager assetManager) {
    aiTexture = assetManager.get(Settings.settings.data.dataFile("tex/base/attitudeindicator.png"), Texture.class);
    aiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    aiPointerTexture = assetManager.get("img/ai-pointer.png", Texture.class);
    aiPointerTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    aiVelTex = assetManager.get("img/ai-vel.png", Texture.class);
    aiVelTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    aiAntivelTex = assetManager.get("img/ai-antivel.png", Texture.class);
    aiAntivelTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    aiVelDec = Decal.newDecal(new TextureRegion(aiVelTex));
    aiAntivelDec = Decal.newDecal(new TextureRegion(aiAntivelTex));
    Material mat = new Material(new TextureAttribute(TextureAttribute.Diffuse, aiTexture), new ColorAttribute(ColorAttribute.Specular, 0.3f, 0.3f, 0.3f, 1f), new DepthTestAttribute(GL20.GL_LESS, aiCam.near, aiCam.far, true));
    aiModel = new IntModelBuilder().createSphere(1.6f, 30, 30, false, mat, Bits.indexes(Usage.Position, Usage.Normal, Usage.Tangent, Usage.BiNormal, Usage.TextureCoordinates));
    aiTransform = new Matrix4();
    aiModelInstance = new IntModelInstance(aiModel, aiTransform);
    aiViewport = new ExtendViewport(indicatorw * Settings.settings.program.ui.scale, indicatorh * Settings.settings.program.ui.scale, aiCam);
    buildGui();
    EventManager.instance.subscribe(this, gaiasky.event.Event.SPACECRAFT_STABILISE_CMD, gaiasky.event.Event.SPACECRAFT_STOP_CMD, gaiasky.event.Event.SPACECRAFT_INFO, gaiasky.event.Event.SPACECRAFT_NEAREST_INFO, gaiasky.event.Event.SPACECRAFT_THRUST_INFO);
    EventManager.instance.unsubscribe(this, gaiasky.event.Event.SPACECRAFT_LOADED);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) IntModelBuilder(gaiasky.util.gdx.IntModelBuilder) IntModelInstance(gaiasky.util.gdx.model.IntModelInstance) ExtendViewport(com.badlogic.gdx.utils.viewport.ExtendViewport) Material(gaiasky.util.gdx.shader.Material) DepthTestAttribute(gaiasky.util.gdx.shader.attribute.DepthTestAttribute) ColorAttribute(gaiasky.util.gdx.shader.attribute.ColorAttribute) Texture(com.badlogic.gdx.graphics.Texture) Matrix4(com.badlogic.gdx.math.Matrix4) TextureAttribute(gaiasky.util.gdx.shader.attribute.TextureAttribute)

Aggregations

ColorAttribute (gaiasky.util.gdx.shader.attribute.ColorAttribute)8 Matrix4 (com.badlogic.gdx.math.Matrix4)6 ModelComponent (gaiasky.scenegraph.component.ModelComponent)5 IntModelInstance (gaiasky.util.gdx.model.IntModelInstance)5 Environment (gaiasky.util.gdx.shader.Environment)5 Material (gaiasky.util.gdx.shader.Material)5 Texture (com.badlogic.gdx.graphics.Texture)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)3 IntModelBuilder (gaiasky.util.gdx.IntModelBuilder)2 Map (java.util.Map)2 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 DecalBatch (com.badlogic.gdx.graphics.g3d.decals.DecalBatch)1 ExtendViewport (com.badlogic.gdx.utils.viewport.ExtendViewport)1 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)1 IntMeshPartBuilder (gaiasky.util.gdx.IntMeshPartBuilder)1