示例#1
0
 public QuadMesh()
 {
     quads = null;
     points = null;
     normals = uvs = new ParameterList.FloatParameter();
     faceShaders = null;
 }
示例#2
0
 public QuadMesh()
 {
     quads       = null;
     points      = null;
     normals     = uvs = new ParameterList.FloatParameter();
     faceShaders = null;
 }
示例#3
0
        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);
        }
示例#4
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     {
         int[] quads1 = pl.getIntArray("quads");
         if (quads != null)
         {
             this.quads = quads1;
         }
     }
     if (quads == null)
     {
         UI.printError(UI.Module.GEOM, "Unable to update mesh - quad indices are missing");
         return(false);
     }
     if (quads.Length % 4 != 0)
     {
         UI.printWarning(UI.Module.GEOM, "Quad index data is not a multiple of 4 - some quads may be missing");
     }
     pl.setFaceCount(quads.Length / 4);
     {
         ParameterList.FloatParameter pointsP = pl.getPointArray("points");
         if (pointsP != null)
         {
             if (pointsP.interp != ParameterList.InterpolationType.VERTEX)
             {
                 UI.printError(UI.Module.GEOM, "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.GEOM, "Unabled to update mesh - vertices are missing");
         return(false);
     }
     pl.setVertexCount(points.Length / 3);
     pl.setFaceVertexCount(4 * (quads.Length / 4));
     ParameterList.FloatParameter normals = pl.getVectorArray("normals");
     if (normals != null)
     {
         this.normals = normals;
     }
     ParameterList.FloatParameter uvs = pl.getTexCoordArray("uvs");
     if (uvs != null)
     {
         this.uvs = uvs;
     }
     int[] faceShaders = pl.getIntArray("faceshaders");
     if (faceShaders != null && faceShaders.Length == quads.Length / 4)
     {
         this.faceShaders = new byte[faceShaders.Length];
         for (int i = 0; i < faceShaders.Length; i++)
         {
             int v = faceShaders[i];
             if (v > 255)
             {
                 UI.printWarning(UI.Module.GEOM, "Shader index too large on quad {0}", i);
             }
             this.faceShaders[i] = (byte)(v & 0xFF);
         }
     }
     return(true);
 }
示例#5
0
 public Hair()
 {
     numSegments = 1;
     points      = null;
     widths      = new ParameterList.FloatParameter(1.0f);
 }
示例#6
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;
        }
示例#7
0
文件: Hair.cs 项目: rzel/sunflowsharp
 public Hair()
 {
     numSegments = 1;
     points = null;
     widths = new ParameterList.FloatParameter(1.0f);
 }
示例#8
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     {
         int[] quads1 = pl.getIntArray("quads");
         if (quads != null)
         {
             this.quads = quads1;
         }
     }
     if (quads == null)
     {
         UI.printError(UI.Module.GEOM, "Unable to update mesh - quad indices are missing");
         return false;
     }
     if (quads.Length % 4 != 0)
         UI.printWarning(UI.Module.GEOM, "Quad index data is not a multiple of 4 - some quads may be missing");
     pl.setFaceCount(quads.Length / 4);
     {
         ParameterList.FloatParameter pointsP = pl.getPointArray("points");
         if (pointsP != null)
             if (pointsP.interp != ParameterList.InterpolationType.VERTEX)
                 UI.printError(UI.Module.GEOM, "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.GEOM, "Unabled to update mesh - vertices are missing");
         return false;
     }
     pl.setVertexCount(points.Length / 3);
     pl.setFaceVertexCount(4 * (quads.Length / 4));
     ParameterList.FloatParameter normals = pl.getVectorArray("normals");
     if (normals != null)
         this.normals = normals;
     ParameterList.FloatParameter uvs = pl.getTexCoordArray("uvs");
     if (uvs != null)
         this.uvs = uvs;
     int[] faceShaders = pl.getIntArray("faceshaders");
     if (faceShaders != null && faceShaders.Length == quads.Length / 4)
     {
         this.faceShaders = new byte[faceShaders.Length];
         for (int i = 0; i < faceShaders.Length; i++)
         {
             int v = faceShaders[i];
             if (v > 255)
                 UI.printWarning(UI.Module.GEOM, "Shader index too large on quad {0}", i);
             this.faceShaders[i] = (byte)(v & 0xFF);
         }
     }
     return true;
 }