Пример #1
0
        public Location(double x, double y, double z, double pitch, double yaw, double roll)
        {
            this.x = x;
            this.y = y;
            this.z = z;

            this.pitch = pitch;
            this.yaw   = yaw;
            this.roll  = roll;

            this.owner = null;

            INSTANCES++;
        }
Пример #2
0
 public virtual void Dispose()
 {
     if (this.entity != null)
     {
         this.entity.removeAnimation(this);
     }
     foreach (AnimationRule rule in this.getAnimationRules())
     {
         Locateable obj = this.getObject(rule.getObjectID());
         if (obj == null)
         {
             continue;
         }
         if (rule.isRelative())
         {
             obj.getLocation().set(rule.originalLocation);
         }
     }
 }
Пример #3
0
        public virtual void tick()
        {
            foreach (AnimationRule rule in this.getAnimationRules())
            {
                lock (rule) {
                    Locateable obj = this.getObject(rule.getObjectID());
                    if (obj == null)
                    {
                        continue;
                    }
                    if (rule.getAnimationType().Equals(AnimationFramingType.FRAME_BY_FRAME))
                    {
                        if (this.getFrame() != rule.getFrame())
                        {
                            continue;
                        }
                        obj.getLocation().set(rule.getTarget());
                    }
                    else if (rule.getAnimationType().Equals(AnimationFramingType.TWEEN))
                    {
                        if (frame < rule.getStartFrame())
                        {
                            continue;
                        }
                        if (frame > (rule.getStartFrame() + rule.getFrame()))
                        {
                            continue;
                        }
                        Location target = rule.getTarget().clone();
                        target.sub(rule.getStartingPosition());

                        double amt        = 0;
                        int    tweenFrame = frame - rule.getStartFrame();
                        double tf         = (double)tweenFrame;

                        double animation_complete_percent = (double)tweenFrame / (double)(rule.getFrame());
                        double curve = (double)rule.getTweenCurve() / 100.0d;
                        double curve_addition_offset = curve * (1 - animation_complete_percent);

                        amt = tf / (double)rule.getFrame();

                        target.multiply(amt);
                        Location q = target.clone();
                        q.multiply(curve_addition_offset);
                        target.add(q);

                        target.add(rule.getStartingPosition());
                        if (rule.isRelative())
                        {
                            target.add(rule.originalLocation);
                        }

                        obj.getLocation().set(target);

                        //Target Dispose
                        target.Dispose();
                        q.Dispose();
                    }
                }
            }
            frame++;
            if (frame > this.getTotalFrames())
            {
                if (loop)
                {
                    frame = 0;
                }
                else
                {
                    this.Dispose();
                }
            }
        }
Пример #4
0
 public Location(Locateable l) : this(0, 0)
 {
     this.setOwner(l);
 }
Пример #5
0
        public void Dispose()
        {
            this.owner = null;

            INSTANCES--;
        }
Пример #6
0
 public Location set(Locateable l)
 {
     return(set(l.getLocation()));
 }
Пример #7
0
 public Location setOwner(Locateable parent)
 {
     this.owner = parent; return(this);
 }
Пример #8
0
        public BezierItem(sb.Point startPoint, sb.Point endPoint, Transform toScreen)
        {
            this._toScreen = toScreen;

            var start = toScreen.Transform(startPoint.AsWpfPoint());

            var end = toScreen.Transform(endPoint.AsWpfPoint());

            var startControlPoint = toScreen.Transform(startPoint.AsWpfPoint());

            var endControlPoint = toScreen.Transform(endPoint.AsWpfPoint());


            var bezierSegment = new BezierSegment(startControlPoint, endControlPoint, end, true);

            _bezierFigure = new PathFigure()
            {
                StartPoint = start
            };

            _bezierFigure.Segments.Add(bezierSegment);

            PathGeometry bezierPathGeometry = new PathGeometry(new List <PathFigure>()
            {
                _bezierFigure
            });

            //pathGeometry.Transform = this.panTransformForPoints;


            _startControlLineFigure = new PathFigure()
            {
                StartPoint = start
            };

            _startControlLineFigure.Segments.Add(new LineSegment(startControlPoint, true));


            _endControlLineFigure = new PathFigure()
            {
                StartPoint = end
            };

            _endControlLineFigure.Segments.Add(new LineSegment(endControlPoint, true));

            StartLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(startPoint))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            StartLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                _bezierFigure.StartPoint = newPoint;

                _startControlLineFigure.StartPoint = newPoint;

                //update();
            };


            EndLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(endPoint))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            EndLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                bezierSegment.Point3 = newPoint;

                _endControlLineFigure.StartPoint = newPoint;

                //update();
            };


            StartControlLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(startControlPoint.AsPoint()))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            StartControlLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                bezierSegment.Point1 = newPoint;

                (_startControlLineFigure.Segments.First() as LineSegment).Point = newPoint;

                //update();
            };


            EndControlLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(endControlPoint.AsPoint()))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            EndControlLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                bezierSegment.Point2 = newPoint;

                (_endControlLineFigure.Segments.First() as LineSegment).Point = newPoint;

                //update();
            };



            Path temp = new Path();

            temp.Data            = bezierPathGeometry;
            temp.Stroke          = new SolidColorBrush(Colors.Black);
            temp.StrokeThickness = 2;
            //temp.RenderTransform = this.panTransformForPoints;
            //temp.Tag = new LayerTag(0) { IsTiled = false, LayerType = LayerType.Drawing };

            //this.mapView.Children.Add(temp);

            //Path axLine2 = new Path() { Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1, RenderTransform = panTransformForPoints };
            Path axLine2 = new Path()
            {
                Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1
            };

            axLine2.Data = new PathGeometry(new List <PathFigure>()
            {
                _startControlLineFigure
            });
            //axLine2.Tag = new LayerTag(-1) { IsTiled = false, LayerType = LayerType.Drawing };
            //this.mapView.Children.Add(axLine2);

            //Path axLine3 = new Path() { Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1, RenderTransform = panTransformForPoints };
            Path axLine3 = new Path()
            {
                Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1
            };

            axLine3.Data = new PathGeometry(new List <PathFigure>()
            {
                _endControlLineFigure
            });
            //axLine3.Tag = new LayerTag(-1) { IsTiled = false, LayerType = LayerType.Drawing };
            //this.mapView.Children.Add(axLine3);
        }