Search in sources :

Example 1 with ColorAttribute

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

the class RecursiveGrid method initialize.

@Override
public void initialize() {
    transformName = Settings.settings.scene.visibility.get(ComponentType.Galactic.toString()) ? "galacticToEquatorial" : (Settings.settings.scene.visibility.get(ComponentType.Ecliptic.toString()) ? "eclipticToEquatorial" : null);
    coordinateSystem = new Matrix4();
    coordinateSystemd = new Matrix4d();
    mat4daux = new Matrix4d();
    scalingFading = new Pair<>(0d, 0d);
    updateCoordinateSystem();
    nf = NumberFormatFactory.getFormatter("0.###E0");
    cc = Settings.settings.scene.visibility.get(ComponentType.Galactic.toString()) ? ccGal : (Settings.settings.scene.visibility.get(ComponentType.Ecliptic.toString()) ? ccEcl : ccEq);
    labelcolor = cc;
    label = true;
    labelPosition = new Vector3b();
    localTransform = new Matrix4();
    p01 = new Vector3d();
    p02 = new Vector3d();
    d01 = -1;
    d02 = -1;
    a = new Vector3d();
    b = new Vector3d();
    c = new Vector3d();
    d = new Vector3d();
    // Init billboard model
    mc = new ModelComponent();
    mc.setType("twofacedbillboard");
    Map<String, Object> p = new HashMap<>();
    p.put("diameter", 1d);
    mc.setParams(p);
    mc.forceInit = true;
    mc.initialize(null);
    mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, cc[0], cc[1], cc[2], cc[3]));
    // Depth reads, no depth writes
    mc.setDepthTest(GL20.GL_LEQUAL, false);
    // Initialize annotations vectorR
    initAnnotations();
}
Also used : Matrix4d(gaiasky.util.math.Matrix4d) Vector3b(gaiasky.util.math.Vector3b) Vector3d(gaiasky.util.math.Vector3d) ModelComponent(gaiasky.scenegraph.component.ModelComponent) HashMap(java.util.HashMap) ColorAttribute(gaiasky.util.gdx.shader.attribute.ColorAttribute) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 2 with ColorAttribute

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

the class Star method initModel.

private void initModel(final AssetManager manager) {
    Texture tex = manager.get(Settings.settings.data.dataFile("tex/base/star.jpg"), Texture.class);
    Texture lut = manager.get(Settings.settings.data.dataFile("tex/base/lut.jpg"), Texture.class);
    tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    Map<String, Object> params = new TreeMap<>();
    params.put("quality", 120L);
    params.put("diameter", 1d);
    params.put("flip", false);
    Pair<IntModel, Map<String, Material>> pair = ModelCache.cache.getModel("sphere", params, Bits.indexes(Usage.Position, Usage.Normal, Usage.TextureCoordinates), GL20.GL_TRIANGLES);
    IntModel model = pair.getFirst();
    Material mat = pair.getSecond().get("base");
    mat.clear();
    mat.set(new TextureAttribute(TextureAttribute.Diffuse, tex));
    mat.set(new TextureAttribute(TextureAttribute.Normal, lut));
    // Only to activate view vector (camera position)
    mat.set(new ColorAttribute(ColorAttribute.Specular));
    mat.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
    Matrix4 modelTransform = new Matrix4();
    mc = new ModelComponent(false);
    mc.initialize(null);
    mc.env = new Environment();
    mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
    mc.env.set(new FloatAttribute(FloatAttribute.Time, 0f));
    mc.instance = new IntModelInstance(model, modelTransform);
    // Relativistic effects
    if (Settings.settings.runtime.relativisticAberration)
        mc.rec.setUpRelativisticEffectsMaterial(mc.instance.materials);
    mc.setModelInitialized(true);
}
Also used : IntModelInstance(gaiasky.util.gdx.model.IntModelInstance) BlendingAttribute(gaiasky.util.gdx.shader.attribute.BlendingAttribute) Material(gaiasky.util.gdx.shader.Material) TreeMap(java.util.TreeMap) Texture(com.badlogic.gdx.graphics.Texture) Matrix4(com.badlogic.gdx.math.Matrix4) ModelComponent(gaiasky.scenegraph.component.ModelComponent) 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) TreeMap(java.util.TreeMap) TextureAttribute(gaiasky.util.gdx.shader.attribute.TextureAttribute)

Example 3 with ColorAttribute

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

the class StarCluster method initModel.

