Example #1
0
        /// <summary>
        /// 将摄像机移动到对象所在的位置
        /// </summary>
        /// <param name="objectInfo">对象信息</param>
        private void MoveCameraToObject(_AtlObjInfo objectInfo)
        {
            // 移动镜头
            Hashtable infoTable   = Helper.GetInfoTable(objectInfo);
            string    positionStr = infoTable["vPosition"] as string;

            if (positionStr != null) // 有效的坐标
            {
                string[] positionData = positionStr.Split(new char[] { ',' });
                float    positionX    = float.Parse(positionData[0]);
                float    positionY    = float.Parse(positionData[1]);
                float    positionZ    = float.Parse(positionData[2]);

                _AtlVector3 objPos = new _AtlVector3();
                objPos.x = positionX;
                objPos.y = positionY;
                objPos.z = positionZ;

                _AtlVector3 oldpos = new _AtlVector3(), oldlookat = new _AtlVector3();
                SceneSceneEditor.GetCameraPosLookat(ref oldpos, ref oldlookat);
                _AtlVector3 delta = new _AtlVector3();
                delta.x = oldlookat.x - oldpos.x; delta.y = oldlookat.y - oldpos.y; delta.z = oldlookat.z - oldpos.z;
                _AtlVector3 newpos = new _AtlVector3();
                newpos.x = objPos.x - delta.x; newpos.y = objPos.y - delta.y; newpos.z = objPos.z - delta.z;
                SceneSceneEditor.SetCameraLocation(newpos.x, newpos.y, newpos.z, objPos.x, objPos.y, objPos.z);
            }
        }
Example #2
0
        /// <summary>
        /// 获取摄像机坐标 ahpho suntao
        /// </summary>
        /// <returns>摄像机坐标字符串</returns>
        private string GetCameraLookAt()
        {
            _AtlVector3 cameraLocation = new _AtlVector3();
            _AtlVector3 cameraLookAt   = new _AtlVector3();

            SceneSceneEditor.GetCameraPosLookat(ref cameraLocation, ref cameraLookAt);
            string cameraLookAtString = string.Format("{0},{1},{2}", (int)cameraLookAt.x, (int)cameraLookAt.y, (int)cameraLookAt.z);

            return(cameraLookAtString);
        }
Example #3
0
        private void MoveCameraToPosition(_AtlVector3 newPos)
        {
            _AtlVector3 oldpos = new _AtlVector3(), oldlookat = new _AtlVector3();

            SceneSceneEditor.GetCameraPosLookat(ref oldpos, ref oldlookat);
            _AtlVector3 delta = new _AtlVector3();

            delta.x = oldlookat.x - oldpos.x; delta.y = oldlookat.y - oldpos.y; delta.z = oldlookat.z - oldpos.z;
            _AtlVector3 newpos = new _AtlVector3();

            newpos.x = newPos.x - delta.x; newpos.y = newPos.y - delta.y; newpos.z = newPos.z - delta.z;
            SceneSceneEditor.SetCameraPosLookat(ref newpos, ref newPos);
        }
Example #4
0
        /// <summary>
        /// 设置相机坐标 ahpho suntao
        /// </summary>
        /// <param name="x">x坐标</param>
        /// <param name="y">y坐标</param>
        /// <param name="z">z坐标</param>
        public void SetCameraFocus(int x, int y, int z)
        {
            _AtlVector3 cameraLocation = new _AtlVector3();
            _AtlVector3 cameraLookAt   = new _AtlVector3();
            _AtlVector3 delta          = new _AtlVector3();

            SceneSceneEditor.GetCameraPosLookat(ref cameraLocation, ref cameraLookAt);

            delta.x = cameraLookAt.x - cameraLocation.x;
            delta.y = cameraLookAt.y - cameraLocation.y;
            delta.z = cameraLookAt.z - cameraLocation.z;

            cameraLookAt.x = x;
            cameraLookAt.y = y;
            cameraLookAt.z = z;

            cameraLocation.x = x - delta.x;
            cameraLocation.y = y - delta.y;
            cameraLocation.z = z - delta.z;

            SceneSceneEditor.SetCameraPosLookat(ref cameraLocation, ref cameraLookAt);
        }
