~ubuntu-branches/ubuntu/natty/spring/natty

« back to all changes in this revision

Viewing changes to rts/Game/Camera/FPSController.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-09-23 18:56:03 UTC
  • mfrom: (3.1.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100923185603-st97s5chplo42y7w
Tags: 0.82.5.1+dfsg1-1ubuntu1
* Latest upstream version for online play
* debian/control: Replace (rather than conflict) spring-engine
  - spring-engine will be a dummy package (LP: #612905)
  - also set maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
 
2
 
1
3
#include "StdAfx.h"
2
4
#include "mmgr.h"
3
5
 
8
10
#include "LogOutput.h"
9
11
#include "Map/Ground.h"
10
12
#include "GlobalUnsynced.h"
 
13
#include "myMath.h"
11
14
 
12
15
using std::min;
13
16
using std::max;
16
19
        : oldHeight(300)
17
20
{
18
21
        scrollSpeed = configHandler->Get("FPSScrollSpeed", 10) * 0.1f;
 
22
        mouseScale = configHandler->Get("FPSMouseScale", 0.01f);
19
23
        enabled = !!configHandler->Get("FPSEnabled", 1);
20
24
        fov = configHandler->Get("FPSFOV", 45.0f);
21
25
}
23
27
 
24
28
void CFPSController::KeyMove(float3 move)
25
29
{
26
 
        move*=move.z*400;
27
 
        pos+=(camera->forward*move.y+camera->right*move.x)*scrollSpeed;
 
30
        move *= move.z * 400;
 
31
        pos  += (camera->forward * move.y + camera->right * move.x) * scrollSpeed;
28
32
}
29
33
 
30
34
 
31
35
void CFPSController::MouseMove(float3 move)
32
36
{
33
 
        camera->rot.y -= mouseScale*move.x;
34
 
        camera->rot.x -= mouseScale*move.y*move.z;
35
 
        if(camera->rot.x>PI*0.4999f)
36
 
                camera->rot.x=PI*0.4999f;
37
 
        if(camera->rot.x<-PI*0.4999f)
38
 
                camera->rot.x=-PI*0.4999f;
 
37
        camera->rot.y -= mouseScale * move.x;
 
38
        camera->rot.x -= mouseScale * move.y * move.z;
 
39
        camera->rot.x = Clamp(camera->rot.x, -PI*0.4999f, PI*0.4999f);
39
40
}
40
41
 
41
42
 
112
113
{
113
114
        if (showText) {
114
115
                logOutput.Print("Switching to FPS style camera");
115
 
  }
 
116
        }
116
117
}
117
118
 
118
119