public virtual void moveHere()
    {
        Direction favored = null;
        if (useFavoredDirection)
            favored = getAt(favoredDirection);

        Direction[] closest = getNearestDirections(Camera.mainCamera.transform.rotation);
        Direction turnTo = closest[0];

        // If favored is activated & the favored direction is present,
        // decide whether we should select the favored direction instead
        if (favored != null && favoredDirection != turnTo.direction) {
            int indexOfFavored = -1;
            for (int i = 0; i < closest.Length; i++) {
                if (closest[i].Equals(favored)) {
                    indexOfFavored = i;
                    break;
                }
            }

            if (indexOfFavored != -1 && indexOfFavored <= Math.Ceiling(((double) closest.Length) / 2.0))
                turnTo = favored;
        }

        curD = turnTo.direction;
        CameraAction action = new CameraAction(this, transform.position + offset, turnTo.rotation);
        CameraController.instance.addAction(action);
    }
        protected virtual string UpdateStatusText()
        {
            CameraAction visibleCamAction = this.drawCamGizmoState != CameraAction.None ? this.drawCamGizmoState : this.camAction;

            // Draw camera action hints
            if (visibleCamAction == CameraAction.Rotate || visibleCamAction == CameraAction.RotateScene)
            {
                return(string.Format("Cam Angle: {0,3:0}°", MathF.RadToDeg(this.CameraObj.Transform.Angle)));
            }
            else if (visibleCamAction == CameraAction.Move || visibleCamAction == CameraAction.DragScene || this.camVel.Z != 0.0f)
            {
                if (visibleCamAction == CameraAction.Move || visibleCamAction == CameraAction.DragScene)
                {
                    return
                        (string.Format("Cam X:{0,7:0}/n", this.CameraObj.Transform.Pos.X) +
                         string.Format("Cam Y:{0,7:0}/n", this.CameraObj.Transform.Pos.Y) +
                         string.Format("Cam Z:{0,7:0}", this.CameraObj.Transform.Pos.Z));
                }
                else if (this.camVel.Z != 0.0f)
                {
                    return(string.Format("Cam Z:{0,7:0}", this.CameraObj.Transform.Pos.Z));
                }
            }

            // Unhandled
            return(null);
        }
    void Update()
    {
        if (cur == null && next != null) {
            cur = next;
            next = null;

            if (cur.getLocation() != null) {
                cur.getLocation().activate();
                GameState.getInstance().setCameraPosition(transform.position);
                GameState.getInstance().setCameraRotation(transform.rotation);
            }

            Vector3 goalPos = cur.hasPosition() ? cur.getPosition() : transform.position;
            Quaternion goalRot = cur.hasRotation() ? cur.getRotation() : transform.rotation;
            movementControl.reset(goalPos, goalRot);
        }

        if (cur != null) {
            float t = Time.time;
            movementControl.update(transform, t);

            if (movementControl.isDone(t)){
                if (cur.hasPosition())
                    transform.position = cur.getPosition();
                if (cur.hasRotation())
                    transform.rotation = cur.getRotation();

                cur = null;

                GameState.getInstance().setCameraPosition(transform.position);
                GameState.getInstance().setCameraRotation(transform.rotation);
            }
        }
    }
Exemple #4
0
        public void HandleAction(CameraAction action)
        {
            switch (action)
            {
            case (CameraAction.right):
                Translate(new Vector2(20, 0) / _zoom);
                break;

            case (CameraAction.left):
                Translate(new Vector2(-20, 0) / _zoom);
                break;

            case (CameraAction.up):
                Translate(new Vector2(0, -20) / _zoom);
                break;

            case (CameraAction.down):
                Translate(new Vector2(0, 20) / _zoom);
                break;

            case (CameraAction.zoom_in):
                Zoom(1.03f);
                break;

            case (CameraAction.zoom_out):
                Zoom(0.97f);
                break;

            default:
                break;
            }
        }
