Ejemplo n.º 1
0
        /// <summary>
        /// Create Top and Bottom of mesh
        /// </summary>
        /// <param name="pts"></param>
        /// <param name="invert"></param>
        /// <returns></returns>
        protected ScanSlice CreateForTopBottom(Point3DList pts, bool invert = false)
        {
            int count = pts.Count;

            if (count < 2)
            {
                return(new ScanSlice(pts));
            }
            ScanSlice outerList = new ScanSlice(count);
            double    x         = 0;
            double    y         = 0;
            double    z         = 0;

            for (int i = 0; i < count + 1; i++)
            {
                Point3D p = pts[i % count];
                if (i == 0 || (pts[i - 1].Position - p.Position).LengthFast != 0)
                {
                    outerList.Add(p);
                    if (i < count)
                    {
                        x += p.Position.X;
                        y += p.Position.Y;
                        z += p.Position.Z;
                    }
                }
            }
            Vector3d center = new Vector3d((double)(x / count), (double)(y / count), (double)(z / count));

            count = outerList.Count;
            if (count < 2)
            {
                return(outerList);
            }

            ScanSlice ret = new ScanSlice(count * 2);
            int       idx = 0;

            for (idx = 0; idx < count; idx++)
            {
                Point3D pt = outerList[idx];
                if (invert)
                {
                    ret.Add(new Point3D(center, pt.Normal, pt.Color));
                }
                ret.Add(pt);
                if (!invert)
                {
                    ret.Add(new Point3D(center, pt.Normal, pt.Color));
                }
            }

            return(ret);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a strip result for 2 Scanline (with same Nbr of Points)
 /// </summary>
 /// <param name="prev"></param>
 /// <param name="current"></param>
 public StripResult(ScanLine prev, ScanLine current)
 {
     if (prev.Count != current.Count)
         throw new Exception(" previous and current pointlist doesn't have the same point count");
     Previous = prev;
     Current = current;
     Result = new ScanSlice(Previous.Count + current.Count);
     //GL.Begin(PrimitiveType.LineStrip);
     int count = Math.Min(Previous.Count, current.Count);
     for (int i = 0; i < count; i++)
     {
         Result.Add(Previous[i]);
         Result.Add(current[i]);
     }
     AbstractMeshBuilder.AdjustNormalFromTriangleStrip(Result);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a strip result for 2 Scanline (with same Nbr of Points)
        /// </summary>
        /// <param name="prev"></param>
        /// <param name="current"></param>
        public StripResult(ScanLine prev, ScanLine current)
        {
            if (prev.Count != current.Count)
            {
                throw new Exception(" previous and current pointlist doesn't have the same point count");
            }
            Previous = prev;
            Current  = current;
            Result   = new ScanSlice(Previous.Count + current.Count);
            //GL.Begin(PrimitiveType.LineStrip);
            int count = Math.Min(Previous.Count, current.Count);

            for (int i = 0; i < count; i++)
            {
                Result.Add(Previous[i]);
                Result.Add(current[i]);
            }
            AbstractMeshBuilder.AdjustNormalFromTriangleStrip(Result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create Top and Bottom of mesh
        /// </summary>
        /// <param name="pts"></param>
        /// <param name="invert"></param>
        /// <returns></returns>
        protected ScanSlice CreateForTopBottom(Point3DList pts, bool invert = false)
        {
            int count = pts.Count;
            if (count < 2)
                return new ScanSlice(pts);
            ScanSlice outerList = new ScanSlice(count);
            double x = 0;
            double y = 0;
            double z = 0;
            for (int i = 0; i < count + 1; i++)
            {
                Point3D p = pts[i % count];
                if (i == 0 || (pts[i - 1].Position - p.Position).LengthFast != 0)
                {
                    outerList.Add(p);
                    if (i < count)
                    {
                        x += p.Position.X;
                        y += p.Position.Y;
                        z += p.Position.Z;
                    }
                }
            }
            Vector3d center = new Vector3d((double)(x / count), (double)(y / count), (double)(z / count));

            count = outerList.Count;
            if (count < 2)
                return outerList;

            ScanSlice ret = new ScanSlice(count * 2);
            int idx = 0;
            for (idx = 0; idx < count; idx++)
            {
                Point3D pt = outerList[idx];
                if (invert)
                    ret.Add(new Point3D(center, pt.Normal, pt.Color));
                ret.Add(pt);
                if (!invert)
                    ret.Add(new Point3D(center, pt.Normal, pt.Color));
            }

            return ret;
        }