Ejemplo n.º 1
0
 static Terrain3D()
 {
     {
     SX = new double[17];
     SZ = new double[17];
     int i = 0;
     for (double d = 0; d < 2; d += 0.125)
     {
       i++;
       SX[i] = Math.Cos(Math.PI * d);
       SZ[i] = Math.Sin(Math.PI * d);
     }
       }
       {
     TEXTURE_COORDINATES = new PointCollection(17);
     TEXTURE_COORDINATES.Add(new Point(0, 0));
     Point p = new Point(1, 0);
     int i = -1;
     while (++i < 16) TEXTURE_COORDINATES.Add(p);
     TEXTURE_COORDINATES.Freeze();
       }
       {
     TRIANGLE_INDICES = new Int32Collection(48);
     for (int i = 1; i < 16; i++)
     {
       TRIANGLE_INDICES.Add(0);
       TRIANGLE_INDICES.Add(i + 1);
       TRIANGLE_INDICES.Add(i);
     }
     TRIANGLE_INDICES.Add(0);
     TRIANGLE_INDICES.Add(1);
     TRIANGLE_INDICES.Add(16);
     TRIANGLE_INDICES.Freeze();
       }
 }
Ejemplo n.º 2
0
 static Pokemon3D()
 {
     TEXTURE_COORDINATES = new PointCollection(new Point[]
     { new Point(0, 1), new Point(0, 0), new Point(1, 1), new Point(1, 0) });
       TRIANGLE_INDICES = new Int32Collection(new int[] { 0, 2, 1, 3, 1, 2 });
       TEXTURE_COORDINATES.Freeze();
       TRIANGLE_INDICES.Freeze();
 }
        /// <summary>
        /// Rebuild connection points.
        /// </summary>
        private void ComputeConnectionPoints()
        {
            PointCollection computedPoints = new PointCollection();
            computedPoints.Add(this.SourceConnectorHotspot);

            double deltaX = Math.Abs(this.DestConnectorHotspot.X - this.SourceConnectorHotspot.X);
            double deltaY = Math.Abs(this.DestConnectorHotspot.Y - this.SourceConnectorHotspot.Y);
            if (deltaX > deltaY)
            {
                double midPointX = this.SourceConnectorHotspot.X + ((this.DestConnectorHotspot.X - this.SourceConnectorHotspot.X) / 2);
                computedPoints.Add(new Point(midPointX, this.SourceConnectorHotspot.Y));
                computedPoints.Add(new Point(midPointX, this.DestConnectorHotspot.Y));
            }
            else
            {
                double midPointY = this.SourceConnectorHotspot.Y + ((this.DestConnectorHotspot.Y - this.SourceConnectorHotspot.Y) / 2);
                computedPoints.Add(new Point(this.SourceConnectorHotspot.X, midPointY));
                computedPoints.Add(new Point(this.DestConnectorHotspot.X, midPointY));
            }

            computedPoints.Add(this.DestConnectorHotspot);
            computedPoints.Freeze();

            this.Points = computedPoints;
        }