Exemple #5
0
        public void CameraControl(ulong videoID, CameraAction action, int speed, int aux)
        {
            int param       = speed * 11 / 256;
            int actionIndex = (int)action;

            if (action == CameraAction.AuxOn || action == CameraAction.AuxOff)
            {
                param = aux;
            }

            int msg = 0x12230; // Msg_Ctrl_Pan

            if (actionIndex >= 10)
            {
                msg = 0x12240; // Msg_Ctrl_Lens
            }
            if (actionIndex >= 17)
            {
                msg = 0x12250; // Msg_Ctrl_Onoff
            }
            if (actionIndex == 19)
            {
                msg = 0x12242; // Msg_Set_Preset
            }
            if (actionIndex == 20)
            {
                msg = 0x12244; // Msg_Goto_Preset
            }
            int actCode = _actionCodes[actionIndex];

            TimeSpan endSpan = TimeSpan.FromSeconds(30);

            if (action == CameraAction.Stop || action == CameraAction.LensStop || action == CameraAction.AuxOn || action == CameraAction.AuxOff)
            {
                endSpan = TimeSpan.FromSeconds(5);
            }
            StartCtrl(videoID, endSpan);
            MessageBuilder mb = new MessageBuilder(0x11028); // Msg_Video_Ctrl

            mb.Writer.Write(videoID);
            mb.Writer.Write(msg);
            if (msg == 0x12250) // Msg_Ctrl_Onoff
            {
                mb.Writer.Write(-param);
                mb.Writer.Write(actCode);
                mb.Writer.Write((int)0);
            }
            else if (msg == 0x12242 || msg == 0x12244) // Msg_Set_Preset || Msg_Goto_Preset
            {
                mb.Writer.Write(aux);
                mb.Writer.Write((int)0);
            }
            else
            {
                mb.Writer.Write(actCode);
                mb.Writer.Write((int)0);
                mb.Writer.Write(param);
            }
            _connection.Send(mb.ToMessage());
        }
        private void RenderableControl_MouseUp(object sender, MouseEventArgs e)
        {
            this.drawCamGizmoState = CameraAction.None;

            if (this.camBeginDragScene)
            {
                this.camAction = CameraAction.None;
                this.Cursor    = CursorHelper.HandGrab;
            }
            else
            {
                if (this.camAction == CameraAction.Move && e.Button == MouseButtons.Middle)
                {
                    this.camAction = CameraAction.None;
                }
                else if (this.camAction == CameraAction.Rotate && e.Button == MouseButtons.Right)
                {
                    this.camAction = CameraAction.None;
                }

                this.OnMouseUp(e);
            }

            this.Invalidate();
        }
            public void ShouldThrowExceptionWhenValueIsEmpty()
            {
                var action = new CameraAction();

                ExceptionAssert.Throws <InvalidOperationException>("The label cannot be null or whitespace.", () =>
                {
                    action.Label = string.Empty;
                });
            }
Exemple #8
0
        public void CameraControl(string videoId, string action, int actData)
        {
            CameraAction act = CameraAction.StopPT;

            if (Enum.TryParse <CameraAction>(action, out act))
            {
                _control.CameraControl(videoId, act, actData);
            }
        }
Exemple #9
0
            public void ShouldThrowExceptionWhenLabelIsNull()
            {
                IAction action = new CameraAction();

                ExceptionAssert.Throws <InvalidOperationException>("The label cannot be null.", () =>
                {
                    action.Validate();
                });
            }
Exemple #10
0
            public void ShouldNotThrowExceptionWhenValid()
            {
                IAction action = new CameraAction()
                {
                    Label = "Test"
                };

                action.Validate();
            }
            public void ShouldThrowExceptionWhenValueIsMoreThan20Chars()
            {
                var action = new CameraAction();

                ExceptionAssert.Throws <InvalidOperationException>("The label cannot be longer than 20 characters.", () =>
                {
                    action.Label = new string('x', 21);
                });
            }
        public CameraSlowMotion(Environment environment, BaseEvent eventFrame)
        {
            this.environment = environment;
            this.eventFrame  = eventFrame;

            CameraAction ca = (CameraAction)eventFrame.ShowAction();

            CameraAction.SlowMotionFx smf = (CameraAction.SlowMotionFx)ca.fx;
            environment.PerformCameraSlowMotion(smf.timeScale, smf.duration);
        }
