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()->GetRawSceneNode()->_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, bool camera_only)
950{
951 if (save_value == true)
952 Gravity = gravity;
953
954 if (EnableBullet == true && !Cameras.empty())
955 {
956 if (camera_only == false)
957 sbs->mWorld->setGravity(Vector3(0, sbs->ToRemote(-gravity), 0));
958 mCharacter->setGravity(sbs->ToRemote(gravity));
959 }
960}
961
963{
964 return Gravity;
965}
966
967void Camera::EnableGravity(bool value)
968{
969 if (Cameras.empty())
970 return;
971
972 if (value == true)
974 else
975 {
976 SetGravity(0, false);
977 velocity.y = 0;
978 desired_velocity.y = 0;
979 }
980 if (EnableBullet == true)
981 mCharacter->reset();
982 GravityStatus = value;
983}
984
986{
987 return GravityStatus;
988}
989
991{
992 //set camera FOV angle
993
994 if (Cameras.empty())
995 return;
996
997 if (angle > 0 && angle < 179.63)
998 {
999 Real ratio = (float)Cameras[0]->getAspectRatio();
1000 if (ratio > 0)
1001 {
1002 for (size_t i = 0; i < Cameras.size(); i++)
1003 {
1004 Cameras[i]->setFOVy(Degree(angle / ratio));
1005 }
1006 }
1007 }
1008}
1009
1011{
1012 if (Cameras.empty())
1013 return 0.0;
1014
1015 return (float)(Cameras[0]->getFOVy().valueDegrees() * Cameras[0]->getAspectRatio());
1016}
1017
1019{
1020 //set to default FOV angle value
1022}
1023
1025{
1026 //return camera's height
1027
1029}
1030
1032{
1033 //set view mode of camera:
1034 //0 - solid polygons (normal)
1035 //1 - wireframe mode
1036 //2 - point mode
1037
1038 if (Cameras.empty())
1039 return;
1040
1041 for (size_t i = 0; i < Cameras.size(); i++)
1042 {
1043 if (mode == 0)
1044 Cameras[i]->setPolygonMode(Ogre::PM_SOLID);
1045 if (mode == 1)
1046 Cameras[i]->setPolygonMode(Ogre::PM_WIREFRAME);
1047 if (mode == 2)
1048 Cameras[i]->setPolygonMode(Ogre::PM_POINTS);
1049 }
1050}
1051
1053{
1054 if (Cameras.empty())
1055 return;
1056
1057 if (value == Collisions)
1058 return;
1059
1060 Collisions = value;
1061 if (EnableBullet == true)
1062 mCharacter->enableCollisions(value);
1063}
1064
1066{
1067 return Collisions;
1068}
1069
1071{
1072 if (Cameras.empty())
1073 return false;
1074
1075 if (EnableBullet == true)
1076 return mCharacter->onGround();
1077 else
1078 return false;
1079}
1080
1082{
1083 //sync scene node with bullet object
1084
1085 if (Cameras.empty())
1086 return;
1087
1088 SBS_PROFILE_MAIN("Camera Sync");
1089
1090 if (EnableBullet == true)
1091 mCharacter->sync();
1092
1093 //notify on movement or rotation
1094 Vector3 position = sbs->ToRemote(GetPosition());
1095 Quaternion orientation = GetOrientation();
1096
1097 if (prev_position.positionEquals(position) == false)
1098 {
1099 GetSceneNode()->Update();
1100 NotifyMove();
1101 }
1102 if (prev_orientation.orientationEquals(orientation) == false)
1103 {
1104 GetSceneNode()->Update();
1105 NotifyRotate();
1106 }
1107
1108 prev_position = position;
1109 prev_orientation = orientation;
1110}
1111
1113{
1114 //set distance of camera's far clipping plane - set to 0 for infinite
1115
1116 if (Cameras.empty())
1117 return;
1118
1119 for (size_t i = 0; i < Cameras.size(); i++)
1120 {
1121 Cameras[i]->setFarClipDistance(sbs->ToRemote(value));
1122 }
1123 FarClip = value;
1124}
1125
1127{
1128 return FarClip;
1129}
1130
1132{
1133 if (Cameras.empty())
1134 return;
1135
1136 if (EnableBullet == true)
1137 mCharacter->showDebugShape(value);
1138}
1139
1141{
1142 if (Cameras.empty())
1143 return;
1144
1145 SBS_PROFILE_MAIN("MoveCharacter");
1146
1147 if (EnableBullet == true)
1148 mCharacter->setWalkDirection(accum_movement, 1);
1149 else
1150 {
1151 for (size_t i = 0; i < Cameras.size(); i++)
1152 {
1153 Cameras[i]->move(accum_movement);
1154 }
1155 }
1157 accum_movement = Vector3::ZERO;
1158}
1159
1161{
1162 //queue a collision reset for next loop cycle
1163 collision_reset = true;
1164}
1165
1166void Camera::GotoFloor(int floor, bool disable_current)
1167{
1168 //have camera warp to specified floor
1169
1170 if (Cameras.empty())
1171 return;
1172
1173 if (sbs->IsValidFloor(floor) == true)
1174 {
1175 Floor* origfloor = sbs->GetFloor(CurrentFloor);
1176 if (disable_current == true && origfloor)
1177 {
1178 origfloor->Enabled(false);
1179 origfloor->EnableGroup(false);
1180 }
1181
1182 Floor* floorobj = sbs->GetFloor(floor);
1183 if (floorobj)
1184 {
1185 Vector3 pos = GetPosition();
1186 pos.y = floorobj->GetBase() + GetHeight();
1187 SetPosition(pos);
1188 floorobj->Enabled(true);
1189 floorobj->EnableGroup(true);
1190 }
1191 }
1192}
1193
1194void Camera::Binoculars(bool value)
1195{
1196 //enable or disable binoculars mode
1197
1198 if (Cameras.empty())
1199 return;
1200
1201 if (value == BinocularsState)
1202 return;
1203
1204 if (value == true)
1205 {
1208 }
1209 else
1211
1212 BinocularsState = value;
1213}
1214
1216{
1217 //returns if a mesh object is visible in the camera's view frustum or not
1218
1219 if (!mesh || Cameras.empty())
1220 return false;
1221
1222 return mesh->IsVisible(Cameras[0]);
1223}
1224
1226{
1227 if (!mesh || Cameras.empty())
1228 return false;
1229
1230 return mesh->IsVisible(Cameras[0], mesh_index);
1231}
1232
1234{
1235 //attach a model to the camera
1236 //this is used for picking up a model, which changes the model's parent to the camera
1237
1238 if (!model || AttachedModel)
1239 return;
1240
1241 AttachedModel = model;
1242}
1243
1245{
1246 //detach a model from the camera
1247
1248 AttachedModel = 0;
1249}
1250
1252{
1253 //pick up model
1254 Vector3 front, top;
1255 GetDirection(front, top);
1256
1257 Vector3 hit_position;
1258 MeshObject *mesh = 0;
1259 Wall *wall = 0;
1260 bool hit = false;
1261
1262 //do a raycast from the collider's position, in the forward direction
1263 Vector3 position = GetPosition();
1264
1265 for (int i = (int)GetPosition().y; i > 0; i--)
1266 {
1267 position.y = i;
1268 Ray ray (sbs->ToRemote(position), sbs->ToRemote(front, false));
1269
1270 hit = sbs->HitBeam(ray, 2.0, mesh, wall, hit_position);
1271
1272 if (hit == true)
1273 break;
1274 }
1275
1276 if (hit == false)
1277 return false;
1278
1279 Model *model = dynamic_cast<Model*>(mesh->GetParent());
1280
1281 if (model)
1282 {
1283 if (model->IsPhysical() == true)
1284 {
1285 model->PickUp();
1286 AttachModel(model);
1287 return true;
1288 }
1289 }
1290
1291 return false;
1292}
1293
1295{
1296 //drop model
1297
1298 if (AttachedModel)
1299 {
1301 DetachModel();
1302 }
1303}
1304
1306{
1307 if (AttachedModel)
1308 return true;
1309 return false;
1310}
1311
1313{
1314 //reset camera position and state
1315
1316 if (Cameras.empty())
1317 return;
1318
1319 Floor *floor = sbs->GetFloor(CurrentFloor);
1320 if (floor)
1321 {
1322 floor->Enabled(false);
1323 floor->EnableGroup(false);
1324 }
1325
1326 EnableGravity(true);
1327 EnableCollisions(true);
1328 SetToStartPosition(true);
1331
1332 floor = sbs->GetFloor(StartFloor);
1333 if (floor)
1334 {
1335 floor->Enabled(true);
1336 floor->EnableGroup(true);
1337 }
1338
1339 sbs->EnableBuildings(true);
1340 sbs->EnableLandscape(true);
1341 sbs->EnableExternal(true);
1342 sbs->EnableSkybox(true);
1343}
1344
1346{
1347 //reset rotation/direction and FOV of camera
1348
1349 if (Cameras.empty())
1350 return;
1351
1355}
1356
1358{
1359 if (mCharacter)
1360 mCharacter->resetLastCollision();
1361}
1362
1363bool Camera::Attach(std::vector<Ogre::Camera*>& cameras, bool init_state)
1364{
1365 if (cameras.empty())
1366 return false;
1367
1368 if (cameras[0]->isAttached() == true)
1369 return false;
1370
1371 Cameras = cameras;
1372
1373 for (size_t i = 0; i < Cameras.size(); i++)
1374 {
1375 Cameras[i]->setNearClipDistance(0.1);
1376 Cameras[i]->setPosition(0, sbs->ToRemote((cfg_body_height + cfg_legs_height + 0.5) / 2), 0);
1378 }
1379
1382
1383 //move camera to start location
1384 if (FirstAttach == false)
1385 {
1386 SetGravity(sbs->GetConfigFloat("Skyscraper.SBS.Camera.Gravity", 32.1719), true, false); // 9.806 m/s/s
1387
1388 if (init_state == true)
1389 {
1390 GravityStatus = sbs->GetConfigBool("Skyscraper.SBS.Camera.GravityStatus", true);
1391 EnableCollisions(sbs->GetConfigBool("Skyscraper.SBS.Camera.EnableCollisions", true));
1392 SetToStartPosition(false); //also turns on start floor
1395 }
1396 FirstAttach = true;
1397 }
1398 else
1399 {
1400 //re-apply rotation
1401 if (init_state == true)
1403 }
1404
1405 Refresh();
1406 Sync();
1407
1409
1410 return true;
1411}
1412
1414{
1415 if (Cameras.empty())
1416 return false;
1417
1418 if (Cameras[0]->isAttached() == false)
1419 return false;
1420
1421 for (size_t i = 0; i < Cameras.size(); i++)
1422 {
1424 }
1425
1426 Cameras.clear();
1427
1428 return true;
1429}
1430
1431void Camera::OnMove(bool parent)
1432{
1433 if (EnableBullet == true)
1434 mCharacter->updateTransform(true, false, false);
1435}
1436
1437void Camera::OnRotate(bool parent)
1438{
1439 if (parent == true)
1440 OnMove(parent); //update position if parent object has been rotated
1441
1442 if (EnableBullet == true)
1443 mCharacter->updateTransform(false, true, false);
1444}
1445
1447{
1448 //returns camera state info
1449 //the position value is in a global/absolute scene format, not engine-relative
1450
1451 CameraState state;
1452 state.position = sbs->ToGlobal(GetPosition());
1453 state.rotation = GetRotation() + sbs->GetRotation();
1454 state.floor = CurrentFloor;
1455 state.collisions = CollisionsEnabled();
1456 state.gravity = GetGravityStatus();
1457 state.freelook = Freelook;
1459 state.velocity = velocity;
1463 state.fov = GetFOVAngle();
1464 state.speed = speed;
1465 return state;
1466}
1467
1468void Camera::SetCameraState(const CameraState &state, bool set_floor)
1469{
1470 //sets camera state
1471 //the position value is in a global/absolute scene format, not engine-relative
1472
1473 Vector3 position = sbs->FromGlobal(state.position);
1474 if (set_floor == true)
1475 GotoFloor(state.floor, true);
1476 else
1477 GotoFloor(sbs->GetFloorNumber((float)position.y));
1478 SetPosition(position);
1479 SetRotation(state.rotation - sbs->GetRotation());
1481 EnableGravity(state.gravity);
1482 Freelook = state.freelook;
1484 velocity = state.velocity;
1488 SetFOVAngle(state.fov);
1489 speed = state.speed;
1490}
1491
1496
1498{
1499 //returns true if either mouse button is down
1500 return (MouseLeftDown || MouseRightDown);
1501}
1502
1504{
1505 //check if the user is in an elevator
1506 if (sbs->ProcessElevators == true)
1507 CheckElevator();
1508
1509 //check if the user is in a shaft
1510 CheckShaft();
1511
1512 //check if the user is in a stairwell
1514}
1515
1517{
1518 //teleport/warp user to specified location
1519
1520 Vector3 destination (X, Y, Z);
1521
1522 GotoFloor(sbs->GetFloorNumber(destination.y));
1523 SetPosition(destination);
1524}
1525
1526void Camera::Drive(bool left, bool right, bool down, bool up, bool key_down)
1527{
1528 if (!vehicle)
1529 return;
1530
1531 if (key_down == true)
1532 vehicle->KeyPressed(left, right, down, up);
1533 else
1534 vehicle->KeyReleased(left, right, down, up);
1535}
1536
1537void Camera::Crouch(bool value)
1538{
1539 if (mCharacter)
1540 mCharacter->crouch(value);
1541}
1542
1543void Camera::SetOrientation(const Quaternion &orientation)
1544{
1545 //set orientation of main camera object, not collider
1546
1547 for (size_t i = 0; i < Cameras.size(); i++)
1548 {
1549 Cameras[i]->setOrientation(orientation);
1550 }
1551}
1552
1554{
1555 //attach/detach camera from a vehicle
1556
1557 if (Cameras.empty())
1558 return;
1559
1560 if (vehicle && value == false)
1561 {
1562 Vector3 newpos = GetPosition() + (vehicle->GetOrientation() * Vector3(vehicle->GetWidth(), 0, 0));
1563 SetPosition(newpos);
1564
1566 inside_vehicle = false;
1567 vehicle->AttachCamera(false);
1568 vehicle = 0;
1569 EnableCollisions(true);
1570 for (size_t i = 0; i < Cameras.size(); i++)
1571 {
1572 Cameras[i]->setOrientation(old_camera_orientation);
1573 }
1574 if (EnableBullet == true)
1575 mCharacter->setOrientation(old_character_orientation);
1576 }
1577 else if (value == true)
1578 {
1579 //search for a vehicle
1580
1581 Vector3 direction, other;
1582 GetDirection(direction, other);
1583 Ray ray = Ray(sbs->ToRemote(GetPosition()), direction);
1584
1585 MeshObject* mesh = 0;
1586 Wall* wall = 0;
1587
1588 bool hit = sbs->HitBeam(ray, 50, mesh, wall, HitPosition);
1589
1590 if (hit == false)
1591 {
1592 ReportError("AttachToVehicle: No vehicles found");
1593 return;
1594 }
1595
1596 meshname = mesh->GetName();
1597 Object *obj = mesh;
1598
1599 //get original object (parent object of clicked mesh)
1600 Object *mesh_parent = GetMeshParent(obj);
1601
1602 if (mesh_parent->GetType() == "Vehicle")
1603 {
1604 //if a vehicle is found, attach to it
1605
1606 Vehicle *v = dynamic_cast<Vehicle*> (mesh_parent);
1607
1608 if (v)
1609 {
1610 vehicle = v;
1612 Freelook = true;
1613 inside_vehicle = true;
1614 EnableCollisions(false);
1615 old_camera_orientation = Cameras[0]->getOrientation();
1616 if (EnableBullet == true)
1617 old_character_orientation = mCharacter->getWorldOrientation();
1618 vehicle->AttachCamera(true);
1619 }
1620 }
1621 else
1622 ReportError("AttachToVehicle: No vehicles found");
1623 }
1624}
1625
1626Ogre::Camera* Camera::GetOgreCamera(int index)
1627{
1628 if (!Cameras.empty())
1629 return Cameras[index];
1630 return 0;
1631}
1632
1633}
std::string object_cmd_processed
Definition camera.h:199
Real cfg_walk_brake
Definition camera.h:59
void OnMove(bool parent)
Definition camera.cpp:1431
void InterpolateMovement(Real delta)
Definition camera.cpp:910
Real FOV
Definition camera.h:205
bool PickUpModel()
Definition camera.cpp:1251
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:1131
std::string CurrentFloorID
Definition camera.h:50
Real GetFOVAngle()
Definition camera.cpp:1010
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:1112
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
Vector3 GetStartDirection()
Definition camera.cpp:441
void Binoculars(bool value)
Definition camera.cpp:1194
void DetachModel()
Definition camera.cpp:1244
bool IsOnGround()
Definition camera.cpp:1070
int object_line
Definition camera.h:197
void AttachToVehicle(bool value)
Definition camera.cpp:1553
void SetStartDirection(const Vector3 &direction)
Definition camera.cpp:435
bool GetGravityStatus()
Definition camera.cpp:985
void ResetView()
Definition camera.cpp:1345
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:1024
std::string GetClickedWallName()
Definition camera.cpp:742
void DropModel()
Definition camera.cpp:1294
void SetGravity(Real gravity, bool save_value=true, bool camera_only=true)
Definition camera.cpp:949
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:1357
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:1468
bool CollisionsEnabled()
Definition camera.cpp:1065
void FreelookMove(const Vector3 &rotation)
Definition camera.cpp:904
void MoveCharacter()
Definition camera.cpp:1140
Real cfg_walk_accelerate
Definition camera.h:55
Real cfg_walk_maxspeed
Definition camera.h:56
void ResetCollisions()
Definition camera.cpp:1160
Real cfg_rotate_accelerate
Definition camera.h:60
void Teleport(Real X, Real Y, Real Z)
Definition camera.cpp:1516
void Drive(bool left, bool right, bool down, bool up, bool key_down)
Definition camera.cpp:1526
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:1166
bool Freelook
Definition camera.h:87
bool MovementStopped
Definition camera.h:210
void Crouch(bool value)
Definition camera.cpp:1537
void SetViewMode(int mode)
Definition camera.cpp:1031
bool IsMeshVisible(MeshObject *mesh)
Definition camera.cpp:1215
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:1497
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:1626
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:1081
void SetOrientation(const Quaternion &orientation)
Definition camera.cpp:1543
Vehicle * vehicle
Definition camera.h:95
Real cfg_speedfast
Definition camera.h:74
void SetFOVAngle(Real angle)
Definition camera.cpp:990
void ResetState()
Definition camera.cpp:1312
std::string GetClickedObjectCommandP()
Definition camera.cpp:767
std::string wallname
Definition camera.h:195
void CheckObjects()
Definition camera.cpp:1503
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:1446
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:1225
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:962
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:1305
void AttachModel(Model *model)
Definition camera.cpp:1233
Real speed
Definition camera.h:81
void RevertMovement()
Definition camera.cpp:1492
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:1363
Vector3 desired_angle_velocity
Definition camera.h:79
Real GetMaxRenderDistance()
Definition camera.cpp:1126
void EnableGravity(bool value)
Definition camera.cpp:967
void OnRotate(bool parent)
Definition camera.cpp:1437
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:1413
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:1052
void SetToDefaultFOV()
Definition camera.cpp:1018
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:928
Real GetBase(bool relative=false)
Definition floor.cpp:1140
std::string ID
Definition floor.h:38
void EnableGroup(bool value)
Definition floor.cpp:706
void Enabled(bool value)
Definition floor.cpp:377
bool IsVisible(Ogre::Camera *camera)
Definition mesh.cpp:466
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:409
virtual Vector3 GetPosition(bool relative=false)
Definition object.cpp:321
void NotifyMove(bool parent=false)
Definition object.cpp:393
int GetNumber()
Definition object.cpp:183
SceneNode * GetSceneNode()
Definition object.cpp:240
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:377
virtual Vector3 GetRotation()
Definition object.cpp:367
std::string command_processed
Definition object.h:60
virtual void OnHit()
Definition object.h:99
const std::string & GetType()
Definition object.cpp:177
virtual void OnClick(Vector3 &position, bool shift, bool ctrl, bool alt, bool right)
Definition object.h:97
virtual void OnUnclick(bool right)
Definition object.h:98
SceneNode * node
Definition object.h:138
std::string ProcessFullName(std::string name, int &instance, int &object_number, bool strip_number=false)
Definition sbs.cpp:4257
unsigned int SmoothFrames
Definition sbs.h:193
Shaft * GetShaft(int number)
Definition sbs.cpp:1753
Ogre::SceneManager * mSceneManager
Definition sbs.h:138
Elevator * GetElevator(int number)
Definition sbs.cpp:1746
bool ProcessElevators
Definition sbs.h:177
void EnableBuildings(bool value)
Definition sbs.cpp:1475
bool HitBeam(const Ray &ray, Real max_distance, MeshObject *&mesh, Wall *&wall, Vector3 &hit_position)
Definition sbs.cpp:4031
Vector3 ToGlobal(const Vector3 &position)
Definition sbs.cpp:4409
bool AutoStairs
Definition sbs.h:176
bool AutoShafts
Definition sbs.h:175
Real GetConfigFloat(const std::string &key, Real default_value)
Definition sbs.cpp:3249
unsigned long GetAverageTime()
Definition sbs.cpp:3302
unsigned long GetElapsedTime()
Definition sbs.cpp:3296
int GetElevatorCount()
Definition sbs.cpp:1703
bool IsValidFloor(int floor)
Definition sbs.cpp:2492
Floor * GetFloor(int number)
Definition sbs.cpp:1739
Stairwell * GetStairwell(int number)
Definition sbs.cpp:1760
int InstanceNumber
Definition sbs.h:197
void EnableLandscape(bool value)
Definition sbs.cpp:1482
void EnableSkybox(bool value)
Definition sbs.cpp:1498
int GetFloorNumber(Real altitude, int lastfloor=0, bool checklastfloor=false)
Definition sbs.cpp:1584
OgreBulletDynamics::DynamicsWorld * mWorld
Definition sbs.h:153
int GetStairwellCount()
Definition sbs.cpp:1727
Real ToLocal(Real remote_value)
Definition sbs.cpp:2367
bool GetConfigBool(const std::string &key, bool default_value)
Definition sbs.cpp:3243
void EnableExternal(bool value)
Definition sbs.cpp:1489
Vector3 FromGlobal(const Vector3 &position)
Definition sbs.cpp:4416
bool InElevator
Definition sbs.h:163
Real ToRemote(Real local_value)
Definition sbs.cpp:2407
unsigned long GetRunTime()
Definition sbs.cpp:3290
ElevatorManager * GetElevatorManager()
Definition sbs.cpp:4538
int GetShaftCount()
Definition sbs.cpp:1721
Object * GetObject(int number)
Definition sbs.cpp:2452
bool DeleteObject(Object *object)
Definition sbs.cpp:2567
bool ElevatorSync
Definition sbs.h:167
bool Verbose
Definition sbs.h:186
void DetachObject(Ogre::MovableObject *object)
void SetPosition(const Vector3 &position)
Ogre::SceneNode * GetRawSceneNode()
Definition scenenode.h:35
void AttachObject(Ogre::MovableObject *object)
Vector3 GetPosition(bool relative=false)
void Check(Vector3 position, int current_floor)
Definition shaft.cpp:501
void Check(Vector3 position, int current_floor, int previous_floor)
Definition stairs.cpp:404
void KeyReleased(bool left, bool right, bool down, bool up)
Definition vehicle.cpp:247
void AttachCamera(bool value)
Definition vehicle.cpp:318
void KeyPressed(bool left, bool right, bool down, bool up)
Definition vehicle.cpp:235
Real GetWidth()
Definition vehicle.cpp:332
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