-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraMan.cs
More file actions
107 lines (87 loc) · 2.64 KB
/
CameraMan.cs
File metadata and controls
107 lines (87 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using Mogre;
using System;
namespace Mogre.TutorialFramework
{
public class CameraMan
{
private Camera mCamera;
private bool mGoingForward;
private bool mGoingBack;
private bool mGoingRight;
private bool mGoingLeft;
private bool mGoingUp;
private bool mGoingDown;
private bool mFastMove;
private bool mFreeze;
public CameraMan(Camera camera)
{
mCamera = camera;
}
public bool GoingForward
{
set { mGoingForward = value; }
get { return mGoingForward; }
}
public bool GoingBack
{
set { mGoingBack = value; }
get { return mGoingBack; }
}
public bool GoingLeft
{
set { mGoingLeft = value; }
get { return mGoingLeft; }
}
public bool GoingRight
{
set { mGoingRight = value; }
get { return mGoingRight; }
}
public bool GoingUp
{
set { mGoingUp = value; }
get { return mGoingUp; }
}
public bool GoingDown
{
set { mGoingDown = value; }
get { return mGoingDown; }
}
public bool FastMove
{
set { mFastMove = value; }
get { return mFastMove; }
}
public bool Freeze
{
set { mFreeze = value; }
get { return mFreeze; }
}
public void UpdateCamera(float timeFragment)
{
if (mFreeze)
return;
// build our acceleration vector based on keyboard input composite
var move = Vector3.ZERO;
if (mGoingForward) move += mCamera.Direction;
if (mGoingBack) move -= mCamera.Direction;
if (mGoingRight) move += mCamera.Right;
if (mGoingLeft) move -= mCamera.Right;
if (mGoingUp) move += mCamera.Up;
if (mGoingDown) move -= mCamera.Up;
move.Normalise();
move *= 150; // Natural speed is 150 units/sec.
if (mFastMove)
move *= 3; // With shift button pressed, move twice as fast.
if (move != Vector3.ZERO)
mCamera.Move(move * timeFragment);
}
public void MouseMovement(int x, int y)
{
if (mFreeze)
return;
mCamera.Yaw(new Degree(-x * 0.15f));
mCamera.Pitch(new Degree(-y * 0.15f));
}
}
}