| 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 |
|
---|
| 28 | using namespace irr;
|
---|
| 29 | using namespace gui;
|
---|
| 30 | using namespace core;
|
---|
| 31 | using namespace scene;
|
---|
| 32 |
|
---|
| 33 | namespace flair {
|
---|
| 34 | namespace simulator {
|
---|
| 35 |
|
---|
| 36 | FixedCamera::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 |
|
---|
| 45 | FixedCamera::~FixedCamera() {}
|
---|
| 46 |
|
---|
| 47 | void 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
|
---|