Search in sources :

Example 21 with Material

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

Example 22 with Material

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

the class IntModel method loadNode.

protected IntNode loadNode(IntModelNode modelNode) {
    IntNode node = new IntNode();
    node.id = modelNode.id;
    if (modelNode.translation != null)
        node.translation.set(modelNode.translation);
    if (modelNode.rotation != null)
        node.rotation.set(modelNode.rotation);
    if (modelNode.scale != null)
        node.scale.set(modelNode.scale);
    // FIXME create temporary maps for faster lookup?
    if (modelNode.parts != null) {
        for (ModelNodePart modelNodePart : modelNode.parts) {
            IntMeshPart meshPart = null;
            Material meshMaterial = null;
            if (modelNodePart.meshPartId != null) {
                for (IntMeshPart part : meshParts) {
                    if (modelNodePart.meshPartId.equals(part.id)) {
                        meshPart = part;
                        break;
                    }
                }
            }
            if (modelNodePart.materialId != null) {
                for (Material material : materials) {
                    if (modelNodePart.materialId.equals(material.id)) {
                        meshMaterial = material;
                        break;
                    }
                }
            }
            if (meshPart == null || meshMaterial == null)
                throw new GdxRuntimeException("Invalid node: " + node.id);
            if (meshPart != null && meshMaterial != null) {
                IntNodePart nodePart = new IntNodePart();
                nodePart.meshPart = meshPart;
                nodePart.material = meshMaterial;
                node.parts.add(nodePart);
                if (modelNodePart.bones != null)
                    nodePartBones.put(nodePart, modelNodePart.bones);
            }
        }
    }
    if (modelNode.children != null) {
        for (IntModelNode child : modelNode.children) {
            node.addChild(loadNode(child));
        }
    }
    return node;
}
Also used : IntModelNode(gaiasky.util.gdx.model.data.IntModelNode) 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