Skyscraper 2.0
camera.cpp
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Camera Object
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#include <OgreCamera.h>
25#include <OgreBulletDynamicsCharacter.h>
26#include <OgreBulletCollisionsRay.h>
27#include <OgreBulletCollisionsCapsuleShape.h>
28#include "globals.h"
29#include "sbs.h"
30#include "manager.h"
31#include "floor.h"
32#include "elevator.h"
33#include "elevatorcar.h"
34#include "shaft.h"
35#include "stairs.h"
36#include "model.h"
37#include "dynamicmesh.h"
38#include "mesh.h"
39#include "wall.h"
40#include "profiler.h"
41#include "scenenode.h"
42#include "manager.h"
43#include "vehicle.h"
44#include "camera.h"
45
46namespace SBS {
47
48Camera::Camera(Object *parent) : Object(parent)
49{
50 //set up SBS object
51 SetValues("Camera", "Camera", true);
52
53 //init variables
54 CurrentFloor = 0;
55 StartFloor = 0;
58 StartDirection = Vector3(0, 0, 0);
59 StartRotation = Vector3(0, 0, 0);
60 FloorTemp = 0;
61 velocity = Vector3(0, 0, 0);
62 desired_velocity = Vector3(0, 0, 0);
63 angle_velocity = Vector3(0, 0, 0);
65 cfg_jumpspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.JumpSpeed", 9.0);
66 cfg_walk_accelerate = sbs->GetConfigFloat("Skyscraper.SBS.Camera.WalkAccelerate", 0.040);
67 cfg_walk_maxspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.WalkMaxSpeed", 0.1);
68 cfg_walk_maxspeed_mult = sbs->GetConfigFloat("Skyscraper.SBS.Camera.WalkMaxSpeed_Mult", 10.0);
69 cfg_walk_maxspeed_multreal = sbs->GetConfigFloat("Skyscraper.SBS.Camera.WalkMaxSpeed_MultReal", 1.0);
70 cfg_walk_brake = sbs->GetConfigFloat("Skyscraper.SBS.Camera.WalkBrake", 0.040);
71 cfg_rotate_accelerate = sbs->GetConfigFloat("Skyscraper.SBS.Camera.RotateAccelerate", 0.005);
72 cfg_rotate_maxspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.RotateMaxSpeed", 0.015);
73 cfg_rotate_brake = sbs->GetConfigFloat("Skyscraper.SBS.Camera.RotateBrake", 0.015);
74 cfg_body_height = sbs->GetConfigFloat("Skyscraper.SBS.Camera.BodyHeight", 3.0);
75 cfg_body_width = sbs->GetConfigFloat("Skyscraper.SBS.Camera.BodyWidth", 1.64);
76 cfg_legs_height = sbs->GetConfigFloat("Skyscraper.SBS.Camera.LegsHeight", 3.0);
77 cfg_legs_width = sbs->GetConfigFloat("Skyscraper.SBS.Camera.LegsWidth", 1.312);
78 cfg_lookspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.LookSpeed", 150.0);
79 cfg_turnspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.TurnSpeed", 100.0);
80 cfg_spinspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.SpinSpeed", 150.0);
81 cfg_floatspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.FloatSpeed", 140.0);
82 cfg_stepspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.StepSpeed", 70.0);
83 cfg_strafespeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.StrafeSpeed", 70.0);
84 cfg_speed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.Speed", 1.0);
85 cfg_speedfast = sbs->GetConfigFloat("Skyscraper.SBS.Camera.FastSpeed", 2.0);
86 cfg_speedslow = sbs->GetConfigFloat("Skyscraper.SBS.Camera.SlowSpeed", 0.5);
87 cfg_zoomspeed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.ZoomSpeed", 0.2);
88 speed = 1;
89 Collisions = 0;
90 lastfloor = 0;
91 lastfloorset = false;
92 MouseLeftDown = false;
93 MouseRightDown = false;
94 ReportCollisions = sbs->GetConfigBool("Skyscraper.SBS.Camera.ReportCollisions", false);
95 Freelook = sbs->GetConfigBool("Skyscraper.SBS.Camera.Freelook", false);
96 Freelook_speed = sbs->GetConfigFloat("Skyscraper.SBS.Camera.FreelookSpeed", 200.0);
97 FOV = sbs->GetConfigFloat("Skyscraper.SBS.Camera.FOV", 71.263794);
98 last_fov = FOV;
99 FarClip = sbs->GetConfigFloat("Skyscraper.SBS.Camera.MaxDistance", 0.0);
100 object_number = 0;
101 object_line = 0;
102 HitPosition = Vector3::ZERO;
103 RotationStopped = false;
104 MovementStopped = false;
105 accum_movement = Vector3::ZERO;
106 prev_accum_movement = Vector3::ZERO;
107 collision_reset = false;
108 EnableBullet = sbs->GetConfigBool("Skyscraper.SBS.Camera.EnableBullet", true);
109 use_startdirection = false;
110 BinocularsFOV = sbs->GetConfigFloat("Skyscraper.SBS.Camera.BinocularsFOV", 10.0);
111 RestrictRotation = sbs->GetConfigBool("Skyscraper.SBS.Camera.RestrictRotation", true);
112 AttachedModel = 0;
113 prev_orientation = Quaternion::ZERO;
114 prev_position = Vector3::ZERO;
115 Gravity = 0;
116 GravityStatus = false;
117 FirstAttach = false;
119 mouse_x = 0;
120 mouse_y = 0;
121 inside_vehicle = false;
122 vehicle = 0;
123 old_freelook_mode = false;
124 BinocularsState = false;
125
126 //set up collider character
127 Real width = cfg_legs_width / 2;
129 width = cfg_body_width / 2;
130
131 Real height = (cfg_body_height + cfg_legs_height - 0.5) - (width * 2);
132 Real step_height = cfg_legs_height - 0.5;
133
134 mCharacter = 0;
135 mShape = 0;
136
137 if (EnableBullet == true)
138 {
139 mCharacter = new OgreBulletDynamics::CharacterController(GetSceneNode()->GetFullName() + " Character", sbs->mWorld, GetSceneNode()->GetRawSceneNode(), sbs->ToRemote(width), sbs->ToRemote(height), sbs->ToRemote(step_height));
140
141 //create debug shape
142 mShape = new OgreBulletCollisions::CapsuleCollisionShape(sbs->ToRemote(width), sbs->ToRemote(height), Vector3::UNIT_Y);
143 mCharacter->setShape(mShape);
144
145 //other movement options
146 mCharacter->setJumpSpeed(sbs->ToRemote(cfg_jumpspeed));
147 mCharacter->setFallSpeed(sbs->ToRemote(sbs->GetConfigFloat("Skyscraper.SBS.Camera.FallSpeed", 177.65)));
148 }
149}
150
152{
153 //Destructor
154
155 //reset view mode on shutdown
156 SetViewMode(0);
157
158 //delete model
159 if (AttachedModel)
160 {
162 delete AttachedModel;
163 AttachedModel = 0;
164 }
165
166 if (mCharacter)
167 delete mCharacter;
168
169 //detach the camera
170 Detach();
171
172 if (GetSceneNode()->GetRawSceneNode()->numChildren() > 0)
173 {
174 std::string nodename = GetSceneNode()->GetRawSceneNode()->getChild(0)->getName();
175 sbs->mSceneManager->destroySceneNode(nodename);
176 }
177}
178
179void Camera::SetPosition(const Vector3 &position)
180{
181 //sets the camera to an absolute position in 3D space
182
183 if (Cameras.empty())
184 return;
185
186 if (EnableBullet == true)
187 GetSceneNode()->SetPosition(position - sbs->ToLocal(Cameras[0]->getPosition()));
188 else
189 {
190 for (size_t i = 0; i < Cameras.size(); i++)
191 {
192 Cameras[i]->setPosition(sbs->ToRemote(position));
193 }
194 }
195
196 OnMove(false);
197}
198
199void Camera::SetDirection(const Vector3 &direction)
200{
201 //sets the camera's direction to an absolute position
202
203 if (Cameras.empty())
204 return;
205
206 //MainCamera->lookAt(sbs->ToRemote(direction));
207}
208
209void Camera::SetRotation(const Vector3 &rotation)
210{
211 //sets the camera's rotation in degrees
212
213 if (Cameras.empty())
214 return;
215
216 //keep rotation within 360 degree boundaries
217 Vector3 vector = rotation;
218 if (RestrictRotation && vector.x > 90 && vector.x < 270)
219 vector.x = vector.x > 180 ? 270 : 90;
220 if (vector.x > 359)
221 vector.x -= 360;
222 if (vector.x < 0)
223 vector.x += 360;
224 if (vector.y > 359)
225 vector.y -= 360;
226 if (vector.y < 0)
227 vector.y += 360;
228 if (vector.z > 359)
229 vector.z -= 360;
230 if (vector.z < 0)
231 vector.z += 360;
232
233 Quaternion x(Degree(vector.x), Vector3::UNIT_X);
234 Quaternion y(Degree(vector.y), Vector3::NEGATIVE_UNIT_Y);
235 Quaternion z(Degree(vector.z), Vector3::UNIT_Z);
236 Quaternion camrot = x * z;
237 Quaternion bodyrot = y;
238 Rotation = vector;
239 for (size_t i = 0; i < Cameras.size(); i++)
240 {
241 Cameras[i]->setOrientation(camrot);
242 }
243
244 if (EnableBullet == true)
245 mCharacter->setOrientation(sbs->ToGlobal(bodyrot));
246
247 OnRotate(false);
248}
249
251{
252 //returns the camera's current position
253 //"relative" value is ignored for camera object
254
255 Vector3 cameraposition = Vector3::ZERO;
256
257 if (!Cameras.empty())
258 cameraposition = sbs->ToLocal(Cameras[0]->getPosition());
259
260 return GetSceneNode()->GetPosition() + cameraposition;
261}
262
263void Camera::GetDirection(Vector3 &front, Vector3 &top, bool global)
264{
265 //returns the camera's current direction in front and top vectors
266
267 if (Cameras.empty())
268 return;
269
270 Quaternion dir;
271 if (global == false)
272 dir = sbs->FromGlobal(Cameras[0]->getDerivedOrientation());
273 else
274 dir = Cameras[0]->getDerivedOrientation();
275
276 front = dir.zAxis();
277 front.x = -front.x; //convert to left-hand coordinate system
278 front.y = -front.y; //convert to left-hand coordinate system
279 front.normalise();
280 top = dir.yAxis();
281 top.z = -top.z; //convert to left-hand coordinate system
282 top.normalise();
283}
284
286{
287 //returns the camera's current rotation
288
289 return Rotation;
290}
291
293{
294 SBS_PROFILE("Camera::UpdateCameraFloor");
295
296 if (Cameras.empty())
297 return;
298
299 int newlastfloor;
300
301 if (lastfloorset == true)
302 newlastfloor = sbs->GetFloorNumber((float)GetPosition().y, lastfloor, true);
303 else
304 newlastfloor = sbs->GetFloorNumber((float)GetPosition().y);
305
306 //if camera moved to a different floor, update floor indicators
307 if ((lastfloor != newlastfloor) && sbs->GetFloor(newlastfloor))
308 sbs->GetFloor(newlastfloor)->UpdateFloorIndicators();
309
310 lastfloor = newlastfloor;
311 lastfloorset = true;
315}
316
317bool Camera::Move(Vector3 vector, Real speed, bool flip)
318{
319 //moves the camera in a relative amount specified by a vector
320
321 if (Cameras.empty())
322 return false;
323
324 if (MovementStopped == true && vector == Vector3::ZERO)
325 return false;
326
327 MovementStopped = false;
328
329 if (vector == Vector3::ZERO)
330 MovementStopped = true;
331
332 if (flip == true)
333 vector *= Vector3(-1, 1, 1);
334
335 Quaternion orientation;
336
337 if (EnableBullet == true)
338 orientation = GetSceneNode()->GetDerivedOrientation();
339 else
340 orientation = Cameras[0]->getOrientation();
341
342 //flip X axis
343 vector *= Vector3(-1, 1, 1);
344
345 //multiply vector with camera's orientation
346 vector = orientation * sbs->ToRemote(vector);
347
348 accum_movement += (vector * speed);
349
350 return true;
351}
352
354{
355 //moves the camera in a relative amount, using SetPosition, instead of character movement
356
357 if (Cameras.empty())
358 return false;
359
360 if (vector == Vector3::ZERO)
361 return false;
362
363 SetPosition(GetPosition() + (vector * speed));
364 return true;
365}
366
367void Camera::Rotate(const Vector3 &rotation, Real speed)
368{
369 //rotates the camera in a relative amount in world space
370
371 if (Cameras.empty())
372 return;
373
374 Vector3 rot = GetRotation() + (rotation * speed);
375 SetRotation(rot);
376}
377
378void Camera::RotateLocal(const Vector3 &rotation, Real speed)
379{
380 //rotates the camera in a relative amount in local camera space
381
382 if (Cameras.empty())
383 return;
384
385 if (RotationStopped == true && rotation == Vector3::ZERO)
386 return;
387
388 RotationStopped = false;
389
390 if (rotation == Vector3::ZERO)
391 RotationStopped = true;
392
393 //convert rotation values to degrees
394 Real xdeg = (float)Ogre::Math::RadiansToDegrees(rotation.x) * speed; //X axis (up/down)
395 Real ydeg = (float)Ogre::Math::RadiansToDegrees(rotation.y) * speed; //Y axis (left/right)
396 Real zdeg = (float)Ogre::Math::RadiansToDegrees(rotation.z) * speed; //Z axis (clockwise/counterclockwise)
397 if (RestrictRotation && Rotation.x + xdeg > 90 && Rotation.x + xdeg < 270)
398 xdeg = Rotation.x > 180 ? 270-Rotation.x : 90-Rotation.x;
399 Rotation.x += xdeg;
400 Rotation.y += ydeg;
401 Rotation.z += zdeg;
402
403 if (Rotation.x > 359)
404 Rotation.x -= 360;
405 if (Rotation.y > 359)
406 Rotation.y -= 360;
407 if (Rotation.z > 359)
408 Rotation.z -= 360;
409 if (Rotation.x < 0)
410 Rotation.x += 360;
411 if (Rotation.y < 0)
412 Rotation.y += 360;
413 if (Rotation.z < 0)
414 Rotation.z += 360;
415
416 for (size_t i = 0; i < Cameras.size(); i++)
417 {
418 Quaternion rot(Degree(Rotation.y), Vector3::NEGATIVE_UNIT_Y);
419 if (EnableBullet == true)
420 {
421 //rotate character collider
422 mCharacter->setOrientation(sbs->ToGlobal(rot));
423
424 //rotate camera
425 Cameras[i]->pitch(Degree(xdeg));
426 Cameras[i]->roll(Degree(zdeg));
427 }
428 else
429 Cameras[i]->setOrientation(rot);
430 }
431
432 OnRotate(false);
433}
434
435void Camera::SetStartDirection(const Vector3 &direction)
436{
437 StartDirection = direction;
438 use_startdirection = true;
439}
440
445
447{
448 StartRotation = rotation;
449}
450
455
456void Camera::SetToStartPosition(bool disable_current_floor)
457{
458 if (sbs->GetFloor(StartFloor))
459 {
461 GotoFloor(StartFloor, disable_current_floor);
462 }
463 else
465}
466
472
478
480{
481 //check to see if user (camera) is in an elevator
482
483 SBS_PROFILE("Camera::CheckElevator");
484
485 if (Cameras.empty())
486 return;
487
488 for (int i = 1; i <= sbs->GetElevatorCount(); i++)
489 {
490 Elevator *elevator = sbs->GetElevator(i);
491
492 if (!elevator)
493 continue;
494
495 bool result = elevator->Check(GetPosition());
496 if (result == true)
497 return;
498 }
499
500 //user is not in an elevator if all elevators returned false
501 sbs->InElevator = false;
502 sbs->ElevatorSync = false;
503}
504
506{
507 //check to see if user (camera) is in a shaft
508
509 if (Cameras.empty())
510 return;
511
512 if (sbs->AutoShafts == false)
513 return;
514
515 SBS_PROFILE("Camera::CheckShaft");
516
517 for (int i = 1; i <= sbs->GetShaftCount(); i++)
518 {
519 Shaft *shaft = sbs->GetShaft(i);
520
521 if (!shaft)
522 continue; //skip if shaft doesn't exist
523
524 shaft->Check(GetPosition(), CurrentFloor);
525 }
526}
527
529{
530 //check to see if user (camera) is in a stairwell
531
532 if (Cameras.empty())
533 return;
534
535 if (sbs->AutoStairs == false)
536 return;
537
538 SBS_PROFILE("Camera::CheckStairwell");
539
540 for (int i = 1; i <= sbs->GetStairwellCount(); i++)
541 {
542 Stairwell *stairs = sbs->GetStairwell(i);
543
544 if (!stairs)
545 continue;
546
548 }
550}
551
552Real Camera::ClickedObject(Camera *camera, bool shift, bool ctrl, bool alt, bool right, Real scale, bool center_only, bool hit_only)
553{
554 //get mesh object that the user clicked on, and perform related work
555
556 if (!camera)
557 return false;
558
559 Real result = -1;
560
561 SBS_PROFILE("Camera::ClickedObject");
562
563 if (!camera->GetOgreCamera())
564 return false;
565
566 //cast a ray from the camera in the direction of the clicked position
567 int width = camera->GetOgreCamera()->getViewport()->getActualWidth();
568 int height = camera->GetOgreCamera()->getViewport()->getActualHeight();
569
570 if (width == 0 || height == 0)
571 return result;
572
573 Real x, y;
574 if (center_only == false)
575 {
576 x = (float)camera->mouse_x / (float)width * scale;
577 y = (float)camera->mouse_y / (float)height * scale;
578 }
579 else
580 {
581 x = 0.5;
582 y = 0.5;
583 }
584
585 Ray ray = camera->GetOgreCamera()->getCameraToViewportRay(x, y);
586
587 //convert ray's origin and direction to engine-relative values
588 ray.setOrigin(sbs->ToRemote(sbs->FromGlobal(sbs->ToLocal(ray.getOrigin()))));
589 ray.setDirection(sbs->GetOrientation().Inverse() * ray.getDirection());
590
591 MeshObject* mesh = 0;
592 Wall* wall = 0;
593
594 Vector3 pos = sbs->ToLocal(ray.getOrigin());
595
596 //only report if in verbose mode, and if the camera is outside of this simulator
597 if (sbs->Verbose && hit_only == false)
598 {
599 if (Cameras.size() == 0)
600 {
601 Report("Clicked from (" + ToString(pos.x) + ", " + ToString(pos.y) + ", " + ToString(pos.z) + ")");
602 }
603 }
604
605 bool hit = sbs->HitBeam(ray, 1000.0, mesh, wall, HitPosition);
606 Vector3 hit_pos = HitPosition - sbs->GetPosition();
607
608 //report hit position if in verbose mode
609 if (hit == true)
610 {
611 result = pos.distance(hit_pos);
612 if (sbs->Verbose && hit_only == false)
613 Report("Hit at (" + ToString(hit_pos.x) + ", " + ToString(hit_pos.y) + ", " + ToString(hit_pos.z)+ ")");
614 }
615
616 if (hit == false || hit_only == true)
617 return result;
618
619 meshname = mesh->GetName();
620 wallname = "";
621 Object *obj = mesh;
622
623 if (wall)
624 {
625 wallname = wall->GetName();
626 obj = wall;
627 }
628
629 //store parameters of object
630 object_number = obj->GetNumber();
631 object_line = obj->linenum;
632 object_cmd = obj->command;
634
635 //show result
636 std::string number = ToString(object_number);
637 if (wall)
638 Report("Clicked on object " + number + ": Mesh: " + meshname + ", Wall: " + wallname);
639
640
641 //object checks and actions
642
643 //get original object (parent object of clicked mesh)
644 Object *mesh_parent = GetMeshParent(obj);
645
646 if (!mesh_parent)
647 return result;
648
649 if (mesh_parent->GetType() == "ButtonPanel")
650 {
651 //for call station panels, the object needs to be the third level
652 Object* callpanel = mesh_parent->GetParent();
653 if (callpanel)
654 {
655 if (callpanel->GetType() == "CallStation")
656 mesh_parent = callpanel;
657 }
658 }
659
660 //show result
661 if (!wall)
662 Report("Clicked on object " + number + ": " + mesh_parent->GetName()+ " - Mesh: " + meshname);
663
664 //delete object if ctrl and alt keys are pressed
665 if (ctrl == true && alt == true && shift == false && right == false)
666 {
667 //delete a wall object, for certain parent objects
668 if (wall && obj->GetType() == "Wall")
669 {
670 std::string type = mesh_parent->GetType();
671 if (type == "Floor" || type == "ElevatorCar" || type == "Shaft" || type == "Stairwell" || type == "SBS")
672 {
673 sbs->DeleteObject(obj);
674 return result;
675 }
676 }
677
678 //for standard objects, delete the mesh parent object
679 sbs->DeleteObject(mesh_parent);
680 return result;
681 }
682
683 //call object's OnClick function
684 mesh_parent->OnClick(pos, shift, ctrl, alt, right);
685 return result;
686}
687
689{
690 //this function is called when a user releases the mouse button on an object
691
693
694 if (!obj)
695 return;
696
697 //get original object (parent object of clicked mesh)
698 Object *mesh_parent = GetMeshParent(obj);
699
700 if (!mesh_parent)
701 return;
702
703 //call object's OnUnclick function
704 mesh_parent->OnUnclick(MouseRightDown);
705
706 MouseLeftDown = false;
707 MouseRightDown = false;
708}
709
711{
712 //get original object (parent object of clicked mesh)
713
714 if (!object)
715 return 0;
716
717 Object *mesh_parent = object->GetParent();
718
719 if (!mesh_parent)
720 return 0;
721
722 //if object is a wall, and parent is a mesh, get mesh's (parent's) parent
723 //or if object is a mesh, and parent is a scenenode, get scenenode's parent
724 if (mesh_parent->GetType() == "Mesh" || mesh_parent->GetType() == "SceneNode")
725 {
726 mesh_parent = mesh_parent->GetParent();
727
728 if (!mesh_parent)
729 return 0;
730 }
731
732 return mesh_parent;
733}
734
736{
737 //return name of last clicked mesh
738
739 return meshname;
740}
741
743{
744 //return name of last clicked polygon
745
746 return wallname;
747}
748
750{
751 //return number of last clicked object
752 return object_number;
753}
754
756{
757 //return line number of last clicked object
758 return object_line;
759}
760
762{
763 //return command line of last clicked object
764 return object_cmd;
765}
766
768{
769 //return processed command line of last clicked object
771}
772
774{
775 SBS_PROFILE_MAIN("Camera Loop");
776
777 if (Cameras.empty())
778 return;
779
780 //get delta value
781 unsigned long timing;
782 if (sbs->SmoothFrames > 0)
783 timing = sbs->GetAverageTime();
784 else
785 timing = sbs->GetElapsedTime();
786 Real delta = timing / 1000.0;
787
788 //reset collisions if needed
789 if (collision_reset == true && EnableBullet == true)
790 mCharacter->resetCollisions();
791 collision_reset = false;
792
793 //get name of the last hit mesh object
794 if (sbs->GetRunTime() > 10) //due to initialization-related crashes, wait before checking
795 {
796 if (EnableBullet == true)
797 {
798 if (mCharacter->getLastCollision())
799 {
800 Ogre::SceneNode *node = mCharacter->getLastCollision()->getRootNode();
801 if (node)
802 {
803 int instance = 0, number = 0;
804 std::string name = sbs->ProcessFullName(node->getParentSceneNode()->getName(), instance, number, false);
805
806 if (instance == sbs->InstanceNumber)
807 {
808 LastHitMesh = name;
809 LastHitMeshNumber = number;
810 }
811 }
812 }
813 }
814 }
815
816 //calculate acceleration
817 InterpolateMovement(delta);
818
819 //general movement
821 Move(velocity, delta * speed, false);
822
823 if (CollisionsEnabled() == true)
824 {
825 //report name of mesh
826 if (ReportCollisions == true)
828
829 if (LastHitMesh != "")
830 {
831 //get SBS object
833
834 if (obj)
835 {
836 //call hit on mesh object
837 obj->OnHit();
838
839 //call hit on original object (parent object of mesh)
840 if (obj->GetParent())
841 obj->GetParent()->OnHit();
842 }
843 }
844 }
845
846 //if a model is attached, run it's loop
847 if (AttachedModel)
849
850 //sync camera with collider
851 Sync();
852}
853
859
865
871
873{
874 if (Cameras.empty())
875 return;
876
877 //velocity.y = cfg_jumpspeed;
878 //desired_velocity.y = 0.0;
879 if (EnableBullet == true)
880 {
881 if (mCharacter->getGravity() != 0)
882 mCharacter->jump();
883 }
884}
885
887{
888 //look up/down by rotating camera on X axis
890}
891
893{
894 //turn camera by rotating on Y axis
896}
897
899{
900 //spin camera by rotating on Z axis
902}
903
909
911{
912 //calculate movement and rotation acceleration
913
914 delta *= 1700.0;
915
916 for (size_t i = 0; i < 3; i++)
917 {
918 if (velocity[i] < desired_velocity[i])
919 {
920 velocity[i] += cfg_walk_accelerate * delta;
921 if (velocity[i] > desired_velocity[i])
923 }
924 else
925 {
926 velocity[i] -= cfg_walk_brake * delta;
927 if (velocity[i] < desired_velocity[i])
929 }
930 }
931
932 for (size_t i = 0; i < 3; i++)
933 {
935 {
939 }
940 else
941 {
942 angle_velocity[i] -= cfg_rotate_brake * delta;
945 }
946 }
947}
948
949void Camera::SetGravity(Real gravity, bool save_value)
950{
951 if (save_value == true)
952 Gravity = gravity;
953
954 if (EnableBullet == true && !Cameras.empty())
955 {
956 sbs->mWorld->setGravity(Vector3(0, sbs->ToRemote(-gravity), 0));
957 mCharacter->setGravity(sbs->ToRemote(gravity));
958 }
959}
960
962{
963 return Gravity;
964}
965
966void Camera::EnableGravity(bool value)
967{
968 if (Cameras.empty())
969 return;
970
971 if (value == true)
973 else
974 {
975 SetGravity(0, false);
976 velocity.y = 0;
977 desired_velocity.y = 0;
978 }
979 if (EnableBullet == true)
980 mCharacter->reset();
981 GravityStatus = value;
982}
983
985{
986 return GravityStatus;
987}
988
990{
991 //set camera FOV angle
992
993 if (Cameras.empty())
994 return;
995
996 if (angle > 0 && angle < 179.63)
997 {
998 Real ratio = (float)Cameras[0]->getAspectRatio();
999 if (ratio > 0)
1000 {
1001 for (size_t i = 0; i < Cameras.size(); i++)
1002 {
1003 Cameras[i]->setFOVy(Degree(angle / ratio));
1004 }
1005 }
1006 }
1007}
1008
1010{
1011 if (Cameras.empty())
1012 return 0.0;
1013
1014 return (float)(Cameras[0]->getFOVy().valueDegrees() * Cameras[0]->getAspectRatio());
1015}
1016
1018{
1019 //set to default FOV angle value
1021}
1022
1024{
1025 //return camera's height
1026
1028}
1029
1031{
1032 //set view mode of camera:
1033 //0 - solid polygons (normal)
1034 //1 - wireframe mode
1035 //2 - point mode
1036
1037 if (Cameras.empty())
1038 return;
1039
1040 for (size_t i = 0; i < Cameras.size(); i++)
1041 {
1042 if (mode == 0)
1043 Cameras[i]->setPolygonMode(Ogre::PM_SOLID);
1044 if (mode == 1)
1045 Cameras[i]->setPolygonMode(Ogre::PM_WIREFRAME);
1046 if (mode == 2)
1047 Cameras[i]->setPolygonMode(Ogre::PM_POINTS);
1048 }
1049}
1050
1052{
1053 if (Cameras.empty())
1054 return;
1055
1056 if (value == Collisions)
1057 return;
1058
1059 Collisions = value;
1060 if (EnableBullet == true)
1061 mCharacter->enableCollisions(value);
1062}
1063
1065{
1066 return Collisions;
1067}
1068
1070{
1071 if (Cameras.empty())
1072 return false;
1073
1074 if (EnableBullet == true)
1075 return mCharacter->onGround();
1076 else
1077 return false;
1078}
1079
1081{
1082 //sync scene node with bullet object
1083
1084 if (Cameras.empty())
1085 return;
1086
1087 SBS_PROFILE_MAIN("Camera Sync");
1088
1089 if (EnableBullet == true)
1090 mCharacter->sync();
1091
1092 //notify on movement or rotation
1093 Vector3 position = sbs->ToRemote(GetPosition());
1094 Quaternion orientation = GetOrientation();
1095
1096 if (prev_position.positionEquals(position) == false)
1097 {
1098 GetSceneNode()->Update();
1099 NotifyMove();
1100 }
1101 if (prev_orientation.orientationEquals(orientation) == false)
1102 {
1103 GetSceneNode()->Update();
1104 NotifyRotate();
1105 }
1106
1107 prev_position = position;
1108 prev_orientation = orientation;
1109}
1110
1112{
1113 //set distance of camera's far clipping plane - set to 0 for infinite
1114
1115 if (Cameras.empty())
1116 return;
1117
1118 for (size_t i = 0; i < Cameras.size(); i++)
1119 {
1120 Cameras[i]->setFarClipDistance(sbs->ToRemote(value));
1121 }
1122 FarClip = value;
1123}
1124
1126{
1127 return FarClip;
1128}
1129
1131{
1132 if (Cameras.empty())
1133 return;
1134
1135 if (EnableBullet == true)
1136 mCharacter->showDebugShape(value);
1137}
1138
1140{
1141 if (Cameras.empty())
1142 return;
1143
1144 SBS_PROFILE_MAIN("MoveCharacter");
1145
1146 if (EnableBullet == true)
1147 mCharacter->setWalkDirection(accum_movement, 1);
1148 else
1149 {
1150 for (size_t i = 0; i < Cameras.size(); i++)
1151 {
1152 Cameras[i]->move(accum_movement);
1153 }
1154 }
1156 accum_movement = Vector3::ZERO;
1157}
1158
1160{
1161 //queue a collision reset for next loop cycle
1162 collision_reset = true;
1163}
1164
1165void Camera::GotoFloor(int floor, bool disable_current)
1166{
1167 //have camera warp to specified floor
1168
1169 if (Cameras.empty())
1170 return;
1171
1172 if (sbs->IsValidFloor(floor) == true)
1173 {
1174 Floor* origfloor = sbs->GetFloor(CurrentFloor);
1175 if (disable_current == true && origfloor)
1176 {
1177 origfloor->Enabled(false);
1178 origfloor->EnableGroup(false);
1179 }
1180
1181 Floor* floorobj = sbs->GetFloor(floor);
1182 if (floorobj)
1183 {
1184 Vector3 pos = GetPosition();
1185 pos.y = floorobj->GetBase() + GetHeight();
1186 SetPosition(pos);
1187 floorobj->Enabled(true);
1188 floorobj->EnableGroup(true);
1189 }
1190 }
1191}
1192
1193void Camera::Binoculars(bool value)
1194{
1195 //enable or disable binoculars mode
1196
1197 if (Cameras.empty())
1198 return;
1199
1200 if (value == BinocularsState)
1201 return;
1202
1203 if (value == true)
1204 {
1207 }
1208 else
1210
1211 BinocularsState = value;
1212}
1213
1215{
1216 //returns if a mesh object is visible in the camera's view frustum or not
1217
1218 if (!mesh || Cameras.empty())
1219 return false;
1220
1221 return mesh->IsVisible(Cameras[0]);
1222}
1223
1225{
1226 if (!mesh || Cameras.empty())
1227 return false;
1228
1229 return mesh->IsVisible(Cameras[0], mesh_index);
1230}
1231
1233{
1234 //attach a model to the camera
1235 //this is used for picking up a model, which changes the model's parent to the camera
1236
1237 if (!model || AttachedModel)
1238 return;
1239
1240 AttachedModel = model;
1241}
1242
1244{
1245 //detach a model from the camera
1246
1247 AttachedModel = 0;
1248}
1249
1251{
1252 //pick up model
1253 Vector3 front, top;
1254 GetDirection(front, top);
1255
1256 Vector3 hit_position;
1257 MeshObject *mesh = 0;
1258 Wall *wall = 0;
1259 bool hit = false;
1260
1261 //do a raycast from the collider's position, in the forward direction
1262 Vector3 position = GetPosition();
1263
1264 for (int i = (int)GetPosition().y; i > 0; i--)
1265 {
1266 position.y = i;
1267 Ray ray (sbs->ToRemote(position), sbs->ToRemote(front, false));
1268
1269 hit = sbs->HitBeam(ray, 2.0, mesh, wall, hit_position);
1270
1271 if (hit == true)
1272 break;
1273 }
1274
1275 if (hit == false)
1276 return false;
1277
1278 Model *model = dynamic_cast<Model*>(mesh->GetParent());
1279
1280 if (model)
1281 {
1282 if (model->IsPhysical() == true)
1283 {
1284 model->PickUp();
1285 AttachModel(model);
1286 return true;
1287 }
1288 }
1289
1290 return false;
1291}
1292
1294{
1295 //drop model
1296
1297 if (AttachedModel)
1298 {
1300 DetachModel();
1301 }
1302}
1303
1305{
1306 if (AttachedModel)
1307 return true;
1308 return false;
1309}
1310
1312{
1313 //reset camera position and state
1314
1315 if (Cameras.empty())
1316 return;
1317
1318 Floor *floor = sbs->GetFloor(CurrentFloor);
1319 if (floor)
1320 {
1321 floor->Enabled(false);
1322 floor->EnableGroup(false);
1323 }
1324
1325 EnableGravity(true);
1326 EnableCollisions(true);
1327 SetToStartPosition(true);
1330
1331 floor = sbs->GetFloor(StartFloor);
1332 if (floor)
1333 {
1334 floor->Enabled(true);
1335 floor->EnableGroup(true);
1336 }
1337
1338 sbs->EnableBuildings(true);
1339 sbs->EnableLandscape(true);
1340 sbs->EnableExternal(true);
1341 sbs->EnableSkybox(true);
1342}
1343
1345{
1346 //reset rotation/direction and FOV of camera
1347
1348 if (Cameras.empty())
1349 return;
1350
1354}
1355
1357{
1358 if (mCharacter)
1359 mCharacter->resetLastCollision();
1360}
1361
1362bool Camera::Attach(std::vector<Ogre::Camera*>& cameras, bool init_state)
1363{
1364 if (cameras.empty())
1365 return false;
1366
1367 if (cameras[0]->isAttached() == true)
1368 return false;
1369
1370 Cameras = cameras;
1371
1372 for (size_t i = 0; i < Cameras.size(); i++)
1373 {
1374 Cameras[i]->setNearClipDistance(0.1);
1375 Cameras[i]->setPosition(0, sbs->ToRemote((cfg_body_height + cfg_legs_height + 0.5) / 2), 0);
1377 }
1378
1381
1382 //move camera to start location
1383 if (FirstAttach == false)
1384 {
1385 SetGravity(sbs->GetConfigFloat("Skyscraper.SBS.Camera.Gravity", 32.1719), true); // 9.806 m/s/s
1386
1387 if (init_state == true)
1388 {
1389 GravityStatus = sbs->GetConfigBool("Skyscraper.SBS.Camera.GravityStatus", true);
1390 EnableCollisions(sbs->GetConfigBool("Skyscraper.SBS.Camera.EnableCollisions", true));
1391 SetToStartPosition(false); //also turns on start floor
1394 }
1395 FirstAttach = true;
1396 }
1397 else
1398 {
1399 //re-apply rotation
1400 if (init_state == true)
1402 }
1403
1404 Refresh();
1405 Sync();
1406
1408
1409 return true;
1410}
1411
1413{
1414 if (Cameras.empty())
1415 return false;
1416
1417 if (Cameras[0]->isAttached() == false)
1418 return false;
1419
1420 for (size_t i = 0; i < Cameras.size(); i++)
1421 {
1423 }
1424
1425 Cameras.clear();
1426
1427 return true;
1428}
1429
1430void Camera::OnMove(bool parent)
1431{
1432 if (EnableBullet == true)
1433 mCharacter->updateTransform(true, false, false);
1434}
1435
1436void Camera::OnRotate(bool parent)
1437{
1438 if (parent == true)
1439 OnMove(parent); //update position if parent object has been rotated
1440
1441 if (EnableBullet == true)
1442 mCharacter->updateTransform(false, true, false);
1443}
1444
1446{
1447 //returns camera state info
1448 //the position value is in a global/absolute scene format, not engine-relative
1449
1450 CameraState state;
1451 state.position = sbs->ToGlobal(GetPosition());
1452 state.rotation = GetRotation() + sbs->GetRotation();
1453 state.floor = CurrentFloor;
1454 state.collisions = CollisionsEnabled();
1455 state.gravity = GetGravityStatus();
1456 state.freelook = Freelook;
1458 state.velocity = velocity;
1462 state.fov = GetFOVAngle();
1463 state.speed = speed;
1464 return state;
1465}
1466
1467void Camera::SetCameraState(const CameraState &state, bool set_floor)
1468{
1469 //sets camera state
1470 //the position value is in a global/absolute scene format, not engine-relative
1471
1472 Vector3 position = sbs->FromGlobal(state.position);
1473 if (set_floor == true)
1474 GotoFloor(state.floor, true);
1475 else
1476 GotoFloor(sbs->GetFloorNumber((float)position.y));
1477 SetPosition(position);
1478 SetRotation(state.rotation - sbs->GetRotation());
1480 EnableGravity(state.gravity);
1481 Freelook = state.freelook;
1483 velocity = state.velocity;
1487 SetFOVAngle(state.fov);
1488 speed = state.speed;
1489}
1490
1495
1497{
1498 //returns true if either mouse button is down
1499 return (MouseLeftDown || MouseRightDown);
1500}
1501
1503{
1504 //check if the user is in an elevator
1505 if (sbs->ProcessElevators == true)
1506 CheckElevator();
1507
1508 //check if the user is in a shaft
1509 CheckShaft();
1510
1511 //check if the user is in a stairwell
1513}
1514
1516{
1517 //teleport/warp user to specified location
1518
1519 Vector3 destination (X, Y, Z);
1520
1521 GotoFloor(sbs->GetFloorNumber(destination.y));
1522 SetPosition(destination);
1523}
1524
1525void Camera::Drive(bool left, bool right, bool down, bool up, bool key_down)
1526{
1527 if (!vehicle)
1528 return;
1529
1530 if (key_down == true)
1531 vehicle->KeyPressed(left, right, down, up);
1532 else
1533 vehicle->KeyReleased(left, right, down, up);
1534}
1535
1536void Camera::Crouch(bool value)
1537{
1538 if (mCharacter)
1539 mCharacter->crouch(value);
1540}
1541
1542void Camera::SetOrientation(const Quaternion &orientation)
1543{
1544 //set orientation of main camera object, not collider
1545
1546 for (size_t i = 0; i < Cameras.size(); i++)
1547 {
1548 Cameras[i]->setOrientation(orientation);
1549 }
1550}
1551
1553{
1554 //attach/detach camera from a vehicle
1555
1556 if (Cameras.empty())
1557 return;
1558
1559 if (vehicle && value == false)
1560 {
1561 Vector3 newpos = GetPosition() + (vehicle->GetOrientation() * Vector3(vehicle->GetWidth(), 0, 0));
1562 SetPosition(newpos);
1563
1565 inside_vehicle = false;
1566 vehicle->AttachCamera(false);
1567 vehicle = 0;
1568 EnableCollisions(true);
1569 for (size_t i = 0; i < Cameras.size(); i++)
1570 {
1571 Cameras[i]->setOrientation(old_camera_orientation);
1572 }
1573 if (EnableBullet == true)
1574 mCharacter->setOrientation(old_character_orientation);
1575 }
1576 else if (value == true)
1577 {
1578 //search for a vehicle
1579
1580 Vector3 direction, other;
1581 GetDirection(direction, other);
1582 Ray ray = Ray(sbs->ToRemote(GetPosition()), direction);
1583
1584 MeshObject* mesh = 0;
1585 Wall* wall = 0;
1586
1587 bool hit = sbs->HitBeam(ray, 50, mesh, wall, HitPosition);
1588
1589 if (hit == false)
1590 {
1591 ReportError("AttachToVehicle: No vehicles found");
1592 return;
1593 }
1594
1595 meshname = mesh->GetName();
1596 Object *obj = mesh;
1597
1598 //get original object (parent object of clicked mesh)
1599 Object *mesh_parent = GetMeshParent(obj);
1600
1601 if (mesh_parent->GetType() == "Vehicle")
1602 {
1603 //if a vehicle is found, attach to it
1604
1605 Vehicle *v = dynamic_cast<Vehicle*> (mesh_parent);
1606
1607 if (v)
1608 {
1609 vehicle = v;
1611 Freelook = true;
1612 inside_vehicle = true;
1613 EnableCollisions(false);
1614 old_camera_orientation = Cameras[0]->getOrientation();
1615 if (EnableBullet == true)
1616 old_character_orientation = mCharacter->getWorldOrientation();
1617 vehicle->AttachCamera(true);
1618 }
1619 }
1620 else
1621 ReportError("AttachToVehicle: No vehicles found");
1622 }
1623}
1624
1625Ogre::Camera* Camera::GetOgreCamera(int index)
1626{
1627 if (!Cameras.empty())
1628 return Cameras[index];
1629 return 0;
1630}
1631
1632}
std::string object_cmd_processed
Definition camera.h:199
Real cfg_walk_brake
Definition camera.h:59
void OnMove(bool parent)
Definition camera.cpp:1430
void InterpolateMovement(Real delta)
Definition camera.cpp:910
Real FOV
Definition camera.h:205
bool PickUpModel()
Definition camera.cpp:1250
void UpdateCameraFloor()
Definition camera.cpp:292
Vector3 StartRotation
Definition camera.h:193
void SetStartRotation(const Vector3 &rotation)
Definition camera.cpp:446
int mouse_y
Definition camera.h:98
Real cfg_walk_maxspeed_mult
Definition camera.h:57
void Strafe(Real speed=1.0)
Definition camera.cpp:854
bool RotationStopped
Definition camera.h:209
void CheckElevator()
Definition camera.cpp:479
void ShowDebugShape(bool value)
Definition camera.cpp:1130
std::string CurrentFloorID
Definition camera.h:50
Real GetFOVAngle()
Definition camera.cpp:1009
Vector3 prev_accum_movement
Definition camera.h:213
Real Freelook_speed
Definition camera.h:88
Vector3 Rotation
Definition camera.h:207
Model * AttachedModel
Definition camera.h:221
bool BinocularsState
Definition camera.h:218
bool Move(Vector3 vector, Real speed=1.0, bool flip=true)
Definition camera.cpp:317
void SetMaxRenderDistance(Real value)
Definition camera.cpp:1111
bool MovePosition(Vector3 vector, Real speed=1.0)
Definition camera.cpp:353
void CheckShaft()
Definition camera.cpp:505
Quaternion old_character_orientation
Definition camera.h:229
Real cfg_body_height
Definition camera.h:63
void SetGravity(Real gravity, bool save_value=true)
Definition camera.cpp:949
Vector3 GetStartDirection()
Definition camera.cpp:441
void Binoculars(bool value)
Definition camera.cpp:1193
void DetachModel()
Definition camera.cpp:1243
bool IsOnGround()
Definition camera.cpp:1069
int object_line
Definition camera.h:197
void AttachToVehicle(bool value)
Definition camera.cpp:1552
void SetStartDirection(const Vector3 &direction)
Definition camera.cpp:435
bool GetGravityStatus()
Definition camera.cpp:984
void ResetView()
Definition camera.cpp:1344
Real cfg_rotate_maxspeed
Definition camera.h:61
Real BinocularsFOV
Definition camera.h:91
bool Collisions
Definition camera.h:208
Real GetHeight()
Definition camera.cpp:1023
std::string GetClickedWallName()
Definition camera.cpp:742
void DropModel()
Definition camera.cpp:1293
Real last_fov
Definition camera.h:206
OgreBulletCollisions::CollisionShape * mShape
Definition camera.h:225
int LastHitMeshNumber
Definition camera.h:86
Vector3 HitPosition
Definition camera.h:89
Real cfg_legs_width
Definition camera.h:66
std::vector< Ogre::Camera * > Cameras
Definition camera.h:191
void GetDirection(Vector3 &front, Vector3 &top, bool global=false)
Definition camera.cpp:263
void Refresh()
Definition camera.cpp:1356
Real FarClip
Definition camera.h:211
Real cfg_legs_height
Definition camera.h:65
std::string LastHitMesh
Definition camera.h:85
void SetCameraState(const CameraState &state, bool set_floor=true)
Definition camera.cpp:1467
bool CollisionsEnabled()
Definition camera.cpp:1064
void FreelookMove(const Vector3 &rotation)
Definition camera.cpp:904
void MoveCharacter()
Definition camera.cpp:1139
Real cfg_walk_accelerate
Definition camera.h:55
Real cfg_walk_maxspeed
Definition camera.h:56
void ResetCollisions()
Definition camera.cpp:1159
Real cfg_rotate_accelerate
Definition camera.h:60
void Teleport(Real X, Real Y, Real Z)
Definition camera.cpp:1515
void Drive(bool left, bool right, bool down, bool up, bool key_down)
Definition camera.cpp:1525
Real cfg_jumpspeed
Definition camera.h:54
void SetPosition(const Vector3 &position)
Definition camera.cpp:179
Vector3 prev_position
Definition camera.h:217
int GetClickedObjectLine()
Definition camera.cpp:755
bool inside_vehicle
Definition camera.h:94
Real cfg_lookspeed
Definition camera.h:67
std::string meshname
Definition camera.h:194
int mouse_x
Definition camera.h:98
int CurrentFloor
Definition camera.h:49
void RotateLocal(const Vector3 &position, Real speed=1.0)
Definition camera.cpp:378
void GotoFloor(int floor, bool disable_current=true)
Definition camera.cpp:1165
bool Freelook
Definition camera.h:87
bool MovementStopped
Definition camera.h:210
void Crouch(bool value)
Definition camera.cpp:1536
void SetViewMode(int mode)
Definition camera.cpp:1030
bool IsMeshVisible(MeshObject *mesh)
Definition camera.cpp:1214
Real cfg_rotate_brake
Definition camera.h:62
Quaternion prev_orientation
Definition camera.h:216
std::string object_cmd
Definition camera.h:198
void Turn(Real speed=1.0)
Definition camera.cpp:892
Real cfg_zoomspeed
Definition camera.h:76
void SetToStartDirection()
Definition camera.cpp:467
Real StartPositionX
Definition camera.h:52
bool MouseDown()
Definition camera.cpp:1496
bool old_freelook_mode
Definition camera.h:230
void SetRotation(const Vector3 &rotation)
Definition camera.cpp:209
Ogre::Camera * GetOgreCamera(int index=0)
Definition camera.cpp:1625
void SetToStartPosition(bool disable_current_floor)
Definition camera.cpp:456
bool MouseLeftDown
Definition camera.h:82
Real Gravity
Definition camera.h:201
Real cfg_spinspeed
Definition camera.h:69
Real cfg_strafespeed
Definition camera.h:72
void Sync()
Definition camera.cpp:1080
void SetOrientation(const Quaternion &orientation)
Definition camera.cpp:1542
Vehicle * vehicle
Definition camera.h:95
Real cfg_speedfast
Definition camera.h:74
void SetFOVAngle(Real angle)
Definition camera.cpp:989
void ResetState()
Definition camera.cpp:1311
std::string GetClickedObjectCommandP()
Definition camera.cpp:767
std::string wallname
Definition camera.h:195
void CheckObjects()
Definition camera.cpp:1502
Vector3 GetRotation()
Definition camera.cpp:285
bool collision_reset
Definition camera.h:214
Object * GetMeshParent(Object *object)
Definition camera.cpp:710
CameraState GetCameraState()
Definition camera.cpp:1445
Real ClickedObject(Camera *camera, bool shift, bool ctrl, bool alt, bool right, Real scale, bool center_only=false, bool hit_only=false)
Definition camera.cpp:552
void UnclickedObject()
Definition camera.cpp:688
bool IsDynamicMeshVisible(DynamicMesh *mesh, int mesh_index)
Definition camera.cpp:1224
Real cfg_stepspeed
Definition camera.h:71
void SetDirection(const Vector3 &direction)
Definition camera.cpp:199
void Jump()
Definition camera.cpp:872
Vector3 angle_velocity
Definition camera.h:80
Real cfg_floatspeed
Definition camera.h:70
bool EnableBullet
Definition camera.h:90
void Step(Real speed=1.0)
Definition camera.cpp:860
bool FirstAttach
Definition camera.h:93
Vector3 GetPosition(bool relative=false)
Definition camera.cpp:250
Camera(Object *parent)
Definition camera.cpp:48
Vector3 desired_velocity
Definition camera.h:77
void SetToStartRotation()
Definition camera.cpp:473
std::string GetClickedMeshName()
Definition camera.cpp:735
int object_number
Definition camera.h:196
OgreBulletDynamics::CharacterController * mCharacter
Definition camera.h:224
Real GetGravity()
Definition camera.cpp:961
bool lastfloorset
Definition camera.h:204
Real cfg_speed
Definition camera.h:73
int lastfloor
Definition camera.h:203
Real StartPositionZ
Definition camera.h:53
bool GravityStatus
Definition camera.h:202
bool IsModelAttached()
Definition camera.cpp:1304
void AttachModel(Model *model)
Definition camera.cpp:1232
Real speed
Definition camera.h:81
void RevertMovement()
Definition camera.cpp:1491
void Float(Real speed=1.0)
Definition camera.cpp:866
void CheckStairwell()
Definition camera.cpp:528
void Look(Real speed=1.0)
Definition camera.cpp:886
Vector3 GetStartRotation()
Definition camera.cpp:451
void Spin(Real speed=1.0)
Definition camera.cpp:898
Real cfg_speedslow
Definition camera.h:75
bool ReportCollisions
Definition camera.h:84
Real cfg_body_width
Definition camera.h:64
bool Attach(std::vector< Ogre::Camera * > &cameras, bool init_state=true)
Definition camera.cpp:1362
Vector3 desired_angle_velocity
Definition camera.h:79
Real GetMaxRenderDistance()
Definition camera.cpp:1125
void EnableGravity(bool value)
Definition camera.cpp:966
void OnRotate(bool parent)
Definition camera.cpp:1436
bool use_startdirection
Definition camera.h:215
Vector3 velocity
Definition camera.h:78
Vector3 accum_movement
Definition camera.h:212
Vector3 StartDirection
Definition camera.h:192
void Loop()
Definition camera.cpp:773
int StartFloor
Definition camera.h:51
void Rotate(const Vector3 &position, Real speed=1.0)
Definition camera.cpp:367
bool Detach()
Definition camera.cpp:1412
bool RestrictRotation
Definition camera.h:92
int GetClickedObjectNumber()
Definition camera.cpp:749
Real cfg_walk_maxspeed_multreal
Definition camera.h:58
Real cfg_turnspeed
Definition camera.h:68
void EnableCollisions(bool value)
Definition camera.cpp:1051
void SetToDefaultFOV()
Definition camera.cpp:1017
Quaternion old_camera_orientation
Definition camera.h:228
bool MouseRightDown
Definition camera.h:83
std::string GetClickedObjectCommand()
Definition camera.cpp:761
int FloorTemp
Definition camera.h:200
bool IsVisible(MeshObject *client=0)
void EnableAll(bool value)
Definition manager.cpp:366
bool Check(Vector3 position)
void UpdateFloorIndicators(int elevator)
Definition floor.cpp:934
Real GetBase(bool relative=false)
Definition floor.cpp:1146
std::string ID
Definition floor.h:38
void EnableGroup(bool value)
Definition floor.cpp:712
void Enabled(bool value)
Definition floor.cpp:378
bool IsVisible(Ogre::Camera *camera)
Definition mesh.cpp:464
void PickUp()
Definition model.cpp:213
void Loop()
Definition model.cpp:153
bool IsPhysical()
Definition model.cpp:116
void Drop()
Definition model.cpp:225
const std::string & GetName()
Definition object.cpp:53
virtual bool ReportError(const std::string &message)
Definition object.cpp:84
Object * GetParent()
Definition object.cpp:42
virtual void Report(const std::string &message)
Definition object.cpp:78
bool parent_deleting
Definition object.h:64
std::string command
Definition object.h:59
int linenum
Definition object.h:62
void NotifyRotate(bool parent=false)
Definition object.cpp:395
virtual Vector3 GetPosition(bool relative=false)
Definition object.cpp:307
void NotifyMove(bool parent=false)
Definition object.cpp:379
int GetNumber()
Definition object.cpp:183
SceneNode * GetSceneNode()
Definition object.cpp:246
void SetValues(const std::string &type, const std::string &name, bool is_permanent, bool is_movable=true)
Definition object.cpp:144
Quaternion GetOrientation(bool relative=false)
Definition object.cpp:363
virtual Vector3 GetRotation()
Definition object.cpp:353
std::string command_processed
Definition object.h:60
virtual void OnHit()
Definition object.h:97
const std::string & GetType()
Definition object.cpp:177
virtual void OnClick(Vector3 &position, bool shift, bool ctrl, bool alt, bool right)
Definition object.h:95
virtual void OnUnclick(bool right)
Definition object.h:96
SceneNode * node
Definition object.h:137
std::string ProcessFullName(std::string name, int &instance, int &object_number, bool strip_number=false)
Definition sbs.cpp:4287
unsigned int SmoothFrames
Definition sbs.h:193
Shaft * GetShaft(int number)
Definition sbs.cpp:1783
Ogre::SceneManager * mSceneManager
Definition sbs.h:138
Elevator * GetElevator(int number)
Definition sbs.cpp:1776
bool ProcessElevators
Definition sbs.h:177
void EnableBuildings(bool value)
Definition sbs.cpp:1518
bool HitBeam(const Ray &ray, Real max_distance, MeshObject *&mesh, Wall *&wall, Vector3 &hit_position)
Definition sbs.cpp:4061
Vector3 ToGlobal(const Vector3 &position)
Definition sbs.cpp:4439
bool AutoStairs
Definition sbs.h:176
bool AutoShafts
Definition sbs.h:175
Real GetConfigFloat(const std::string &key, Real default_value)
Definition sbs.cpp:3279
unsigned long GetAverageTime()
Definition sbs.cpp:3332
unsigned long GetElapsedTime()
Definition sbs.cpp:3326
int GetElevatorCount()
Definition sbs.cpp:1733
bool IsValidFloor(int floor)
Definition sbs.cpp:2522
Floor * GetFloor(int number)
Definition sbs.cpp:1769
Stairwell * GetStairwell(int number)
Definition sbs.cpp:1790
int InstanceNumber
Definition sbs.h:197
void EnableLandscape(bool value)
Definition sbs.cpp:1525
void EnableSkybox(bool value)
Definition sbs.cpp:1541
int GetFloorNumber(Real altitude, int lastfloor=0, bool checklastfloor=false)
Definition sbs.cpp:1596
OgreBulletDynamics::DynamicsWorld * mWorld
Definition sbs.h:153
int GetStairwellCount()
Definition sbs.cpp:1757
Real ToLocal(Real remote_value)
Definition sbs.cpp:2397
bool GetConfigBool(const std::string &key, bool default_value)
Definition sbs.cpp:3273
void EnableExternal(bool value)
Definition sbs.cpp:1532
Vector3 FromGlobal(const Vector3 &position)
Definition sbs.cpp:4446
bool InElevator
Definition sbs.h:163
Real ToRemote(Real local_value)
Definition sbs.cpp:2437
unsigned long GetRunTime()
Definition sbs.cpp:3320
ElevatorManager * GetElevatorManager()
Definition sbs.cpp:4568
int GetShaftCount()
Definition sbs.cpp:1751
Object * GetObject(int number)
Definition sbs.cpp:2482
bool DeleteObject(Object *object)
Definition sbs.cpp:2597
bool ElevatorSync
Definition sbs.h:167
bool Verbose
Definition sbs.h:186
void DetachObject(Ogre::MovableObject *object)
Ogre::SceneNode * GetRawSceneNode()
Definition scenenode.h:35
Quaternion GetDerivedOrientation()
void SetPosition(const Vector3 &position, bool relative=false, bool force=false)
void AttachObject(Ogre::MovableObject *object)
Vector3 GetPosition(bool relative=false)
void Check(Vector3 position, int current_floor)
Definition shaft.cpp:502
void Check(Vector3 position, int current_floor, int previous_floor)
Definition stairs.cpp:405
void KeyReleased(bool left, bool right, bool down, bool up)
Definition vehicle.cpp:247
void AttachCamera(bool value)
Definition vehicle.cpp:324
void KeyPressed(bool left, bool right, bool down, bool up)
Definition vehicle.cpp:235
Real GetWidth()
Definition vehicle.cpp:338
Ogre::Ray Ray
Definition globals.h:63
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
Ogre::Quaternion Quaternion
Definition globals.h:60
Ogre::Degree Degree
Definition globals.h:61
std::string ToString(int number)
Definition globals.cpp:279
#define SBS_PROFILE(name)
Definition profiler.h:131
#define SBS_PROFILE_MAIN(name)
Definition profiler.h:132
Vector3 velocity
Definition camera.h:38
Vector3 desired_velocity
Definition camera.h:37
bool collisions
Definition camera.h:34
Vector3 position
Definition camera.h:31
Vector3 angle_velocity
Definition camera.h:40
Vector3 accum_movement
Definition camera.h:41
Vector3 desired_angle_velocity
Definition camera.h:39
Vector3 rotation
Definition camera.h:32