Ejemplo n.º 4
0
        public static PointCollection ConvertToPointCollection(int[] values)
        {
            PointCollection points = new PointCollection();
            if (values == null)
            {
                points.Freeze();
                return points;
            }

            values = SmoothHistogram(values);

            int max = values.Max();

            // first point (lower-left corner)
            points.Add(new Point(0, max));
            // middle points
            for (int i = 0; i < values.Length; i++)
            {
                points.Add(new Point(i, max - values[i]));
            }
            // last point (lower-right corner)
            points.Add(new Point(values.Length - 1, max));
            points.Freeze();
            return points;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Rebuild connection points.
        /// </summary>
        private void ComputeConnectionPoints()
        {
            const double offset = 120.0;

            double srcDeltaX = offset;
            double destDeltaX = -offset;

            if (SourceConnector != null)
            {
                if (SourceConnector.Type == ConnectorType.Input
                    || SourceConnector.Type == ConnectorType.VariableInput)
                {
                    srcDeltaX = -offset;
                }
                else if (SourceConnector.Type == ConnectorType.Output
                    || SourceConnector.Type == ConnectorType.VariableOutput)
                {
                    srcDeltaX = offset;
                }
            }

            if (DestConnector != null)
            {
                if (DestConnector.Type == ConnectorType.Output
                    || DestConnector.Type == ConnectorType.VariableOutput
                    || DestConnector.Type == ConnectorType.VariableInputOutput)
                {
                    destDeltaX = offset;
                }
            }

            PointCollection computedPoints = new PointCollection();
            computedPoints.Add(SourceConnectorHotspot);
            computedPoints.Add(new Point(SourceConnectorHotspot.X + srcDeltaX, SourceConnectorHotspot.Y));
            computedPoints.Add(new Point(DestConnectorHotspot.X + destDeltaX, this.DestConnectorHotspot.Y));
            computedPoints.Add(DestConnectorHotspot);
            computedPoints.Freeze();

            this.Points = computedPoints;
        }
Ejemplo n.º 6
0
            internal unsafe void AddFigureToList(bool isFilled, bool isClosed, MilPoint2F *pPoints, UInt32 pointCount, byte *pSegTypes, UInt32 segmentCount)
            {
                if (pointCount >= 1 && segmentCount >= 1)
                {
                    PathFigure figure = new PathFigure();

                    figure.IsFilled   = isFilled;
                    figure.StartPoint = new Point(pPoints->X, pPoints->Y);

                    int pointIndex   = 1;
                    int sameSegCount = 0;

                    for (int segIndex = 0; segIndex < segmentCount; segIndex += sameSegCount)
                    {
                        byte segType = (byte)(pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegTypeMask);

                        sameSegCount = 1;

                        // Look for a run of same-type segments for a PolyXXXSegment.
                        while (((segIndex + sameSegCount) < segmentCount) &&
                               (pSegTypes[segIndex] == pSegTypes[segIndex + sameSegCount]))
                        {
                            sameSegCount++;
                        }

                        bool fStroked = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegIsAGap) == (byte)0;
                        bool fSmooth  = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegSmoothJoin) != (byte)0;

                        if (segType == (byte)MILCoreSegFlags.SegTypeLine)
                        {
                            if (pointIndex + sameSegCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount > 1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i = 0; i < sameSegCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex + i].X, pPoints[pointIndex + i].Y));
                                }
                                ptCollection.Freeze();

                                PolyLineSegment polySeg = new PolyLineSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);
                                figure.Segments.Add(new LineSegment(new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y), fStroked, fSmooth));
                            }

                            pointIndex += sameSegCount;
                        }
                        else if (segType == (byte)MILCoreSegFlags.SegTypeBezier)
                        {
                            int pointBezierCount = sameSegCount * 3;

                            if (pointIndex + pointBezierCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount > 1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i = 0; i < pointBezierCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex + i].X, pPoints[pointIndex + i].Y));
                                }
                                ptCollection.Freeze();

                                PolyBezierSegment polySeg = new PolyBezierSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);

                                figure.Segments.Add(new BezierSegment(
                                                        new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y),
                                                        new Point(pPoints[pointIndex + 1].X, pPoints[pointIndex + 1].Y),
                                                        new Point(pPoints[pointIndex + 2].X, pPoints[pointIndex + 2].Y),
                                                        fStroked,
                                                        fSmooth));
                            }

                            pointIndex += pointBezierCount;
                        }
                        else
                        {
                            throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                        }
                    }

                    if (isClosed)
                    {
                        figure.IsClosed = true;
                    }

                    figure.Freeze();
                    Figures.Add(figure);

                    // Do not bother adding empty figures.
                }
            }
Ejemplo n.º 7
0
        private PointCollection ConvertToPointCollection(int[] values)
        {
            values = SmoothHistogram(values);

            int max = values.Max();

            PointCollection points = new PointCollection();
            // first point (lower-left corner)
            points.Add(new System.Windows.Point(0, max));
            // middle points
            for (int i = 0; i < values.Length; i++)
            {
                points.Add(new System.Windows.Point(i, max - values[i]));
            }
            // last point (lower-right corner)
            points.Add(new System.Windows.Point(values.Length - 1, max));
            points.Freeze();
            return points;
        }