Exemple #13
0
        public CameraFade(Environment environment, BaseEvent eventFrame)
        {
            this.environment = environment;
            this.eventFrame  = eventFrame;

            CameraAction ca = (CameraAction)eventFrame.action;

            CameraAction.FadeFx ff = (CameraAction.FadeFx)ca.fx;
            environment.FadeCamera(ff.duration, ff.color, ff.alphaCurve);
        }
        private void ChangeActiveMode(CameraAction cameraAction)
        {
            if (_currentAction?.CameraAction == cameraAction)
            {
                return;
            }

            _currentAction = _cameraActions.FirstOrDefault(cc => cc.CameraAction == cameraAction);
            _currentAction?.StartAction();
        }
        public void CameraControl(string videoId, string action, int actData)
        {
            CameraAction act = CameraAction.StopPT;

            if (Enum.TryParse <CameraAction>(action, out act))
            {
                Common.Log.Logger.Default.Trace($"VideoPlugin 操作 {videoId}: {act} {actData}");
                CCTVInfoManager.Instance.CameraControl.CameraControl(videoId, act, actData);
            }
        }
            public void ShouldNotThrowExceptionWhenValueIs20Chars()
            {
                var value = new string('x', 20);

                var action = new CameraAction()
                {
                    Label = value
                };

                Assert.AreEqual(value, action.Label);
            }
Exemple #17
0
            public void ShouldCreateSerializeableObject()
            {
                var action = new CameraAction
                {
                    Label = "Test"
                };

                string serialized = JsonSerializer.SerializeObject(action);

                Assert.AreEqual(@"{""type"":""camera"",""label"":""Test""}", serialized);
            }
Exemple #18
0
        private void RenderableControl_LostFocus(object sender, EventArgs e)
        {
            if (DualityEditorApp.MainForm == null)
            {
                return;
            }

            this.camAction = CameraAction.None;
            this.OnLostFocus();
            this.Invalidate();
        }
Exemple #19
0
        private void RenderableControl_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Space && this.camBeginDragScene)
            {
                this.camBeginDragScene = false;
                this.camAction         = CameraAction.None;
                this.Cursor            = CursorHelper.Arrow;
                this.OnCamActionRequiresCursorChanged(EventArgs.Empty);
            }

            this.OnKeyUp(e);
        }
Exemple #20
0
        private void RenderableControl_MouseDown(object sender, MouseEventArgs e)
        {
            bool alt = (Control.ModifierKeys & Keys.Alt) != Keys.None;

            this.drawCamGizmoState = CameraAction.None;

            if (this.camBeginDragScene)
            {
                this.camActionBeginLoc = e.Location;
                if (e.Button == MouseButtons.Left)
                {
                    this.camAction = CameraAction.DragScene;
                    this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
                    this.Cursor = CursorHelper.HandGrabbing;
                }
                else if (e.Button == MouseButtons.Right)
                {
                    this.camAction = CameraAction.RotateScene;
                    this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
                    this.Cursor = CursorHelper.HandGrabbing;
                }
                else if (e.Button == MouseButtons.Middle)
                {
                    this.camAction = CameraAction.Move;
                    this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
                }
            }
            else
            {
                if (this.camActionAllowed && this.camAction == CameraAction.None)
                {
                    this.camActionBeginLoc = e.Location;
                    if (e.Button == MouseButtons.Middle)
                    {
                        this.camAction = CameraAction.Move;
                        this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        this.camAction = CameraAction.Rotate;
                        this.camActionBeginLocSpace = new Vector3(this.CameraObj.Transform.RelativeAngle, 0.0f, 0.0f);
                    }
                }

                this.OnMouseDown(e);
            }
        }
