示例#1
0
        private static void TransformAndAddVInfo(List <VInfo> list, VInfo input, CopyAndTransformVInfo xform)
        {
            VInfo result;

            xform(input, out result);
            list.Add(result);
        }
示例#2
0
        // vertices grouped into 3's (3 verts per triangle)
        public CSGModel(List<Vec3> modelVerts, List<VInfo> matchingInfos)
            : this()
        {
            List<CSGVertex> vertexMapping = new List<CSGVertex>();
            for (int i = 0; i < modelVerts.Count; i++)
                vertexMapping.Add(GetVertex(modelVerts[i], true));

            for (int i = 0; i < modelVerts.Count; i += 3)
            {
                CSGVertex[] tri = new CSGVertex[3];
                VInfo[] vinfos = new VInfo[3];
                bool acceptable = true;
                for (int j = 0; j < 3; j++)
                {
                    tri[j] = vertexMapping[i + j];
                    for (int k = 0; k < j; k++)
                        if (tri[j] == tri[k])
                            acceptable = false;
                    vinfos[j] = matchingInfos[i + j];
                    if (!acceptable)
                        break;
                }
                if (acceptable)
                {
                    CSGSourceTriangle triangle = new CSGSourceTriangle(this, tri, vinfos);
                    foreach (CSGShape shape in triangle.divisions)
                        shapes.Add(shape);
                    sourceTriangles.Add(triangle);
                }
            }
        }
示例#3
0
 // clone a model (scraps any WIP intersection info)
 // not suitable if there's custom vinfo
 public CSGModel CloneModel()
 {
     return(CloneModel(new ModelUtil.CopyAndTransformVInfo(
                           (VInfo basis, out VInfo result) =>
     {
         result = new VInfo();
     })));
 }
        public CSGSourceTriangle(CSGModel model, CSGVertex[] verts, VInfo[] vinfos)
            : this()
        {
            this.model = model;

            for(int i = 0; i< 3;i++)
            {
                sourceVerts[i] = verts[i];
                vertexVInfos[verts[i].id] = vinfos[i];
            }

            ComputePlane();

            divisions.Add(new CSGShape(model, this));
        }
示例#5
0
        public CSGModel(List <Vec3> modelVerts, List <VInfo> matchingInfos)                      // vertices grouped into 3's (3 verts per triangle)
            : this()
        {
            List <CSGVertex> vertexMapping = new List <CSGVertex>();

            for (int i = 0; i < modelVerts.Count; i++)
            {
                vertexMapping.Add(GetVertex(modelVerts[i], true));
            }

            for (int i = 0; i < modelVerts.Count; i += 3)
            {
                CSGVertex[] tri        = new CSGVertex[3];
                VInfo[]     vinfos     = new VInfo[3];
                bool        acceptable = true;
                for (int j = 0; j < 3; j++)
                {
                    tri[j] = vertexMapping[i + j];
                    for (int k = 0; k < j; k++)
                    {
                        if (tri[j] == tri[k])
                        {
                            acceptable = false;
                        }
                    }
                    vinfos[j] = matchingInfos[i + j];
                    if (!acceptable)
                    {
                        break;
                    }
                }
                if (acceptable)
                {
                    CSGSourceTriangle triangle = new CSGSourceTriangle(this, tri, vinfos);
                    foreach (CSGShape shape in triangle.divisions)
                    {
                        shapes.Add(shape);
                    }
                    sourceTriangles.Add(triangle);
                }
            }
        }
示例#6
0
 // clone a model (scraps any WIP intersection info)
 // not suitable if there's custom vinfo
 public CSGModel CloneModel()
 {
     return CloneModel(new ModelUtil.CopyAndTransformVInfo(
         (VInfo basis, out VInfo result) =>
         {
             result = new VInfo();
         }));
 }
示例#7
0
 private static void TransformAndAddVInfo(List<VInfo> list, VInfo input, CopyAndTransformVInfo xform)
 {
     VInfo result;
     xform(input, out result);
     list.Add(result);
 }