1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 10:53:51 +00:00

removing tabs

This commit is contained in:
Jason Hooks 2011-11-04 21:57:39 -04:00
parent 6c80e75deb
commit 8edcd4d15b
2 changed files with 71 additions and 72 deletions

View file

@ -23,91 +23,91 @@ bool Objects::lightOutQuadInLin = false;
int Objects::uniqueID = 0; int Objects::uniqueID = 0;
void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
Ogre::SceneNode* root = mRend.getScene()->getRootSceneNode(); Ogre::SceneNode* root = mRend.getScene()->getRootSceneNode();
Ogre::SceneNode* cellnode; Ogre::SceneNode* cellnode;
if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end()) if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
{ {
//Create the scenenode and put it in the map //Create the scenenode and put it in the map
cellnode = root->createChildSceneNode(); cellnode = root->createChildSceneNode();
mCellSceneNodes[ptr.getCell()] = cellnode; mCellSceneNodes[ptr.getCell()] = cellnode;
} }
else else
{ {
cellnode = mCellSceneNodes[ptr.getCell()]; 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]);
insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale); insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale);
// Convert MW rotation to a quaternion: // Convert MW rotation to a quaternion:
f = ptr.getCellRef().pos.rot; f = ptr.getCellRef().pos.rot;
// Rotate around X axis // Rotate around X axis
Quaternion xr(Radian(-f[0]), Vector3::UNIT_X); Quaternion xr(Radian(-f[0]), Vector3::UNIT_X);
// Rotate around Y axis // Rotate around Y axis
Quaternion yr(Radian(-f[1]), Vector3::UNIT_Y); Quaternion yr(Radian(-f[1]), Vector3::UNIT_Y);
// Rotate around Z axis // Rotate around Z axis
Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z); Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z);
// Rotates first around z, then y, then x // Rotates first around z, then y, then x
insert->setOrientation(xr*yr*zr); insert->setOrientation(xr*yr*zr);
if (!enabled) if (!enabled)
insert->setVisible (false); insert->setVisible (false);
ptr.getRefData().setBaseNode(insert); ptr.getRefData().setBaseNode(insert);
isStatic = static_; isStatic = static_;
} }
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle()); Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle());
assert(insert); assert(insert);
NifOgre::NIFLoader::load(mesh); NifOgre::NIFLoader::load(mesh);
Entity *ent = mRend.getScene()->createEntity(mesh); Entity *ent = mRend.getScene()->createEntity(mesh);
if(!isStatic) if(!isStatic)
{ {
insert->attachObject(ent); insert->attachObject(ent);
} }
else else
{ {
Ogre::StaticGeometry* sg; Ogre::StaticGeometry* sg;
if(mSG.find(ptr.getCell()) == mSG.end()) if(mSG.find(ptr.getCell()) == mSG.end())
{ {
uniqueID = uniqueID +1; uniqueID = uniqueID +1;
sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
//Create the scenenode and put it in the map //Create the scenenode and put it in the map
mSG[ptr.getCell()] = sg; mSG[ptr.getCell()] = sg;
} }
else else
{ {
sg = mSG[ptr.getCell()]; 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? sg->build(); //Is this the right place for building?
mRend.getScene()->destroyEntity(ent); mRend.getScene()->destroyEntity(ent);
} }
} }
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){
Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle()); Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle());
assert(insert); assert(insert);
Ogre::Light *light = mRend.getScene()->createLight(); Ogre::Light *light = mRend.getScene()->createLight();
light->setDiffuseColour (r, g, b); light->setDiffuseColour (r, g, b);
float cval=0.0f, lval=0.0f, qval=0.0f; float cval=0.0f, lval=0.0f, qval=0.0f;
if(lightConst) if(lightConst)
cval = lightConstValue; cval = lightConstValue;
if(!lightOutQuadInLin) if(!lightOutQuadInLin)
{ {
if(lightLinear) if(lightLinear)
@ -145,10 +145,10 @@ void Objects::deleteObject (const std::string& handle)
void Objects::removeCell(const MWWorld::Ptr& ptr){ void Objects::removeCell(const MWWorld::Ptr& ptr){
if(mCellSceneNodes.find(ptr.getCell()) != mCellSceneNodes.end()) if(mCellSceneNodes.find(ptr.getCell()) != mCellSceneNodes.end())
{ {
Ogre::SceneNode* base = mCellSceneNodes[ptr.getCell()]; Ogre::SceneNode* base = mCellSceneNodes[ptr.getCell()];
base->removeAndDestroyAllChildren(); base->removeAndDestroyAllChildren();
mRend.getScene()->destroySceneNode(base); mRend.getScene()->destroySceneNode(base);
base = 0; base = 0;
} }

View file

@ -10,9 +10,9 @@ 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; std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mSG;
bool isStatic; bool isStatic;
static int uniqueID; static int uniqueID;
static bool lightConst; static bool lightConst;
static float lightConstValue; static float lightConstValue;
static bool lightLinear; static bool lightLinear;
@ -27,14 +27,13 @@ private:
static bool lightOutQuadInLin; static bool lightOutQuadInLin;
public: public:
Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){ Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){}
}
~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 deleteObject (const std::string& handle);
void removeCell(const MWWorld::Ptr& ptr); 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.