source: flair-src/trunk/lib/FlairSimulator/src/VisualizationCamera.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.2 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: VisualizationCamera.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: class for a visualization camera in the gui
14//
15/*********************************************************************/
16#ifdef GL
17
18#include "VisualizationCamera.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
36VisualizationCamera::VisualizationCamera(float inRotateSpeed,float inZoomSpeed) {
37 zoomSpeed = inZoomSpeed;
38 rotateSpeed = inRotateSpeed;
39 currentZoom = 100;
40 LMouseKey = false;
41
42 // camera
43 camera = getGui()->getSceneManager()->addCameraSceneNode();
44 camera->setAspectRatio(getGui()->getAspectRatio()); // on force a cause du view port
45 camera->setUpVector(vector3df(0, 0, 1));
46 camera->addAnimator(this);
47 camera->setFarValue(8000);
48}
49
50VisualizationCamera::~VisualizationCamera() {}
51
52ICameraSceneNode *VisualizationCamera::getCameraSceneNode(void) {
53 return camera;
54}
55
56ISceneNodeAnimator *VisualizationCamera::createClone(ISceneNode *node,
57 ISceneManager *newManager) {
58 return NULL;
59}
60
61bool VisualizationCamera::OnEvent(const irr::SEvent& event) {
62 if (event.EventType != EET_MOUSE_INPUT_EVENT)
63 return false;
64
65 switch (event.MouseInput.Event) {
66
67 case EMIE_MOUSE_WHEEL:
68 currentZoom -= event.MouseInput.Wheel * zoomSpeed;
69 if (currentZoom <= 0)
70 currentZoom = zoomSpeed;
71 break;
72 case EMIE_LMOUSE_PRESSED_DOWN:
73 LMouseKey = true;
74 break;
75 case EMIE_LMOUSE_LEFT_UP:
76 LMouseKey = false;
77 break;
78 case EMIE_MOUSE_MOVED:
79 MousePos = getGui()->getDevice()->getCursorControl()->getRelativePosition();
80 break;
81 default:
82 return false;
83 break;
84 }
85
86 return true;
87}
88
89} // end namespace simulator
90} // end namespace flair
91
92#endif // GL
Note: See TracBrowser for help on using the repository browser.