Ejemplo n.º 1
0
        public void Transform(ref CCV3F_C4B_T2F quadPoint)
        {
            var x = quadPoint.Vertices.X;
            var y = quadPoint.Vertices.Y;
            var z = quadPoint.Vertices.Z;

            Transform(ref x, ref y, ref z);
            quadPoint.Vertices.X = x;
            quadPoint.Vertices.Y = y;
            quadPoint.Vertices.Z = z;
        }
Ejemplo n.º 2
0
        public void Transform(ref CCV3F_C4B_T2F quadPoint)
        {
            CCPoint projectedPoint = Transform(new CCPoint(quadPoint.Vertices.X, quadPoint.Vertices.Y));

            quadPoint.Vertices = new CCVertex3F(projectedPoint.X, projectedPoint.Y, quadPoint.Vertices.Z);
        }
Ejemplo n.º 3
0
        static void VertexLineToPolygon(CCPoint[] points, float stroke, CCV3F_C4B_T2F[] vertices, int offset, int nuPoints)
        {
            nuPoints += offset;
            if (nuPoints <= 1) return;

            stroke *= 0.5f;

            int idx;
            int nuPointsMinus = nuPoints - 1;

            float rad70 = MathHelper.ToRadians(70);
            float rad170 = MathHelper.ToRadians(170);

            for (int i = offset; i < nuPoints; i++)
            {
                idx = i * 2;
                CCPoint p1 = points[i];
                CCPoint perpVector;

                if (i == 0)
                {
                    perpVector = CCPoint.PerpendicularCCW(CCPoint.Normalize(p1 - points[i + 1]));
                }
                else if (i == nuPointsMinus)
                {
                    perpVector = CCPoint.PerpendicularCCW(CCPoint.Normalize(points[i - 1] - p1));
                }
                else
                {
                    CCPoint p2 = points[i + 1];
                    CCPoint p0 = points[i - 1];

                    CCPoint p2p1 = CCPoint.Normalize(p2 - p1);
                    CCPoint p0p1 = CCPoint.Normalize(p0 - p1);

                    // Calculate angle between vectors
                    var angle = (float) Math.Acos(CCPoint.Dot(p2p1, p0p1));

                    if (angle < rad70)
                    {
                        perpVector = CCPoint.PerpendicularCCW(CCPoint.Normalize(CCPoint.Midpoint(p2p1, p0p1)));
                    }
                    else if (angle < rad170)
                    {
                        perpVector = CCPoint.Normalize(CCPoint.Midpoint(p2p1, p0p1));
                    }
                    else
                    {
                        perpVector = CCPoint.PerpendicularCCW(CCPoint.Normalize(p2 - p0));
                    }
                }

                perpVector = perpVector * stroke;

                vertices[idx].Vertices = new CCVertex3F(p1.X + perpVector.X, p1.Y + perpVector.Y, 0);
                vertices[idx + 1].Vertices = new CCVertex3F(p1.X - perpVector.X, p1.Y - perpVector.Y, 0);
            }

            // Validate vertexes
            offset = (offset == 0) ? 0 : offset - 1;
            for (int i = offset; i < nuPointsMinus; i++)
            {
                idx = i * 2;
                int idx1 = idx + 2;

                CCVertex3F p1 = vertices[idx].Vertices;
                CCVertex3F p2 = vertices[idx + 1].Vertices;
                CCVertex3F p3 = vertices[idx1].Vertices;
                CCVertex3F p4 = vertices[idx1 + 1].Vertices;

                float s;
                bool fixVertex = !VertexLineIntersect(p1.X, p1.Y, p4.X, p4.Y, p2.X, p2.Y, p3.X, p3.Y, out s);
                if (!fixVertex)
                {
                    if (s < 0.0f || s > 1.0f)
                    {
                        fixVertex = true;
                    }
                }

                if (fixVertex)
                {
                    vertices[idx1].Vertices = p4;
                    vertices[idx1 + 1].Vertices = p3;
                }
            }
        }
Ejemplo n.º 4
0
 public void Transform(ref CCV3F_C4B_T2F quadPoint)
 {
     var x = quadPoint.Vertices.X;
     var y = quadPoint.Vertices.Y;
     var z = quadPoint.Vertices.Z;
     Transform(ref x, ref y, ref z);
     quadPoint.Vertices.X = x;
     quadPoint.Vertices.Y = y;
     quadPoint.Vertices.Z = z;
 }
Ejemplo n.º 5
0
        public void Transform(ref CCV3F_C4B_T2F quadPoint)
        {
            CCPoint projectedPoint = Transform(new CCPoint(quadPoint.Vertices.X, quadPoint.Vertices.Y));

            quadPoint.Vertices = new CCVertex3F(projectedPoint.X, projectedPoint.Y, quadPoint.Vertices.Z);
        }