use of org.sunflow.core.LightSource in project joons-renderer by joonhyublee.
the class SunflowAPI method light.
@Override
public final void light(String name, String lightType) {
if (!isIncremental(lightType)) {
// we are declaring this light for the first time
if (renderObjects.has(name)) {
UI.printError(Module.API, "Unable to declare light \"%s\", name is already in use", name);
parameterList.clear(true);
return;
}
LightSource light = PluginRegistry.lightSourcePlugins.createObject(lightType);
if (light == null) {
UI.printError(Module.API, "Unable to create light source of type \"%s\"", lightType);
return;
}
renderObjects.put(name, light);
}
if (lookupLight(name) != null) {
update(name);
} else {
UI.printError(Module.API, "Unable to update instance \"%s\" - instance object was not found", name);
parameterList.clear(true);
}
}
use of org.sunflow.core.LightSource in project joons-renderer by joonhyublee.
the class RenderObjectMap method updateScene.
final void updateScene(Scene scene) {
if (rebuildInstanceList) {
UI.printInfo(Module.API, "Building scene instance list for rendering ...");
int numInfinite = 0, numInstance = 0;
for (FastHashMap.Entry<String, RenderObjectHandle> e : renderObjects) {
Instance i = e.getValue().getInstance();
if (i != null) {
i.updateBounds();
if (i.getBounds() == null) {
numInfinite++;
} else if (!i.getBounds().isEmpty()) {
numInstance++;
} else {
UI.printWarning(Module.API, "Ignoring empty instance: \"%s\"", e.getKey());
}
}
}
Instance[] infinite = new Instance[numInfinite];
Instance[] instance = new Instance[numInstance];
numInfinite = numInstance = 0;
for (FastHashMap.Entry<String, RenderObjectHandle> e : renderObjects) {
Instance i = e.getValue().getInstance();
if (i != null) {
if (i.getBounds() == null) {
infinite[numInfinite] = i;
numInfinite++;
} else if (!i.getBounds().isEmpty()) {
instance[numInstance] = i;
numInstance++;
}
}
}
scene.setInstanceLists(instance, infinite);
rebuildInstanceList = false;
}
if (rebuildLightList) {
UI.printInfo(Module.API, "Building scene light list for rendering ...");
ArrayList<LightSource> lightList = new ArrayList<LightSource>();
for (FastHashMap.Entry<String, RenderObjectHandle> e : renderObjects) {
LightSource light = e.getValue().getLight();
if (light != null) {
lightList.add(light);
}
}
scene.setLightList(lightList.toArray(new LightSource[lightList.size()]));
rebuildLightList = false;
}
}
Aggregations