mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
More Objects functionality
This commit is contained in:
parent
e041006063
commit
6c80e75deb
@ -33,8 +33,11 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cellnode = (mCellSceneNodes.find(ptr.getCell()))->second;
|
cellnode = mCellSceneNodes[ptr.getCell()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ogre::SceneNode* insert = cellnode->createChildSceneNode();
|
Ogre::SceneNode* insert = cellnode->createChildSceneNode();
|
||||||
const float *f = ptr.getCellRef().pos.pos;
|
const float *f = ptr.getCellRef().pos.pos;
|
||||||
insert->setPosition(f[0], f[1], f[2]);
|
insert->setPosition(f[0], f[1], f[2]);
|
||||||
@ -74,8 +77,23 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Ogre::StaticGeometry* sg;
|
||||||
|
if(mSG.find(ptr.getCell()) == mSG.end())
|
||||||
|
{
|
||||||
|
uniqueID = uniqueID +1;
|
||||||
|
sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
|
||||||
|
//Create the scenenode and put it in the map
|
||||||
|
mSG[ptr.getCell()] = sg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sg = mSG[ptr.getCell()];
|
||||||
|
}
|
||||||
|
|
||||||
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
|
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
|
||||||
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
||||||
|
|
||||||
|
sg->build(); //Is this the right place for building?
|
||||||
mRend.getScene()->destroyEntity(ent);
|
mRend.getScene()->destroyEntity(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,3 +132,31 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f
|
|||||||
insert->attachObject(light);
|
insert->attachObject(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Objects::deleteObject (const std::string& handle)
|
||||||
|
{
|
||||||
|
if (!handle.empty())
|
||||||
|
{
|
||||||
|
Ogre::SceneNode *node = mRend.getScene()->getSceneNode (handle);
|
||||||
|
node->removeAndDestroyAllChildren();
|
||||||
|
mRend.getScene()->destroySceneNode (node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Objects::removeCell(const MWWorld::Ptr& ptr){
|
||||||
|
if(mCellSceneNodes.find(ptr.getCell()) != mCellSceneNodes.end())
|
||||||
|
{
|
||||||
|
Ogre::SceneNode* base = mCellSceneNodes[ptr.getCell()];
|
||||||
|
base->removeAndDestroyAllChildren();
|
||||||
|
mRend.getScene()->destroySceneNode(base);
|
||||||
|
base = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(mSG.find(ptr.getCell()) != mSG.end())
|
||||||
|
{
|
||||||
|
Ogre::StaticGeometry* sg = mSG[ptr.getCell()];
|
||||||
|
mRend.getScene()->destroyStaticGeometry (sg);
|
||||||
|
sg = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ class Objects{
|
|||||||
private:
|
private:
|
||||||
OEngine::Render::OgreRenderer &mRend;
|
OEngine::Render::OgreRenderer &mRend;
|
||||||
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
|
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
|
||||||
|
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mSG;
|
||||||
bool isStatic;
|
bool isStatic;
|
||||||
Ogre::StaticGeometry *sg;
|
|
||||||
static int uniqueID;
|
static int uniqueID;
|
||||||
static bool lightConst;
|
static bool lightConst;
|
||||||
static float lightConstValue;
|
static float lightConstValue;
|
||||||
@ -28,13 +28,13 @@ private:
|
|||||||
static bool lightOutQuadInLin;
|
static bool lightOutQuadInLin;
|
||||||
public:
|
public:
|
||||||
Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){
|
Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){
|
||||||
uniqueID = uniqueID +1;
|
|
||||||
sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
|
|
||||||
}
|
}
|
||||||
~Objects(){}
|
~Objects(){}
|
||||||
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
|
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
|
||||||
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
|
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||||
void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius);
|
void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius);
|
||||||
|
void deleteObject (const std::string& handle);
|
||||||
|
void removeCell(const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
/// insert a light related to the most recent insertBegin call.
|
/// insert a light related to the most recent insertBegin call.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user