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

Rename EntityList to ObjectList

This commit is contained in:
Chris Robinson 2013-04-07 01:52:35 -07:00
parent 834a6a1f00
commit 2db72ae607
10 changed files with 129 additions and 129 deletions

View file

@ -25,10 +25,10 @@ ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
{ {
std::string mesh = "meshes\\" + ref->mBase->mModel; std::string mesh = "meshes\\" + ref->mBase->mModel;
createEntityList(mPtr.getRefData().getBaseNode(), mesh); createObjectList(mPtr.getRefData().getBaseNode(), mesh);
for(size_t i = 0;i < mEntityList.mEntities.size();i++) for(size_t i = 0;i < mObjectList.mEntities.size();i++)
{ {
Ogre::Entity *ent = mEntityList.mEntities[i]; Ogre::Entity *ent = mObjectList.mEntities[i];
for(unsigned int j=0; j < ent->getNumSubEntities(); ++j) for(unsigned int j=0; j < ent->getNumSubEntities(); ++j)
{ {

View file

@ -40,21 +40,21 @@ Animation::~Animation()
if(mInsert) if(mInsert)
{ {
Ogre::SceneManager *sceneMgr = mInsert->getCreator(); Ogre::SceneManager *sceneMgr = mInsert->getCreator();
for(size_t i = 0;i < mEntityList.mParticles.size();i++) for(size_t i = 0;i < mObjectList.mParticles.size();i++)
sceneMgr->destroyParticleSystem(mEntityList.mParticles[i]); sceneMgr->destroyParticleSystem(mObjectList.mParticles[i]);
for(size_t i = 0;i < mEntityList.mEntities.size();i++) for(size_t i = 0;i < mObjectList.mEntities.size();i++)
sceneMgr->destroyEntity(mEntityList.mEntities[i]); sceneMgr->destroyEntity(mObjectList.mEntities[i]);
} }
mEntityList.mControllers.clear(); mObjectList.mControllers.clear();
mEntityList.mParticles.clear(); mObjectList.mParticles.clear();
mEntityList.mEntities.clear(); mObjectList.mEntities.clear();
mEntityList.mSkelBase = NULL; mObjectList.mSkelBase = NULL;
} }
void Animation::setAnimationSources(const std::vector<std::string> &names) void Animation::setAnimationSources(const std::vector<std::string> &names)
{ {
if(!mEntityList.mSkelBase) if(!mObjectList.mSkelBase)
return; return;
mCurrentAnim = NULL; mCurrentAnim = NULL;
@ -87,7 +87,7 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
if(!mNonAccumRoot) if(!mNonAccumRoot)
{ {
mAccumRoot = mInsert; mAccumRoot = mInsert;
mNonAccumRoot = mEntityList.mSkelBase->getSkeleton()->getBone(bone->getName()); mNonAccumRoot = mObjectList.mSkelBase->getSkeleton()->getBone(bone->getName());
} }
mSkeletonSources.push_back(skel); mSkeletonSources.push_back(skel);
@ -105,15 +105,15 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
} }
} }
void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model) void Animation::createObjectList(Ogre::SceneNode *node, const std::string &model)
{ {
mInsert = node->createChildSceneNode(); mInsert = node->createChildSceneNode();
assert(mInsert); assert(mInsert);
mEntityList = NifOgre::Loader::createEntities(mInsert, model); mObjectList = NifOgre::Loader::createObjects(mInsert, model);
if(mEntityList.mSkelBase) if(mObjectList.mSkelBase)
{ {
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates(); Ogre::AnimationStateSet *aset = mObjectList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator(); Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator();
while(asiter.hasMoreElements()) while(asiter.hasMoreElements())
{ {
@ -125,17 +125,17 @@ void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model
// Set the bones as manually controlled since we're applying the // Set the bones as manually controlled since we're applying the
// transformations manually (needed if we want to apply an animation // transformations manually (needed if we want to apply an animation
// from one skeleton onto another). // from one skeleton onto another).
Ogre::SkeletonInstance *skelinst = mEntityList.mSkelBase->getSkeleton(); Ogre::SkeletonInstance *skelinst = mObjectList.mSkelBase->getSkeleton();
Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator(); Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator();
while(boneiter.hasMoreElements()) while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true); boneiter.getNext()->setManuallyControlled(true);
} }
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > ctrlval(OGRE_NEW AnimationValue(this)); Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > ctrlval(OGRE_NEW AnimationValue(this));
for(size_t i = 0;i < mEntityList.mControllers.size();i++) for(size_t i = 0;i < mObjectList.mControllers.size();i++)
{ {
if(mEntityList.mControllers[i].getSource().isNull()) if(mObjectList.mControllers[i].getSource().isNull())
mEntityList.mControllers[i].setSource(ctrlval); mObjectList.mControllers[i].setSource(ctrlval);
} }
} }
@ -242,7 +242,7 @@ void Animation::applyAnimation(const Ogre::Animation *anim, float time, Ogre::Sk
// HACK: Dirty the animation state set so that Ogre will apply the // HACK: Dirty the animation state set so that Ogre will apply the
// transformations to entities this skeleton instance is shared with. // transformations to entities this skeleton instance is shared with.
mEntityList.mSkelBase->getAllAnimationStates()->_notifyDirty(); mObjectList.mSkelBase->getAllAnimationStates()->_notifyDirty();
} }
static void updateBoneTree(const Ogre::SkeletonInstance *skelsrc, Ogre::Bone *bone) static void updateBoneTree(const Ogre::SkeletonInstance *skelsrc, Ogre::Bone *bone)
@ -289,7 +289,7 @@ Ogre::Vector3 Animation::updatePosition(float time)
mCurrentTime = std::fmod(std::max(time, 0.0f), mCurrentAnim->getLength()); mCurrentTime = std::fmod(std::max(time, 0.0f), mCurrentAnim->getLength());
else else
mCurrentTime = std::min(mCurrentAnim->getLength(), std::max(time, 0.0f)); mCurrentTime = std::min(mCurrentAnim->getLength(), std::max(time, 0.0f));
applyAnimation(mCurrentAnim, mCurrentTime, mEntityList.mSkelBase->getSkeleton()); applyAnimation(mCurrentAnim, mCurrentTime, mObjectList.mSkelBase->getSkeleton());
Ogre::Vector3 posdiff = Ogre::Vector3::ZERO; Ogre::Vector3 posdiff = Ogre::Vector3::ZERO;
if(mNonAccumRoot) if(mNonAccumRoot)
@ -465,8 +465,8 @@ Ogre::Vector3 Animation::runAnimation(float timepassed)
if(!handleEvent(time, evt)) if(!handleEvent(time, evt))
break; break;
} }
for(size_t i = 0;i < mEntityList.mControllers.size();i++) for(size_t i = 0;i < mObjectList.mControllers.size();i++)
mEntityList.mControllers[i].update(); mObjectList.mControllers[i].update();
return movement; return movement;
} }

