Search in sources :

Example 1 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class AbstractNode method addInputRunOrderConnection.

public boolean addInputRunOrderConnection(RunOrderConnection from, int inputId) {
    DependencyConnection runOrderconnection = new RunOrderConnection(RunOrderConnection.getConnectionName(inputId, this.nodeUri), DependencyConnection.Type.INPUT, this.getUri());
    runOrderconnection.setConnectedConnection(from);
    return addInputConnection(runOrderconnection);
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection) RunOrderConnection(org.terasology.engine.rendering.dag.dependencyConnections.RunOrderConnection)

Example 2 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class AbstractNode method getOutputConnection.

@Nullable
public DependencyConnection getOutputConnection(String name) {
    DependencyConnection connection = outputConnections.get(name);
    if (connection == null) {
        String errorMessage = String.format("Getting output connection named %s returned null." + " No such output connection in %s", name, this.toString());
        logger.error(errorMessage);
    // throw new NullPointerException(errorMessage);
    }
    return connection;
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection) Nullable(javax.annotation.Nullable)

Example 3 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class AbstractNode method disconnectInputFbo.

public void disconnectInputFbo(int inputId) {
    logger.info("Disconnecting" + this.getUri() + " input Fbo number " + inputId);
    DependencyConnection connectionToDisconnect = this.inputConnections.get(FboConnection.getConnectionName(inputId, this.nodeUri));
    if (connectionToDisconnect != null) {
        // TODO make it reconnectInputFboToOutput
        if (!connectionToDisconnect.getConnectedConnections().isEmpty()) {
            connectionToDisconnect.disconnect();
        } else {
            logger.warn("Connection was not connected, it probably originated in this node. (Support FBOs can be created inside nodes)");
        }
    } else {
        logger.error("No such connection");
    }
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection)

Example 4 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class AbstractNode method addOutputBufferPairConnection.

/**
 * TODO do something if could not insert
 * @param id
 * @param bufferPair
 * @return true if inserted, false otherwise
 */
public boolean addOutputBufferPairConnection(int id, BufferPair bufferPair) {
    boolean success = false;
    String connectionUri = BufferPairConnection.getConnectionName(id, this.nodeUri);
    if (outputConnections.containsKey(connectionUri)) {
        BufferPairConnection localBufferPairConnection = (BufferPairConnection) outputConnections.get(connectionUri);
        // set data for all connected connections
        if (!localBufferPairConnection.getConnectedConnections().isEmpty()) {
            logger.debug("Propagating bufferPair data to all connected connections of " + localBufferPairConnection + ": ");
            localBufferPairConnection.getConnectedConnections().forEach((k, v) -> {
                logger.debug("setting data for: " + v.toString() + " ,");
                v.setData(bufferPair);
            });
            logger.debug("data propagated.\n");
        }
        if (localBufferPairConnection.getData() != null) {
            logger.warn("Adding output buffer pair to slot id " + id + " of " + this.nodeUri + "node overwrites data of existing connection: " + localBufferPairConnection.toString());
        }
        localBufferPairConnection.setData(bufferPair);
        success = true;
    } else {
        DependencyConnection localBufferPairConnection = new BufferPairConnection(BufferPairConnection.getConnectionName(id, this.nodeUri), DependencyConnection.Type.OUTPUT, bufferPair, this.getUri());
        success = addOutputConnection(localBufferPairConnection);
    }
    return success;
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection) BufferPairConnection(org.terasology.engine.rendering.dag.dependencyConnections.BufferPairConnection)

Example 5 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class AbstractNode method addOutputBufferPairConnection.

/**
 * TODO do something if could not insert
 * @param id
 * @param from
 * @return true if inserted, false otherwise
 */
public boolean addOutputBufferPairConnection(int id, BufferPairConnection from) {
    boolean success = false;
    String connectionUri = BufferPairConnection.getConnectionName(id, this.nodeUri);
    if (outputConnections.containsKey(connectionUri)) {
        BufferPairConnection localBufferPairConnection = (BufferPairConnection) outputConnections.get(connectionUri);
        // set data for all connected connections
        if (!localBufferPairConnection.getConnectedConnections().isEmpty()) {
            logger.info("Propagating data from " + from.toString() + " to all connected connections of " + localBufferPairConnection + ": ");
            localBufferPairConnection.getConnectedConnections().forEach((k, v) -> {
                logger.info("setting data for: " + v.toString() + " ,");
                v.setData(from.getData());
            });
            logger.info("data propagated.\n");
        }
        if (localBufferPairConnection.getData() != null) {
            logger.warn("Adding output buffer pair connection " + from.toString() + "\n to slot id " + id + " of " + this.nodeUri + "node overwrites data of existing connection: " + localBufferPairConnection.toString());
        }
        localBufferPairConnection.setData(from.getData());
        success = true;
    } else {
        DependencyConnection localBufferPairConnection = new BufferPairConnection(BufferPairConnection.getConnectionName(id, this.nodeUri), DependencyConnection.Type.OUTPUT, from.getData(), this.getUri());
        success = addOutputConnection(localBufferPairConnection);
    }
    return success;
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection) BufferPairConnection(org.terasology.engine.rendering.dag.dependencyConnections.BufferPairConnection)

Aggregations

DependencyConnection (org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection)18 BufferPairConnection (org.terasology.engine.rendering.dag.dependencyConnections.BufferPairConnection)4 FboConnection (org.terasology.engine.rendering.dag.dependencyConnections.FboConnection)3 Nullable (javax.annotation.Nullable)2 SimpleUri (org.terasology.engine.core.SimpleUri)1 RunOrderConnection (org.terasology.engine.rendering.dag.dependencyConnections.RunOrderConnection)1