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);
// }
}
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);
}
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);
}*/
}
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);
}
}
}
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;
}
Aggregations