From 41d283a3aabda4143ca277cd0d75e658744b1506 Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 23 May 2011 15:00:01 +0200 Subject: [PATCH] very experimental: static geometry. --- apps/openmw/mwrender/exterior.cpp | 24 ++++++++++++++++++++++-- apps/openmw/mwrender/exterior.hpp | 6 ++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/exterior.cpp b/apps/openmw/mwrender/exterior.cpp index fe54af84ac..01e2fc6273 100644 --- a/apps/openmw/mwrender/exterior.cpp +++ b/apps/openmw/mwrender/exterior.cpp @@ -31,8 +31,21 @@ float ExteriorCellRender::lightQuadraticRadiusMult = 1; bool ExteriorCellRender::lightOutQuadInLin = false; -// start inserting a new reference. +ExteriorCellRender::ExteriorCellRender(ESMS::CellStore &_cell, MWWorld::Environment& environment, + MWScene &_scene) + : mCell(_cell), mEnvironment (environment), mScene(_scene), mBase(NULL), mInsert(NULL), mAmbientMode (0) +{ + //char a = mCell.cell->name; + //char *rand1; + srand (150); + //itoa(rand(),rand1,10); + int a; + Ogre::StringConverter::toString(rand()); + sg = Ogre::Root::getSingleton().getSceneManagerIterator().getNext()->createStaticGeometry( Ogre::StringConverter::toString(a)); +} + +// start inserting a new reference. void ExteriorCellRender::insertBegin (ESM::CellRef &ref) { assert (!mInsert); @@ -202,9 +215,12 @@ void ExteriorCellRender::insertMesh(const std::string &mesh) assert (mInsert); NIFLoader::load(mesh); - MovableObject *ent = mScene.getMgr()->createEntity(mesh); + Entity *ent = mScene.getMgr()->createEntity(mesh); mInsert->attachObject(ent); + /*sg->addEntity(ent,mInsert->_getDerivedPosition(),mInsert->_getDerivedOrientation(),mInsert->_getDerivedScale()); + sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));*/ + if (mInsertMesh.empty()) mInsertMesh = mesh; } @@ -333,6 +349,8 @@ void ExteriorCellRender::show() configureFog(); insertCell(mCell, mEnvironment); + + sg->build(); } void ExteriorCellRender::hide() @@ -350,6 +368,8 @@ void ExteriorCellRender::destroy() } mBase = NULL; + std::cout << "destroy"; + Ogre::Root::getSingleton().getSceneManagerIterator().getNext()->destroyStaticGeometry(sg); } // Switch through lighting modes. diff --git a/apps/openmw/mwrender/exterior.hpp b/apps/openmw/mwrender/exterior.hpp index 93491f263e..c4ce065c2d 100644 --- a/apps/openmw/mwrender/exterior.hpp +++ b/apps/openmw/mwrender/exterior.hpp @@ -57,6 +57,9 @@ namespace MWRender std::string mInsertMesh; Ogre::SceneNode *mNpcPart; + //the static geometry + Ogre::StaticGeometry *sg; + // 0 normal, 1 more bright, 2 max int mAmbientMode; @@ -95,8 +98,7 @@ namespace MWRender public: ExteriorCellRender(ESMS::CellStore &_cell, MWWorld::Environment& environment, - MWScene &_scene) - : mCell(_cell), mEnvironment (environment), mScene(_scene), mBase(NULL), mInsert(NULL), mAmbientMode (0) {} + MWScene &_scene); virtual ~ExteriorCellRender() { destroy(); }