private void parseCamera(SunflowAPI api) { p.checkNextToken("{"); p.checkNextToken("type"); string type = p.getNextToken(); UI.printInfo(UI.Module.API, "Reading {0} camera ...", type); if (p.peekNextToken("shutter")) { api.parameter("shutter.open", p.getNextFloat()); api.parameter("shutter.close", p.getNextFloat()); } parseCameraTransform(api); string name = generateUniqueName("camera"); if (type == "pinhole") { p.checkNextToken("fov"); api.parameter("fov", p.getNextFloat()); p.checkNextToken("aspect"); api.parameter("aspect", p.getNextFloat()); if (p.peekNextToken("shift")) { api.parameter("shift.x", p.getNextFloat()); api.parameter("shift.y", p.getNextFloat()); } api.camera(name, "pinhole"); } else if (type == "thinlens") { p.checkNextToken("fov"); api.parameter("fov", p.getNextFloat()); p.checkNextToken("aspect"); api.parameter("aspect", p.getNextFloat()); if (p.peekNextToken("shift")) { api.parameter("shift.x", p.getNextFloat()); api.parameter("shift.y", p.getNextFloat()); } p.checkNextToken("fdist"); api.parameter("focus.distance", p.getNextFloat()); p.checkNextToken("lensr"); api.parameter("lens.radius", p.getNextFloat()); if (p.peekNextToken("sides")) api.parameter("lens.sides", p.getNextInt()); if (p.peekNextToken("rotation")) api.parameter("lens.rotation", p.getNextFloat()); api.camera(name, "thinlens"); } else if (type == "spherical") { // no extra arguments api.camera(name, "spherical"); } else if (type == "fisheye") { // no extra arguments api.camera(name, "fisheye"); } else { UI.printWarning(UI.Module.API, "Unrecognized camera type: {0}", p.getNextToken()); p.checkNextToken("}"); return; } p.checkNextToken("}"); if (name != null) { api.parameter("camera", name); api.options(SunflowAPI.DEFAULT_OPTIONS); } }