Search in sources :

Example 1 with CommonPropertiesModelInstanceModelAdapter

use of com.gempukku.libgdx.graph.util.model.CommonPropertiesModelInstanceModelAdapter 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)

Example 2 with CommonPropertiesModelInstanceModelAdapter

use of com.gempukku.libgdx.graph.util.model.CommonPropertiesModelInstanceModelAdapter in project gdx-graph by MarcinSc.

the class Episode11Scene method createModels.

private void createModels(GraphModels models) {
    ModelBuilder modelBuilder = new ModelBuilder();
    Model forceField = modelBuilder.createRect(0, 10, 10, 0, -10, 10, 0, -10, -10, 0, 10, -10, 0, 0, 1, new Material(), VertexAttributes.Usage.Position);
    disposables.add(forceField);
    Model sphere = modelBuilder.createSphere(4f, 4f, 4f, 50, 50, new Material(), VertexAttributes.Usage.Position);
    disposables.add(sphere);
    ModelInstance forceFieldInstance = new ModelInstance(forceField);
    sphereInstance = new ModelInstance(sphere);
    CommonPropertiesModelInstanceModelAdapter forceFieldAdapter = new CommonPropertiesModelInstanceModelAdapter(forceFieldInstance, models, new MapWritablePropertyContainer());
    forceFieldAdapter.addTag("force-field");
    CommonPropertiesModelInstanceModelAdapter sphereAdapter = new CommonPropertiesModelInstanceModelAdapter(sphereInstance, models, new MapWritablePropertyContainer());
    sphereAdapter.addTag("default");
    sphereInstance.transform.idt().translate(-3f, 0, 0);
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) GraphModelInstance(com.gempukku.libgdx.graph.plugin.models.GraphModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) CommonPropertiesModelInstanceModelAdapter(com.gempukku.libgdx.graph.util.model.CommonPropertiesModelInstanceModelAdapter) Model(com.badlogic.gdx.graphics.g3d.Model) Material(com.badlogic.gdx.graphics.g3d.Material) MapWritablePropertyContainer(com.gempukku.libgdx.graph.shader.property.MapWritablePropertyContainer)

Aggregations

Material (com.badlogic.gdx.graphics.g3d.Material)2 Model (com.badlogic.gdx.graphics.g3d.Model)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)2 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)2 CommonPropertiesModelInstanceModelAdapter (com.gempukku.libgdx.graph.util.model.CommonPropertiesModelInstanceModelAdapter)2 Color (com.badlogic.gdx.graphics.Color)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 Vector3 (com.badlogic.gdx.math.Vector3)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 GraphModelInstance (com.gempukku.libgdx.graph.plugin.models.GraphModelInstance)1 GraphModels (com.gempukku.libgdx.graph.plugin.models.GraphModels)1 UIPluginPublicData (com.gempukku.libgdx.graph.plugin.ui.UIPluginPublicData)1 MapWritablePropertyContainer (com.gempukku.libgdx.graph.shader.property.MapWritablePropertyContainer)1