Ejemplo n.º 8
0
            internal unsafe void AddFigureToList(bool isFilled, bool isClosed, MilPoint2F* pPoints, UInt32 pointCount, byte* pSegTypes, UInt32 segmentCount)
            {
                if (pointCount >=1 && segmentCount >= 1)
                {
                    PathFigure figure = new PathFigure();

                    figure.IsFilled = isFilled;
                    figure.StartPoint = new Point(pPoints->X, pPoints->Y);

                    int pointIndex = 1;
                    int sameSegCount = 0;

                    for (int segIndex=0; segIndex<segmentCount; segIndex += sameSegCount)
                    {
                        byte segType = (byte)(pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegTypeMask);

                        sameSegCount = 1;

                        // Look for a run of same-type segments for a PolyXXXSegment.
                        while (((segIndex + sameSegCount) < segmentCount) &&
                            (pSegTypes[segIndex] == pSegTypes[segIndex+sameSegCount]))
                        {
                            sameSegCount++;
                        }

                        bool fStroked = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegIsAGap) == (byte)0;
                        bool fSmooth = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegSmoothJoin) != (byte)0;

                        if (segType == (byte)MILCoreSegFlags.SegTypeLine)
                        {
                            if (pointIndex+sameSegCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount>1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i=0; i<sameSegCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex+i].X, pPoints[pointIndex+i].Y));
                                }
                                ptCollection.Freeze();

                                PolyLineSegment polySeg = new PolyLineSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);
                                figure.Segments.Add(new LineSegment(new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y), fStroked, fSmooth));
                            }

                            pointIndex += sameSegCount;
                        }
                        else if (segType == (byte)MILCoreSegFlags.SegTypeBezier)
                        {
                            int pointBezierCount = sameSegCount*3;

                            if (pointIndex+pointBezierCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount>1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i=0; i<pointBezierCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex+i].X, pPoints[pointIndex+i].Y));
                                }
                                ptCollection.Freeze();

                                PolyBezierSegment polySeg = new PolyBezierSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);

                                figure.Segments.Add(new BezierSegment(
                                    new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y),
                                    new Point(pPoints[pointIndex+1].X, pPoints[pointIndex+1].Y),
                                    new Point(pPoints[pointIndex+2].X, pPoints[pointIndex+2].Y),
                                    fStroked,
                                    fSmooth));
                            }

                            pointIndex += pointBezierCount;
                        }
                        else
                        {
                            throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                        }
                    }

                    if (isClosed)
                    {
                        figure.IsClosed = true;
                    }

                    figure.Freeze();
                    Figures.Add(figure);

                    // Do not bother adding empty figures.
                }
            }
Ejemplo n.º 9
0
        /// <summary>
        /// Rebuild connection points.
        /// </summary>
        private void ComputeConnectionPoints()
        {
            PointCollection computedPoints = new PointCollection();
            computedPoints.Add(this.SourceConnectorHotspot);

            double midPointX = this.SourceConnectorHotspot.X + ((this.DestConnectorHotspot.X - this.SourceConnectorHotspot.X) / 2);
            computedPoints.Add(new Point(midPointX, this.SourceConnectorHotspot.Y));
            computedPoints.Add(new Point(midPointX, this.DestConnectorHotspot.Y));

            //Add an extra point to the curve that allows the line into the destination look visually pleasing.
            const double precedingPoint = 2.5;
            if ( (this.DestConnectorHotspot.X - precedingPoint) > midPointX)
                computedPoints.Add(new Point(this.DestConnectorHotspot.X - precedingPoint, this.DestConnectorHotspot.Y));

            computedPoints.Add(this.DestConnectorHotspot);
            computedPoints.Freeze();

            this.Points = computedPoints;
        }