4 Scalable Building Simulator - Camera Object Class
5 The Skyscraper Project - Version 1.8 Alpha
6 Copyright (C)20042012 Ryan Thoryk
7 http://www.skyscrapersim.com
8 http://sourceforge.net/projects/skyscraper
9 Contact - ryan@tliquest.net
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include <OgreBulletDynamicsCharacter.h>
31 class SBSIMPEXP Camera
34 Object *object; //SBS object
35 int CurrentFloor; //floor camera's on
36 std::string CurrentFloorID; //indicator ID of camera's current floor
37 int StartFloor; //Starting floor
38 float StartPositionX; //starting position on X axis
39 float StartPositionZ; //starting position on Z axis
40 float cfg_jumpspeed; //Initial speed of jumping.
41 float cfg_walk_accelerate; //walk acceleration
42 float cfg_walk_maxspeed; //walk maximum speed
43 float cfg_walk_maxspeed_mult; //multiplier for max speed
44 float cfg_walk_maxspeed_multreal; //is multiplier used?
45 float cfg_walk_brake; //walk brake deceleration
46 float cfg_rotate_accelerate; //rotate acceleration
47 float cfg_rotate_maxspeed; //rotate maximum speed
48 float cfg_rotate_brake; //rotate brake deceleration
49 float cfg_look_accelerate; //look acceleration
50 float cfg_body_height; //body height
51 float cfg_body_width; //body width
52 float cfg_body_depth; //body depth
53 float cfg_legs_height; //legs height
54 float cfg_legs_width; //legs width
55 float cfg_legs_depth; //legs depth
56 float cfg_lookspeed; //base look speed
57 float cfg_turnspeed; //base turn speed
58 float cfg_spinspeed; //base spin speed
59 float cfg_floatspeed; //base float speed
60 float cfg_stepspeed; //base step speed
61 float cfg_strafespeed; //base strafe speed
62 float cfg_speed; //camera speed multiplier
63 float cfg_speedfast; //camera fast speed multiplier
64 float cfg_speedslow; //camera slow speed multiplier
65 float cfg_zoomspeed; //camera zoom speed
66 Ogre::Vector3 desired_velocity;
67 Ogre::Vector3 velocity;
68 Ogre::Vector3 desired_angle_velocity;
69 Ogre::Vector3 angle_velocity;
70 float speed; //movement speed base
71 bool MouseDown; //mouse status
72 bool ReportCollisions; //if true, print collisions on console
73 std::string LastHitMesh; //name of last hit mesh
74 bool Freelook; //freelook (mouselook) is enabled/disabled
75 float Freelook_speed; //freelook speed
76 Ogre::Vector3 HitPosition; //last hit position
79 Camera(Ogre::Camera *camera);
81 void SetPosition(const Ogre::Vector3 &vector);
82 void SetDirection(const Ogre::Vector3 &vector);
83 void SetRotation(Ogre::Vector3 vector);
84 Ogre::Vector3 GetPosition();
85 void GetDirection(Ogre::Vector3 &front, Ogre::Vector3 &top);
86 Ogre::Vector3 GetRotation();
87 void UpdateCameraFloor();
88 bool Move(Ogre::Vector3 vector, float speed);
89 void Rotate(const Ogre::Vector3 &vector, float speed);
90 void RotateLocal(const Ogre::Vector3 &vector, float speed);
91 void SetStartDirection(const Ogre::Vector3 &vector);
92 Ogre::Vector3 GetStartDirection();
93 void SetStartRotation(const Ogre::Vector3 &vector);
94 Ogre::Vector3 GetStartRotation();
95 void SetToStartPosition();
96 void SetToStartDirection();
97 void SetToStartRotation();
100 void CheckStairwell();
101 void ClickedObject(bool shift, bool ctrl, bool alt);
102 const char* GetClickedMeshName();
103 const char* GetClickedPolyName();
104 int GetClickedObjectNumber();
105 int GetClickedObjectLine();
106 const char* GetClickedObjectCommand();
107 const char* GetClickedObjectCommandP();
109 void Strafe(float speed);
110 void Step(float speed);
111 void Float(float speed);
113 void Look(float speed);
114 void Turn(float speed);
115 void Spin(float speed);
116 void InterpolateMovement();
117 void SetGravity(float gravity, bool save_value = true);
119 void EnableGravity(bool value);
120 bool GetGravityStatus();
121 void SetFOVAngle(float angle);
123 void SetToDefaultFOV();
125 void SetViewMode(int mode);
126 void EnableCollisions(bool value);
127 bool CollisionsEnabled();
130 void SetMaxRenderDistance(float value);
131 float GetMaxRenderDistance();
132 void ShowDebugShape(bool value);
133 void MoveCharacter();
136 Ogre::Camera* MainCamera; //main first-person view camera
137 Ogre::SceneNode* CameraNode; //camera scene node
138 Ogre::Vector3 StartDirection; //direction camera faces on start
139 Ogre::Vector3 StartRotation; //camera's startup rotation
140 std::string meshname; //last clicked mesh name
141 std::string polyname; //last clicked polygon name
142 int object_number; //last clicked object number
143 int object_line; //script line number of last clicked object
144 std::string object_cmd; //original script command of last clicked object
145 std::string object_cmd_processed; //processed script command of last clicked object
148 int FloorTemp; //previous floor check value
153 float FOV; //default FOV angle
154 Ogre::Vector3 rotation;
155 bool Collisions; //collision detection status
156 bool RotationStopped;
157 bool MovementStopped;
159 Ogre::Vector3 accum_movement;
162 OgreBulletDynamics::CharacterController* mCharacter;
163 OgreBulletCollisions::CollisionShape* mShape;