source: flair-src/trunk/lib/FlairSimulator/src/GenericObject.cpp

Last change on this file was 426, checked in by Sanahuja Guillaume, 5 months ago

up

File size: 2.1 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:    2013/03/25
6//  filename:   GenericObject.cpp
7//
8//  author:     Cesar Richard
9//              Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11//  version:    $Id: $
12//
13//  purpose:    classe definissant un modele a simuler
14//
15/*********************************************************************/
16
17#ifdef GL
18#include "GenericObject.h"
19#include "Simulator.h"
20#include "Simulator_impl.h"
21#include "Gui.h"
22
23#include "Quaternion.h"
24#include "Euler.h"
25#include <ISceneManager.h>
26#include <IMeshSceneNode.h>
27
28using namespace irr;
29using namespace video;
30using namespace scene;
31using namespace core;
32
33using namespace flair::core;
34using namespace flair::simulator;
35
36namespace flair {
37namespace simulator {
38
39GenericObject::GenericObject(IMesh *mesh) {
40        meshSceneNode=getGui()->getSceneManager()->addMeshSceneNode(mesh);
41        /*
42  selector = getGui()->getSceneManager()->createTriangleSelector(mesh, meshSceneNode);
43  meshSceneNode->setTriangleSelector(selector);
44        */
45  meshSceneNode->setMaterialFlag(EMF_LIGHTING, false);
46
47  getSimulator()->pimpl_->objects.push_back(this);
48}
49
50GenericObject::~GenericObject() {}
51
52ITriangleSelector *GenericObject::TriangleSelector(void) { return selector; }
53
54void GenericObject::setVisible(bool isVisible) {
55  meshSceneNode->setVisible(isVisible);
56}
57void GenericObject::setScale(float value) {
58  meshSceneNode->setScale(vector3df(value, value, value));
59}
60
61void GenericObject::setScale(const vector3df& scale) { 
62        meshSceneNode->setScale(scale);
63}
64
65void GenericObject::setPosition(const vector3df& pos) {
66  meshSceneNode->setPosition(ToIrrlichtCoordinates(pos));
67}
68
69void GenericObject::setRotation(const vector3df& rotation) {
70  Euler eulerA(rotation.X, rotation.Y, rotation.Z);
71  Euler eulerB;
72  Quaternion quatA, quatB;
73  eulerA.ToQuaternion(quatA);
74  quatB = ToIrrlichtOrientation(quatA);
75  quatB.ToEuler(eulerB);
76
77  meshSceneNode->setRotation(Euler::ToDegree(1) *
78                          vector3df(eulerB.roll, eulerB.pitch, eulerB.yaw));
79}
80
81} // end namespace simulator
82} // end namespace flair
83#endif
Note: See TracBrowser for help on using the repository browser.