View file

@ -40,7 +40,7 @@ protected:
MWMechanics::CharacterController *mController; MWMechanics::CharacterController *mController;
Ogre::SceneNode* mInsert; Ogre::SceneNode* mInsert;
NifOgre::EntityList mEntityList; NifOgre::ObjectList mObjectList;
std::map<std::string,NifOgre::TextKeyMap> mTextKeys; std::map<std::string,NifOgre::TextKeyMap> mTextKeys;
Ogre::Node *mAccumRoot; Ogre::Node *mAccumRoot;
Ogre::Bone *mNonAccumRoot; Ogre::Bone *mNonAccumRoot;
@ -91,7 +91,7 @@ protected:
setAnimationSources(names); setAnimationSources(names);
} }
void createEntityList(Ogre::SceneNode *node, const std::string &model); void createObjectList(Ogre::SceneNode *node, const std::string &model);
public: public:
Animation(const MWWorld::Ptr &ptr); Animation(const MWWorld::Ptr &ptr);

View file

@ -25,10 +25,10 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
{ {
std::string model = "meshes\\"+ref->mBase->mModel; std::string model = "meshes\\"+ref->mBase->mModel;
createEntityList(mPtr.getRefData().getBaseNode(), model); createObjectList(mPtr.getRefData().getBaseNode(), model);
for(size_t i = 0;i < mEntityList.mEntities.size();i++) for(size_t i = 0;i < mObjectList.mEntities.size();i++)
{ {
Ogre::Entity *ent = mEntityList.mEntities[i]; Ogre::Entity *ent = mObjectList.mEntities[i];
ent->setVisibilityFlags(RV_Actors); ent->setVisibilityFlags(RV_Actors);
for(unsigned int j=0; j < ent->getNumSubEntities(); ++j) for(unsigned int j=0; j < ent->getNumSubEntities(); ++j)

View file

@ -50,7 +50,7 @@ const NpcAnimation::PartInfo NpcAnimation::sPartList[NpcAnimation::sPartListSize
NpcAnimation::~NpcAnimation() NpcAnimation::~NpcAnimation()
{ {
for(size_t i = 0;i < sPartListSize;i++) for(size_t i = 0;i < sPartListSize;i++)
removeEntities(mEntityParts[i]); removeObjects(mObjectParts[i]);
} }
@ -94,10 +94,10 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0; bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
createEntityList(node, smodel); createObjectList(node, smodel);
for(size_t i = 0;i < mEntityList.mEntities.size();i++) for(size_t i = 0;i < mObjectList.mEntities.size();i++)
{ {
Ogre::Entity *base = mEntityList.mEntities[i]; Ogre::Entity *base = mObjectList.mEntities[i];
base->getUserObjectBindings().setUserAny(Ogre::Any(-1)); base->getUserObjectBindings().setUserAny(Ogre::Any(-1));
if (mVisibilityFlags != 0) if (mVisibilityFlags != 0)
@ -302,11 +302,11 @@ void NpcAnimation::updateParts(bool forceupdate)
} }
} }
NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int group, const std::string &bonename) NifOgre::ObjectList NpcAnimation::insertBoundedPart(const std::string &model, int group, const std::string &bonename)
{ {
NifOgre::EntityList entities = NifOgre::Loader::createEntities(mEntityList.mSkelBase, bonename, NifOgre::ObjectList objects = NifOgre::Loader::createObjects(mObjectList.mSkelBase, bonename,
mInsert, mesh); mInsert, model);
std::vector<Ogre::Entity*> &parts = entities.mEntities; const std::vector<Ogre::Entity*> &parts = objects.mEntities;
for(size_t i = 0;i < parts.size();i++) for(size_t i = 0;i < parts.size();i++)
{ {
parts[i]->getUserObjectBindings().setUserAny(Ogre::Any(group)); parts[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
@ -319,9 +319,9 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main); subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
} }
} }
if(entities.mSkelBase) if(objects.mSkelBase)
{ {
Ogre::AnimationStateSet *aset = entities.mSkelBase->getAllAnimationStates(); Ogre::AnimationStateSet *aset = objects.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator(); Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator();
while(asiter.hasMoreElements()) while(asiter.hasMoreElements())
{ {
@ -329,12 +329,12 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
state->setEnabled(false); state->setEnabled(false);
state->setLoop(false); state->setLoop(false);
} }
Ogre::SkeletonInstance *skelinst = entities.mSkelBase->getSkeleton(); Ogre::SkeletonInstance *skelinst = objects.mSkelBase->getSkeleton();
Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator(); Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator();
while(boneiter.hasMoreElements()) while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true); boneiter.getNext()->setManuallyControlled(true);
} }
return entities; return objects;
} }
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed) Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
@ -347,10 +347,10 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
mTimeToChange -= timepassed; mTimeToChange -= timepassed;
Ogre::Vector3 ret = Animation::runAnimation(timepassed); Ogre::Vector3 ret = Animation::runAnimation(timepassed);
const Ogre::SkeletonInstance *skelsrc = mEntityList.mSkelBase->getSkeleton(); const Ogre::SkeletonInstance *skelsrc = mObjectList.mSkelBase->getSkeleton();
for(size_t i = 0;i < sPartListSize;i++) for(size_t i = 0;i < sPartListSize;i++)
{ {
Ogre::Entity *ent = mEntityParts[i].mSkelBase; Ogre::Entity *ent = mObjectParts[i].mSkelBase;
if(!ent) continue; if(!ent) continue;
updateSkeletonInstance(skelsrc, ent->getSkeleton()); updateSkeletonInstance(skelsrc, ent->getSkeleton());
ent->getAllAnimationStates()->_notifyDirty(); ent->getAllAnimationStates()->_notifyDirty();
@ -358,19 +358,19 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
return ret; return ret;
} }
void NpcAnimation::removeEntities(NifOgre::EntityList &entities) void NpcAnimation::removeObjects(NifOgre::ObjectList &objects)
{ {
assert(&entities != &mEntityList); assert(&objects != &mObjectList);
Ogre::SceneManager *sceneMgr = mInsert->getCreator(); Ogre::SceneManager *sceneMgr = mInsert->getCreator();
for(size_t i = 0;i < entities.mParticles.size();i++) for(size_t i = 0;i < objects.mParticles.size();i++)
sceneMgr->destroyParticleSystem(entities.mParticles[i]); sceneMgr->destroyParticleSystem(objects.mParticles[i]);
for(size_t i = 0;i < entities.mEntities.size();i++) for(size_t i = 0;i < objects.mEntities.size();i++)
sceneMgr->destroyEntity(entities.mEntities[i]); sceneMgr->destroyEntity(objects.mEntities[i]);
entities.mControllers.clear(); objects.mControllers.clear();
entities.mParticles.clear(); objects.mParticles.clear();
entities.mEntities.clear(); objects.mEntities.clear();
entities.mSkelBase = NULL; objects.mSkelBase = NULL;
} }
void NpcAnimation::removeIndividualPart(int type) void NpcAnimation::removeIndividualPart(int type)
@ -382,7 +382,7 @@ void NpcAnimation::removeIndividualPart(int type)
{ {
if(type == sPartList[i].type) if(type == sPartList[i].type)
{ {
removeEntities(mEntityParts[i]); removeObjects(mObjectParts[i]);
break; break;
} }
} }
@ -420,7 +420,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority,
{ {
if(type == sPartList[i].type) if(type == sPartList[i].type)
{ {
mEntityParts[i] = insertBoundedPart(mesh, group, sPartList[i].name); mObjectParts[i] = insertBoundedPart(mesh, group, sPartList[i].name);
break; break;
} }
} }
@ -451,7 +451,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
Ogre::Node* NpcAnimation::getHeadNode() Ogre::Node* NpcAnimation::getHeadNode()
{ {
return mEntityList.mSkelBase->getSkeleton()->getBone("Bip01 Head"); return mObjectList.mSkelBase->getSkeleton()->getBone("Bip01 Head");
} }
} }

