Search in sources :

Example 1 with IntMeshPartBuilder

use of gaiasky.util.gdx.IntMeshPartBuilder 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)

Aggregations

Texture (com.badlogic.gdx.graphics.Texture)1 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)1 Matrix4 (com.badlogic.gdx.math.Matrix4)1 ModelComponent (gaiasky.scenegraph.component.ModelComponent)1 IntMeshPartBuilder (gaiasky.util.gdx.IntMeshPartBuilder)1 IntModelBuilder (gaiasky.util.gdx.IntModelBuilder)1 IntModelInstance (gaiasky.util.gdx.model.IntModelInstance)1 Environment (gaiasky.util.gdx.shader.Environment)1 Material (gaiasky.util.gdx.shader.Material)1 BlendingAttribute (gaiasky.util.gdx.shader.attribute.BlendingAttribute)1 ColorAttribute (gaiasky.util.gdx.shader.attribute.ColorAttribute)1 FloatAttribute (gaiasky.util.gdx.shader.attribute.FloatAttribute)1