| 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: 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 |
|
---|
| 30 | namespace flair
|
---|
| 31 | {
|
---|
| 32 | namespace simulator
|
---|
| 33 | {
|
---|
| 34 |
|
---|
| 35 | MeshSceneNode::MeshSceneNode(Model* parent,IMesh* mesh,
|
---|
| 36 | const vector3df& position ,const vector3df& rotation,
|
---|
| 37 | ITexture* texture, s32 id ): IMeshSceneNode(parent->getSceneNode(), getGui()->getSceneManager(), id,position,rotation)
|
---|
| 38 | {
|
---|
| 39 | Material.Wireframe = false;
|
---|
| 40 | Material.Lighting = false;
|
---|
| 41 |
|
---|
| 42 | setMesh(mesh);
|
---|
| 43 |
|
---|
| 44 | if(texture!=NULL)
|
---|
| 45 | {
|
---|
| 46 | setMaterialTexture(0,texture);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | parent->Box()->addInternalBox(getTransformedBoundingBox());
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | void MeshSceneNode::OnRegisterSceneNode(void)
|
---|
| 54 | {
|
---|
| 55 | if (IsVisible)
|
---|
| 56 | SceneManager->registerNodeForRendering(this);
|
---|
| 57 |
|
---|
| 58 | ISceneNode::OnRegisterSceneNode();
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | void MeshSceneNode::render(void)
|
---|
| 62 | {
|
---|
| 63 | IVideoDriver* driver = SceneManager->getVideoDriver();
|
---|
| 64 |
|
---|
| 65 | driver->setMaterial(Material);
|
---|
| 66 | driver->setTransform(ETS_WORLD, AbsoluteTransformation);
|
---|
| 67 | driver->drawMeshBuffer(mesh->getMeshBuffer(0));
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | SMaterial& MeshSceneNode::getMaterial(u32 i)
|
---|
| 72 | {
|
---|
| 73 | return Material;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | void MeshSceneNode::setMesh(IMesh* ptr)
|
---|
| 77 | {
|
---|
| 78 | mesh=ptr;
|
---|
| 79 | Box=mesh->getBoundingBox();
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | IMesh* MeshSceneNode::getMesh(void)
|
---|
| 84 | {
|
---|
| 85 | return mesh;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | void MeshSceneNode::setReadOnlyMaterials(bool readonly)
|
---|
| 90 | {
|
---|
| 91 |
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | } // end namespace simulator
|
---|
| 95 | } // end namespace flair
|
---|
| 96 | #endif //GL
|
---|