Exemple #21
0
        private void RenderableControl_MouseWheel(object sender, MouseEventArgs e)
        {
            if (!this.mouseover)
            {
                return;
            }

            this.drawCamGizmoState = CameraAction.None;

            if (e.Delta != 0)
            {
                if (this.View.PerspectiveMode == PerspectiveMode.Parallax)
                {
                    GameObject camObj  = this.CameraObj;
                    float      curVel  = this.camVel.Length * MathF.Sign(this.camVel.Z);
                    Vector2    curTemp = new Vector2(
                        (e.X * 2.0f / this.ClientSize.Width) - 1.0f,
                        (e.Y * 2.0f / this.ClientSize.Height) - 1.0f);
                    MathF.TransformCoord(ref curTemp.X, ref curTemp.Y, camObj.Transform.RelativeAngle);

                    if (MathF.Sign(e.Delta) != MathF.Sign(curVel))
                    {
                        curVel = 0.0f;
                    }
                    else
                    {
                        curVel *= 1.5f;
                    }
                    curVel += 0.015f * e.Delta;
                    curVel  = MathF.Sign(curVel) * MathF.Min(MathF.Abs(curVel), 500.0f);

                    Vector3 movVec = new Vector3(
                        MathF.Sign(e.Delta) * MathF.Sign(curTemp.X) * MathF.Pow(curTemp.X, 2.0f),
                        MathF.Sign(e.Delta) * MathF.Sign(curTemp.Y) * MathF.Pow(curTemp.Y, 2.0f),
                        1.0f);
                    movVec.Normalize();
                    this.camVel = movVec * curVel;
                }
                else
                {
                    this.View.FocusDist = this.View.FocusDist + this.View.FocusDistIncrement * e.Delta / 40;
                }
            }

            this.OnMouseWheel(e);
        }
        public CameraCinematicZoomToSelf(Environment environment, BaseEvent eventFrame, Character caster)
        {
            this.environment = environment;
            this.eventFrame  = eventFrame;
            this.caster      = caster;

            CameraAction ca = (CameraAction)eventFrame.ShowAction();

            CameraAction.CinematicZoomToSelfFx cztsf = (CameraAction.CinematicZoomToSelfFx)ca.fx;
            offset = cztsf.offset.FlipFollowDirection(caster.FacingDirection());
            Vector2 zoomPosition = (Vector2)caster.Position() + offset;

            zoomTarget = environment.PerformCameraCinematicZoom(
                zoomPosition, cztsf.easeDuration, cztsf.ShowEaseType(), cztsf.holdDuration, cztsf.zoomLevel
                );
            zoomTarget.onLeftTarget += () => { isFinished = true; };
        }
        public void rotateCamera3(Vector3 rotStep, Vector3 rotTarget)
        {
            vectorStep   = rotStep;
            vectorTarget = rotTarget;
            bool  xIsReachable = isReachableTrans(_cameraPosition.X, rotStep.X, rotTarget.X);
            bool  yIsReachable = isReachableTrans(_cameraPosition.Y, rotStep.Y, rotTarget.Y);
            bool  zIsReachable = isReachableTrans(_cameraPosition.Z, rotStep.Z, rotTarget.Z);
            float error        = 2;

            if (Vector3.Distance(_cameraPosition, rotTarget) < error)
            {
                return;
            }
            else
            {
                currentAction = CameraAction.Rotating;
                rotateCameraPos(rotStep);
            }
        }
        public bool translateCameraToTarget3(Vector3 posTarget, float factor)
        {
            Vector3 step = posTarget - _cameraPosition;

            step.Normalize();
            step *= factor;

            if (Vector3.Distance(posTarget, _cameraPosition) < 1)
            {
                _cameraPosition = posTarget;
                return(true);
            }
            else
            {
                currentAction = CameraAction.translateCameraToTarget3;
                translateCameraPosStep(step);
                return(false);
            }
        }
