A point in a Spline storing position, velocity, acceleration, and time information.
Пример #1
0
        public static void UpdateToSplinePoint(SplinePoint splinePoint)
        {
            GuiData.SplineListDisplay.SelectedSplinePoint = splinePoint;



        }
Пример #2
0
 public SplinePoint ToSplinePoint()
 {
     SplinePoint sp = new SplinePoint();
     sp.Position = this.Position;
     sp.Velocity = this.Velocity;
     sp.Time = this.Time;
     sp.UseCustomVelocityValue = this.UseCustomVelocityValue;
     // Acceleration will be calculated later
     return sp;
 }
Пример #3
0
        public static SplinePointSave FromSplinePoint(SplinePoint splinePoint)
        {
            SplinePointSave sps = new SplinePointSave();
            sps.Position = splinePoint.Position;
            sps.Velocity = splinePoint.Velocity;
            sps.Time = splinePoint.Time;
            sps.UseCustomVelocityValue = splinePoint.UseCustomVelocityValue;

            return sps;
        }
        public void UpdateToSplinePoint(SplinePoint splinePoint)
        {
            Visible = splinePoint != null;

            if (Visible)
            {
                mRectangle.Position = splinePoint.Position;

                mRectangle.ScaleX = AppState.Self.CurrentSpline.SplinePointVisibleRadius;
                mRectangle.ScaleY = mRectangle.ScaleX;

                mLine.RelativePoint1 = new Point3D(-splinePoint.Velocity / 2.0f);
                mLine.RelativePoint2 = new Point3D(splinePoint.Velocity / 2.0f);
                mLine.Position = splinePoint.Position;

                if (splinePoint.UseCustomVelocityValue)
                {
                    mEndpoint1.Visible = true;
                    mEndpoint2.Visible = true;

                    mEndpoint1.Position = mLine.AbsolutePoint1.ToVector3();
                    mEndpoint2.Position = mLine.AbsolutePoint2.ToVector3();

                    mEndpoint1.Radius = 8 / Camera.Main.PixelsPerUnitAt(splinePoint.Position.Z);
                    mEndpoint2.Radius = 8 / Camera.Main.PixelsPerUnitAt(splinePoint.Position.Z);
                }
                else
                {
                    mEndpoint1.Visible = false;
                    mEndpoint2.Visible = false;
                }



            }

        }
 internal void UpdateToList(SplinePoint splinePoint)
 {
     this.SplineListDisplayControl.UpdateListDisplay(splinePoint);
 }
Пример #6
0
        internal void AddSplinePoint()
        {
            Spline spline = EditorData.EditorLogic.CurrentSpline;
            if (spline == null)
            {
                MessageBox.Show("Select a spline to add points to");
            }
            else
            {
                SplinePoint newSplinePoint = new SplinePoint();
                if (spline.Count > 1)
                {
                    SplinePoint pointBefore = spline[spline.Count - 1];

                    newSplinePoint.Time = pointBefore.Time + 1;

                    if (spline.Count == 1)
                    {
                        newSplinePoint.Position = pointBefore.Position;
                        newSplinePoint.Position.X += 30 / SpriteManager.Camera.PixelsPerUnitAt(newSplinePoint.Position.Z);
                    }
                    else
                    {
                        SplinePoint pointBeforePointBefore = spline[spline.Count - 2];

                        Vector3 difference = pointBefore.Position - pointBeforePointBefore.Position;

                        if (difference == Vector3.Zero)
                        {
                            newSplinePoint.Position = pointBefore.Position;
                            newSplinePoint.Position.X += 30 / Camera.Main.PixelsPerUnitAt(0);
                        }
                        else
                        {
                            newSplinePoint.Position = pointBefore.Position + difference;
                        }

                    }

                }
                else
                {
                    newSplinePoint.Position.X = SpriteManager.Camera.X;
                    newSplinePoint.Position.Y = SpriteManager.Camera.Y;

                    if (spline.Count > 0)
                    {
                        newSplinePoint.Time = spline[0].Time + 1;

                        newSplinePoint.Position = spline[0].Position;
                        newSplinePoint.Position.X += 30 / Camera.Main.PixelsPerUnitAt(0);
                    }
                }
                spline.Add(newSplinePoint);
                spline.CalculateVelocities();
                spline.CalculateAccelerations();
                spline.CalculateDistanceTimeRelationships(.1f);

                GuiData.PropertyGrid.Refresh();
                GuiData.SplineListDisplay.UpdateToList();
            }
            //if (AfterNewPointAdded != null)
            //{
            //    AfterNewPointAdded(this);
            //}
        }
