Search in sources :

Example 1 with GraphModels

use of com.gempukku.libgdx.graph.plugin.models.GraphModels in project gdx-graph by MarcinSc.

the class Episode7Scene method createStage.

private Stage createStage() {
    skin = new Skin(Gdx.files.classpath("skin/default/uiskin.json"));
    final TextButton switchButton = new TextButton("Normal/Toon", skin, "toggle");
    switchButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            boolean checked = switchButton.isChecked();
            String removeTag = checked ? "Default" : "Toon";
            String tag = checked ? "Toon" : "Default";
            GraphModels graphModels = pipelineRenderer.getPluginData(GraphModels.class);
            modelAdapter.removeTag(removeTag);
            modelAdapter.addTag(tag);
        }
    });
    Stage stage = new Stage(new ScreenViewport());
    Table tbl = new Table();
    tbl.add(switchButton).row();
    tbl.setFillParent(true);
    tbl.align(Align.topLeft);
    stage.addActor(tbl);
    return stage;
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) GraphModels(com.gempukku.libgdx.graph.plugin.models.GraphModels) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport)

Example 2 with GraphModels

use of com.gempukku.libgdx.graph.plugin.models.GraphModels in project gdx-graph by MarcinSc.

the class SpriteShaderTestScene method initializeScene.

@Override
public void initializeScene() {
    camera = new OrthographicCamera();
    pipelineRenderer = loadPipelineRenderer();
    ArrayValuePerVertex<Vector2> uvPerVertex = new ArrayValuePerVertex<>(new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 1), new Vector2(1, 1));
    GraphModels graphModels = pipelineRenderer.getPluginData(GraphModels.class);
    spriteBatch = new MultiPageSpriteBatchModel(true, 2, graphModels, "Test");
    MapWritablePropertyContainer sprite1 = new MapWritablePropertyContainer();
    sprite1.setValue("Position", new Vector3(0, 0, -10));
    sprite1.setValue("UV", uvPerVertex);
    ArrayValuePerVertex<Vector2> colorPerVertex = new ArrayValuePerVertex<>(new Vector2(0, 1), new Vector2(1, 0), new Vector2(0, 0), new Vector2(1, 1));
    sprite1.setValue("Vertex Color", colorPerVertex);
    MapWritablePropertyContainer sprite2 = new MapWritablePropertyContainer();
    sprite2.setValue("Position", new Vector3(150, 0, -10));
    sprite2.setValue("UV", uvPerVertex);
    spriteBatch.addSprite(new DefaultRenderableSprite(sprite1));
    spriteBatch.addSprite(new DefaultRenderableSprite(sprite2));
    graphModels.setGlobalProperty("Test", "Color", new Vector2(1f, 1f));
}
Also used : DefaultRenderableSprite(com.gempukku.libgdx.graph.util.sprite.DefaultRenderableSprite) GraphModels(com.gempukku.libgdx.graph.plugin.models.GraphModels) Vector2(com.badlogic.gdx.math.Vector2) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Vector3(com.badlogic.gdx.math.Vector3) MapWritablePropertyContainer(com.gempukku.libgdx.graph.shader.property.MapWritablePropertyContainer) ArrayValuePerVertex(com.gempukku.libgdx.graph.util.ArrayValuePerVertex) MultiPageSpriteBatchModel(com.gempukku.libgdx.graph.util.sprite.MultiPageSpriteBatchModel)

Example 3 with GraphModels

use of com.gempukku.libgdx.graph.plugin.models.GraphModels in project gdx-graph by MarcinSc.

the class ShadowShaderTestScene method initializeScene.

@Override
public void initializeScene() {
    camera = new PerspectiveCamera();
    camera.near = 0.1f;
    camera.far = 100;
    updateCamera();
    pipelineRenderer = loadPipelineRenderer();
    float halfSize = 5;
    ModelBuilder modelBuilder = new ModelBuilder();
    Model wall = modelBuilder.createBox(halfSize * 2, halfSize * 2, 0.001f, new Material(), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
    Model sphere = modelBuilder.createSphere(2, 2, 2, 50, 50, new Material(), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
    disposables.add(wall);
    disposables.add(sphere);
    ModelInstance wallInstance = new ModelInstance(wall);
    wallInstance.transform.translate(0, 0, -3);
    sphereInstance = new ModelInstance(sphere);
    GraphModels graphModels = pipelineRenderer.getPluginData(GraphModels.class);
    CommonPropertiesModelInstanceModelAdapter wallAdapter = new CommonPropertiesModelInstanceModelAdapter(wallInstance, graphModels);
    wallAdapter.getPropertyContainer().setValue("Color", Color.LIGHT_GRAY);
    CommonPropertiesModelInstanceModelAdapter sphereAdapter = new CommonPropertiesModelInstanceModelAdapter(sphereInstance, graphModels);
    sphereAdapter.getPropertyContainer().setValue("Color", Color.RED);
    wallAdapter.addTag("Color");
    wallAdapter.addTag("Color Shadow");
    sphereAdapter.addTag("Color");
    sphereAdapter.addTag("Color Shadow");
    Lighting3DPublicData lighting = pipelineRenderer.getPluginData(Lighting3DPublicData.class);
    environment = new Lighting3DEnvironment(new Vector3(), 20f);
    environment.setAmbientColor(new Color(0.1f, 0.1f, 0.1f, 1f));
    Directional3DLight directionalLight = new Directional3DLight();
    directionalLight.setColor(Color.WHITE);
    directionalLight.setIntensity(0.4f);
    directionalLight.setDirection(0, 0, -1);
    directionalLight.setShadowsEnabled(true);
    directionalLight.setShadowBufferSize(512);
    environment.addDirectionalLight(directionalLight);
    lighting.setEnvironment("Scene", environment);
    stage = createStage();
    disposables.add(stage);
    Gdx.input.setInputProcessor(stage);
    UIPluginPublicData ui = pipelineRenderer.getPluginData(UIPluginPublicData.class);
    ui.setStage("Stage", stage);
}
Also used : CommonPropertiesModelInstanceModelAdapter(com.gempukku.libgdx.graph.util.model.CommonPropertiesModelInstanceModelAdapter) Directional3DLight(com.gempukku.libgdx.graph.plugin.lighting3d.Directional3DLight) Color(com.badlogic.gdx.graphics.Color) Material(com.badlogic.gdx.graphics.g3d.Material) Vector3(com.badlogic.gdx.math.Vector3) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) UIPluginPublicData(com.gempukku.libgdx.graph.plugin.ui.UIPluginPublicData) GraphModels(com.gempukku.libgdx.graph.plugin.models.GraphModels) Lighting3DEnvironment(com.gempukku.libgdx.graph.plugin.lighting3d.Lighting3DEnvironment) Model(com.badlogic.gdx.graphics.g3d.Model) Lighting3DPublicData(com.gempukku.libgdx.graph.plugin.lighting3d.Lighting3DPublicData)

Aggregations

GraphModels (com.gempukku.libgdx.graph.plugin.models.GraphModels)3 Vector3 (com.badlogic.gdx.math.Vector3)2 Color (com.badlogic.gdx.graphics.Color)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 Material (com.badlogic.gdx.graphics.g3d.Material)1 Model (com.badlogic.gdx.graphics.g3d.Model)1 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)1 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)1 Directional3DLight (com.gempukku.libgdx.graph.plugin.lighting3d.Directional3DLight)1 Lighting3DEnvironment (com.gempukku.libgdx.graph.plugin.lighting3d.Lighting3DEnvironment)1 Lighting3DPublicData (com.gempukku.libgdx.graph.plugin.lighting3d.Lighting3DPublicData)1