Exemple #25
0
    void Update()
    {
        if (cur == null && next != null)
        {
            cur  = next;
            next = null;

            if (cur.getLocation() != null)
            {
                cur.getLocation().activate();
                GameState.getInstance().setCameraPosition(transform.position);
                GameState.getInstance().setCameraRotation(transform.rotation);
            }

            Vector3    goalPos = cur.hasPosition() ? cur.getPosition() : transform.position;
            Quaternion goalRot = cur.hasRotation() ? cur.getRotation() : transform.rotation;
            movementControl.reset(goalPos, goalRot);
        }

        if (cur != null)
        {
            float t = Time.time;
            movementControl.update(transform, t);

            if (movementControl.isDone(t))
            {
                if (cur.hasPosition())
                {
                    transform.position = cur.getPosition();
                }
                if (cur.hasRotation())
                {
                    transform.rotation = cur.getRotation();
                }

                cur = null;

                GameState.getInstance().setCameraPosition(transform.position);
                GameState.getInstance().setCameraRotation(transform.rotation);
            }
        }
    }
    public virtual void moveHere()
    {
        Direction favored = null;

        if (useFavoredDirection)
        {
            favored = getAt(favoredDirection);
        }

        Direction[] closest = getNearestDirections(Camera.mainCamera.transform.rotation);
        Direction   turnTo  = closest[0];

        // If favored is activated & the favored direction is present,
        // decide whether we should select the favored direction instead
        if (favored != null && favoredDirection != turnTo.direction)
        {
            int indexOfFavored = -1;
            for (int i = 0; i < closest.Length; i++)
            {
                if (closest[i].Equals(favored))
                {
                    indexOfFavored = i;
                    break;
                }
            }

            if (indexOfFavored != -1 && indexOfFavored <= Math.Ceiling(((double)closest.Length) / 2.0))
            {
                turnTo = favored;
            }
        }

        curD = turnTo.direction;
        CameraAction action = new CameraAction(this, transform.position + offset, turnTo.rotation);

        CameraController.instance.addAction(action);
    }
        public CameraAddTarget(Environment environment, BaseEvent eventFrame, Character caster)
        {
            this.environment = environment;
            this.eventFrame  = eventFrame;

            CameraAction ca = (CameraAction)eventFrame.ShowAction();

            atf = (CameraAction.AddTargetFx)ca.fx;
            Character target = environment.FindNearbyCharacters(
                caster, Vector3.zero, 999,
                new[] { FindingFilter.ExcludeMe, FindingFilter.ExcludeDead, FindingFilter.ExcludeAllies }
                )[0];

            joint = target.GameObject().transform.FindDeepChild(atf.joint);
            pc2d  = environment.GetCamera().GetComponent <ProCamera2D>();
            casterCameraTarget = pc2d.CameraTargets[0];
            originalX          = casterCameraTarget.TargetInfluenceH;
            originalY          = casterCameraTarget.TargetInfluenceV;
            casterCameraTarget.TargetInfluenceH = atf.curInfX;
            casterCameraTarget.TargetInfluenceV = atf.curInfY;
            cameraTarget = pc2d.AddCameraTarget(
                joint, atf.influenceY, atf.influenceX, atf.translationDuration
                );
        }
        public void Control(CameraAction action, int actData)
        {
            string uri = _api + @"/ptzcontrol/control?videoid=" + _videoId + "&action=" + (int)action + "&data=" + actData;

            dooGet(uri);
        }
Exemple #29
0
        public void Control(CameraAction action, int actData)
        {
            CCTVInfo.CameraAction act = CCTVInfo.CameraAction.Stop;
            int speed = 0;
            int aux   = 0;

            switch (action)
            {
            case CameraAction.StopPT:
            case CameraAction.StopZoom:
            case CameraAction.StopFocus:
            case CameraAction.StopIris:
                act = CCTVInfo.CameraAction.Stop;
                break;

            case CameraAction.Up:
            case CameraAction.Down:
            case CameraAction.Left:
            case CameraAction.Right:
            case CameraAction.LeftUp:
            case CameraAction.LeftDown:
            case CameraAction.RightUp:
            case CameraAction.RightDown:
            case CameraAction.AutoScan:
                act   = (CCTVInfo.CameraAction)(int) action;
                speed = actData;
                break;

            case CameraAction.AuxOn:
                act = CCTVInfo.CameraAction.AuxOn;
                aux = actData;
                break;

            case CameraAction.AuxOff:
                act = CCTVInfo.CameraAction.AuxOff;
                aux = actData;
                break;

            case CameraAction.ZoomIn:
                act = CCTVInfo.CameraAction.ZoomWide;
                break;

            case CameraAction.ZoomOut:
                act = CCTVInfo.CameraAction.ZoomTele;
                break;

            case CameraAction.FocusNear:
                act = CCTVInfo.CameraAction.FocusNear;
                break;

            case CameraAction.FocusFar:
                act = CCTVInfo.CameraAction.FocusFar;
                break;

            case CameraAction.IrisOpen:
                act = CCTVInfo.CameraAction.IrisOpen;
                break;

            case CameraAction.IrisClose:
                act = CCTVInfo.CameraAction.IrisClose;
                break;

            case CameraAction.GoPreset:
                act = CCTVInfo.CameraAction.GoPreset;
                aux = actData;
                break;

            case CameraAction.SetPreset:
                act = CCTVInfo.CameraAction.SetPreset;
                aux = actData;
                break;

            default:
                return;
            }
            _info.CameraControl(_videoId, act, speed, aux);
        }
