forked from rtpHarry/Sokoban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamera.cpp
601 lines (475 loc) · 21.5 KB
/
Camera.cpp
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
// Camera.cpp: implementation of the CCamera class.
//
//////////////////////////////////////////////////////////////////////
#include <iostream>
#include <fstream>
using namespace std;
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include "GLee.h"
//#include <gl/GL.h>
#include <gl/GLU.h>
#include "NeHeGL.h" // Header File For The NeHeGL Basecode
#include "Camera.h"
#include "Timer.h"
//#include "Vector3.h"
// Create a global float that stores the elapsed time between the current
// and last frame. For your engine, this would move likely go into a
// CTime or CTimer class, along with the CalculateFrameRate() function.
// float g_FrameInterval = 0.0f;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCamera::CCamera()
{
m_vPosition = CVector3(0.0f, 0.0f, 6.0f); // position vector
m_vView = CVector3(0.0f, 0.0f, 0.0f); // view vector (direction)
m_vUpVector = CVector3(0.0f, 1.0f, 0.0f); // standard up vector
// disable mouse control
m_bMouseControlOn = false;
// show mouse cursor
ShowCursor(TRUE);
}
CCamera::~CCamera()
{
}
///////////////////////////////// CALCULATE FRAME RATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This function calculates the frame rate and time intervals between frames
/////
///////////////////////////////// CALCULATE FRAME RATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/*
void CalculateFrameRate()
{
static float framesPerSecond = 0.0f; // This will store our fps
static float lastTime = 0.0f; // This will hold the time from the last frame
static char strFrameRate[50] = {0}; // We will store the string here for the window title
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
static float frameTime = 0.0f; // This stores the last frame's time
// Get the current time in seconds. Notice that we use timeGetTime() instead
// of GetTickCount(). This is because on some computers, depending on their
// CPU, GetTickCount() does update as fast or correctly as clock(). You need
// to include <mmsystem.h> to use this function. You will also need to include
// winmm.lib and mmsystem.h in your code.
float currentTime = timeGetTime() * 0.001f;
// Here we store the elapsed time between the current and last frame,
// then keep the current frame in our static variable for the next frame.
g_FrameInterval = currentTime - frameTime;
frameTime = currentTime;
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
// Increase the frame counter
++framesPerSecond;
// Now we want to subtract the current time by the last time that was stored
// to see if the time elapsed has been over a second, which means we found our FPS.
if( currentTime - lastTime > 1.0f )
{
// Here we set the lastTime to the currentTime
lastTime = currentTime;
// Copy the frames per second into a string to display in the window title bar
sprintf(strFrameRate, "Current Frames Per Second: %d", int(framesPerSecond));
// Set the window title bar to our string
SetWindowText(g_window->hWnd, strFrameRate);
// Reset the frames per second
framesPerSecond = 0;
}
}
*/
//////////////////////////// CHECK FOR MOVEMENT \\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This function handles the input faster than in the WinProc()
/////
//////////////////////////// CHECK FOR MOVEMENT \\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CCamera::CheckForMovement()
{
/*
// Check if we hit the Up arrow or the 'w' key
if(GetKeyState(VK_UP) & 0x80 || GetKeyState('W') & 0x80) {
// Move our camera forward by a positive SPEED
MoveCamera(speed);
}
// Check if we hit the Down arrow or the 's' key
if(GetKeyState(VK_DOWN) & 0x80 || GetKeyState('S') & 0x80) {
// Move our camera backward by a negative SPEED
MoveCamera(-speed);
}
// Check if we hit the Left arrow or the 'a' key
if(GetKeyState(VK_LEFT) & 0x80 || GetKeyState('A') & 0x80) {
// Strafe the camera left
StrafeCamera(-speed);
}
// Check if we hit the Right arrow or the 'd' key
if(GetKeyState(VK_RIGHT) & 0x80 || GetKeyState('D') & 0x80) {
// Strafe the camera right
StrafeCamera(speed);
}
*/
}
/////////////////////////////////////// CROSS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This returns a perpendicular vector from 2 given vectors by taking the cross product.
/////
/////////////////////////////////////// CROSS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
CVector3 Cross(CVector3 vVector1, CVector3 vVector2)
{
CVector3 vNormal; // The vector to hold the cross product
// If we are given 2 vectors (the view and up vector) then we have a plane define.
// The cross product finds a vector that is perpendicular to that plane,
// which means it's point straight out of the plane at a 90 degree angle.
// The equation for the cross product is simple, but difficult at first to memorize:
// The X value for the vector is: (V1.y * V2.z) - (V1.z * V2.y) // Get the X value
vNormal.x = ((vVector1.y * vVector2.z) - (vVector1.z * vVector2.y));
// The Y value for the vector is: (V1.z * V2.x) - (V1.x * V2.z)
vNormal.y = ((vVector1.z * vVector2.x) - (vVector1.x * vVector2.z));
// The Z value for the vector is: (V1.x * V2.y) - (V1.y * V2.x)
vNormal.z = ((vVector1.x * vVector2.y) - (vVector1.y * vVector2.x));
// *IMPORTANT* This is not communitive. You can not change the order or this or
// else it won't work correctly. It has to be exactly like that. Just remember,
// If you are trying to find the X, you don't use the X value of the 2 vectors, and
// it's the same for the Y and Z. You notice you use the other 2, but never that axis.
// If you look at the camera rotation tutorial, you will notice it's the same for rotations.
// So why do I need the cross product to do a first person view? Well, we need
// to find the axis that our view has to rotate around. Rotating the camera left
// and right is simple, the axis is always (0, 1, 0). Rotating around the camera
// up and down is different because we are constantly going in and out of axises.
// We need to find the axis that our camera is on, and that is why we use the cross
// product. By taking the cross product between our view vector and up vector,
// we get a perpendicular vector to those 2 vectors, which is our desired axis.
// Pick up a linear algebra book if you don't already have one, you'll need it.
// Return the cross product
return vNormal;
}
/////////////////////////////////////// MAGNITUDE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This returns the magnitude of a vector
/////
/////////////////////////////////////// MAGNITUDE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
float Magnitude(CVector3 vNormal)
{
// This will give us the magnitude or "Norm" as some say of, our normal.
// The magnitude has to do with the length of the vector. We use this
// information to normalize a vector, which gives it a length of 1.
// Here is the equation: magnitude = sqrt(V.x^2 + V.y^2 + V.z^2) Where V is the vector
return (float)sqrt( (vNormal.x * vNormal.x) +
(vNormal.y * vNormal.y) +
(vNormal.z * vNormal.z) );
}
/////////////////////////////////////// NORMALIZE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This returns a normalize vector (A vector exactly of length 1)
/////
/////////////////////////////////////// NORMALIZE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
CVector3 Normalize(CVector3 vVector)
{
// What's this function for you might ask? Well, since we are using the cross
// product formula, we need to make sure our view vector is normalized.
// For a vector to be normalized, it means that it has a length of 1.
// For instance, a vector (2, 0, 0) would be (1, 0, 0) once normalized.
// Most equations work well with normalized vectors. If in doubt, normalize.
// Get the magnitude of our normal
float magnitude = Magnitude(vVector);
// Now that we have the magnitude, we can divide our vector by that magnitude.
// That will make our vector a total length of 1.
// This makes it easier to work with too.
vVector = vVector / magnitude;
// Finally, return our normalized vector
return vVector;
}
////
// Position Camera
//////////////////
// Allows access to set the camera's vectors
/////////////////////////////
void CCamera::PositionCamera(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ)
{
// compress parameters
CVector3 vPosition = CVector3(positionX, positionY, positionZ);
CVector3 vView = CVector3(viewX, viewY, viewZ);
CVector3 vUpVector = CVector3(upVectorX, upVectorY, upVectorZ);
// assign paramaters to member variables
m_vPosition = vPosition;
m_vView = vView;
m_vUpVector = vUpVector;
}
///////////////////////////////// SET VIEW BY MOUSE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This allows us to look around using the mouse, like in most first person games.
/////
///////////////////////////////// SET VIEW BY MOUSE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CCamera::SetViewByMouse()
{
POINT mousePos; // This is a window structure that holds an X and Y
int middleX = g_window->init.width >> 1; // This is a binary shift to get half the width
int middleY = g_window->init.height >> 1; // This is a binary shift to get half the height
float angleY = 0.0f; // This is the direction for looking up or down
float angleZ = 0.0f; // This will be the value we need to rotate around the Y axis (Left and Right)
static float currentRotX = 0.0f;
// Get the mouse's current X,Y position
GetCursorPos(&mousePos);
// Now that we got the mouse position, we want to put the mouse position
// back at the middle of the screen. We pass in half of our screen width and height.
// The >> operator is a binary shift. So, we are shifting our width and height
// to the right by 1. If you do the binary math, it is the same thing and dividing by 2,
// but extremely faster. The reason why we put the cursor in the middle of the
// screen each time is we can can get a delta (difference) of how far we move
// each frame, so we know how much to rotate the camera.
// If our cursor is still in the middle, we never moved... so don't update the screen
if( (mousePos.x == middleX) && (mousePos.y == middleY) ) return;
// Set the mouse position to the middle of our window
SetCursorPos(middleX, middleY);
// Now we need to get the direction (or VECTOR) that the mouse moved.
// To do this, it's a simple subtraction. Just take the middle point,
// and subtract the new point from it: VECTOR = P1 - P2; with P1
// being the middle point (400, 300) and P2 being the new mouse location.
// Look below at the *Quick Notes* for more information and examples.
// After we get the X and Y delta (or direction), I divide by 1000 to bring the number
// down a bit, otherwise the camera would move lightning fast!
// Get the direction the mouse moved in, but bring the number down to a reasonable amount
angleY = (float)( (middleX - mousePos.x) ) / 1000.0f;
angleZ = (float)( (middleY - mousePos.y) ) / 1000.0f;
static float lastRotX = 0.0f;
lastRotX = currentRotX; // We store off the currentRotX and will use it in when the angle is capped
// Here we keep track of the current rotation (for up and down) so that
// we can restrict the camera from doing a full 360 loop.
currentRotX += angleZ;
// If the current rotation (in radians) is greater than 1.0, we want to cap it.
if(currentRotX > 1.0f)
{
currentRotX = 1.0f;
// Rotate by remaining angle if there is any
if(lastRotX != 1.0f)
{
// To find the axis we need to rotate around for up and down
// movements, we need to get a perpendicular vector from the
// camera's view vector and up vector. This will be the axis.
// Before using the axis, it's a good idea to normalize it first.
CVector3 vAxis = Cross(m_vView - m_vPosition, m_vUpVector);
vAxis = Normalize(vAxis);
// rotate the camera by the remaining angle (1.0f - lastRotX)
RotateView( 1.0f - lastRotX, vAxis.x, vAxis.y, vAxis.z);
}
}
// Check if the rotation is below -1.0, if so we want to make sure it doesn't continue
else if(currentRotX < -1.0f)
{
currentRotX = -1.0f;
// Rotate by the remaining angle if there is any
if(lastRotX != -1.0f)
{
// To find the axis we need to rotate around for up and down
// movements, we need to get a perpendicular vector from the
// camera's view vector and up vector. This will be the axis.
// Before using the axis, it's a good idea to normalize it first.
CVector3 vAxis = Cross(m_vView - m_vPosition, m_vUpVector);
vAxis = Normalize(vAxis);
// rotate the camera by ( -1.0f - lastRotX)
RotateView( -1.0f - lastRotX, vAxis.x, vAxis.y, vAxis.z);
}
}
// Otherwise, we can rotate the view around our position
else
{
// To find the axis we need to rotate around for up and down
// movements, we need to get a perpendicular vector from the
// camera's view vector and up vector. This will be the axis.
// Before using the axis, it's a good idea to normalize it first.
CVector3 vAxis = Cross(m_vView - m_vPosition, m_vUpVector);
vAxis = Normalize(vAxis);
// Rotate around our perpendicular axis
RotateView(angleZ, vAxis.x, vAxis.y, vAxis.z);
}
// Always rotate the camera around the y-axis
RotateView(angleY, 0, 1, 0);
}
///////////////////////////////// ROTATE VIEW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This rotates the view around the position using an axis-angle rotation
/////
///////////////////////////////// ROTATE VIEW \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CCamera::RotateView(float angle, float x, float y, float z)
{
CVector3 vNewView;
CVector3 vView;
// Get our view vector (The direciton we are facing)
vView.x = m_vView.x - m_vPosition.x; // This gets the direction of the X
vView.y = m_vView.y - m_vPosition.y; // This gets the direction of the Y
vView.z = m_vView.z - m_vPosition.z; // This gets the direction of the Z
// Calculate the sine and cosine of the angle once
float cosTheta = (float)cos(angle);
float sinTheta = (float)sin(angle);
// Find the new x position for the new rotated point
vNewView.x = (cosTheta + (1 - cosTheta) * x * x) * vView.x;
vNewView.x += ((1 - cosTheta) * x * y - z * sinTheta) * vView.y;
vNewView.x += ((1 - cosTheta) * x * z + y * sinTheta) * vView.z;
// Find the new y position for the new rotated point
vNewView.y = ((1 - cosTheta) * x * y + z * sinTheta) * vView.x;
vNewView.y += (cosTheta + (1 - cosTheta) * y * y) * vView.y;
vNewView.y += ((1 - cosTheta) * y * z - x * sinTheta) * vView.z;
// Find the new z position for the new rotated point
vNewView.z = ((1 - cosTheta) * x * z - y * sinTheta) * vView.x;
vNewView.z += ((1 - cosTheta) * y * z + x * sinTheta) * vView.y;
vNewView.z += (cosTheta + (1 - cosTheta) * z * z) * vView.z;
// Now we just add the newly rotated vector to our position to set
// our new rotated view of our camera.
m_vView.x = m_vPosition.x + vNewView.x;
m_vView.y = m_vPosition.y + vNewView.y;
m_vView.z = m_vPosition.z + vNewView.z;
}
///////////////////////////////// ROTATE AROUND POINT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This rotates the position around a given point
/////
///////////////////////////////// ROTATE AROUND POINT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CCamera::RotateAroundPoint(CVector3 vCenter, float angle, float x, float y, float z)
{
CVector3 vNewPosition;
// To rotate our position around a point, what we need to do is find
// a vector from our position to the center point we will be rotating around.
// Once we get this vector, then we rotate it along the specified axis with
// the specified degree. Finally the new vector is added center point that we
// rotated around (vCenter) to become our new position. That's all it takes.
// Get the vVector from our position to the center we are rotating around
CVector3 vPos = m_vPosition - vCenter;
// Calculate the sine and cosine of the angle once
float cosTheta = (float)cos(angle);
float sinTheta = (float)sin(angle);
// Find the new x position for the new rotated point
vNewPosition.x = (cosTheta + (1 - cosTheta) * x * x) * vPos.x;
vNewPosition.x += ((1 - cosTheta) * x * y - z * sinTheta) * vPos.y;
vNewPosition.x += ((1 - cosTheta) * x * z + y * sinTheta) * vPos.z;
// Find the new y position for the new rotated point
vNewPosition.y = ((1 - cosTheta) * x * y + z * sinTheta) * vPos.x;
vNewPosition.y += (cosTheta + (1 - cosTheta) * y * y) * vPos.y;
vNewPosition.y += ((1 - cosTheta) * y * z - x * sinTheta) * vPos.z;
// Find the new z position for the new rotated point
vNewPosition.z = ((1 - cosTheta) * x * z - y * sinTheta) * vPos.x;
vNewPosition.z += ((1 - cosTheta) * y * z + x * sinTheta) * vPos.y;
vNewPosition.z += (cosTheta + (1 - cosTheta) * z * z) * vPos.z;
// Now we just add the newly rotated vector to our position to set
// our new rotated position of our camera.
m_vPosition = vCenter + vNewPosition;
}
////
// Move Camera
//////////////
// Allows camera forward / backward movement
////////////////////////////////////////////
void CCamera::MoveCamera(float speed)
{
CVector3 vVector= CVector3(0.0f,0.0f,0.0f); // a view vector
// Get our view vector (The direciton we are facing)
vVector.x = m_vView.x - m_vPosition.x;
vVector.y = m_vView.y - m_vPosition.y;
vVector.z = m_vView.z - m_vPosition.z;
m_vPosition.x += vVector.x * speed; // Add our acceleration to our position's X
m_vPosition.y += vVector.y * speed; // Add our acceleration to our position's Y
m_vPosition.z += vVector.z * speed; // Add our acceleration to our position's Z
m_vView.x += vVector.x * speed; // Add our acceleration to our view's X
m_vView.y += vVector.y * speed; // Add our acceleration to our view's X
m_vView.z += vVector.z * speed; // Add our acceleration to our view's Z
}
///////////////////////////////// STRAFE CAMERA \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This strafes the camera left and right depending on the speed (-/+)
/////
///////////////////////////////// STRAFE CAMERA \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CCamera::StrafeCamera(float speed)
{
// Strafing is quite simple if you understand what the cross product is.
// If you have 2 vectors (say the up vVector and the view vVector) you can
// use the cross product formula to get a vVector that is 90 degrees from the 2 vectors.
// For a better explanation on how this works, check out the OpenGL "Normals" tutorial at our site.
// In our new Update() function, we set the strafing vector (m_vStrafe). Due
// to the fact that we need this vector for many things including the strafing
// movement and camera rotation (up and down), we just calculate it once.
//
// Like our MoveCamera() function, we add the strafing vector to our current position
// and view. It's as simple as that. It has already been calculated in Update().
// Add the strafe vector to our position
m_vPosition.x += m_vStrafe.x * speed;
m_vPosition.z += m_vStrafe.z * speed;
// Add the strafe vector to our view
m_vView.x += m_vStrafe.x * speed;
m_vView.z += m_vStrafe.z * speed;
}
///////////////////////////////// LOOK \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This updates the camera according to the
/////
///////////////////////////////// LOOK \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CCamera::Look()
{
// Give openGL our camera position, then camera view, then camera up vector
gluLookAt(m_vPosition.x, m_vPosition.y, m_vPosition.z,
m_vView.x, m_vView.y, m_vView.z,
m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);
}
///////////////////////////////// UPDATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This updates the camera's view and strafe vector
/////
///////////////////////////////// UPDATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CCamera::Update()
{
// Below we calculate the strafe vector every time we update
// the camera. This is because many functions use it so we might
// as well calculate it only once.
// Initialize a variable for the cross product result
CVector3 vCross = Cross(m_vView - m_vPosition, m_vUpVector);
// Normalize the strafe vector
m_vStrafe = Normalize(vCross);
// Move the camera's view by the mouse
if (m_bMouseControlOn) SetViewByMouse();
// This checks to see if the keyboard was pressed
// HANDLED IN mainDriver.cpp::update(DWORD milliseconds)
CheckForMovement();
CTimer Timer;
float speed = (float)kSpeed * Timer.GetFrameDelta();
}
//g_camera->PositionCamera(0.0f, 6.0f, -6.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
void CCamera::DEBUG_WritePositionToFile(void)
{
ofstream examplefile (".\\camerapos.txt", ios::app);
if (examplefile.is_open())
{
examplefile << Position().x << "f, "
<< Position().y << "f, "
<< Position().z << "f, "
<< View().x << "f, "
<< View().y << "f, "
<< View().z << "f" << endl;
examplefile.close();
}
}
/*
void CCamera::DEBUG_WritePositionToFile(void)
{
ofstream examplefile (".\\camerapos.txt");
if (examplefile.is_open())
{
examplefile << Position().x << endl;
examplefile << Position().y << endl;
examplefile << Position().z << endl;
examplefile << View().x << endl;
examplefile << View().y << endl;
examplefile << View().z << endl;
examplefile.close();
}
}*/
// Toggle if the mouse controls the camera
void CCamera::ToggleMouseControl(void)
{
m_bMouseControlOn = !m_bMouseControlOn;
if (m_bMouseControlOn)
{
// hide mouse cursor
ShowCursor(FALSE);
}
else
{
// show mouse cursor
ShowCursor(TRUE);
}
}