forked from teamnwah/openmw-tes3coop
NpcAnimation compiles
This commit is contained in:
parent
13a1ba0aab
commit
5b8c28f641
7 changed files with 104 additions and 136 deletions
|
@ -20,8 +20,8 @@ set(GAME_HEADER
|
||||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||||
|
|
||||||
add_openmw_dir (mwrender
|
add_openmw_dir (mwrender
|
||||||
actors objects renderingmanager animation sky
|
actors objects renderingmanager animation sky npcanimation
|
||||||
# debugging camera npcanimation creatureanimation activatoranimation
|
# debugging camera creatureanimation activatoranimation
|
||||||
# renderinginterface localmap occlusionquery water shadows
|
# renderinginterface localmap occlusionquery water shadows
|
||||||
# characterpreview globalmap ripplesimulation refraction
|
# characterpreview globalmap ripplesimulation refraction
|
||||||
# terrainstorage renderconst effectmanager weaponanimation
|
# terrainstorage renderconst effectmanager weaponanimation
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
Animation::Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> node, Resource::ResourceSystem* resourceSystem)
|
Animation::Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem)
|
||||||
: mPtr(ptr)
|
: mPtr(ptr)
|
||||||
, mInsert(node)
|
, mInsert(parentNode)
|
||||||
, mResourceSystem(resourceSystem)
|
, mResourceSystem(resourceSystem)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> node, Resource::ResourceSystem* resourceSystem);
|
Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem);
|
||||||
virtual ~Animation();
|
virtual ~Animation();
|
||||||
|
|
||||||
osg::Group* getOrCreateObjectRoot();
|
osg::Group* getOrCreateObjectRoot();
|
||||||
|
|
|
@ -10,12 +10,14 @@
|
||||||
#include <OgreBone.h>
|
#include <OgreBone.h>
|
||||||
#include <OgreTechnique.h>
|
#include <OgreTechnique.h>
|
||||||
|
|
||||||
#include <extern/shiny/Main/Factory.hpp>
|
|
||||||
|
|
||||||
#include <openengine/misc/rng.hpp>
|
#include <openengine/misc/rng.hpp>
|
||||||
|
|
||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
|
||||||
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
#include <components/resource/scenemanager.hpp>
|
||||||
|
#include <components/sceneutil/attach.hpp>
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
@ -69,27 +71,13 @@ std::string getVampireHead(const std::string& race, bool female)
|
||||||
return "meshes\\" + bodyPart->mModel;
|
return "meshes\\" + bodyPart->mModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSkinned (NifOgre::ObjectScenePtr scene)
|
|
||||||
{
|
|
||||||
if (scene->mSkelBase == NULL)
|
|
||||||
return false;
|
|
||||||
for(size_t j = 0; j < scene->mEntities.size(); j++)
|
|
||||||
{
|
|
||||||
Ogre::Entity *ent = scene->mEntities[j];
|
|
||||||
if(scene->mSkelBase != ent && ent->hasSkeleton())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
HeadAnimationTime::HeadAnimationTime(MWWorld::Ptr reference)
|
HeadAnimationTime::HeadAnimationTime(MWWorld::Ptr reference)
|
||||||
: mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mValue(0), mEnabled(true)
|
: mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mValue(0), mEnabled(true)
|
||||||
{
|
{
|
||||||
|
@ -159,6 +147,7 @@ void HeadAnimationTime::setBlinkStop(float value)
|
||||||
{
|
{
|
||||||
mBlinkStop = value;
|
mBlinkStop = value;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static NpcAnimation::PartBoneMap createPartListMap()
|
static NpcAnimation::PartBoneMap createPartListMap()
|
||||||
{
|
{
|
||||||
|
@ -201,8 +190,8 @@ NpcAnimation::~NpcAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int visibilityFlags, bool disableListener, bool disableSounds, ViewMode viewMode)
|
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem, int visibilityFlags, bool disableListener, bool disableSounds, ViewMode viewMode)
|
||||||
: Animation(ptr, node),
|
: Animation(ptr, parentNode, resourceSystem),
|
||||||
mVisibilityFlags(visibilityFlags),
|
mVisibilityFlags(visibilityFlags),
|
||||||
mListenerDisabled(disableListener),
|
mListenerDisabled(disableListener),
|
||||||
mViewMode(viewMode),
|
mViewMode(viewMode),
|
||||||
|
@ -217,8 +206,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int v
|
||||||
{
|
{
|
||||||
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
mHeadAnimationTime = Ogre::SharedPtr<HeadAnimationTime>(new HeadAnimationTime(mPtr));
|
//mHeadAnimationTime = Ogre::SharedPtr<HeadAnimationTime>(new HeadAnimationTime(mPtr));
|
||||||
mWeaponAnimationTime = Ogre::SharedPtr<WeaponAnimationTime>(new WeaponAnimationTime(this));
|
//mWeaponAnimationTime = Ogre::SharedPtr<WeaponAnimationTime>(new WeaponAnimationTime(this));
|
||||||
|
|
||||||
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
||||||
{
|
{
|
||||||
|
@ -251,7 +240,7 @@ void NpcAnimation::rebuild()
|
||||||
|
|
||||||
void NpcAnimation::updateNpcBase()
|
void NpcAnimation::updateNpcBase()
|
||||||
{
|
{
|
||||||
clearAnimSources();
|
//clearAnimSources();
|
||||||
|
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace);
|
const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace);
|
||||||
|
@ -296,9 +285,10 @@ void NpcAnimation::updateNpcBase()
|
||||||
(!isWerewolf ? !isBeast ? "meshes\\base_anim.1st.nif"
|
(!isWerewolf ? !isBeast ? "meshes\\base_anim.1st.nif"
|
||||||
: "meshes\\base_animkna.1st.nif"
|
: "meshes\\base_animkna.1st.nif"
|
||||||
: "meshes\\wolf\\skin.1st.nif");
|
: "meshes\\wolf\\skin.1st.nif");
|
||||||
smodel = Misc::ResourceHelpers::correctActorModelPath(smodel);
|
smodel = Misc::ResourceHelpers::correctActorModelPath(smodel, mResourceSystem->getVFS());
|
||||||
setObjectRoot(smodel, true);
|
setObjectRoot(smodel /*, baseonly = true*/);
|
||||||
|
|
||||||
|
/*
|
||||||
if(mViewMode != VM_FirstPerson)
|
if(mViewMode != VM_FirstPerson)
|
||||||
{
|
{
|
||||||
addAnimSource(smodel);
|
addAnimSource(smodel);
|
||||||
|
@ -318,9 +308,8 @@ void NpcAnimation::updateNpcBase()
|
||||||
addAnimSource(smodel);
|
addAnimSource(smodel);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* A bit counter-intuitive, but unlike third-person anims, it seems
|
// A bit counter-intuitive, but unlike third-person anims, it seems
|
||||||
* beast races get both base_anim.1st.nif and base_animkna.1st.nif.
|
// beast races get both base_anim.1st.nif and base_animkna.1st.nif.
|
||||||
*/
|
|
||||||
addAnimSource("meshes\\xbase_anim.1st.nif");
|
addAnimSource("meshes\\xbase_anim.1st.nif");
|
||||||
if(isBeast)
|
if(isBeast)
|
||||||
addAnimSource("meshes\\xbase_animkna.1st.nif");
|
addAnimSource("meshes\\xbase_animkna.1st.nif");
|
||||||
|
@ -328,18 +317,19 @@ void NpcAnimation::updateNpcBase()
|
||||||
addAnimSource("meshes\\xbase_anim_female.1st.nif");
|
addAnimSource("meshes\\xbase_anim_female.1st.nif");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
||||||
removeIndividualPart((ESM::PartReferenceType)i);
|
removeIndividualPart((ESM::PartReferenceType)i);
|
||||||
updateParts();
|
updateParts();
|
||||||
|
|
||||||
mWeaponAnimationTime->updateStartTime();
|
//mWeaponAnimationTime->updateStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::updateParts()
|
void NpcAnimation::updateParts()
|
||||||
{
|
{
|
||||||
if (!mSkelBase)
|
//if (!mSkelBase)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
mAlpha = 1.f;
|
mAlpha = 1.f;
|
||||||
const MWWorld::Class &cls = mPtr.getClass();
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
|
@ -379,7 +369,7 @@ void NpcAnimation::updateParts()
|
||||||
};
|
};
|
||||||
static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]);
|
static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]);
|
||||||
|
|
||||||
bool wasArrowAttached = (mAmmunition.get() != NULL);
|
bool wasArrowAttached = 0;//(mAmmunition.get() != NULL);
|
||||||
|
|
||||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++)
|
for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++)
|
||||||
|
@ -396,7 +386,8 @@ void NpcAnimation::updateParts()
|
||||||
|
|
||||||
int prio = 1;
|
int prio = 1;
|
||||||
bool enchantedGlow = !store->getClass().getEnchantment(*store).empty();
|
bool enchantedGlow = !store->getClass().getEnchantment(*store).empty();
|
||||||
Ogre::Vector3 glowColor = getEnchantmentColor(*store);
|
//Ogre::Vector3 glowColor = getEnchantmentColor(*store);
|
||||||
|
Ogre::Vector3 glowColor (1,1,1);
|
||||||
if(store->getTypeName() == typeid(ESM::Clothing).name())
|
if(store->getTypeName() == typeid(ESM::Clothing).name())
|
||||||
{
|
{
|
||||||
prio = ((slotlist[i].mBasePriority+1)<<1) + 0;
|
prio = ((slotlist[i].mBasePriority+1)<<1) + 0;
|
||||||
|
@ -448,7 +439,7 @@ void NpcAnimation::updateParts()
|
||||||
const ESM::Light *light = part.get<ESM::Light>()->mBase;
|
const ESM::Light *light = part.get<ESM::Light>()->mBase;
|
||||||
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft,
|
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft,
|
||||||
1, "meshes\\"+light->mModel);
|
1, "meshes\\"+light->mModel);
|
||||||
addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], light);
|
//addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], light);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,6 +588,15 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PartHolderPtr NpcAnimation::insertBoundedPart(const std::string& model, int group, const std::string& bonename, const std::string& bonefilter, bool enchantedGlow, Ogre::Vector3* glowColor)
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osg::Node> instance = mResourceSystem->getSceneManager()->createInstance(model);
|
||||||
|
std::cout << "inserting " << model << std::endl;
|
||||||
|
osg::ref_ptr<osg::Node> attached = SceneUtil::attach(instance, mObjectRoot, bonefilter, bonename);
|
||||||
|
return PartHolderPtr(new PartHolder(attached));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
NifOgre::ObjectScenePtr NpcAnimation::insertBoundedPart(const std::string &model, int group, const std::string &bonename, const std::string &bonefilter, bool enchantedGlow, Ogre::Vector3* glowColor)
|
NifOgre::ObjectScenePtr NpcAnimation::insertBoundedPart(const std::string &model, int group, const std::string &bonename, const std::string &bonefilter, bool enchantedGlow, Ogre::Vector3* glowColor)
|
||||||
{
|
{
|
||||||
NifOgre::ObjectScenePtr objects = NifOgre::Loader::createObjects(mSkelBase, bonename, bonefilter, mInsert, model);
|
NifOgre::ObjectScenePtr objects = NifOgre::Loader::createObjects(mSkelBase, bonename, bonefilter, mInsert, model);
|
||||||
|
@ -624,7 +624,9 @@ NifOgre::ObjectScenePtr NpcAnimation::insertBoundedPart(const std::string &model
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 ret = Animation::runAnimation(timepassed);
|
Ogre::Vector3 ret = Animation::runAnimation(timepassed);
|
||||||
|
@ -675,13 +677,14 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void NpcAnimation::removeIndividualPart(ESM::PartReferenceType type)
|
void NpcAnimation::removeIndividualPart(ESM::PartReferenceType type)
|
||||||
{
|
{
|
||||||
mPartPriorities[type] = 0;
|
mPartPriorities[type] = 0;
|
||||||
mPartslots[type] = -1;
|
mPartslots[type] = -1;
|
||||||
|
|
||||||
mObjectParts[type].setNull();
|
//mObjectParts[type].setNull();
|
||||||
if (!mSoundIds[type].empty() && !mSoundsDisabled)
|
if (!mSoundIds[type].empty() && !mSoundsDisabled)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->stopSound3D(mPtr, mSoundIds[type]);
|
MWBase::Environment::get().getSoundManager()->stopSound3D(mPtr, mSoundIds[type]);
|
||||||
|
@ -743,6 +746,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if(mObjectParts[type]->mSkelBase)
|
if(mObjectParts[type]->mSkelBase)
|
||||||
{
|
{
|
||||||
Ogre::SkeletonInstance *skel = mObjectParts[type]->mSkelBase->getSkeleton();
|
Ogre::SkeletonInstance *skel = mObjectParts[type]->mSkelBase->getSkeleton();
|
||||||
|
@ -795,6 +799,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||||
ctrl->setSource(mWeaponAnimationTime);
|
ctrl->setSource(mWeaponAnimationTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -856,7 +861,7 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||||
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
if(weapon != inv.end())
|
if(weapon != inv.end())
|
||||||
{
|
{
|
||||||
Ogre::Vector3 glowColor = getEnchantmentColor(*weapon);
|
Ogre::Vector3 glowColor (1,1,1); //= getEnchantmentColor(*weapon);
|
||||||
std::string mesh = weapon->getClass().getModel(*weapon);
|
std::string mesh = weapon->getClass().getModel(*weapon);
|
||||||
addOrReplaceIndividualPart(ESM::PRT_Weapon, MWWorld::InventoryStore::Slot_CarriedRight, 1,
|
addOrReplaceIndividualPart(ESM::PRT_Weapon, MWWorld::InventoryStore::Slot_CarriedRight, 1,
|
||||||
mesh, !weapon->getClass().getEnchantment(*weapon).empty(), &glowColor);
|
mesh, !weapon->getClass().getEnchantment(*weapon).empty(), &glowColor);
|
||||||
|
@ -868,11 +873,11 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||||
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||||
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
||||||
attachArrow();
|
attachArrow();
|
||||||
else
|
//else
|
||||||
mAmmunition.setNull();
|
//mAmmunition.setNull();
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
mAmmunition.setNull();
|
//mAmmunition.setNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -889,29 +894,19 @@ void NpcAnimation::showCarriedLeft(bool show)
|
||||||
MWWorld::ContainerStoreIterator iter = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
MWWorld::ContainerStoreIterator iter = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
if(show && iter != inv.end())
|
if(show && iter != inv.end())
|
||||||
{
|
{
|
||||||
Ogre::Vector3 glowColor = getEnchantmentColor(*iter);
|
Ogre::Vector3 glowColor(1,1,1);// = getEnchantmentColor(*iter);
|
||||||
std::string mesh = iter->getClass().getModel(*iter);
|
std::string mesh = iter->getClass().getModel(*iter);
|
||||||
if (addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
|
if (addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
|
||||||
mesh, !iter->getClass().getEnchantment(*iter).empty(), &glowColor))
|
mesh, !iter->getClass().getEnchantment(*iter).empty(), &glowColor))
|
||||||
{
|
{
|
||||||
if (iter->getTypeName() == typeid(ESM::Light).name())
|
//if (iter->getTypeName() == typeid(ESM::Light).name())
|
||||||
addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], iter->get<ESM::Light>()->mBase);
|
//addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], iter->get<ESM::Light>()->mBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
removeIndividualPart(ESM::PRT_Shield);
|
removeIndividualPart(ESM::PRT_Shield);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot)
|
|
||||||
{
|
|
||||||
Ogre::Vector3 glowColor = getEnchantmentColor(ptr);
|
|
||||||
setRenderProperties(object, (mViewMode == VM_FirstPerson) ? RV_FirstPerson : mVisibilityFlags, RQG_Main, RQG_Alpha, 0,
|
|
||||||
!ptr.getClass().getEnchantment(ptr).empty(), &glowColor);
|
|
||||||
|
|
||||||
std::for_each(object->mEntities.begin(), object->mEntities.end(), SetObjectGroup(slot));
|
|
||||||
std::for_each(object->mParticles.begin(), object->mParticles.end(), SetObjectGroup(slot));
|
|
||||||
}
|
|
||||||
|
|
||||||
void NpcAnimation::attachArrow()
|
void NpcAnimation::attachArrow()
|
||||||
{
|
{
|
||||||
WeaponAnimation::attachArrow(mPtr);
|
WeaponAnimation::attachArrow(mPtr);
|
||||||
|
@ -942,11 +937,13 @@ void NpcAnimation::permanentEffectAdded(const ESM::MagicEffect *magicEffect, boo
|
||||||
|
|
||||||
if (!magicEffect->mHit.empty())
|
if (!magicEffect->mHit.empty())
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
|
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
|
||||||
bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
|
bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
|
||||||
// Don't play particle VFX unless the effect is new or it should be looping.
|
// Don't play particle VFX unless the effect is new or it should be looping.
|
||||||
if (isNew || loop)
|
if (isNew || loop)
|
||||||
addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "");
|
addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,67 +953,17 @@ void NpcAnimation::setAlpha(float alpha)
|
||||||
return;
|
return;
|
||||||
mAlpha = alpha;
|
mAlpha = alpha;
|
||||||
|
|
||||||
for (int i=0; i<ESM::PRT_Count; ++i)
|
// TODO
|
||||||
{
|
|
||||||
if (mObjectParts[i].isNull())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (unsigned int j=0; j<mObjectParts[i]->mEntities.size(); ++j)
|
|
||||||
{
|
|
||||||
Ogre::Entity* ent = mObjectParts[i]->mEntities[j];
|
|
||||||
if (ent != mObjectParts[i]->mSkelBase)
|
|
||||||
applyAlpha(alpha, ent, mObjectParts[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::enableHeadAnimation(bool enable)
|
void NpcAnimation::enableHeadAnimation(bool enable)
|
||||||
{
|
{
|
||||||
mHeadAnimationTime->setEnabled(enable);
|
//mHeadAnimationTime->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::preRender(Ogre::Camera *camera)
|
void NpcAnimation::setWeaponGroup(const std::string &group)
|
||||||
{
|
{
|
||||||
Animation::preRender(camera);
|
//mWeaponAnimationTime->
|
||||||
for (int i=0; i<ESM::PRT_Count; ++i)
|
|
||||||
{
|
|
||||||
if (mObjectParts[i].isNull())
|
|
||||||
continue;
|
|
||||||
mObjectParts[i]->rotateBillboardNodes(camera);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NpcAnimation::applyAlpha(float alpha, Ogre::Entity *ent, NifOgre::ObjectScenePtr scene)
|
|
||||||
{
|
|
||||||
sh::Factory::getInstance()._ensureMaterial(ent->getSubEntity(0)->getMaterial()->getName(), "Default");
|
|
||||||
ent->getSubEntity(0)->setRenderQueueGroup(alpha != 1.f || ent->getSubEntity(0)->getMaterial()->isTransparent()
|
|
||||||
? RQG_Alpha : RQG_Main);
|
|
||||||
|
|
||||||
|
|
||||||
Ogre::MaterialPtr mat = scene->mMaterialControllerMgr.getWritableMaterial(ent);
|
|
||||||
if (mAlpha == 1.f)
|
|
||||||
{
|
|
||||||
// Don't bother remembering what the original values were. Just remove the techniques and let the factory restore them.
|
|
||||||
mat->removeAllTechniques();
|
|
||||||
sh::Factory::getInstance()._ensureMaterial(mat->getName(), "Default");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::Material::TechniqueIterator techs = mat->getTechniqueIterator();
|
|
||||||
while(techs.hasMoreElements())
|
|
||||||
{
|
|
||||||
Ogre::Technique *tech = techs.getNext();
|
|
||||||
Ogre::Technique::PassIterator passes = tech->getPassIterator();
|
|
||||||
while(passes.hasMoreElements())
|
|
||||||
{
|
|
||||||
Ogre::Pass *pass = passes.getNext();
|
|
||||||
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
|
|
||||||
Ogre::ColourValue diffuse = pass->getDiffuse();
|
|
||||||
diffuse.a = alpha;
|
|
||||||
pass->setDiffuse(diffuse);
|
|
||||||
pass->setVertexColourTracking(pass->getVertexColourTracking() &~Ogre::TVC_DIFFUSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::equipmentChanged()
|
void NpcAnimation::equipmentChanged()
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace ESM
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
class HeadAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
class HeadAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -47,6 +48,27 @@ public:
|
||||||
virtual void setValue(Ogre::Real value)
|
virtual void setValue(Ogre::Real value)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// @brief Detaches the node from its parent when the object goes out of scope.
|
||||||
|
class PartHolder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PartHolder(osg::ref_ptr<osg::Node> node)
|
||||||
|
: mNode(node)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~PartHolder()
|
||||||
|
{
|
||||||
|
if (mNode->getNumParents())
|
||||||
|
mNode->getParent(0)->removeChild(mNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
osg::ref_ptr<osg::Node> mNode;
|
||||||
|
};
|
||||||
|
typedef boost::shared_ptr<PartHolder> PartHolderPtr;
|
||||||
|
|
||||||
class NpcAnimation : public Animation, public WeaponAnimation, public MWWorld::InventoryStoreListener
|
class NpcAnimation : public Animation, public WeaponAnimation, public MWWorld::InventoryStoreListener
|
||||||
{
|
{
|
||||||
|
@ -69,7 +91,7 @@ private:
|
||||||
bool mListenerDisabled;
|
bool mListenerDisabled;
|
||||||
|
|
||||||
// Bounded Parts
|
// Bounded Parts
|
||||||
NifOgre::ObjectScenePtr mObjectParts[ESM::PRT_Count];
|
PartHolderPtr mObjectParts[ESM::PRT_Count];
|
||||||
std::string mSoundIds[ESM::PRT_Count];
|
std::string mSoundIds[ESM::PRT_Count];
|
||||||
|
|
||||||
const ESM::NPC *mNpc;
|
const ESM::NPC *mNpc;
|
||||||
|
@ -94,8 +116,8 @@ private:
|
||||||
|
|
||||||
Ogre::Vector3 mFirstPersonOffset;
|
Ogre::Vector3 mFirstPersonOffset;
|
||||||
|
|
||||||
Ogre::SharedPtr<HeadAnimationTime> mHeadAnimationTime;
|
//Ogre::SharedPtr<HeadAnimationTime> mHeadAnimationTime;
|
||||||
Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
|
//Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
|
||||||
|
|
||||||
float mAlpha;
|
float mAlpha;
|
||||||
bool mSoundsDisabled;
|
bool mSoundsDisabled;
|
||||||
|
@ -105,9 +127,8 @@ private:
|
||||||
|
|
||||||
void updateNpcBase();
|
void updateNpcBase();
|
||||||
|
|
||||||
NifOgre::ObjectScenePtr insertBoundedPart(const std::string &model, int group, const std::string &bonename,
|
PartHolderPtr insertBoundedPart(const std::string &model, int group, const std::string &bonename,
|
||||||
const std::string &bonefilter,
|
const std::string &bonefilter, bool enchantedGlow, Ogre::Vector3* glowColor=NULL);
|
||||||
bool enchantedGlow, Ogre::Vector3* glowColor=NULL);
|
|
||||||
|
|
||||||
void removeIndividualPart(ESM::PartReferenceType type);
|
void removeIndividualPart(ESM::PartReferenceType type);
|
||||||
void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority);
|
void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority);
|
||||||
|
@ -118,7 +139,7 @@ private:
|
||||||
void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
|
void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
|
||||||
bool enchantedGlow=false, Ogre::Vector3* glowColor=NULL);
|
bool enchantedGlow=false, Ogre::Vector3* glowColor=NULL);
|
||||||
|
|
||||||
void applyAlpha(float alpha, Ogre::Entity* ent, NifOgre::ObjectScenePtr scene);
|
//void applyAlpha(float alpha, Ogre::Entity* ent, NifOgre::ObjectScenePtr scene);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -132,15 +153,16 @@ public:
|
||||||
* @param disableSounds Same as \a disableListener but for playing items sounds
|
* @param disableSounds Same as \a disableListener but for playing items sounds
|
||||||
* @param viewMode
|
* @param viewMode
|
||||||
*/
|
*/
|
||||||
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int visibilityFlags, bool disableListener = false,
|
NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem,
|
||||||
|
int visibilityFlags, bool disableListener = false,
|
||||||
bool disableSounds = false, ViewMode viewMode=VM_Normal);
|
bool disableSounds = false, ViewMode viewMode=VM_Normal);
|
||||||
virtual ~NpcAnimation();
|
virtual ~NpcAnimation();
|
||||||
|
|
||||||
virtual void enableHeadAnimation(bool enable);
|
virtual void enableHeadAnimation(bool enable);
|
||||||
|
|
||||||
virtual void setWeaponGroup(const std::string& group) { mWeaponAnimationTime->setGroup(group); }
|
virtual void setWeaponGroup(const std::string& group);
|
||||||
|
|
||||||
virtual Ogre::Vector3 runAnimation(float timepassed);
|
//virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||||
|
|
||||||
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
||||||
/// to indicate the facing orientation of the character.
|
/// to indicate the facing orientation of the character.
|
||||||
|
@ -158,9 +180,9 @@ public:
|
||||||
virtual void releaseArrow();
|
virtual void releaseArrow();
|
||||||
|
|
||||||
// WeaponAnimation
|
// WeaponAnimation
|
||||||
virtual NifOgre::ObjectScenePtr getWeapon() { return mObjectParts[ESM::PRT_Weapon]; }
|
//virtual NifOgre::ObjectScenePtr getWeapon() { return mObjectParts[ESM::PRT_Weapon]; }
|
||||||
virtual void showWeapon(bool show) { showWeapons(show); }
|
virtual void showWeapon(bool show) { showWeapons(show); }
|
||||||
virtual void configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot);
|
//virtual void configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot);
|
||||||
|
|
||||||
void setViewMode(ViewMode viewMode);
|
void setViewMode(ViewMode viewMode);
|
||||||
|
|
||||||
|
@ -178,9 +200,6 @@ public:
|
||||||
virtual void setAlpha(float alpha);
|
virtual void setAlpha(float alpha);
|
||||||
|
|
||||||
virtual void setVampire(bool vampire);
|
virtual void setVampire(bool vampire);
|
||||||
|
|
||||||
/// Prepare this animation for being rendered with \a camera (rotates billboard nodes)
|
|
||||||
virtual void preRender (Ogre::Camera* camera);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "renderconst.hpp"
|
#include "renderconst.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
#include "npcanimation.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -199,7 +200,10 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b
|
||||||
|
|
||||||
void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
||||||
{
|
{
|
||||||
|
insertBegin(ptr);
|
||||||
|
|
||||||
|
std::auto_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem, 0));
|
||||||
|
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Objects::deleteObject (const MWWorld::Ptr& ptr)
|
bool Objects::deleteObject (const MWWorld::Ptr& ptr)
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
#ifndef OPENMW_MWRENDER_WEAPONANIMATION_H
|
#ifndef OPENMW_MWRENDER_WEAPONANIMATION_H
|
||||||
#define OPENMW_MWRENDER_WEAPONANIMATION_H
|
#define OPENMW_MWRENDER_WEAPONANIMATION_H
|
||||||
|
|
||||||
#include <OgreController.h>
|
|
||||||
|
|
||||||
#include <components/nifogre/ogrenifloader.hpp>
|
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
|
@ -12,6 +8,7 @@ namespace MWRender
|
||||||
|
|
||||||
class Animation;
|
class Animation;
|
||||||
|
|
||||||
|
/*
|
||||||
class WeaponAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
class WeaponAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -27,6 +24,7 @@ namespace MWRender
|
||||||
virtual void setValue(Ogre::Real value)
|
virtual void setValue(Ogre::Real value)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
/// Handles attach & release of projectiles for ranged weapons
|
/// Handles attach & release of projectiles for ranged weapons
|
||||||
class WeaponAnimation
|
class WeaponAnimation
|
||||||
|
@ -36,23 +34,23 @@ namespace MWRender
|
||||||
virtual ~WeaponAnimation() {}
|
virtual ~WeaponAnimation() {}
|
||||||
|
|
||||||
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
|
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
|
||||||
void attachArrow(MWWorld::Ptr actor);
|
void attachArrow(MWWorld::Ptr actor) {}
|
||||||
|
|
||||||
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
|
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
|
||||||
void releaseArrow(MWWorld::Ptr actor);
|
void releaseArrow(MWWorld::Ptr actor) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NifOgre::ObjectScenePtr mAmmunition;
|
//NifOgre::ObjectScenePtr mAmmunition;
|
||||||
|
|
||||||
virtual NifOgre::ObjectScenePtr getWeapon() = 0;
|
//virtual NifOgre::ObjectScenePtr getWeapon() = 0;
|
||||||
virtual void showWeapon(bool show) = 0;
|
virtual void showWeapon(bool show) = 0;
|
||||||
virtual void configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot) = 0;
|
//virtual void configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot) = 0;
|
||||||
|
|
||||||
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
||||||
/// to indicate the facing orientation of the character, for ranged weapon aiming.
|
/// to indicate the facing orientation of the character, for ranged weapon aiming.
|
||||||
float mPitchFactor;
|
float mPitchFactor;
|
||||||
|
|
||||||
void pitchSkeleton(float xrot, Ogre::SkeletonInstance* skel);
|
//void pitchSkeleton(float xrot, Ogre::SkeletonInstance* skel);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue