Exemple #1
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);
        }