Exemple #30
0
		private void RenderableControl_LostFocus(object sender, EventArgs e)
		{
			if (DualityEditorApp.MainForm == null) return;

			this.camAction = CameraAction.None;
			this.OnLostFocus();
			this.Invalidate();
		}
Exemple #31
0
		private void RenderableControl_KeyUp(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Space && this.camBeginDragScene)
			{
				this.camBeginDragScene = false;
				this.camAction = CameraAction.None;
				this.Cursor = CursorHelper.Arrow;
				this.OnCamActionRequiresCursorChanged(EventArgs.Empty);
			}

			this.OnKeyUp(e);
		}
 public void rotateCamera3(Vector3 rotStep, Vector3 rotTarget)
 {
     vectorStep = rotStep;
     vectorTarget = rotTarget;
     bool xIsReachable = isReachableTrans(_cameraPosition.X, rotStep.X, rotTarget.X);
     bool yIsReachable = isReachableTrans(_cameraPosition.Y, rotStep.Y, rotTarget.Y);
     bool zIsReachable = isReachableTrans(_cameraPosition.Z, rotStep.Z, rotTarget.Z);
     float error = 2;
     if (Vector3.Distance(_cameraPosition, rotTarget) < error)
     {
         return;
     }
     else
     {
         currentAction = CameraAction.Rotating;
         rotateCameraPos(rotStep);
     }
 }
Exemple #33
0
		private void RenderableControl_MouseWheel(object sender, MouseEventArgs e)
		{
			if (!this.mouseover) return;

			this.drawCamGizmoState = CameraAction.None;

			if (e.Delta != 0)
			{
				if (this.View.PerspectiveMode == PerspectiveMode.Parallax)
				{
					GameObject camObj = this.CameraObj;
					float curVel = this.camVel.Length * MathF.Sign(this.camVel.Z);
					Vector2 curTemp = new Vector2(
						(e.X * 2.0f / this.ClientSize.Width) - 1.0f,
						(e.Y * 2.0f / this.ClientSize.Height) - 1.0f);
					MathF.TransformCoord(ref curTemp.X, ref curTemp.Y, camObj.Transform.RelativeAngle);

					if (MathF.Sign(e.Delta) != MathF.Sign(curVel))
						curVel = 0.0f;
					else
						curVel *= 1.5f;
					curVel += 0.015f * e.Delta;
					curVel = MathF.Sign(curVel) * MathF.Min(MathF.Abs(curVel), 500.0f);

					Vector3 movVec = new Vector3(
						MathF.Sign(e.Delta) * MathF.Sign(curTemp.X) * MathF.Pow(curTemp.X, 2.0f), 
						MathF.Sign(e.Delta) * MathF.Sign(curTemp.Y) * MathF.Pow(curTemp.Y, 2.0f), 
						1.0f);
					movVec.Normalize();
					this.camVel = movVec * curVel;
				}
				else
				{
					this.View.FocusDist = this.View.FocusDist + this.View.FocusDistIncrement * e.Delta / 40;
				}
			}

			this.OnMouseWheel(e);
		}
Exemple #34
0
		private void RenderableControl_MouseDown(object sender, MouseEventArgs e)
		{
			bool alt = (Control.ModifierKeys & Keys.Alt) != Keys.None;

			this.drawCamGizmoState = CameraAction.None;

			if (this.camBeginDragScene)
			{
				this.camActionBeginLoc = e.Location;
				if (e.Button == MouseButtons.Left)
				{
					this.camAction = CameraAction.DragScene;
					this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
					this.Cursor = CursorHelper.HandGrabbing;
				}
				else if (e.Button == MouseButtons.Right)
				{
					this.camAction = CameraAction.RotateScene;
					this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
					this.Cursor = CursorHelper.HandGrabbing;
				}
				else if (e.Button == MouseButtons.Middle)
				{
					this.camAction = CameraAction.Move;
					this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
				}
			}
			else
			{
				if (this.camActionAllowed && this.camAction == CameraAction.None)
				{
					this.camActionBeginLoc = e.Location;
					if (e.Button == MouseButtons.Middle)
					{
						this.camAction = CameraAction.Move;
						this.camActionBeginLocSpace = this.CameraObj.Transform.RelativePos;
					}
					else if (e.Button == MouseButtons.Right)
					{
						this.camAction = CameraAction.Rotate;
						this.camActionBeginLocSpace = new Vector3(this.CameraObj.Transform.RelativeAngle, 0.0f, 0.0f);
					}
				}

				this.OnMouseDown(e);
			}
		}
