[69] | 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"
|
---|
[70] | 23 | #include "Gui_impl.h"
|
---|
[69] | 24 | #include <ICursorControl.h>
|
---|
| 25 | #include <ICameraSceneNode.h>
|
---|
| 26 | #include <IrrlichtDevice.h>
|
---|
| 27 | #include <ISceneManager.h>
|
---|
| 28 |
|
---|
| 29 | using namespace irr;
|
---|
| 30 | using namespace gui;
|
---|
| 31 | using namespace core;
|
---|
| 32 | using namespace scene;
|
---|
| 33 |
|
---|
| 34 | namespace flair {
|
---|
| 35 | namespace simulator {
|
---|
| 36 |
|
---|
[70] | 37 | VisualizationCamera::VisualizationCamera(std::string inName) {
|
---|
| 38 | name=inName;
|
---|
| 39 | currentZoom = 0;
|
---|
[69] | 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);
|
---|
[70] | 48 |
|
---|
| 49 | getGui()->pimpl_->AddVisualizationCamera(this);
|
---|
[69] | 50 | }
|
---|
| 51 |
|
---|
| 52 | VisualizationCamera::~VisualizationCamera() {}
|
---|
| 53 |
|
---|
[70] | 54 | std::string VisualizationCamera::getName(void) {
|
---|
| 55 | return name;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[69] | 58 | ICameraSceneNode *VisualizationCamera::getCameraSceneNode(void) {
|
---|
| 59 | return camera;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | ISceneNodeAnimator *VisualizationCamera::createClone(ISceneNode *node,
|
---|
| 63 | ISceneManager *newManager) {
|
---|
| 64 | return NULL;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | bool VisualizationCamera::OnEvent(const irr::SEvent& event) {
|
---|
| 68 | if (event.EventType != EET_MOUSE_INPUT_EVENT)
|
---|
| 69 | return false;
|
---|
| 70 |
|
---|
| 71 | switch (event.MouseInput.Event) {
|
---|
| 72 |
|
---|
| 73 | case EMIE_MOUSE_WHEEL:
|
---|
[70] | 74 | currentZoom -= event.MouseInput.Wheel;
|
---|
[69] | 75 | break;
|
---|
| 76 | case EMIE_LMOUSE_PRESSED_DOWN:
|
---|
| 77 | LMouseKey = true;
|
---|
| 78 | break;
|
---|
| 79 | case EMIE_LMOUSE_LEFT_UP:
|
---|
| 80 | LMouseKey = false;
|
---|
| 81 | break;
|
---|
| 82 | case EMIE_MOUSE_MOVED:
|
---|
| 83 | MousePos = getGui()->getDevice()->getCursorControl()->getRelativePosition();
|
---|
| 84 | break;
|
---|
| 85 | default:
|
---|
| 86 | return false;
|
---|
| 87 | break;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | return true;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | } // end namespace simulator
|
---|
| 94 | } // end namespace flair
|
---|
| 95 |
|
---|
| 96 | #endif // GL
|
---|