public virtual void Update(GameTime time)
        {
            var move = GetTranslation(time);

            if (move != Vector3.Zero)
            {
                Position += TranslationVelocity * (float)time.ElapsedGameTime.TotalSeconds * Vector3.Normalize(move);//same speed for oblique direction
            }
            var rotation = GetRotation(time);

            //TODO bounding up down look
            //if (sign(horizontal.X) != sign(Direction.X) || sign(horizontal.Z) != sign(Direction.Z))
            //    Direction = horizontal;

            ForwardDirection = Vector3.Transform(ForwardDirection, rotation);
            ForwardDirection.Normalize();
            var         t   = ForwardDirection;
            const float val = 0.93f;

            if (t.Y > val)
            {
                t.Y = val;
            }
            if (t.Y < -val)
            {
                t.Y = -val;
            }

            t.Normalize();
            ForwardDirection = t;

            View = Matrix.CreateLookAt(Position, Position + ForwardDirection, Up);
        }
Exemple #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = StartUtc.GetHashCode();
         hashCode = (hashCode * 397) ^ EndUtc.GetHashCode();
         hashCode = (hashCode * 397) ^ (DateRangeType != null ? DateRangeType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (DesignUid != null ? DesignUid.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (DesignFileName != null ? DesignFileName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (ContributingMachines != null ? ContributingMachines.GetListHashCode() : 397);
         hashCode = (hashCode * 397) ^ (OnMachineDesignId != null ? OnMachineDesignId.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (OnMachineDesignName != null ? OnMachineDesignName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (ElevationType != null ? ElevationType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (VibeStateOn != null ? VibeStateOn.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonUid != null ? PolygonUid.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonName != null ? PolygonName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonLL != null ? PolygonLL.GetListHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PolygonType != null ? PolygonType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (ForwardDirection != null ? ForwardDirection.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (LayerNumber != null ? LayerNumber.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AlignmentUid != null ? AlignmentUid.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AlignmentFileName != null ? AlignmentFileName.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (StartStation != null ? StartStation.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (EndStation != null ? EndStation.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (LeftOffset != null ? LeftOffset.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (RightOffset != null ? RightOffset.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AsAtDate != null ? AsAtDate.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (AutomaticsType != null ? AutomaticsType.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (TemperatureRangeMin != null ? TemperatureRangeMin.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (TemperatureRangeMax != null ? TemperatureRangeMax.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PassCountRangeMin != null ? PassCountRangeMin.GetHashCode() : 397);
         hashCode = (hashCode * 397) ^ (PassCountRangeMax != null ? PassCountRangeMax.GetHashCode() : 397);
         return(hashCode);
     }
 }
Exemple #3
0
    void GenerateSecondFloor()
    {
        /*this void is quite similar to GenerateFirstFloor, the difference is in the random, some ground will be placed,
         * and some ground will not be placed*/
        int index = 0;

        for (int i = 0; i < 8; i++)
        {
            float            X       = 2.9f * i;
            float            Z       = 2.9f * index;
            ForwardDirection forward = new ForwardDirection();
            if (Random.Range(0, 4) < 2 /*changing this 2 I can control partially the level of instances*/)
            {
                Instantiate(ground, new Vector3(forward.x = X, 1, forward.z = Z), new Quaternion(0, 0, 0, 0));
                ValidMatrix.Add(forward);
            }

            if (i == 7 && index < 7)
            {
                i = -1; index++;
            }
        }

        //when this void finishes it work, it will call the Third void
        GenerateThirdFloor();
    }
        void ChangeForwardDirection(string turnDirection)
        {
            if (turnDirection == TURN_LEFT)
            {
                switch (this.forwardDirection)
                {
                case ForwardDirection.UP:
                    this.forwardDirection = ForwardDirection.LEFT;
                    break;

                case ForwardDirection.LEFT:
                    this.forwardDirection = ForwardDirection.DOWN;
                    break;

                case ForwardDirection.DOWN:
                    this.forwardDirection = ForwardDirection.RIGHT;
                    break;

                case ForwardDirection.RIGHT:
                    this.forwardDirection = ForwardDirection.UP;
                    break;
                }
            }
            else
            {
                switch (this.forwardDirection)
                {
                case ForwardDirection.UP:
                    this.forwardDirection = ForwardDirection.RIGHT;
                    break;

                case ForwardDirection.LEFT:
                    this.forwardDirection = ForwardDirection.UP;
                    break;

                case ForwardDirection.DOWN:
                    this.forwardDirection = ForwardDirection.LEFT;
                    break;

                case ForwardDirection.RIGHT:
                    this.forwardDirection = ForwardDirection.DOWN;
                    break;
                }
            }

            //    //this.forwardDirection++;
            //    this.forwardDirection = (this.forwardDirection == ForwardDirection.RIGHT ? ForwardDirection.UP :
            //        (ForwardDirection)(Forward++);
            //}
            //else {
            //    this.forwardDirection = (this.forwardDirection == ForwardDirection.UP ? ForwardDirection.RIGHT : this.forwardDirection++);
            //}
        }
    public Pipe(Quaternion rotation, int sectionCount = 4) : base(rotation)
    {
        sectionContains = new int[sectionCount];
        sectionMovement = new float[sectionCount];

        sectionInterval = 0.25f;

        itemsMesh = new ModelInfo[sectionCount];

        requestedNeighbours    = new Vector3Int[2];
        requestedNeighbours[0] = ForwardDirection;
        requestedNeighbours[1] = ForwardDirection.Multiply(-1);

        lastSection  = sectionCount - 1;
        sectionStart = -(Vector3)ForwardDirection * 0.5f;
    }
        public RobotPainter(string[] instructionsInput)
        {
            // The computer's available memory should be much larger than the initial program. Memory beyond the initial program starts with
            // the value 0 and can be read or written like any other memory. (It is invalid to try to access memory at a negative address, though.)
            this.instructions = new string[10000];
            for (int index = 0; index < instructions.Length; index++)
            {
                instructions.SetValue("0", index);
            }
            for (int index = 0; index < instructionsInput.Length; index++)
            {
                instructions.SetValue(instructionsInput[index], index);
            }

            this.forwardDirection = ForwardDirection.UP;
            this.row = 0;
            this.col = 0;
        }
Exemple #7
0
        public static Pos Carving()//选择初始点
        {
            Pos tmp_emptyPos = emptyPosList[0];

            foreach (var pair in emptyPosList)//选择空节点中坐标最小的
            {
                if (pair.x < tmp_emptyPos.x && pair.y < tmp_emptyPos.y)
                {
                    tmp_emptyPos = pair;
                }
                else if (pair.x < tmp_emptyPos.x)
                {
                    tmp_emptyPos = pair;
                }
                else if (pair.x <= tmp_emptyPos.x && pair.y < tmp_emptyPos.y)
                {
                    tmp_emptyPos = pair;
                }
            }
            nowDirct = ForwardDirection.None;//重置
            return(tmp_emptyPos);
        }
    void GenerateSecondFloor()
    {
        /*this void is quite similar to GenerateFirstFloor, the difference is in the random, some ground will be placed,
         and some ground will not be placed*/
        int index = 0;
        for (int i = 0; i < 8; i++)
        {
            float X = 2.9f * i;
            float Z = 2.9f * index;
            ForwardDirection forward = new ForwardDirection();
            if (Random.Range(0, 4) < 2/*changing this 2 I can control partially the level of instances*/)
            {
                Instantiate(ground, new Vector3(forward.x = X, 1, forward.z = Z), new Quaternion(0, 0, 0, 0));
                ValidMatrix.Add(forward);
            }

            if (i == 7 && index < 7)
            { i = -1; index++; }
        }

        //when this void finishes it work, it will call the Third void
        GenerateThirdFloor();
    }
Exemple #9
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Document      doc   = uidoc.Document;

            // Save current 3D view
            var view3D = doc.ActiveView as View3D;

            if (view3D == null || view3D.IsPerspective)
            {
                TaskDialog ts = new TaskDialog("Incorrect View selected")
                {
                    MainContent = "Please, select 3D Orthographic view."
                };

                ts.Show();
                return(Result.Succeeded);
            }

            // Get viewOrientation3D
            ViewOrientation3D viewOrientation3D = view3D.GetOrientation();

            ForwardDirection = viewOrientation3D.ForwardDirection;
            UpDirection      = viewOrientation3D.UpDirection;
            var rightDirection = ForwardDirection.CrossProduct(UpDirection);

            EyePosition = viewOrientation3D.EyePosition;

            IList <UIView> views       = uidoc.GetOpenUIViews();
            UIView         currentView = views.FirstOrDefault(t => t.ViewId == view3D.Id);

            //Corners of the active UI view
            if (currentView == null)
            {
                return(Result.Succeeded);
            }

            IList <XYZ> corners = currentView.GetZoomCorners();
            XYZ         corner1 = corners[0];
            XYZ         corner2 = corners[1];

            //center of the UI view
            double x          = (corner1.X + corner2.X) / 2;
            double y          = (corner1.Y + corner2.Y) / 2;
            double z          = (corner1.Z + corner2.Z) / 2;
            XYZ    viewCenter = new XYZ(x, y, z);

            EyePosition = viewCenter;

            // Calculate diagonal vector
            XYZ diagVector = corner1 - corner2;

            double height = 0.5 * Math.Abs(diagVector.DotProduct(UpDirection));
            double width  = 0.5 * Math.Abs(diagVector.DotProduct(rightDirection));

            Scale = Math.Min(height, width);

            TaskDialog ts1 = new TaskDialog("Camera parameters")
            {
                MainContent = "Camera parameters have been successfully saved."
            };

            ts1.Show();
            return(Result.Succeeded);
        }
Exemple #10
0
        public static Pos Painting(Pos startPos)//画点
        {
            ChoiceDir(startPos);
            ForwardDirection dirt2 = ForwardDirection.None;

            if (startPos.dirt.Count > 0)
            {
                if (nowDirct == ForwardDirection.None)
                {
                    nowDirct = startPos.dirt[0];
                }

                //bool isCanDir = IsDir(startPos);
                if (startPos.dirt.Count == 1)
                {
                    dirt2 = startPos.dirt[0];
                }

                if (startPos.dirt.Count > 1)
                {
                    bool isDir = r.Next(1, 4) == 2 ? true : false;//是否转向

                    if (isDir)
                    {
                        dirt2 = startPos.dirt[r.Next(0, startPos.dirt.Count)];
                    }
                    else
                    {
                        if (startPos.dirt.Contains(nowDirct))
                        {
                            dirt2 = nowDirct;
                        }
                        else
                        {
                            dirt2 = startPos.dirt[0];
                        }
                    }
                }
                FillRoad(startPos);    //画点
                roadPos.Add(startPos); //添加到道路列表
                DeltEmptyPos(startPos);
                startPos.dirt.Clear();
            }
            else
            {
                FillRoad(startPos);//画点
                return(null);
            }

            nowDirct = dirt2;
            Pos tmp_ForwardPos;//声明临时POS用于接取下一个点的引用

            switch (dirt2)
            {
            case ForwardDirection.Up:
                tmp_ForwardPos = new Pos(startPos.x - 1, startPos.y); //从空列表获取这个点表示的POS引用
                return(tmp_ForwardPos);                               //传出这个点的引用

            case ForwardDirection.Down:
                tmp_ForwardPos = new Pos(startPos.x + 1, startPos.y);
                return(tmp_ForwardPos);

            case ForwardDirection.Left:
                tmp_ForwardPos = new Pos(startPos.x, startPos.y - 1);
                return(tmp_ForwardPos);

            case ForwardDirection.Right:
                tmp_ForwardPos = new Pos(startPos.x, startPos.y + 1);
                return(tmp_ForwardPos);
            }
            return(null);
        }