Exemple #35
0
		private void RenderableControl_MouseUp(object sender, MouseEventArgs e)
		{
			this.drawCamGizmoState = CameraAction.None;

			if (this.camBeginDragScene)
			{
				this.camAction = CameraAction.None;
				this.Cursor = CursorHelper.HandGrab;
			}
			else
			{
				if (this.camAction == CameraAction.Move && e.Button == MouseButtons.Middle)
					this.camAction = CameraAction.None;
				else if (this.camAction == CameraAction.Rotate && e.Button == MouseButtons.Right)
					this.camAction = CameraAction.None;

				this.OnMouseUp(e);
			}

			this.Invalidate();
		}
 //public void Update(float elapsedSeconds)
 //{
 //}
 public void DoAction(CameraAction action)
 {
     switch (action)
     {
         case CameraAction.MoveUp:
             DoActionMove(new Vector2(0, -1));
             break;
         case CameraAction.MoveDown:
             DoActionMove(new Vector2(0, 1));
             break;
         case CameraAction.MoveLeft:
             DoActionMove(new Vector2(-1, 0));
             break;
         case CameraAction.MoveRight:
             DoActionMove(new Vector2(1, 0));
             break;
         case CameraAction.ZoomIn:
             DoActionZoom(ZoomValue);
             break;
         case CameraAction.ZoomOut:
             DoActionZoom(-ZoomValue);
             break;
     }
 }
 public void addAction(CameraAction action)
 {
     next = action;
 }
Exemple #38
0
            public void ShouldNotThrowExceptionWhenActionIsCameraAction()
            {
                var action = new CameraAction();

                IActionExtensions.CheckActionType(action);
            }
Exemple #39
0
        private void RenderableControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (this.camActionAllowed)
            {
                if (e.KeyCode == Keys.Space && !this.IsActionInProgress && !this.camBeginDragScene)
                {
                    this.camBeginDragScene = true;
                    this.OnCamActionRequiresCursorChanged(EventArgs.Empty);
                    this.Cursor = CursorHelper.HandGrab;
                }
                else if (e.KeyCode == Keys.F)
                {
                    if (DualityEditorApp.Selection.MainGameObject != null)
                    {
                        this.View.FocusOnObject(DualityEditorApp.Selection.MainGameObject);
                    }
                    else
                    {
                        this.View.ResetCamera();
                    }
                }
                else if (e.Control && e.KeyCode == Keys.Left)
                {
                    this.drawCamGizmoState = CameraAction.Move;
                    Vector3 pos = this.CameraObj.Transform.Pos;
                    pos.X = MathF.Round(pos.X - 1.0f);
                    this.CameraObj.Transform.Pos = pos;
                    this.Invalidate();
                }
                else if (e.Control && e.KeyCode == Keys.Right)
                {
                    this.drawCamGizmoState = CameraAction.Move;
                    Vector3 pos = this.CameraObj.Transform.Pos;
                    pos.X = MathF.Round(pos.X + 1.0f);
                    this.CameraObj.Transform.Pos = pos;
                    this.Invalidate();
                }
                else if (e.Control && e.KeyCode == Keys.Up)
                {
                    this.drawCamGizmoState = CameraAction.Move;
                    Vector3 pos = this.CameraObj.Transform.Pos;
                    pos.Y = MathF.Round(pos.Y - 1.0f);
                    this.CameraObj.Transform.Pos = pos;
                    this.Invalidate();
                }
                else if (e.Control && e.KeyCode == Keys.Down)
                {
                    this.drawCamGizmoState = CameraAction.Move;
                    Vector3 pos = this.CameraObj.Transform.Pos;
                    pos.Y = MathF.Round(pos.Y + 1.0f);
                    this.CameraObj.Transform.Pos = pos;
                    this.Invalidate();
                }
                else if (e.Control && e.KeyCode == Keys.Add)
                {
                    this.drawCamGizmoState = CameraAction.Move;
                    Vector3 pos = this.CameraObj.Transform.Pos;
                    pos.Z = MathF.Round(pos.Z + 1.0f);
                    this.CameraObj.Transform.Pos = pos;
                    this.Invalidate();
                }
                else if (e.Control && e.KeyCode == Keys.Subtract)
                {
                    this.drawCamGizmoState = CameraAction.Move;
                    Vector3 pos = this.CameraObj.Transform.Pos;
                    pos.Z = MathF.Round(pos.Z - 1.0f);
                    this.CameraObj.Transform.Pos = pos;
                    this.Invalidate();
                }
            }

            this.OnKeyDown(e);
        }
