Пример #1
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     ParameterList.FloatParameter pts = pl.getPointArray("points");
     if (pts != null)
     {
         BoundingBox bounds = new BoundingBox();
         for (int i = 0; i < pts.data.Length; i += 3)
             bounds.include(pts.data[i], pts.data[i + 1], pts.data[i + 2]);
         // cube extents
         minX = bounds.getMinimum().x;
         minY = bounds.getMinimum().y;
         minZ = bounds.getMinimum().z;
         maxX = bounds.getMaximum().x;
         maxY = bounds.getMaximum().y;
         maxZ = bounds.getMaximum().z;
     }
     return true;
 }
Пример #2
0
 public virtual bool update(ParameterList pl, SunflowAPI api)
 {
     bool updatedTopology = false;
     {
         int[] trianglesi = pl.getIntArray("triangles");
         if (trianglesi != null)
         {
             this.triangles = trianglesi;
             updatedTopology = true;
         }
     }
     if (triangles == null)
     {
         UI.printError(UI.Module.GEOM, "Unable to update mesh - triangle indices are missing");
         return false;
     }
     if (triangles.Length % 3 != 0)
         UI.printWarning(UI.Module.GEOM, "Triangle index data is not a multiple of 3 - triangles may be missing");
     pl.setFaceCount(triangles.Length / 3);
     {
         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;
                 updatedTopology = true;
             }
     }
     if (points == null)
     {
         UI.printError(UI.Module.GEOM, "Unable to update mesh - vertices are missing");
         return false;
     }
     pl.setVertexCount(points.Length / 3);
     pl.setFaceVertexCount(3 * (triangles.Length / 3));
     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 == triangles.Length / 3)
     {
         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 triangle {0}", i);
             this.faceShaders[i] = (byte)(v & 0xFF);
         }
     }
     if (updatedTopology)
     {
         // create triangle acceleration structure
         init();
     }
     return true;
 }
Пример #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 bool Update(ParameterList pl, SunflowAPI api)
 {
     ParameterList.FloatParameter p = pl.getPointArray("particles");
     if (p != null)
         particles = p.data;
     r = pl.getFloat("radius", r);
     r2 = r * r;
     n = pl.getInt("num", n);
     return particles != null && n <= (particles.Length / 3);
 }
Пример #6
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     subdivs = pl.getInt("subdivs", subdivs);
     smooth = pl.getbool("smooth", smooth);
     quads = pl.getbool("quads", quads);
     int nu = pl.getInt("nu", 0);
     int nv = pl.getInt("nv", 0);
     pl.setVertexCount(nu * nv);
     bool uwrap = pl.getbool("uwrap", false);
     bool vwrap = pl.getbool("vwrap", false);
     ParameterList.FloatParameter points = pl.getPointArray("points");
     if (points != null && points.interp == ParameterList.InterpolationType.VERTEX)
     {
         int numUPatches = uwrap ? nu / 3 : (nu - 4) / 3 + 1;
         int numVPatches = vwrap ? nv / 3 : (nv - 4) / 3 + 1;
         if (numUPatches < 1 || numVPatches < 1)
         {
             UI.printError(UI.Module.GEOM, "Invalid number of patches for bezier mesh - ignoring");
             return false;
         }
         // generate patches
         patches = new float[numUPatches * numVPatches][];
         for (int v = 0, p = 0; v < numVPatches; v++)
         {
             for (int u = 0; u < numUPatches; u++, p++)
             {
                 float[] patch = patches[p] = new float[16 * 3];
                 int up = u * 3;
                 int vp = v * 3;
                 for (int pv = 0; pv < 4; pv++)
                 {
                     for (int pu = 0; pu < 4; pu++)
                     {
                         int meshU = (up + pu) % nu;
                         int meshV = (vp + pv) % nv;
                         // copy point
                         patch[3 * (pv * 4 + pu) + 0] = points.data[3 * (meshU + nu * meshV) + 0];
                         patch[3 * (pv * 4 + pu) + 1] = points.data[3 * (meshU + nu * meshV) + 1];
                         patch[3 * (pv * 4 + pu) + 2] = points.data[3 * (meshU + nu * meshV) + 2];
                     }
                 }
             }
         }
     }
     if (subdivs < 1)
     {
         UI.printError(UI.Module.GEOM, "Invalid subdivisions for bezier mesh - ignoring");
         return false;
     }
     if (patches == null)
     {
         UI.printError(UI.Module.GEOM, "No patch data present in bezier mesh - ignoring");
         return false;
     }
     return true;
 }