Search in sources :

Example 6 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class RenderGraph method addNode.

public void addNode(Node node) {
    Preconditions.checkNotNull(node, "node cannot be null!");
    SimpleUri nodeUri = node.getUri();
    Name nodeAka = node.getAka();
    // TODO how bout aka
    if (nodeMap.containsKey(nodeUri)) {
        throw new RuntimeException("A node with Uri " + nodeUri + " already exists!");
    }
    if (akaNodeMap.containsKey(nodeAka)) {
        Node aNode = akaNodeMap.get(nodeAka);
        logger.info("Node " + nodeUri + " also known as" + nodeAka + " already matches existing node with uri " + aNode.getUri() + " - attempting replacing...");
        replaceNode(aNode, node);
    } else {
        nodeMap.put(nodeUri, node);
        akaNodeMap.put(nodeAka, node);
        graph.addNode(node);
    }
// TODO this must be moved to a later stage ideally with the improved connecting of nodes which would be based on
// TODO on dep connections. So far when creating dep. connections, connections are made and destroyed, which is wrong.
// if (node instanceof AbstractNode) {
// node.setDependencies(context);
// }
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) Name(org.terasology.gestalt.naming.Name)

Example 7 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class RenderGraph method reconnectInputBufferPairToOutput.

public void reconnectInputBufferPairToOutput(String fromNodeUri, int outputId, Node toNode, int inputId, boolean disconnectPrevious) {
    Node fromNode = findNode(new SimpleUri(fromNodeUri));
    if (fromNode == null) {
        fromNode = findAka(fromNodeUri);
        if (fromNode == null) {
            throw new RuntimeException(("No node is associated with URI '" + fromNodeUri + "'"));
        }
    }
    reconnectInputToOutput(fromNodeUri, outputId, toNode, inputId, ConnectionType.BUFFER_PAIR, disconnectPrevious);
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri)

Example 8 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class RenderGraph method reconnectInputFboToOutput.

public void reconnectInputFboToOutput(String fromNodeUri, int outputId, Node toNode, int inputId, boolean disconnectPrevious) {
    Node fromNode = findNode(new SimpleUri(fromNodeUri));
    if (fromNode == null) {
        fromNode = findAka(fromNodeUri);
        if (fromNode == null) {
            throw new RuntimeException(("No node is associated with URI '" + fromNodeUri + "'"));
        }
    }
    reconnectInputToOutput(fromNodeUri, outputId, toNode, inputId, ConnectionType.FBO, disconnectPrevious);
/*if (!areConnected(fromNode, toNode)) {
            connect(fromNode, toNode);
        }*/
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri)

Example 9 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class ShadowMapResolutionDependentFbo method propertyChange.

/**
 * Triggers the regeneration of the shadow map FBOs, if necessary.
 *
 * Once triggered this method checks if "dynamic shadows" are enabled.
 * If dynamics shadows are enabled it obtains the new Shadow Map resolution from the event
 * passed to the method and regenerates the shadow map FBOs.
 *
 * @param evt a PropertyChangeEvent, containing the shadow map resolution.
 */
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (renderingConfig.isDynamicShadows()) {
        int shadowMapResFromSettings = (int) evt.getNewValue();
        shadowMapResolution = new FBO.Dimensions(shadowMapResFromSettings, shadowMapResFromSettings);
        for (Map.Entry<SimpleUri, FboConfig> entry : fboConfigs.entrySet()) {
            SimpleUri fboName = entry.getKey();
            FboConfig fboConfig = entry.getValue();
            if (fboLookup.containsKey(fboName)) {
                FBO fbo = fboLookup.get(fboName);
                if (fbo != null) {
                    // TODO: validate if necessary
                    fbo.dispose();
                }
            }
            FBO shadowMapResDependentFBO = generateWithDimensions(fboConfig, shadowMapResolution);
            if (shadowMapResDependentFBO.getStatus() == FBO.Status.DISPOSED) {
                logger.warn("Failed to generate ShadowMap FBO. Turning off shadows.");
                renderingConfig.setDynamicShadows(false);
                break;
            }
            fboLookup.put(fboName, shadowMapResDependentFBO);
        }
    }
}
Also used : FBO(org.terasology.engine.rendering.opengl.FBO) FboConfig(org.terasology.engine.rendering.opengl.FboConfig) SimpleUri(org.terasology.engine.core.SimpleUri) Map(java.util.Map)

