use of com.gempukku.libgdx.graph.pipeline.producer.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class AddPipelineNodeProducer method createNode.
@Override
public PipelineNode createNode(JsonValue data, ObjectMap<String, Array<String>> inputTypes, ObjectMap<String, String> outputTypes) {
final String resultType = outputTypes.get("output");
final Object resultValue = createDefaultValue(resultType);
final ObjectMap<String, PipelineNode.FieldOutput<?>> result = new ObjectMap<>();
final DefaultFieldOutput resultOutput = new DefaultFieldOutput(resultType);
result.put("output", resultOutput);
return new AbstractPipelineNode(result) {
private Array<FieldOutput<?>> inputs;
@Override
public void setInputs(ObjectMap<String, Array<FieldOutput<?>>> inputs) {
this.inputs = inputs.get("inputs");
}
@Override
public void executeNode(PipelineRenderingContext pipelineRenderingContext, PipelineRequirementsCallback pipelineRequirementsCallback) {
Object returnValue = resetDefaultValue(resultType, resultValue);
for (FieldOutput<?> input : inputs) {
Object value = input.getValue();
returnValue = add(returnValue, value);
}
resultOutput.setValue(returnValue);
}
};
}
use of com.gempukku.libgdx.graph.pipeline.producer.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class TwoParamMathFunctionPipelineNodeProducer method createNodeForSingleInputs.
@Override
public PipelineNode createNodeForSingleInputs(JsonValue data, ObjectMap<String, String> inputTypes, ObjectMap<String, String> outputTypes) {
final String resultType = inputTypes.get(param1);
final Object resultValue = createResult(resultType);
final ObjectMap<String, PipelineNode.FieldOutput<?>> result = new ObjectMap<>();
final DefaultFieldOutput resultOutput = new DefaultFieldOutput(resultType);
result.put(outputName, resultOutput);
return new SingleInputsPipelineNode(result) {
@Override
public void executeNode(PipelineRenderingContext pipelineRenderingContext, PipelineRequirementsCallback pipelineRequirementsCallback) {
FieldOutput<?> aFunction = inputs.get(param1);
FieldOutput<?> bFunction = inputs.get(param2);
Object a = aFunction.getValue();
Object b = bFunction.getValue();
Object returnValue;
if (resultType.equals(PipelineFieldType.Float)) {
returnValue = executeFunction(a, b, 0);
} else if (resultType.equals(PipelineFieldType.Vector2)) {
returnValue = ((Vector2) resultValue).set(executeFunction(a, b, 0), executeFunction(a, b, 1));
} else if (resultType.equals(PipelineFieldType.Vector3)) {
returnValue = ((Vector3) resultValue).set(executeFunction(a, b, 0), executeFunction(a, b, 1), executeFunction(a, b, 2));
} else {
returnValue = ((Color) resultValue).set(executeFunction(a, b, 0), executeFunction(a, b, 1), executeFunction(a, b, 2), executeFunction(a, b, 3));
}
resultOutput.setValue(returnValue);
}
};
}
Aggregations