View file

@ -33,7 +33,7 @@ private:
int mStateID; int mStateID;
// Bounded Parts // Bounded Parts
NifOgre::EntityList mEntityParts[sPartListSize]; NifOgre::ObjectList mObjectParts[sPartListSize];
const ESM::NPC *mNpc; const ESM::NPC *mNpc;
std::string mHeadModel; std::string mHeadModel;
@ -60,11 +60,11 @@ private:
int mPartslots[sPartListSize]; //Each part slot is taken by clothing, armor, or is empty int mPartslots[sPartListSize]; //Each part slot is taken by clothing, armor, or is empty
int mPartPriorities[sPartListSize]; int mPartPriorities[sPartListSize];
NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename); NifOgre::ObjectList insertBoundedPart(const std::string &model, int group, const std::string &bonename);
void updateParts(bool forceupdate = false); void updateParts(bool forceupdate = false);
void removeEntities(NifOgre::EntityList &entities); void removeObjects(NifOgre::ObjectList &objects);
void removeIndividualPart(int type); void removeIndividualPart(int type);
void reserveIndividualPart(int type, int group, int priority); void reserveIndividualPart(int type, int group, int priority);

View file

@ -130,9 +130,9 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
assert(insert); assert(insert);
Ogre::AxisAlignedBox bounds = Ogre::AxisAlignedBox::BOX_NULL; Ogre::AxisAlignedBox bounds = Ogre::AxisAlignedBox::BOX_NULL;
NifOgre::EntityList entities = NifOgre::Loader::createEntities(insert, mesh); NifOgre::ObjectList objects = NifOgre::Loader::createObjects(insert, mesh);
for(size_t i = 0;i < entities.mEntities.size();i++) for(size_t i = 0;i < objects.mEntities.size();i++)
bounds.merge(entities.mEntities[i]->getWorldBoundingBox(true)); bounds.merge(objects.mEntities[i]->getWorldBoundingBox(true));
Ogre::Vector3 extents = bounds.getSize(); Ogre::Vector3 extents = bounds.getSize();
extents *= insert->getScale(); extents *= insert->getScale();
@ -149,9 +149,9 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
mBounds[ptr.getCell()].merge(bounds); mBounds[ptr.getCell()].merge(bounds);
bool anyTransparency = false; bool anyTransparency = false;
for(size_t i = 0;!anyTransparency && i < entities.mEntities.size();i++) for(size_t i = 0;!anyTransparency && i < objects.mEntities.size();i++)
{ {
Ogre::Entity *ent = entities.mEntities[i]; Ogre::Entity *ent = objects.mEntities[i];
for(unsigned int i=0;!anyTransparency && i < ent->getNumSubEntities(); ++i) for(unsigned int i=0;!anyTransparency && i < ent->getNumSubEntities(); ++i)
{ {
anyTransparency = ent->getSubEntity(i)->getMaterial()->isTransparent(); anyTransparency = ent->getSubEntity(i)->getMaterial()->isTransparent();
@ -159,11 +159,11 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
} }
if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") || if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") ||
anyTransparency || entities.mParticles.size() > 0) anyTransparency || objects.mParticles.size() > 0)
{ {
for(size_t i = 0;i < entities.mEntities.size();i++) for(size_t i = 0;i < objects.mEntities.size();i++)
{ {
Ogre::Entity *ent = entities.mEntities[i]; Ogre::Entity *ent = objects.mEntities[i];
for(unsigned int i=0; i < ent->getNumSubEntities(); ++i) for(unsigned int i=0; i < ent->getNumSubEntities(); ++i)
{ {
Ogre::SubEntity* subEnt = ent->getSubEntity(i); Ogre::SubEntity* subEnt = ent->getSubEntity(i);
@ -172,9 +172,9 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0); ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0);
ent->setVisibilityFlags(mIsStatic ? (small ? RV_StaticsSmall : RV_Statics) : RV_Misc); ent->setVisibilityFlags(mIsStatic ? (small ? RV_StaticsSmall : RV_Statics) : RV_Misc);
} }
for(size_t i = 0;i < entities.mParticles.size();i++) for(size_t i = 0;i < objects.mParticles.size();i++)
{ {
Ogre::ParticleSystem *part = entities.mParticles[i]; Ogre::ParticleSystem *part = objects.mParticles[i];
// TODO: Check the particle system's material for actual transparency // TODO: Check the particle system's material for actual transparency
part->setRenderQueueGroup(RQG_Alpha); part->setRenderQueueGroup(RQG_Alpha);
part->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0); part->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0);
@ -225,8 +225,8 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
sg->setRenderQueueGroup(RQG_Main); sg->setRenderQueueGroup(RQG_Main);
std::vector<Ogre::Entity*>::reverse_iterator iter = entities.mEntities.rbegin(); std::vector<Ogre::Entity*>::reverse_iterator iter = objects.mEntities.rbegin();
while(iter != entities.mEntities.rend()) while(iter != objects.mEntities.rend())
{ {
Ogre::Node *node = (*iter)->getParentNode(); Ogre::Node *node = (*iter)->getParentNode();
sg->addEntity(*iter, node->_getDerivedPosition(), node->_getDerivedOrientation(), node->_getDerivedScale()); sg->addEntity(*iter, node->_getDerivedPosition(), node->_getDerivedOrientation(), node->_getDerivedScale());
@ -239,7 +239,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
if (light) if (light)
{ {
insertLight(ptr, entities.mSkelBase, bounds.getCenter() - insert->_getDerivedPosition()); insertLight(ptr, objects.mSkelBase, bounds.getCenter() - insert->_getDerivedPosition());
} }
} }

View file

@ -288,10 +288,10 @@ void SkyManager::create()
// Stars // Stars
mAtmosphereNight = mRootNode->createChildSceneNode(); mAtmosphereNight = mRootNode->createChildSceneNode();
NifOgre::EntityList entities = NifOgre::Loader::createEntities(mAtmosphereNight, "meshes\\sky_night_01.nif"); NifOgre::ObjectList objects = NifOgre::Loader::createObjects(mAtmosphereNight, "meshes\\sky_night_01.nif");
for(size_t i = 0, matidx = 0;i < entities.mEntities.size();i++) for(size_t i = 0, matidx = 0;i < objects.mEntities.size();i++)
{ {
Entity* night1_ent = entities.mEntities[i]; Entity* night1_ent = objects.mEntities[i];
night1_ent->setRenderQueueGroup(RQG_SkiesEarly+1); night1_ent->setRenderQueueGroup(RQG_SkiesEarly+1);
night1_ent->setVisibilityFlags(RV_Sky); night1_ent->setVisibilityFlags(RV_Sky);
night1_ent->setCastShadows(false); night1_ent->setCastShadows(false);
@ -314,10 +314,10 @@ void SkyManager::create()
// Atmosphere (day) // Atmosphere (day)
mAtmosphereDay = mRootNode->createChildSceneNode(); mAtmosphereDay = mRootNode->createChildSceneNode();
entities = NifOgre::Loader::createEntities(mAtmosphereDay, "meshes\\sky_atmosphere.nif"); objects = NifOgre::Loader::createObjects(mAtmosphereDay, "meshes\\sky_atmosphere.nif");
for(size_t i = 0;i < entities.mEntities.size();i++) for(size_t i = 0;i < objects.mEntities.size();i++)
{ {
Entity* atmosphere_ent = entities.mEntities[i]; Entity* atmosphere_ent = objects.mEntities[i];
atmosphere_ent->setCastShadows(false); atmosphere_ent->setCastShadows(false);
atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly); atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly);
atmosphere_ent->setVisibilityFlags(RV_Sky); atmosphere_ent->setVisibilityFlags(RV_Sky);
@ -332,10 +332,10 @@ void SkyManager::create()
// Clouds // Clouds
SceneNode* clouds_node = mRootNode->createChildSceneNode(); SceneNode* clouds_node = mRootNode->createChildSceneNode();
entities = NifOgre::Loader::createEntities(clouds_node, "meshes\\sky_clouds_01.nif"); objects = NifOgre::Loader::createObjects(clouds_node, "meshes\\sky_clouds_01.nif");
for(size_t i = 0;i < entities.mEntities.size();i++) for(size_t i = 0;i < objects.mEntities.size();i++)
{ {
Entity* clouds_ent = entities.mEntities[i]; Entity* clouds_ent = objects.mEntities[i];
clouds_ent->setVisibilityFlags(RV_Sky); clouds_ent->setVisibilityFlags(RV_Sky);
clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5); clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5);
for(unsigned int j = 0;j < clouds_ent->getNumSubEntities();j++) for(unsigned int j = 0;j < clouds_ent->getNumSubEntities();j++)

View file

@ -1421,7 +1421,7 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
createSubMesh(mesh, dynamic_cast<const Nif::NiTriShape*>(record)); createSubMesh(mesh, dynamic_cast<const Nif::NiTriShape*>(record));
} }
void createObjects(Ogre::SceneManager *sceneMgr, const Nif::Node *node, EntityList &entities, int flags=0) void createObjects(Ogre::SceneManager *sceneMgr, const Nif::Node *node, ObjectList &objectlist, int flags=0)
{ {
// Do not create objects for the collision shape (includes all children) // Do not create objects for the collision shape (includes all children)
if(node->recType == Nif::RC_RootCollisionNode) if(node->recType == Nif::RC_RootCollisionNode)
@ -1460,12 +1460,12 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
const Nif::NiVisController *vis = static_cast<const Nif::NiVisController*>(ctrl.getPtr()); const Nif::NiVisController *vis = static_cast<const Nif::NiVisController*>(ctrl.getPtr());
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(mName, ctrl->target->recIndex); int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(mName, ctrl->target->recIndex);
Ogre::Bone *trgtbone = entities.mSkelBase->getSkeleton()->getBone(trgtid); Ogre::Bone *trgtbone = objectlist.mSkelBase->getSkeleton()->getBone(trgtid);
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > srcval; /* Filled in later */ Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > srcval; /* Filled in later */
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > dstval(OGRE_NEW VisController::Value(trgtbone)); Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > dstval(OGRE_NEW VisController::Value(trgtbone));
Ogre::SharedPtr<Ogre::ControllerFunction<Ogre::Real> > func(OGRE_NEW VisController::Function(vis->data.getPtr())); Ogre::SharedPtr<Ogre::ControllerFunction<Ogre::Real> > func(OGRE_NEW VisController::Function(vis->data.getPtr()));
entities.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func)); objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
} }
ctrl = ctrl->next; ctrl = ctrl->next;
} }
@ -1494,16 +1494,16 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
Ogre::Entity *entity = sceneMgr->createEntity(mesh); Ogre::Entity *entity = sceneMgr->createEntity(mesh);
entity->setVisible(!(flags&0x01)); entity->setVisible(!(flags&0x01));
entities.mEntities.push_back(entity); objectlist.mEntities.push_back(entity);
if(entities.mSkelBase) if(objectlist.mSkelBase)
{ {
if(entity->hasSkeleton()) if(entity->hasSkeleton())
entity->shareSkeletonInstanceWith(entities.mSkelBase); entity->shareSkeletonInstanceWith(objectlist.mSkelBase);
else else
{ {
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(mName, shape->recIndex); int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(mName, shape->recIndex);
Ogre::Bone *trgtbone = entities.mSkelBase->getSkeleton()->getBone(trgtid); Ogre::Bone *trgtbone = objectlist.mSkelBase->getSkeleton()->getBone(trgtid);
entities.mSkelBase->attachObjectToBone(trgtbone->getName(), entity); objectlist.mSkelBase->attachObjectToBone(trgtbone->getName(), entity);
} }
} }
@ -1519,7 +1519,7 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
Ogre::ControllerValueRealPtr dstval(OGRE_NEW UVController::Value(material, uv->data.getPtr())); Ogre::ControllerValueRealPtr dstval(OGRE_NEW UVController::Value(material, uv->data.getPtr()));
Ogre::ControllerFunctionRealPtr func(OGRE_NEW UVController::Function(uv)); Ogre::ControllerFunctionRealPtr func(OGRE_NEW UVController::Function(uv));
entities.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func)); objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
} }
ctrl = ctrl->next; ctrl = ctrl->next;
} }
@ -1528,11 +1528,11 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
if(node->recType == Nif::RC_NiAutoNormalParticles || if(node->recType == Nif::RC_NiAutoNormalParticles ||
node->recType == Nif::RC_NiRotatingParticles) node->recType == Nif::RC_NiRotatingParticles)
{ {
Ogre::ParticleSystem *partsys = createParticleSystem(sceneMgr, entities.mSkelBase, node); Ogre::ParticleSystem *partsys = createParticleSystem(sceneMgr, objectlist.mSkelBase, node);
if(partsys != NULL) if(partsys != NULL)
{ {
partsys->setVisible(!(flags&0x01)); partsys->setVisible(!(flags&0x01));
entities.mParticles.push_back(partsys); objectlist.mParticles.push_back(partsys);
} }
} }
@ -1543,12 +1543,12 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
for(size_t i = 0;i < children.length();i++) for(size_t i = 0;i < children.length();i++)
{ {
if(!children[i].empty()) if(!children[i].empty())
createObjects(sceneMgr, children[i].getPtr(), entities, flags); createObjects(sceneMgr, children[i].getPtr(), objectlist, flags);
} }
} }
} }
void createSkelBase(Ogre::SceneManager *sceneMgr, const Nif::Node *node, EntityList &entities) void createSkelBase(Ogre::SceneManager *sceneMgr, const Nif::Node *node, ObjectList &objectlist)
{ {
/* This creates an empty mesh to which a skeleton gets attached. This /* This creates an empty mesh to which a skeleton gets attached. This
* is to ensure we have an entity with a skeleton instance, even if all * is to ensure we have an entity with a skeleton instance, even if all
@ -1567,15 +1567,15 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
mesh = meshMgr.createManual(fullname, mGroup, loader); mesh = meshMgr.createManual(fullname, mGroup, loader);
mesh->setAutoBuildEdgeLists(false); mesh->setAutoBuildEdgeLists(false);
} }
entities.mSkelBase = sceneMgr->createEntity(mesh); objectlist.mSkelBase = sceneMgr->createEntity(mesh);
entities.mEntities.push_back(entities.mSkelBase); objectlist.mEntities.push_back(objectlist.mSkelBase);
} }
public: public:
NIFObjectLoader() : mShapeIndex(~(size_t)0) NIFObjectLoader() : mShapeIndex(~(size_t)0)
{ } { }
static void load(Ogre::SceneManager *sceneMgr, EntityList &entities, const std::string &name, const std::string &group) static void load(Ogre::SceneManager *sceneMgr, ObjectList &objectlist, const std::string &name, const std::string &group)
{ {
Nif::NIFFile::ptr pnif = Nif::NIFFile::create(name); Nif::NIFFile::ptr pnif = Nif::NIFFile::create(name);
Nif::NIFFile &nif = *pnif.get(); Nif::NIFFile &nif = *pnif.get();
@ -1603,44 +1603,44 @@ public:
NIFObjectLoader meshldr(name, group); NIFObjectLoader meshldr(name, group);
if(hasSkel) if(hasSkel)
meshldr.createSkelBase(sceneMgr, node, entities); meshldr.createSkelBase(sceneMgr, node, objectlist);
meshldr.createObjects(sceneMgr, node, entities); meshldr.createObjects(sceneMgr, node, objectlist);
} }
}; };
NIFObjectLoader::LoaderMap NIFObjectLoader::sLoaders; NIFObjectLoader::LoaderMap NIFObjectLoader::sLoaders;
EntityList Loader::createEntities(Ogre::SceneNode *parentNode, std::string name, const std::string &group) ObjectList Loader::createObjects(Ogre::SceneNode *parentNode, std::string name, const std::string &group)
{ {
EntityList entitylist; ObjectList objectlist;
Misc::StringUtils::toLower(name); Misc::StringUtils::toLower(name);
NIFObjectLoader::load(parentNode->getCreator(), entitylist, name, group); NIFObjectLoader::load(parentNode->getCreator(), objectlist, name, group);
for(size_t i = 0;i < entitylist.mEntities.size();i++) for(size_t i = 0;i < objectlist.mEntities.size();i++)
{ {
Ogre::Entity *entity = entitylist.mEntities[i]; Ogre::Entity *entity = objectlist.mEntities[i];
if(!entity->isAttached()) if(!entity->isAttached())
parentNode->attachObject(entity); parentNode->attachObject(entity);
} }
return entitylist; return objectlist;
} }
EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonename, ObjectList Loader::createObjects(Ogre::Entity *parent, const std::string &bonename,
Ogre::SceneNode *parentNode, Ogre::SceneNode *parentNode,
std::string name, const std::string &group) std::string name, const std::string &group)
{ {
EntityList entitylist; ObjectList objectlist;
Misc::StringUtils::toLower(name); Misc::StringUtils::toLower(name);
NIFObjectLoader::load(parentNode->getCreator(), entitylist, name, group); NIFObjectLoader::load(parentNode->getCreator(), objectlist, name, group);
bool isskinned = false; bool isskinned = false;
for(size_t i = 0;i < entitylist.mEntities.size();i++) for(size_t i = 0;i < objectlist.mEntities.size();i++)
{ {
Ogre::Entity *ent = entitylist.mEntities[i]; Ogre::Entity *ent = objectlist.mEntities[i];
if(entitylist.mSkelBase != ent && ent->hasSkeleton()) if(objectlist.mSkelBase != ent && ent->hasSkeleton())
{ {
isskinned = true; isskinned = true;
break; break;
@ -1655,12 +1655,12 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
{ {
std::string filter = "@shape=tri "+bonename; std::string filter = "@shape=tri "+bonename;
Misc::StringUtils::toLower(filter); Misc::StringUtils::toLower(filter);
for(size_t i = 0;i < entitylist.mEntities.size();i++) for(size_t i = 0;i < objectlist.mEntities.size();i++)
{ {
Ogre::Entity *entity = entitylist.mEntities[i]; Ogre::Entity *entity = objectlist.mEntities[i];
if(entity->hasSkeleton()) if(entity->hasSkeleton())
{ {
if(entity == entitylist.mSkelBase || if(entity == objectlist.mSkelBase ||
entity->getMesh()->getName().find(filter) != std::string::npos) entity->getMesh()->getName().find(filter) != std::string::npos)
parentNode->attachObject(entity); parentNode->attachObject(entity);
} }
@ -1673,9 +1673,9 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
} }
else else
{ {
for(size_t i = 0;i < entitylist.mEntities.size();i++) for(size_t i = 0;i < objectlist.mEntities.size();i++)
{ {
Ogre::Entity *entity = entitylist.mEntities[i]; Ogre::Entity *entity = objectlist.mEntities[i];
if(!entity->isAttached()) if(!entity->isAttached())
{ {
Ogre::TagPoint *tag = parent->attachObjectToBone(bonename, entity); Ogre::TagPoint *tag = parent->attachObjectToBone(bonename, entity);
@ -1684,7 +1684,7 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
} }
} }
return entitylist; return objectlist;
} }

View file

@ -39,7 +39,7 @@ namespace NifOgre
typedef std::multimap<float,std::string> TextKeyMap; typedef std::multimap<float,std::string> TextKeyMap;
static const char sTextKeyExtraDataID[] = "TextKeyExtraData"; static const char sTextKeyExtraDataID[] = "TextKeyExtraData";
struct EntityList { struct ObjectList {
Ogre::Entity *mSkelBase; Ogre::Entity *mSkelBase;
std::vector<Ogre::Entity*> mEntities; std::vector<Ogre::Entity*> mEntities;
@ -47,7 +47,7 @@ struct EntityList {
std::vector<Ogre::Controller<Ogre::Real> > mControllers; std::vector<Ogre::Controller<Ogre::Real> > mControllers;
EntityList() : mSkelBase(0) ObjectList() : mSkelBase(0)
{ } { }
}; };
@ -55,14 +55,14 @@ struct EntityList {
class Loader class Loader
{ {
public: public:
static EntityList createEntities(Ogre::Entity *parent, const std::string &bonename, static ObjectList createObjects(Ogre::Entity *parent, const std::string &bonename,
Ogre::SceneNode *parentNode, Ogre::SceneNode *parentNode,
std::string name, std::string name,
const std::string &group="General"); const std::string &group="General");
static EntityList createEntities(Ogre::SceneNode *parentNode, static ObjectList createObjects(Ogre::SceneNode *parentNode,
std::string name, std::string name,
const std::string &group="General"); const std::string &group="General");
static Ogre::SkeletonPtr getSkeleton(std::string name, const std::string &group="General"); static Ogre::SkeletonPtr getSkeleton(std::string name, const std::string &group="General");
}; };