[10] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[10] | 4 | // %flair:license}
|
---|
[8] | 5 | // created: 2012/08/22
|
---|
| 6 | // filename: MeshSceneNode.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: classe definissant un IMeshSceneNode
|
---|
| 14 | //
|
---|
| 15 | /*********************************************************************/
|
---|
| 16 | #ifdef GL
|
---|
| 17 |
|
---|
| 18 | #include "MeshSceneNode.h"
|
---|
| 19 | #include "Gui.h"
|
---|
| 20 | #include "Model.h"
|
---|
| 21 | #include <ISceneManager.h>
|
---|
| 22 | #include <IVideoDriver.h>
|
---|
| 23 |
|
---|
| 24 | using namespace irr;
|
---|
| 25 | using namespace irr::video;
|
---|
| 26 | using namespace irr::scene;
|
---|
| 27 | using namespace irr::core;
|
---|
| 28 | using namespace flair::core;
|
---|
| 29 |
|
---|
[15] | 30 | namespace flair {
|
---|
| 31 | namespace simulator {
|
---|
[8] | 32 |
|
---|
[15] | 33 | MeshSceneNode::MeshSceneNode(Model *parent, IMesh *mesh,
|
---|
| 34 | const vector3df &position,
|
---|
| 35 | const vector3df &rotation, ITexture *texture,
|
---|
| 36 | s32 id)
|
---|
| 37 | : IMeshSceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,
|
---|
| 38 | position, rotation) {
|
---|
| 39 | Material.Wireframe = false;
|
---|
| 40 | Material.Lighting = false;
|
---|
[8] | 41 |
|
---|
[15] | 42 | setMesh(mesh);
|
---|
[8] | 43 |
|
---|
[15] | 44 | if (texture != NULL) {
|
---|
| 45 | setMaterialTexture(0, texture);
|
---|
| 46 | }
|
---|
[8] | 47 |
|
---|
[15] | 48 | parent->Box()->addInternalBox(getTransformedBoundingBox());
|
---|
[8] | 49 | }
|
---|
| 50 |
|
---|
[286] | 51 | MeshSceneNode::MeshSceneNode(ISceneNode *parent, IMesh *mesh,
|
---|
| 52 | const vector3df &position,
|
---|
| 53 | const vector3df &rotation, ITexture *texture,
|
---|
| 54 | s32 id)
|
---|
| 55 | : IMeshSceneNode(parent, getGui()->getSceneManager(), id,
|
---|
| 56 | position, rotation) {
|
---|
| 57 | Material.Wireframe = false;
|
---|
| 58 | Material.Lighting = false;
|
---|
| 59 |
|
---|
| 60 | setMesh(mesh);
|
---|
| 61 |
|
---|
| 62 | if (texture != NULL) {
|
---|
| 63 | setMaterialTexture(0, texture);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | //parent->getBoundingBox().addInternalBox(getTransformedBoundingBox());
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[15] | 69 | void MeshSceneNode::OnRegisterSceneNode(void) {
|
---|
| 70 | if (IsVisible)
|
---|
| 71 | SceneManager->registerNodeForRendering(this);
|
---|
[8] | 72 |
|
---|
[15] | 73 | ISceneNode::OnRegisterSceneNode();
|
---|
[8] | 74 | }
|
---|
| 75 |
|
---|
[15] | 76 | void MeshSceneNode::render(void) {
|
---|
| 77 | IVideoDriver *driver = SceneManager->getVideoDriver();
|
---|
[8] | 78 |
|
---|
[15] | 79 | driver->setMaterial(Material);
|
---|
| 80 | driver->setTransform(ETS_WORLD, AbsoluteTransformation);
|
---|
| 81 | driver->drawMeshBuffer(mesh->getMeshBuffer(0));
|
---|
[8] | 82 | }
|
---|
| 83 |
|
---|
[15] | 84 | SMaterial &MeshSceneNode::getMaterial(u32 i) { return Material; }
|
---|
[8] | 85 |
|
---|
[15] | 86 | void MeshSceneNode::setMesh(IMesh *ptr) {
|
---|
| 87 | mesh = ptr;
|
---|
| 88 | Box = mesh->getBoundingBox();
|
---|
[8] | 89 | }
|
---|
| 90 |
|
---|
[15] | 91 | IMesh *MeshSceneNode::getMesh(void) { return mesh; }
|
---|
[8] | 92 |
|
---|
[15] | 93 | void MeshSceneNode::setReadOnlyMaterials(bool readonly) {}
|
---|
[8] | 94 |
|
---|
| 95 | } // end namespace simulator
|
---|
| 96 | } // end namespace flair
|
---|
[15] | 97 | #endif // GL
|
---|