public void initModel() {
    if (clusterTex == null) {
        clusterTex = new Texture(Settings.settings.data.dataFileHandle("data/tex/base/cluster-tex.png"), true);
        clusterTex.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Linear);
    }
    if (model == null) {
        Material mat = new Material(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE), new ColorAttribute(ColorAttribute.Diffuse, cc[0], cc[1], cc[2], cc[3]));
        IntModelBuilder modelBuilder = ModelCache.cache.mb;
        modelBuilder.begin();
        // create part
        IntMeshPartBuilder bPartBuilder = modelBuilder.part("sph", GL20.GL_LINES, Bits.indexes(Usage.Position), mat);
        bPartBuilder.icosphere(1, 3, false, true);
        model = (modelBuilder.end());
        modelTransform = new Matrix4();
    }
    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, modelTransform);
    // 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 : IntModelBuilder(gaiasky.util.gdx.IntModelBuilder) IntModelInstance(gaiasky.util.gdx.model.IntModelInstance) BlendingAttribute(gaiasky.util.gdx.shader.attribute.BlendingAttribute) ModelComponent(gaiasky.scenegraph.component.ModelComponent) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) Environment(gaiasky.util.gdx.shader.Environment) Material(gaiasky.util.gdx.shader.Material) FloatAttribute(gaiasky.util.gdx.shader.attribute.FloatAttribute) ColorAttribute(gaiasky.util.gdx.shader.attribute.ColorAttribute) IntMeshPartBuilder(gaiasky.util.gdx.IntMeshPartBuilder) Texture(com.badlogic.gdx.graphics.Texture) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 4 with ColorAttribute

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

the class StarGroup method initModel.

private void initModel(final AssetManager manager) {
    Texture tex = manager.get(Settings.settings.data.dataFile("tex/base/star.jpg"), Texture.class);
    Texture lut = manager.get(Settings.settings.data.dataFile("tex/base/lut.jpg"), Texture.class);
    tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    Map<String, Object> params = new TreeMap<>();
    params.put("quality", 120L);
    params.put("diameter", 1d);
    params.put("flip", false);
    Pair<IntModel, Map<String, Material>> pair = ModelCache.cache.getModel("sphere", params, Bits.indexes(Usage.Position, Usage.Normal, Usage.Tangent, Usage.BiNormal, Usage.TextureCoordinates), GL20.GL_TRIANGLES);
    IntModel model = pair.getFirst();
    Material mat = pair.getSecond().get("base");
    mat.clear();
    mat.set(new TextureAttribute(TextureAttribute.Diffuse, tex));
    mat.set(new TextureAttribute(TextureAttribute.Normal, lut));
    // Only to activate view vector (camera position)
    mat.set(new ColorAttribute(ColorAttribute.Specular));
    mat.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
    Matrix4 modelTransform = new Matrix4();
    mc = new ModelComponent(false);
    mc.initialize(null);
    mc.env = new Environment();
    mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
    mc.env.set(new FloatAttribute(FloatAttribute.Time, 0f));
    mc.instance = new IntModelInstance(model, modelTransform);
    // Relativistic effects
    if (Settings.settings.runtime.relativisticAberration)
        mc.rec.setUpRelativisticEffectsMaterial(mc.instance.materials);
    mc.setModelInitialized(true);
}
Also used : IntModelInstance(gaiasky.util.gdx.model.IntModelInstance) BlendingAttribute(gaiasky.util.gdx.shader.attribute.BlendingAttribute) Material(gaiasky.util.gdx.shader.Material) Texture(com.badlogic.gdx.graphics.Texture) Matrix4(com.badlogic.gdx.math.Matrix4) ModelComponent(gaiasky.scenegraph.component.ModelComponent) 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) TextureAttribute(gaiasky.util.gdx.shader.attribute.TextureAttribute)

Example 5 with ColorAttribute

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

the class SpacecraftGui method initialize.

public void initialize(AssetManager assetManager, SpriteBatch sb) {
    this.sb = sb;
    // User interface
    ScreenViewport vp = new ScreenViewport();
    vp.setUnitsPerPixel(unitsPerPixel);
    ui = new Stage(vp, sb);
    indicatorw = 480f;
    indicatorh = 480f;
    indicatorx = -32f;
    indicatory = -20f;
    // init gui camera
    aiCam = new PerspectiveCamera(30, indicatorw * Settings.settings.program.ui.scale, indicatorh * Settings.settings.program.ui.scale);
    aiCam.near = (float) (1e5 * Constants.KM_TO_U);
    aiCam.far = (float) (1e8 * Constants.KM_TO_U);
    aiCam.up.set(0, 1, 0);
    aiCam.direction.set(0, 0, 1);
    aiCam.position.set(0, 0, 0);
    // Init AI
    dlight = new DirectionalLight();
    dlight.color.set(1f, 1f, 1f, 1f);
    dlight.setDirection(-1f, .05f, .5f);
    env = new Environment();
    env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f), new ColorAttribute(ColorAttribute.Specular, .5f, .5f, .5f, 1f));
    env.add(dlight);
    db = new DecalBatch(4, new CameraGroupStrategy(aiCam));
    mb = new IntModelBatch();
    assetManager.load(Settings.settings.data.dataFile("tex/base/attitudeindicator.png"), Texture.class);
    assetManager.load("img/ai-pointer.png", Texture.class);
    assetManager.load("img/ai-vel.png", Texture.class);
    assetManager.load("img/ai-antivel.png", Texture.class);
    EventManager.instance.subscribe(this, gaiasky.event.Event.SPACECRAFT_LOADED);
}
Also used : DecalBatch(com.badlogic.gdx.graphics.g3d.decals.DecalBatch) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) Environment(gaiasky.util.gdx.shader.Environment) CameraGroupStrategy(gaiasky.util.gdx.g3d.decals.CameraGroupStrategy) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(gaiasky.util.gdx.shader.attribute.ColorAttribute) IntModelBatch(gaiasky.util.gdx.IntModelBatch)

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