Rename EntityList to ObjectList

actorid
Chris Robinson 12 years ago
parent 834a6a1f00
commit 2db72ae607

@ -25,10 +25,10 @@ ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
{
std::string mesh = "meshes\\" + ref->mBase->mModel;
createEntityList(mPtr.getRefData().getBaseNode(), mesh);
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
createObjectList(mPtr.getRefData().getBaseNode(), mesh);
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)
{

@ -40,21 +40,21 @@ Animation::~Animation()
if(mInsert)
{
Ogre::SceneManager *sceneMgr = mInsert->getCreator();
for(size_t i = 0;i < mEntityList.mParticles.size();i++)
sceneMgr->destroyParticleSystem(mEntityList.mParticles[i]);
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
sceneMgr->destroyEntity(mEntityList.mEntities[i]);
for(size_t i = 0;i < mObjectList.mParticles.size();i++)
sceneMgr->destroyParticleSystem(mObjectList.mParticles[i]);
for(size_t i = 0;i < mObjectList.mEntities.size();i++)
sceneMgr->destroyEntity(mObjectList.mEntities[i]);
}
mEntityList.mControllers.clear();
mEntityList.mParticles.clear();
mEntityList.mEntities.clear();
mEntityList.mSkelBase = NULL;
mObjectList.mControllers.clear();
mObjectList.mParticles.clear();
mObjectList.mEntities.clear();
mObjectList.mSkelBase = NULL;
}
void Animation::setAnimationSources(const std::vector<std::string> &names)
{
if(!mEntityList.mSkelBase)
if(!mObjectList.mSkelBase)
return;
mCurrentAnim = NULL;
@ -87,7 +87,7 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
if(!mNonAccumRoot)
{
mAccumRoot = mInsert;
mNonAccumRoot = mEntityList.mSkelBase->getSkeleton()->getBone(bone->getName());
mNonAccumRoot = mObjectList.mSkelBase->getSkeleton()->getBone(bone->getName());
}
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();
assert(mInsert);
mEntityList = NifOgre::Loader::createEntities(mInsert, model);
if(mEntityList.mSkelBase)
mObjectList = NifOgre::Loader::createObjects(mInsert, model);
if(mObjectList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateSet *aset = mObjectList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator();
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
// transformations manually (needed if we want to apply an animation
// from one skeleton onto another).
Ogre::SkeletonInstance *skelinst = mEntityList.mSkelBase->getSkeleton();
Ogre::SkeletonInstance *skelinst = mObjectList.mSkelBase->getSkeleton();
Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator();
while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true);
}
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())
mEntityList.mControllers[i].setSource(ctrlval);
if(mObjectList.mControllers[i].getSource().isNull())
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
// 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)
@ -289,7 +289,7 @@ Ogre::Vector3 Animation::updatePosition(float time)
mCurrentTime = std::fmod(std::max(time, 0.0f), mCurrentAnim->getLength());
else
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;
if(mNonAccumRoot)
@ -465,8 +465,8 @@ Ogre::Vector3 Animation::runAnimation(float timepassed)
if(!handleEvent(time, evt))
break;
}
for(size_t i = 0;i < mEntityList.mControllers.size();i++)
mEntityList.mControllers[i].update();
for(size_t i = 0;i < mObjectList.mControllers.size();i++)
mObjectList.mControllers[i].update();
return movement;
}

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

@ -25,10 +25,10 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
{
std::string model = "meshes\\"+ref->mBase->mModel;
createEntityList(mPtr.getRefData().getBaseNode(), model);
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
createObjectList(mPtr.getRefData().getBaseNode(), model);
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);
for(unsigned int j=0; j < ent->getNumSubEntities(); ++j)