Exemple #40
0
		private void RenderableControl_KeyDown(object sender, KeyEventArgs e)
		{
			if (this.camActionAllowed)
			{
				if (e.KeyCode == Keys.Space && !this.IsActionInProgress && !this.camBeginDragScene)
				{
					this.camBeginDragScene = true;
					this.OnCamActionRequiresCursorChanged(EventArgs.Empty);
					this.Cursor = CursorHelper.HandGrab;
				}
				else if (e.KeyCode == Keys.F)
				{
					if (DualityEditorApp.Selection.MainGameObject != null)
						this.View.FocusOnObject(DualityEditorApp.Selection.MainGameObject);
					else
						this.View.ResetCamera();
				}
				else if (e.Control && e.KeyCode == Keys.Left)
				{
					this.drawCamGizmoState = CameraAction.Move;
					Vector3 pos = this.CameraObj.Transform.Pos;
					pos.X = MathF.Round(pos.X - 1.0f);
					this.CameraObj.Transform.Pos = pos;
					this.Invalidate();
				}
				else if (e.Control && e.KeyCode == Keys.Right)
				{
					this.drawCamGizmoState = CameraAction.Move;
					Vector3 pos = this.CameraObj.Transform.Pos;
					pos.X = MathF.Round(pos.X + 1.0f);
					this.CameraObj.Transform.Pos = pos;
					this.Invalidate();
				}
				else if (e.Control && e.KeyCode == Keys.Up)
				{
					this.drawCamGizmoState = CameraAction.Move;
					Vector3 pos = this.CameraObj.Transform.Pos;
					pos.Y = MathF.Round(pos.Y - 1.0f);
					this.CameraObj.Transform.Pos = pos;
					this.Invalidate();
				}
				else if (e.Control && e.KeyCode == Keys.Down)
				{
					this.drawCamGizmoState = CameraAction.Move;
					Vector3 pos = this.CameraObj.Transform.Pos;
					pos.Y = MathF.Round(pos.Y + 1.0f);
					this.CameraObj.Transform.Pos = pos;
					this.Invalidate();
				}
				else if (e.Control && e.KeyCode == Keys.Add)
				{
					this.drawCamGizmoState = CameraAction.Move;
					Vector3 pos = this.CameraObj.Transform.Pos;
					pos.Z = MathF.Round(pos.Z + 1.0f);
					this.CameraObj.Transform.Pos = pos;
					this.Invalidate();
				}
				else if (e.Control && e.KeyCode == Keys.Subtract)
				{
					this.drawCamGizmoState = CameraAction.Move;
					Vector3 pos = this.CameraObj.Transform.Pos;
					pos.Z = MathF.Round(pos.Z - 1.0f);
					this.CameraObj.Transform.Pos = pos;
					this.Invalidate();
				}
			}

			this.OnKeyDown(e);
		}
        public bool translateCameraToTarget3(Vector3 posTarget, float factor)
        {
            Vector3 step = posTarget - _cameraPosition;
            step.Normalize();
            step *= factor;

            if (Vector3.Distance(posTarget, _cameraPosition) < 1)
            {
                _cameraPosition = posTarget;
                return true;
            }
            else
            {
                currentAction = CameraAction.translateCameraToTarget3;
                translateCameraPosStep(step);
                return false;
            }
        }
Exemple #42
0
 public void CameraControl(string videoId, CameraAction action, int actData)
 {
     _control.CameraControl(videoId, action, actData);
 }
 void Awake()
 {
     cameraTransform = Camera.main.transform;
     scriptCamera = Camera.main.GetComponent<CameraAction>();
 }