Example #5
0
        private void BaseForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Shift)
            {
                m_shiftPress = true;
            }
            if (e.Control)
            {
                m_ctrlPress = true;
            }

            if (!(this.ActiveControl is PanelDockContainer) && this.ActiveControl != this.PanelView)
            {
                return;
            }
            if (!e.Alt && !e.Shift && e.Control && e.KeyCode == Keys.Enter)
            {
                ToggleFullScreen();
                return;
            }
            if (!e.Alt && !e.Shift && !e.Control && e.KeyCode == Keys.P)
            {
                TogglePMode();
                return;
            }
            if (!e.Alt && !e.Shift && !e.Control && e.KeyCode == Keys.T)
            {
                ToggleTopView();
                return;
            }
            if (!e.Alt && !e.Shift && !e.Control && e.KeyCode == Keys.X)
            {
                SceneSceneEditor.DropSelectedEntity();
            }
            if (!e.Alt && !e.Shift && !e.Control && e.KeyCode == Keys.Z)
            {
                SceneSceneEditor.ZoomToObj();
            }
            if (e.Shift && e.KeyCode >= Keys.F1 && e.KeyCode <= Keys.F1 + CAMERA_STORAGE - 1)
            {
                int saveindex = e.KeyCode - Keys.F1;
                m_bPosSaved[saveindex] = true;
                SceneSceneEditor.GetCameraPosLookat(ref m_SavedCameraPos[saveindex], ref m_SavedCameraLookat[saveindex]);
                return;
            }
            if (!e.Shift && e.KeyCode >= Keys.F1 && e.KeyCode <= Keys.F1 + CAMERA_STORAGE - 1)
            {
                int saveindex = e.KeyCode - Keys.F1;
                if (m_bPosSaved[saveindex])
                {
                    SceneSceneEditor.SetCameraPosLookat(ref m_SavedCameraPos[saveindex], ref m_SavedCameraLookat[saveindex]);
                }
                return;
            }
            if (!e.Shift && !e.Control && e.KeyCode == Keys.Enter)
            {
                ShowProperties();
            }

            switch (e.KeyCode)
            {
            case Keys.Oemcomma:
            {
                NpcPlayNextAction();
                return;
            }

            case Keys.OemPeriod:
            {
                NpcPlayPreviousAction();
                return;
            }

            case Keys.G:
            {
                EditGroup();
                return;
            }

            case Keys.Oem1:
            {
                editMode = EditMode.None;
                break;
            }

            case Keys.W:
            {
                cameraLookAtBox.Text = GetCameraLookAt();
                break;
            }

            case Keys.S:
            {
                cameraLookAtBox.Text = GetCameraLookAt();
                break;
            }

            case Keys.A:
            {
                cameraLookAtBox.Text = GetCameraLookAt();
                break;
            }

            case Keys.D:
            {
                cameraLookAtBox.Text = GetCameraLookAt();
                break;
            }

            case Keys.Delete:
            {
                DeleteSelectedObject();
                break;
            }

            case Keys.Add:
                goto case Keys.Oemplus;

            case Keys.Oemplus:
            {
                m_parent.m_sliderCameraSpeed.Value++;
                m_parent.UpdateCameraSpeedToUI();
                break;
            }

            case Keys.Subtract:
                goto case Keys.OemMinus;

            case Keys.OemMinus:
            {
                m_parent.m_sliderCameraSpeed.Value--;
                m_parent.UpdateCameraSpeedToUI();
                break;
            }
            }

            EngineLayer.ATLBase.ProcessMessage((uint)WM_KEYDOWN, e.KeyValue, e.KeyValue);
        }