close Warning: Can't use blame annotator:
svn blame failed on trunk/lib/FlairSimulator/src/FollowMeCamera.cpp: 200029 - Couldn't perform atomic initialization

source: flair-src/trunk/lib/FlairSimulator/src/FollowMeCamera.cpp@ 69

Last change on this file since 69 was 69, checked in by Sanahuja Guillaume, 8 years ago

refonte camera simu

File size: 2.4 KB
RevLine 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2012/08/21
6// filename: FollowMeCamera.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: classe definissant une animation poursuite pour camera
14//
15/*********************************************************************/
16#ifdef GL
17
18#include "FollowMeCamera.h"
19#include "Simulator.h"
20#include "Model.h"
21#include "Model_impl.h"
22#include "Gui.h"
23#include <ICursorControl.h>
24#include <ICameraSceneNode.h>
25#include <IrrlichtDevice.h>
26#include <ISceneManager.h>
27
28using namespace irr;
29using namespace gui;
30using namespace core;
31using namespace scene;
32
33namespace flair {
34namespace simulator {
35
36FollowMeCamera::FollowMeCamera(const ISceneNode *parent, float rotateSpeed,
37 float zoomSpeed):VisualizationCamera(rotateSpeed,zoomSpeed) {
38 this->parent = parent;
39 RotY = 20;
40 RotZ = 0;
41 Rotating = false;
42}
43
44FollowMeCamera::~FollowMeCamera() {}
45
46void FollowMeCamera::setPositionOffset(vector3df newpos) { pos_offset = newpos; }
47
48void FollowMeCamera::setTargetOffset(vector3df newpos) {
49 target_offset = newpos;
50}
51
52float FollowMeCamera::sat(float value) {
53 if (value > 89)
54 value = 89;
55 if (value < -89)
56 value = -89;
57 return value;
58}
59
60void FollowMeCamera::animateNode(ISceneNode *node, u32 timeMs) {
61 vector3df pos;
62
63 float nRotY = RotY;
64 float nRotZ = RotZ;
65
66 if (LMouseKey == true) {
67 if (!Rotating) {
68 RotateStart = MousePos;
69 Rotating = true;
70 nRotY = RotY;
71 nRotZ = RotZ;
72 } else {
73 nRotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
74 nRotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
75 nRotY = sat(nRotY);
76 }
77 } else if (Rotating) {
78 RotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
79 RotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
80 RotY = sat(RotY);
81 nRotY = RotY;
82 nRotZ = RotZ;
83 Rotating = false;
84 }
85
86 pos.X = -currentZoom;
87 pos.Y = 0;
88 pos.Z = 0;
89
90 pos.rotateXZBy(-nRotY);
91 pos.rotateXYBy(getSimulator()->Yaw() + nRotZ + parent->getRotation().Z);
92
93 camera->setPosition(parent->getPosition() + pos + pos_offset);
94 camera->setTarget(parent->getPosition() + target_offset);
95}
96
97
98} // end namespace simulator
99} // end namespace flair
100
101#endif // GL
Note: See TracBrowser for help on using the repository browser.