@ -50,7 +50,7 @@ const NpcAnimation::PartInfo NpcAnimation::sPartList[NpcAnimation::sPartListSize
NpcAnimation::~NpcAnimation()
{
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;
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
createEntityList(node, smodel);
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
createObjectList(node, smodel);
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));
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,
mInsert, mesh);
std::vector<Ogre::Entity*> &parts = entities.mEntities;
NifOgre::ObjectList objects = NifOgre::Loader::createObjects(mObjectList.mSkelBase, bonename,
mInsert, model);
const std::vector<Ogre::Entity*> &parts = objects.mEntities;
for(size_t i = 0;i < parts.size();i++)
{
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);
}
}
if(entities.mSkelBase)
if(objects.mSkelBase)
{
Ogre::AnimationStateSet *aset = entities.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateSet *aset = objects.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator();
while(asiter.hasMoreElements())
{
@ -329,12 +329,12 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
state->setEnabled(false);
state->setLoop(false);
}
Ogre::SkeletonInstance *skelinst = entities.mSkelBase->getSkeleton();
Ogre::SkeletonInstance *skelinst = objects.mSkelBase->getSkeleton();
Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator();
while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true);
}
return entities;
return objects;
}
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
@ -347,10 +347,10 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
mTimeToChange -= 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++)
{
Ogre::Entity *ent = mEntityParts[i].mSkelBase;
Ogre::Entity *ent = mObjectParts[i].mSkelBase;
if(!ent) continue;
updateSkeletonInstance(skelsrc, ent->getSkeleton());
ent->getAllAnimationStates()->_notifyDirty();
@ -358,19 +358,19 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
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();
for(size_t i = 0;i < entities.mParticles.size();i++)
sceneMgr->destroyParticleSystem(entities.mParticles[i]);
for(size_t i = 0;i < entities.mEntities.size();i++)
sceneMgr->destroyEntity(entities.mEntities[i]);
entities.mControllers.clear();
entities.mParticles.clear();
entities.mEntities.clear();
entities.mSkelBase = NULL;
for(size_t i = 0;i < objects.mParticles.size();i++)
sceneMgr->destroyParticleSystem(objects.mParticles[i]);
for(size_t i = 0;i < objects.mEntities.size();i++)
sceneMgr->destroyEntity(objects.mEntities[i]);
objects.mControllers.clear();
objects.mParticles.clear();
objects.mEntities.clear();
objects.mSkelBase = NULL;
}
void NpcAnimation::removeIndividualPart(int type)
@ -382,7 +382,7 @@ void NpcAnimation::removeIndividualPart(int type)
{
if(type == sPartList[i].type)
{
removeEntities(mEntityParts[i]);
removeObjects(mObjectParts[i]);
break;
}
}
@ -420,7 +420,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority,
{
if(type == sPartList[i].type)
{
mEntityParts[i] = insertBoundedPart(mesh, group, sPartList[i].name);
mObjectParts[i] = insertBoundedPart(mesh, group, sPartList[i].name);
break;
}
}
@ -451,7 +451,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
Ogre::Node* NpcAnimation::getHeadNode()
{
return mEntityList.mSkelBase->getSkeleton()->getBone("Bip01 Head");
return mObjectList.mSkelBase->getSkeleton()->getBone("Bip01 Head");
}
}

@ -33,7 +33,7 @@ private:
int mStateID;
// Bounded Parts
NifOgre::EntityList mEntityParts[sPartListSize];
NifOgre::ObjectList mObjectParts[sPartListSize];
const ESM::NPC *mNpc;
std::string mHeadModel;
@ -60,11 +60,11 @@ private:
int mPartslots[sPartListSize]; //Each part slot is taken by clothing, armor, or is empty
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 removeEntities(NifOgre::EntityList &entities);
void removeObjects(NifOgre::ObjectList &objects);
void removeIndividualPart(int type);
void reserveIndividualPart(int type, int group, int priority);

@ -130,9 +130,9 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
assert(insert);
Ogre::AxisAlignedBox bounds = Ogre::AxisAlignedBox::BOX_NULL;
NifOgre::EntityList entities = NifOgre::Loader::createEntities(insert, mesh);
for(size_t i = 0;i < entities.mEntities.size();i++)
bounds.merge(entities.mEntities[i]->getWorldBoundingBox(true));
NifOgre::ObjectList objects = NifOgre::Loader::createObjects(insert, mesh);
for(size_t i = 0;i < objects.mEntities.size();i++)
bounds.merge(objects.mEntities[i]->getWorldBoundingBox(true));
Ogre::Vector3 extents = bounds.getSize();
extents *= insert->getScale();
@ -149,9 +149,9 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
mBounds[ptr.getCell()].merge(bounds);
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)
{
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") ||
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)
{
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->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
part->setRenderQueueGroup(RQG_Alpha);
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);
std::vector<Ogre::Entity*>::reverse_iterator iter = entities.mEntities.rbegin();
while(iter != entities.mEntities.rend())
std::vector<Ogre::Entity*>::reverse_iterator iter = objects.mEntities.rbegin();
while(iter != objects.mEntities.rend())
{
Ogre::Node *node = (*iter)->getParentNode();
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)
{
insertLight(ptr, entities.mSkelBase, bounds.getCenter() - insert->_getDerivedPosition());
insertLight(ptr, objects.mSkelBase, bounds.getCenter() - insert->_getDerivedPosition());
}
}

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

