Beispiel #1
0
 /* Specifies a single skeleton name to use as an animation source. */
 void setAnimationSource(const std::string &name)
 {
     std::vector<std::string> names(1, name);
     setAnimationSources(names);
 }
Beispiel #2
0
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags, bool headOnly)
  : Animation(ptr),
    mStateID(-1),
    mTimeToChange(0),
    mVisibilityFlags(visibilityFlags),
    mRobe(inv.end()),
    mHelmet(inv.end()),
    mShirt(inv.end()),
    mCuirass(inv.end()),
    mGreaves(inv.end()),
    mPauldronL(inv.end()),
    mPauldronR(inv.end()),
    mBoots(inv.end()),
    mPants(inv.end()),
    mGloveL(inv.end()),
    mGloveR(inv.end()),
    mSkirtIter(inv.end()),
    mHeadOnly(headOnly)
{
    mNpc = mPtr.get<ESM::NPC>()->mBase;

    for(size_t i = 0;i < sPartListSize;i++)
    {
        mPartslots[i] = -1;  //each slot is empty
        mPartPriorities[i] = 0;
    }

    const MWWorld::ESMStore &store =
        MWBase::Environment::get().getWorld()->getStore();
    const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace);

    float scale = race->mData.mHeight.mMale;
    if(!mNpc->isMale())
        scale = race->mData.mHeight.mFemale;
    node->scale(Ogre::Vector3(scale));

    mHeadModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHead)->mModel;
    mHairModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHair)->mModel;

    mBodyPrefix = "b_n_" + mNpc->mRace;
    Misc::StringUtils::toLower(mBodyPrefix);

    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++)
    {
        Ogre::Entity *base = mEntityList.mEntities[i];

        base->getUserObjectBindings().setUserAny(Ogre::Any(-1));
        if (mVisibilityFlags != 0)
            base->setVisibilityFlags(mVisibilityFlags);

        for(unsigned int j=0; j < base->getNumSubEntities(); ++j)
        {
            Ogre::SubEntity* subEnt = base->getSubEntity(j);
            subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
        }
    }

    std::vector<std::string> skelnames(1, smodel);
    if(!mNpc->isMale() && !isBeast)
        skelnames.push_back("meshes\\base_anim_female.nif");
    else if(mBodyPrefix.find("argonian") != std::string::npos)
        skelnames.push_back("meshes\\argonian_swimkna.nif");
    if(mNpc->mModel.length() > 0)
        skelnames.push_back("meshes\\"+Misc::StringUtils::lowerCase(mNpc->mModel));
    setAnimationSources(skelnames);

    updateParts(true);
}