Пример #1
0
        private void CheckForPositionChanges()
        {
            var position = transform.position;

            if (expectedPositionSet == true)
            {
                if (expectedPosition.x != position.x || expectedPosition.y != position.y || expectedPosition.z != position.z)
                {
                    point.Position.LocalX += position.x - expectedPosition.x;
                    point.Position.LocalY += position.y - expectedPosition.y;
                    point.Position.LocalZ += position.z - expectedPosition.z;

                    point.Position.SnapLocal();

                    expectedPosition = position;

                    point.PositionChanged();
                }
            }
            else
            {
                expectedPosition    = position;
                expectedPositionSet = true;
            }
        }
Пример #2
0
        protected virtual void Update()
        {
            if (TetherPoint != null)
            {
                var position = TetherPoint.Position;
                var sizeX    = Size.x * TetherScale;
                var sizeY    = Size.y * TetherScale;
                var sizeZ    = Size.z * TetherScale;
                var delta    = SgtPosition.Delta(ref position, ref SgtFloatingOrigin.CurrentPoint.Position);
                var deltaX   = delta.GlobalX * SgtPosition.CellSize + delta.LocalX;
                var deltaY   = delta.GlobalX * SgtPosition.CellSize + delta.LocalY;
                var deltaZ   = delta.GlobalX * SgtPosition.CellSize + delta.LocalZ;
                var stepX    = System.Math.Round(deltaX / sizeX);
                var stepY    = System.Math.Round(deltaY / sizeY);
                var stepZ    = System.Math.Round(deltaZ / sizeZ);

                if (stepX != 0 || stepY != 0 || stepZ != 0)
                {
                    position.LocalX -= stepX * sizeX;
                    position.LocalY -= stepY * sizeY;
                    position.LocalZ -= stepZ * sizeZ;
                    position.SnapLocal();

                    TetherPoint.Position = position;
                    TetherPoint.PositionChanged();
                }
            }
        }
Пример #3
0
        public void UpdateOrbit()
        {
            var position = ParentPoint.Position;
            var rotation = ParentPoint.transform.rotation * Quaternion.Euler(Tilt);
            var r1       = Radius;
            var r2       = Radius * (1.0f - Oblateness);
            var localX   = System.Math.Sin(Angle * Mathf.Deg2Rad) * r1;
            var localY   = 0.0;
            var localZ   = System.Math.Cos(Angle * Mathf.Deg2Rad) * r2;

            Rotate(rotation, ref localX, ref localY, ref localZ);

            position.LocalX += localX;
            position.LocalY += localY;
            position.LocalZ += localZ;
            position.SnapLocal();

            cachedPoint.Position = position;
            cachedPoint.PositionChanged();

            if (SgtHelper.Enabled(Visual) == true)
            {
                Visual.Draw(this);
            }
        }
Пример #4
0
        public void UpdateOrbit()
        {
            cachedPoint.Position = CalculatePosition(ParentPoint, Radius, Angle, Tilt, Oblateness);

            cachedPoint.PositionChanged();

            if (SgtHelper.Enabled(Visual) == true)
            {
                Visual.Draw(this);
            }
        }
        protected virtual void Update()
        {
            if (MonitorPosition == true)
            {
                var position = transform.position;

                if (expectedPositionSet == true)
                {
                    if (expectedPosition.x != position.x || expectedPosition.y != position.y || expectedPosition.z != position.z)
                    {
                        Point.Position.LocalX += position.x - expectedPosition.x;
                        Point.Position.LocalY += position.y - expectedPosition.y;
                        Point.Position.LocalZ += position.z - expectedPosition.z;

                        expectedPosition = position;

                        Point.Position.SnapLocal();

                        Point.PositionChanged();
                    }
                    else
                    {
                        expectedPosition = position;
                    }
                }
                else
                {
                    expectedPositionSet = true;
                    expectedPosition    = position;
                }
            }
            else
            {
                expectedPositionSet = false;
            }

            if (OnDistance != null)
            {
                var position = SgtFloatingOrigin.CurrentPoint.Position;
                var distance = SgtPosition.Distance(ref position, ref Point.Position);

                OnDistance.Invoke(distance);
            }
        }