OSDN Git Service

56c622ec5ef5d1c5c15460e06cf4fa5a773e0769
[skyscrapersim/skyscraper.git] / src / camera.h
1 /* $Id$ */
2
3 /*
4         Scalable Building Simulator - Camera Object Class
5         The Skyscraper Project - Version 1.7 Alpha
6         Copyright (C)2004-2010 Ryan Thoryk
7         http://www.skyscrapersim.com
8         http://sourceforge.net/projects/skyscraper
9         Contact - ryan@tliquest.net
10
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.
15
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.
20
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.
24 */
25
26 #ifndef _SBS_CAMERA_H
27 #define _SBS_CAMERA_H
28
29 #include <iengine/camera.h>
30 #include <iengine/movable.h>
31
32 class SBSIMPEXP Camera
33 {
34 public:
35         Object *object; //SBS object
36         int CurrentFloor; //floor camera's on
37         csString CurrentFloorID; //indicator ID of camera's current floor
38         int StartFloor; //Starting floor
39         float StartPositionX; //starting position on X axis
40         float StartPositionZ; //starting position on Z axis
41         float cfg_jumpspeed; //Initial speed of jumping.
42         float cfg_walk_accelerate; //walk acceleration
43         float cfg_walk_maxspeed; //walk maximum speed
44         float cfg_walk_maxspeed_mult; //multiplier for max speed
45         float cfg_walk_maxspeed_multreal; //is multiplier used?
46         float cfg_walk_brake; //walk brake deceleration
47         float cfg_rotate_accelerate; //rotate acceleration
48         float cfg_rotate_maxspeed; //rotate maximum speed
49         float cfg_rotate_brake; //rotate brake deceleration
50         float cfg_look_accelerate; //look acceleration
51         float cfg_body_height; //body height
52         float cfg_body_width; //body width
53         float cfg_body_depth; //body depth
54         float cfg_legs_height; //legs height
55         float cfg_legs_width; //legs width
56         float cfg_legs_depth; //legs depth
57         float cfg_lookspeed; //base look speed
58         float cfg_turnspeed; //base turn speed
59         float cfg_spinspeed; //base spin speed
60         float cfg_floatspeed; //base float speed
61         float cfg_stepspeed; //base step speed
62         float cfg_strafespeed; //base strafe speed
63         float cfg_speed; //camera speed multiplier
64         float cfg_speedfast; //camera fast speed multiplier
65         float cfg_speedslow; //camera slow speed multiplier
66         float cfg_zoomspeed; //camera zoom speed
67         csVector3 desired_velocity;
68         csVector3 velocity;
69         csVector3 desired_angle_velocity;
70         csVector3 angle_velocity;
71         float speed; //movement speed base
72         bool EnableCollisions; //enable collision detection
73         bool MouseDown; //mouse status
74         bool ReportCollisions; //if true, print collisions on console
75         csString LastHitMesh; //name of last hit mesh
76         bool Freelook; //freelook (mouselook) is enabled/disabled
77         float Freelook_speed; //freelook speed
78         csVector3 HitPosition; //last hit position
79
80         //functions
81         Camera();
82         ~Camera();
83         void SetPosition(const csVector3 &vector);
84         void SetDirection(const csVector3 &vector);
85         void SetRotation(csVector3 vector);
86         csVector3 GetPosition();
87         void GetDirection(csVector3 &front, csVector3 &top);
88         csVector3 GetRotation();
89         void UpdateCameraFloor();
90         bool Move(const csVector3 &vector, float speed);
91         void Rotate(const csVector3 &vector, float speed);
92         void SetStartDirection(const csVector3 &vector);
93         csVector3 GetStartDirection();
94         void SetStartRotation(const csVector3 &vector);
95         csVector3 GetStartRotation();
96         void SetToStartPosition();
97         void SetToStartDirection();
98         void SetToStartRotation();
99         void CheckElevator();
100         void CheckShaft();
101         void CheckStairwell();
102         void ClickedObject(bool shift, bool ctrl, bool alt);
103         const char* GetClickedMeshName();
104         const char* GetClickedPolyName();
105         int GetClickedObjectNumber();
106         int GetClickedObjectLine();
107         const char* GetClickedObjectCommand();
108         const char* GetClickedObjectCommandP();
109         void CreateColliders();
110         void Loop();
111         void Strafe(float speed);
112         void Step(float speed);
113         void Float(float speed);
114         void Jump();
115         void Look(float speed);
116         void Turn(float speed);
117         void Spin(float speed);
118         void InterpolateMovement();
119         void SetGravity(float gravity);
120         float GetGravity();
121         void EnableGravity(bool value);
122         bool GetGravityStatus();
123         void SetFOVAngle(float angle);
124         float GetFOVAngle();
125         void SetToDefaultFOV();
126         float GetHeight();
127
128 private:
129         csRef<iCamera> MainCamera; //main first-person view camera
130         csVector3 StartDirection; //direction camera faces on start
131         csVector3 StartRotation; //camera's startup rotation
132         csString meshname; //last clicked mesh name
133         csString polyname; //last clicked polygon name
134         int object_number; //last clicked object number
135         int object_line; //script line number of last clicked object
136         csString object_cmd; //original script command of last clicked object
137         csString object_cmd_processed; //processed script command of last clicked object
138         char intbuffer[65];
139         char buffer[20];
140         int FloorTemp; //previous floor check value
141         float Gravity;
142         bool GravityStatus;
143         int lastfloor;
144         bool lastfloorset;
145         float FOV; //default FOV angle
146         bool ResetOnGround;
147
148         //collision
149         csColliderActor collider_actor;
150 };
151
152 #endif