Exemplo n.º 1
0
 public CameraBase(CameraLens lens)
 {
     this.lens = lens;
     c2w = new MovingMatrix4(null);
     w2c = new MovingMatrix4(null);
     shutterOpen = shutterClose = 0;
 }
Exemplo n.º 2
0
 public Instance()
 {
     o2w = new MovingMatrix4(null);
     w2o = new MovingMatrix4(null);
     bounds = null;
     geometry = null;
     shaders = null;
     modifiers = null;
 }
Exemplo n.º 3
0
 public MovingMatrix4 inverse()
 {
     MovingMatrix4 mi = new MovingMatrix4(transforms.Length, t0, t1, inv);
     for (int i = 0; i < transforms.Length; i++) {
         if (transforms[i] != null) {
             mi.transforms[i] = transforms[i].inverse();
             if (mi.transforms[i] == null)
                 return null; // unable to invert
         }
     }
     return mi;
 }
Exemplo n.º 4
0
        public MovingMatrix4 inverse()
        {
            MovingMatrix4 mi = new MovingMatrix4(transforms.Length, t0, t1, inv);

            for (int i = 0; i < transforms.Length; i++)
            {
                if (transforms[i] != null)
                {
                    mi.transforms[i] = transforms[i].inverse();
                    if (mi.transforms[i] == null)
                    {
                        return(null);                        // unable to invert
                    }
                }
            }
            return(mi);
        }
Exemplo n.º 5
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     shutterOpen = pl.getFloat("shutter.open", shutterOpen);
     shutterClose = pl.getFloat("shutter.close", shutterClose);
     c2w = pl.getMovingMatrix("transform", c2w);
     w2c = c2w.inverse();
     if (w2c == null) {
         UI.printWarning(UI.Module.CAM, "Unable to compute camera's inverse transform");
         return false;
     }
     return lens.Update(pl, api);
 }
Exemplo n.º 6
0
        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]);
                }
            }

            o2w = pl.getMovingMatrix("transform", o2w);
            w2o = o2w.inverse();
            if (w2o == null) {
                UI.printError(UI.Module.GEOM, "Unable to compute transform inverse");
                return false;
            }
            return true;
        }