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

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

refonte camera simu

File size: 1.9 KB
Line 
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: 2016/09/01
6// filename: FixedCamera.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: class for a fixed camera in the gui
14//
15/*********************************************************************/
16#ifdef GL
17
18#include "FixedCamera.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
36FixedCamera::FixedCamera(core::Vector3D position,float rotateSpeed,float zoomSpeed):VisualizationCamera(rotateSpeed,zoomSpeed) {
37 RotY = 020;
38 RotZ = 0;
39 Rotating = false;
40
41 // camera
42 camera->setPosition(vector3df(position.x,position.y,position.z));
43}
44
45FixedCamera::~FixedCamera() {}
46
47void FixedCamera::animateNode(ISceneNode *node, u32 timeMs) {
48 ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node);
49
50 float nRotY = RotY;
51 float nRotZ = RotZ;
52
53 if (LMouseKey == true) {
54 if (!Rotating) {
55 RotateStart = MousePos;
56 Rotating = true;
57 nRotY = RotY;
58 nRotZ = RotZ;
59 } else {
60 nRotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
61 nRotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
62 }
63 } else if (Rotating) {
64 RotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;
65 RotZ += (RotateStart.X - MousePos.X) * rotateSpeed;
66 nRotY = RotY;
67 nRotZ = RotZ;
68 Rotating = false;
69 }
70
71 camera->setRotation(vector3df(0,nRotY,nRotZ));
72 camera->bindTargetAndRotation(true);
73}
74
75
76} // end namespace simulator
77} // end namespace flair
78
79#endif // GL
Note: See TracBrowser for help on using the repository browser.