Пример #7
0
        private void MouseGrabbingActivity()
        {
            Cursor cursor = GuiManager.Cursor;

            if (cursor.PrimaryPush && GuiManager.Cursor.WindowOver == null)
            {
                mCurrentSplinePoint = null;

                if (mReactiveHud.SplineMover.IsMouseOver == false)
                {
                    mSwitchedCurrentOnLastPush = mCurrentSpline != mSplineOver;

                    CurrentSpline = mSplineOver;
                    // Make sure we set the CurrentSplinePoint after setting the CurrentSpline so that
                    // the GUI for the CurrentSpline is already set.
                    CurrentSplinePoint = mSplinePointOver;
                    mGrabbedSplinePoint = mSplinePointOver;

                    if (mGrabbedSplinePoint != null)
                    {
                        float cursorX = cursor.WorldXAt(mGrabbedSplinePoint.Position.Z);
                        float cursorY = cursor.WorldYAt(mGrabbedSplinePoint.Position.Z);

                        mXGrabOffset = mGrabbedSplinePoint.Position.X - cursorX;
                        mYGrabOffset = mGrabbedSplinePoint.Position.Y - cursorY;
                    }

                }
                // else if over the spline mover, let the current spline point stay at null
            }

            if (cursor.PrimaryDown && mGrabbedSplinePoint != null)
            {
                if (mHandleIndexOver0Base != -1)
                {
                    float cursorX = cursor.WorldXAt(mGrabbedSplinePoint.Position.Z);
                    float cursorY = cursor.WorldYAt(mGrabbedSplinePoint.Position.Z);

                    float differenceX = cursorX - mGrabbedSplinePoint.Position.X;
                    float differenceY = cursorY - mGrabbedSplinePoint.Position.Y;

                    differenceX *= 2;
                    differenceY *= 2;

                    if (mHandleIndexOver0Base == 0)
                    {
                        // Index 0 goes negative, index 1 goes positive
                        differenceX *= -1;
                        differenceY *= -1;
                    }

                    mGrabbedSplinePoint.Velocity.X = differenceX;
                    mGrabbedSplinePoint.Velocity.Y = differenceY;
                }
                else if (!mSwitchedCurrentOnLastPush)
                {
                    mGrabbedSplinePoint.Position = new Vector3(
                        cursor.WorldXAt(mGrabbedSplinePoint.Position.Z) + mXGrabOffset,
                        cursor.WorldYAt(mGrabbedSplinePoint.Position.Z) + mYGrabOffset,
                        mGrabbedSplinePoint.Position.Z);
                }
            }
            if (cursor.PrimaryClick)
            {
                mGrabbedSplinePoint = null;

                GuiData.PropertyGrid.Refresh();
            }


        }
Пример #8
0
        private void GetSplineAndSplinePointOver()
        {
            mSplinePointOver = null;
            mSplineOver = null;
            mHandleIndexOver0Base = -1;


            #region First see if the cursor is over the current Spline

            if (mCurrentSpline != null)
            {
                if (mReactiveHud.SplinePointSelectionMarker.HasCursorOver(GuiManager.Cursor, out mHandleIndexOver0Base))
                {
                    mSplineOver = AppState.Self.CurrentSpline;
                    mSplinePointOver = AppState.Self.CurrentSplinePoint;
                }
                else
                {
                    SplinePoint splinePointOver = GetSplinePointOver(mCurrentSpline);

                    if (splinePointOver != null)
                    {
                        mSplinePointOver = splinePointOver;
                        mSplineOver = mCurrentSpline;
                        return;
                    }
                }
            }

            #endregion

            #region If not, try the other Splines

            for (int i = 0; i < EditorData.SplineList.Count; i++)
            {
                Spline spline = EditorData.SplineList[i];
                if (spline.Visible)
                {
                    SplinePoint splinePointOver = GetSplinePointOver(spline);

                    if (splinePointOver != null)
                    {
                        mSplineOver = spline;
                        mSplinePointOver = splinePointOver;
                        break;
                    }
                }
            }

            #endregion
        }
 private TreeNode GetTreeNodeFor(SplinePoint splinePoint)
 {
     foreach(TreeNode splineTreeNode in TreeView.Nodes)
     {
         foreach(TreeNode splinePointTreeNode in splineTreeNode.Nodes)
         {
             if(splinePointTreeNode.Tag == splinePoint)
             {
                 return splinePointTreeNode;
             }
         }
     }
     return null;
 }
 private static string TextForPoint(SplinePoint point)
 {
     return "Time: " + point.Time.ToString();
 }
 internal void UpdateListDisplay(SplinePoint point)
 {
     var foundNode = GetTreeNodeFor(point);
     if (foundNode != null)
     {
         foundNode.Text = TextForPoint(point);
     }
 }
        internal void UpdateListDisplay()
        {
            mSuppressSelectionEvents = true;

            object lastSelection = null;
            if (TreeView.SelectedNode != null)
            {
                lastSelection = TreeView.SelectedNode.Tag;
            }

            TreeView.Nodes.Clear();
            if (this.Splines != null)
            {
                foreach (var item in this.Splines)
                {
                    TreeNode newNode = CreateTreeNodeFor(item);
                    TreeView.Nodes.Add(newNode);
                }
            }

            if (lastSelection is Spline)
            {
                this.SelectedSpline = lastSelection as Spline;
            }
            else if (lastSelection is SplinePoint)
            {
                this.SelectedSplinePoint = lastSelection as SplinePoint;
            }

            mSuppressSelectionEvents = false;
        }
Пример #13
0
 public void RefreshTreeView(SplinePoint splinePoint)
 {
     GuiData.SplineListDisplay.UpdateToList(splinePoint);
 }