예제 #1
0
void EffectManager::update(float dt, Ogre::Camera* camera)
{
    for (std::vector<std::pair<Ogre::SceneNode*, NifOgre::ObjectScenePtr> >::iterator it = mEffects.begin(); it != mEffects.end(); )
    {
        NifOgre::ObjectScenePtr objects = it->second;
        for(size_t i = 0; i < objects->mControllers.size() ;i++)
        {
            EffectAnimationTime* value = dynamic_cast<EffectAnimationTime*>(objects->mControllers[i].getSource().get());
            if (value)
                value->addTime(dt);

            objects->mControllers[i].update();
        }
        objects->rotateBillboardNodes(camera);

        // Finished playing?
        if (objects->mControllers[0].getSource()->getValue() >= objects->mMaxControllerLength)
        {
            Ogre::SceneNode* node = it->first;
            it = mEffects.erase(it);
            mSceneMgr->destroySceneNode(node);
            continue;
        }
        ++it;
    }
}
예제 #2
0
파일: animation.cpp 프로젝트: Chiur/openmw
void Animation::preRender(Ogre::Camera *camera)
{
    for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it)
    {
        NifOgre::ObjectScenePtr objects = it->mObjects;
        objects->rotateBillboardNodes(camera);
    }
    mObjectRoot->rotateBillboardNodes(camera);
}
예제 #3
0
void CreatureWeaponAnimation::updatePart(NifOgre::ObjectScenePtr& scene, int slot)
{
    MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
    MWWorld::ContainerStoreIterator it = inv.getSlot(slot);

    if (it == inv.end())
    {
        scene.setNull();
        return;
    }
    MWWorld::Ptr item = *it;

    std::string bonename;
    if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
        bonename = "Weapon Bone";
    else
        bonename = "Shield Bone";

    scene = NifOgre::Loader::createObjects(mSkelBase, bonename, mInsert, item.getClass().getModel(item));
    Ogre::Vector3 glowColor = getEnchantmentColor(item);

    setRenderProperties(scene, RV_Actors, RQG_Main, RQG_Alpha, 0,
                        !item.getClass().getEnchantment(item).empty(), &glowColor);

    if(scene->mSkelBase)
    {
        Ogre::SkeletonInstance *skel = scene->mSkelBase->getSkeleton();
        if(scene->mSkelBase->isParentTagPoint())
        {
            Ogre::Node *root = scene->mSkelBase->getParentNode();
            if(skel->hasBone("BoneOffset"))
            {
                Ogre::Bone *offset = skel->getBone("BoneOffset");

                root->translate(offset->getPosition());

                // It appears that the BoneOffset rotation is completely bogus, at least for light models.
                //root->rotate(offset->getOrientation());
                root->pitch(Ogre::Degree(-90.0f));

                root->scale(offset->getScale());
                root->setInitialState();
            }
        }
        updateSkeletonInstance(mSkelBase->getSkeleton(), skel);
    }

    // TODO:
    // type == ESM::PRT_Weapon should get an animation source based on the current offset
    // of the weapon attack animation (from its beginning, or start marker?)
    std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(scene->mControllers.begin());
    for(;ctrl != scene->mControllers.end();ctrl++)
    {
        if(ctrl->getSource().isNull())
            ctrl->setSource(Ogre::SharedPtr<NullAnimationTime>(new NullAnimationTime()));
    }
}