示例#1
0
文件: Hair.cs 项目: rzel/sunflowsharp
        public bool update(ParameterList pl, SunflowAPI api)
        {
            numSegments = pl.getInt("segments", numSegments);
            if (numSegments < 1)
            {
                UI.printError(UI.Module.HAIR, "Invalid number of segments: {0}", numSegments);
                return false;
            }
            ParameterList.FloatParameter pointsP = pl.getPointArray("points");
            if (pointsP != null)
            {
                if (pointsP.interp != ParameterList.InterpolationType.VERTEX)
                    UI.printError(UI.Module.HAIR, "Point interpolation type must be set to \"vertex\" - was \"{0}\"", pointsP.interp.ToString().ToLower());
                else
                {
                    points = pointsP.data;
                }
            }
            if (points == null)
            {
                UI.printError(UI.Module.HAIR, "Unabled to update hair - vertices are missing");
                return false;
            }

            pl.setVertexCount(points.Length / 3);
            ParameterList.FloatParameter widthsP = pl.getFloatArray("widths");
            if (widthsP != null)
            {
                if (widthsP.interp == ParameterList.InterpolationType.NONE || widthsP.interp == ParameterList.InterpolationType.VERTEX)
                    widths = widthsP;
                else
                    UI.printWarning(UI.Module.HAIR, "Width interpolation type {0} is not supported -- ignoring", widthsP.interp.ToString().ToLower());
            }
            return true;
        }