@ -1421,7 +1421,7 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
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)
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());
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> > dstval(OGRE_NEW VisController::Value(trgtbone));
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;
}
@ -1494,16 +1494,16 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
Ogre::Entity *entity = sceneMgr->createEntity(mesh);
entity->setVisible(!(flags&0x01));
entities.mEntities.push_back(entity);
if(entities.mSkelBase)
objectlist.mEntities.push_back(entity);
if(objectlist.mSkelBase)
{
if(entity->hasSkeleton())
entity->shareSkeletonInstanceWith(entities.mSkelBase);
entity->shareSkeletonInstanceWith(objectlist.mSkelBase);
else
{
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(mName, shape->recIndex);
Ogre::Bone *trgtbone = entities.mSkelBase->getSkeleton()->getBone(trgtid);
entities.mSkelBase->attachObjectToBone(trgtbone->getName(), entity);
Ogre::Bone *trgtbone = objectlist.mSkelBase->getSkeleton()->getBone(trgtid);
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::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;
}
@ -1528,11 +1528,11 @@ class NIFObjectLoader : Ogre::ManualResourceLoader
if(node->recType == Nif::RC_NiAutoNormalParticles ||
node->recType == Nif::RC_NiRotatingParticles)
{
Ogre::ParticleSystem *partsys = createParticleSystem(sceneMgr, entities.mSkelBase, node);
Ogre::ParticleSystem *partsys = createParticleSystem(sceneMgr, objectlist.mSkelBase, node);
if(partsys != NULL)
{
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++)
{
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
* 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->setAutoBuildEdgeLists(false);
}
entities.mSkelBase = sceneMgr->createEntity(mesh);
entities.mEntities.push_back(entities.mSkelBase);
objectlist.mSkelBase = sceneMgr->createEntity(mesh);
objectlist.mEntities.push_back(objectlist.mSkelBase);
}
public:
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 &nif = *pnif.get();
@ -1603,44 +1603,44 @@ public:
NIFObjectLoader meshldr(name, group);
if(hasSkel)
meshldr.createSkelBase(sceneMgr, node, entities);
meshldr.createObjects(sceneMgr, node, entities);
meshldr.createSkelBase(sceneMgr, node, objectlist);
meshldr.createObjects(sceneMgr, node, objectlist);
}
};
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);
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())
parentNode->attachObject(entity);
}
return entitylist;
return objectlist;
}
EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonename,
Ogre::SceneNode *parentNode,
std::string name, const std::string &group)
ObjectList Loader::createObjects(Ogre::Entity *parent, const std::string &bonename,
Ogre::SceneNode *parentNode,
std::string name, const std::string &group)
{
EntityList entitylist;
ObjectList objectlist;
Misc::StringUtils::toLower(name);
NIFObjectLoader::load(parentNode->getCreator(), entitylist, name, group);
NIFObjectLoader::load(parentNode->getCreator(), objectlist, name, group);
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];
if(entitylist.mSkelBase != ent && ent->hasSkeleton())
Ogre::Entity *ent = objectlist.mEntities[i];
if(objectlist.mSkelBase != ent && ent->hasSkeleton())
{
isskinned = true;
break;
@ -1655,12 +1655,12 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
{
std::string filter = "@shape=tri "+bonename;
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 == entitylist.mSkelBase ||
if(entity == objectlist.mSkelBase ||
entity->getMesh()->getName().find(filter) != std::string::npos)
parentNode->attachObject(entity);
}
@ -1673,9 +1673,9 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
}
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())
{
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;
}

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

Loading…
Cancel
Save