Example 10 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class CreateWorldEntity method step.

@Override
public boolean step() {
    this.entityManager = context.get(EntityManager.class);
    this.worldGenerator = context.get(WorldGenerator.class);
    this.config = context.get(Config.class);
    this.chunkProvider = context.get(ChunkProvider.class);
    this.worldConfigurator = worldGenerator.getConfigurator();
    Iterator<EntityRef> worldEntityIterator = entityManager.getEntitiesWith(WorldComponent.class).iterator();
    if (worldEntityIterator.hasNext()) {
        EntityRef worldEntity = worldEntityIterator.next();
        worldEntityIterator.forEachRemaining(w -> logger.warn("Ignored extra world {}", w));
        chunkProvider.setWorldEntity(worldEntity);
        // replace the world generator values from the components in the world entity
        worldConfigurator.getProperties().forEach((key, currentComponent) -> {
            Component component = worldEntity.getComponent(currentComponent.getClass());
            if (component != null) {
                worldConfigurator.setProperty(key, component);
            }
        });
    } else {
        // create world entity if one does not exist.
        EntityRef worldEntity = createWorldPoolsAndEntity();
        chunkProvider.setWorldEntity(worldEntity);
        // transfer all world generation parameters from Config to WorldEntity
        SimpleUri generatorUri = worldGenerator.getUri();
        worldConfigurator.getProperties().forEach((key, currentComponent) -> {
            Class<? extends Component> clazz = currentComponent.getClass();
            Component moduleComponent = gameManifest.getModuleConfig(generatorUri, key, clazz);
            if (moduleComponent != null) {
                // configure entity from component
                worldEntity.addComponent(moduleComponent);
                worldConfigurator.setProperty(key, moduleComponent);
            } else {
                worldEntity.addComponent(currentComponent);
            }
        });
    }
    return true;
}
Also used : EntityManager(org.terasology.engine.entitySystem.entity.EntityManager) WorldGenerator(org.terasology.engine.world.generator.WorldGenerator) Config(org.terasology.engine.config.Config) SimpleUri(org.terasology.engine.core.SimpleUri) ChunkProvider(org.terasology.engine.world.chunks.ChunkProvider) WorldComponent(org.terasology.engine.world.WorldComponent) Component(org.terasology.gestalt.entitysystem.component.Component) NetworkComponent(org.terasology.engine.network.NetworkComponent) WorldComponent(org.terasology.engine.world.WorldComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Aggregations

SimpleUri (org.terasology.engine.core.SimpleUri)51 Name (org.terasology.gestalt.naming.Name)13 Map (java.util.Map)6 ModuleManager (org.terasology.engine.core.module.ModuleManager)6 FBO (org.terasology.engine.rendering.opengl.FBO)6 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)6 DependencyResolver (org.terasology.gestalt.module.dependencyresolution.DependencyResolver)6 ResolutionResult (org.terasology.gestalt.module.dependencyresolution.ResolutionResult)6 Config (org.terasology.engine.config.Config)5 BindableButton (org.terasology.engine.input.BindableButton)5 Module (org.terasology.gestalt.module.Module)5 Input (org.terasology.input.Input)5 Test (org.junit.jupiter.api.Test)4 RegisterBindButton (org.terasology.engine.input.RegisterBindButton)4 Lists (com.google.common.collect.Lists)3 List (java.util.List)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 GameManifest (org.terasology.engine.game.GameManifest)3 FboConfig (org.terasology.engine.rendering.opengl.FboConfig)3