Пример #1
0
        bool _snip(int u, int v, int w, int n, int [] V)
        {
            int      p;
            Point3DF A = Points[V[u]];
            Point3DF B = Points[V[v]];
            Point3DF C = Points[V[w]];

            if (C_EPSILON > (((B.X - A.X) * (C.Y - A.Y)) - ((B.Y - A.Y) * (C.x - A.x))))
            {
                return(false);
            }
            for (p = 0; p < n; p++)
            {
                if ((p == u) || (p == v) || (p == w))
                {
                    continue;
                }
                Point3DF P = Points.get(V[p]);
                if (_insideTriangle(A, B, C, P))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #2
0
        //
        public MeshIndexed()
        {
            this.Vertices     = new List <Vector3Ext>();
            this.Polygons     = new List <GlPolyIndex>();
            this.Attributes   = new Attributes();
            this.DisplayScale = 1.0f;

            this.Rotation = new Point3DF(0, 0, 0);
        }
Пример #3
0
 public void Translate(Point3DF translation)
 {
     for (int j = 0; j < Points.Count; j++)
     {
         Points[j].X += translation.X;
         Points[j].Y += translation.Y;
         Points[j].Z += translation.Z;
     }
 }
Пример #4
0
 public void Scale(Point3DF scale)
 {
     for (int j = 0; j < Points.Count; j++)
     {
         Points[j].X *= scale.X;
         Points[j].Y *= scale.Y;
         Points[j].Z *= scale.Z;
     }
 }
Пример #5
0
        public Point3DF Scale(Point3DF scale)
        {
            Point3DF result = new Point3DF();

            result.X = this.X * scale.X;
            result.Y = this.Y * scale.Y;
            result.Z = this.Z * scale.Z;

            return(result);
        }
Пример #6
0
        public Point3DF Scale(float scaleX, float scaleY, float scaleZ)
        {
            Point3DF result = new Point3DF();

            result.X = this.X * scaleX;
            result.Y = this.Y * scaleY;
            result.Z = this.Z * scaleZ;

            return(result);
        }
Пример #7
0
        public Matrix4 CalculateRotation(Point3DF rotation)
        {
            Matrix4 rotX = Matrix4.CreateRotationX(rotation.X);
            Matrix4 rotY = Matrix4.CreateRotationY(rotation.Y);
            Matrix4 rotZ = Matrix4.CreateRotationZ(rotation.Z);

            Matrix4.Mult(ref rotX, ref rotY, out rotationMatrix);

            return(Matrix4.Mult(rotationMatrix, rotZ));
        }
Пример #8
0
        public Vector3 Mult(ref Matrix4 matrix, Point3DF vector)
        {
            Vector3 result = new Vector3();

            result.X = matrix.M11 * vector.X + matrix.M12 * vector.Y + matrix.M13 * vector.Z;
            result.Y = matrix.M21 * vector.X + matrix.M22 * vector.Y + matrix.M23 * vector.Z;
            result.Z = matrix.M31 * vector.X + matrix.M32 * vector.Y + matrix.M33 * vector.Z;

            return(result);
        }
Пример #9
0
        ///
        ///     Returns the area of the contour
        ///
        float _area()
        {
            int   n = Points.Count;
            float A = 0.0f;

            for (int p = n - 1, q = 0; q < n; p = q++)
            {
                Point3DF pval = Points[p];
                Point3DF qval = Points[q];
                A += pval.X * qval.Y - qval.X * pval.Y;
            }
            return(A * 0.5f);
        }
Пример #10
0
        // 3d shapes

        public static MeshIndexed MakeCube(float x, float y, float z, Color color)
        {
            MeshIndexed result = new MeshIndexed();

            Point3DF[] points = new Point3DF[8];

            // create vertexes
            points[0] = new Point3DF(0, 0, 0);
            points[1] = new Point3DF(0, y, 0);
            points[2] = new Point3DF(x, y, 0);
            points[3] = new Point3DF(x, 0, 0);

            points[4] = new Point3DF(0, 0, z);
            points[5] = new Point3DF(0, y, z);
            points[6] = new Point3DF(x, y, z);
            points[7] = new Point3DF(x, 0, z);

            foreach (Point3DF point in points)
            {
                result.Vertices.Add(new Vector3Ext(point));
            }

            // base
            result.AddFacet(new Facet(points[0], points[3], points[2]), color);
            result.AddFacet(new Facet(points[2], points[1], points[0]), color);

            // sides
            result.AddFacet(new Facet(points[0], points[4], points[3]), color);
            result.AddFacet(new Facet(points[3], points[4], points[7]), color);

            result.AddFacet(new Facet(points[0], points[1], points[5]), color);
            result.AddFacet(new Facet(points[5], points[4], points[0]), color);

            result.AddFacet(new Facet(points[2], points[6], points[5]), color);
            result.AddFacet(new Facet(points[5], points[1], points[2]), color);

            result.AddFacet(new Facet(points[7], points[6], points[2]), color);
            result.AddFacet(new Facet(points[2], points[3], points[7]), color);

            // top
            result.AddFacet(new Facet(points[4], points[5], points[6]), color);
            result.AddFacet(new Facet(points[6], points[7], points[4]), color);

            result.Translate(-x / 2, -y / 2, 0);

            return(result);
        }
Пример #11
0
 //
 public Vector3Ext(Point3DF point)
 {
     this.Attributes = new Attributes();
     this.Position   = new Vector3(point.X, point.Y, point.Z);
 }
Пример #12
0
 public Facet(Point3DF p1, Point3DF p2, Point3DF p3)
 {
     Points = new Point3DF[3] {
         p1, p2, p3
     };
 }