private bool updateCameraMatrix(int index, ParameterList pl) { string offset = index < 0 ? "" : string.Format("[{0}]", index); if (index < 0) { index = 0; } Matrix4 transform = pl.getMatrix(string.Format("transform{0}", offset), null); if (transform == null) { // no transform was specified, check eye/target/up Point3 eye = pl.getPoint(string.Format("eye{0}", offset), null); Point3 target = pl.getPoint(string.Format("target{0}", offset), null); Vector3 up = pl.getVector(string.Format("up{0}", offset), null); if (eye != null && target != null && up != null) { c2w[index] = Matrix4.fromBasis(OrthoNormalBasis.makeFromWV(Point3.sub(eye, target, new Vector3()), up)); c2w[index] = Matrix4.translation(eye.x, eye.y, eye.z).multiply(c2w[index]); } else { // the matrix for this index was not specified // return an error, unless this is a regular update return(offset.Length == 0); } } else { c2w[index] = transform; } return(true); }
private bool updateCameraMatrix(int index, ParameterList pl) { string offset = index < 0 ? "" : string.Format("[{0}]", index); if (index < 0) index = 0; Matrix4 transform = pl.getMatrix(string.Format("transform{0}", offset), null); if (transform == null) { // no transform was specified, check eye/target/up Point3 eye = pl.getPoint(string.Format("eye{0}", offset), null); Point3 target = pl.getPoint(string.Format("target{0}", offset), null); Vector3 up = pl.getVector(string.Format("up{0}", offset), null); if (eye != null && target != null && up != null) { c2w[index] = Matrix4.fromBasis(OrthoNormalBasis.makeFromWV(Point3.sub(eye, target, new Vector3()), up)); c2w[index] = Matrix4.translation(eye.x, eye.y, eye.z).multiply(c2w[index]); } else { // the matrix for this index was not specified // return an error, unless this is a regular update return offset.Length == 0; } } else c2w[index] = transform; return true; }
public bool update(ParameterList pl, SunflowAPI api) { string geometryName = pl.getstring("geometry", null); if (geometry == null || geometryName != null) { if (geometryName == null) { UI.printError(UI.Module.GEOM, "geometry parameter missing - unable to create instance"); return(false); } geometry = api.lookupGeometry(geometryName); if (geometry == null) { UI.printError(UI.Module.GEOM, "Geometry \"{0}\" was not declared yet - instance is invalid", geometryName); return(false); } } string[] shaderNames = pl.getstringArray("shaders", null); if (shaderNames != null) { // new shader names have been provided shaders = new IShader[shaderNames.Length]; for (int i = 0; i < shaders.Length; i++) { shaders[i] = api.lookupShader(shaderNames[i]); if (shaders[i] == null) { UI.printWarning(UI.Module.GEOM, "Shader \"{0}\" was not declared yet - ignoring", shaderNames[i]); } } } else { // re-use existing shader array } string[] modifierNames = pl.getstringArray("modifiers", null); if (modifierNames != null) { // new modifier names have been provided modifiers = new Modifier[modifierNames.Length]; for (int i = 0; i < modifiers.Length; i++) { modifiers[i] = api.lookupModifier(modifierNames[i]); if (modifiers[i] == null) { UI.printWarning(UI.Module.GEOM, "Modifier \"{0}\" was not declared yet - ignoring", modifierNames[i]); } } } Matrix4 transform = pl.getMatrix("transform", o2w); if (transform != o2w) { o2w = transform; if (o2w != null) { w2o = o2w.inverse(); if (w2o == null) { UI.printError(UI.Module.GEOM, "Unable to compute transform inverse - determinant is: {0}", o2w.determinant()); return(false); } } else { o2w = w2o = null; } } return(true); }
public bool update(ParameterList pl, SunflowAPI api) { string geometryName = pl.getstring("geometry", null); if (geometry == null || geometryName != null) { if (geometryName == null) { UI.printError(UI.Module.GEOM, "geometry parameter missing - unable to create instance"); return false; } geometry = api.lookupGeometry(geometryName); if (geometry == null) { UI.printError(UI.Module.GEOM, "Geometry \"{0}\" was not declared yet - instance is invalid", geometryName); return false; } } string[] shaderNames = pl.getstringArray("shaders", null); if (shaderNames != null) { // new shader names have been provided shaders = new IShader[shaderNames.Length]; for (int i = 0; i < shaders.Length; i++) { shaders[i] = api.lookupShader(shaderNames[i]); if (shaders[i] == null) UI.printWarning(UI.Module.GEOM, "Shader \"{0}\" was not declared yet - ignoring", shaderNames[i]); } } else { // re-use existing shader array } string[] modifierNames = pl.getstringArray("modifiers", null); if (modifierNames != null) { // new modifier names have been provided modifiers = new Modifier[modifierNames.Length]; for (int i = 0; i < modifiers.Length; i++) { modifiers[i] = api.lookupModifier(modifierNames[i]); if (modifiers[i] == null) UI.printWarning(UI.Module.GEOM, "Modifier \"{0}\" was not declared yet - ignoring", modifierNames[i]); } } Matrix4 transform = pl.getMatrix("transform", o2w); if (transform != o2w) { o2w = transform; if (o2w != null) { w2o = o2w.inverse(); if (w2o == null) { UI.printError(UI.Module.GEOM, "Unable to compute transform inverse - determinant is: {0}", o2w.determinant()); return false; } } else o2w = w2o = null; } return true; }