|
|
|
@ -5,6 +5,7 @@
|
|
|
|
|
#include <osg/Depth>
|
|
|
|
|
|
|
|
|
|
#include <osgUtil/RenderBin>
|
|
|
|
|
#include <osgUtil/CullVisitor>
|
|
|
|
|
|
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
|
|
|
|
|
@ -274,13 +275,15 @@ NpcAnimation::~NpcAnimation()
|
|
|
|
|
mPtr.getClass().getInventoryStore(mPtr).setListener(NULL, mPtr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem, bool disableListener, bool disableSounds, ViewMode viewMode)
|
|
|
|
|
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem,
|
|
|
|
|
bool disableListener, bool disableSounds, ViewMode viewMode, float firstPersonFieldOfView)
|
|
|
|
|
: Animation(ptr, parentNode, resourceSystem),
|
|
|
|
|
mListenerDisabled(disableListener),
|
|
|
|
|
mViewMode(viewMode),
|
|
|
|
|
mShowWeapons(false),
|
|
|
|
|
mShowCarriedLeft(true),
|
|
|
|
|
mNpcType(Type_Normal),
|
|
|
|
|
mFirstPersonFieldOfView(firstPersonFieldOfView),
|
|
|
|
|
mSoundsDisabled(disableSounds),
|
|
|
|
|
mAccurateAiming(false),
|
|
|
|
|
mAimingFactor(0.f)
|
|
|
|
@ -336,6 +339,37 @@ public:
|
|
|
|
|
osg::ref_ptr<osg::Depth> mDepth;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Overrides Field of View to given value for rendering the subgraph.
|
|
|
|
|
/// Must be added as cull callback.
|
|
|
|
|
class OverrideFieldOfViewCallback : public osg::NodeCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OverrideFieldOfViewCallback(float fov)
|
|
|
|
|
: mFov(fov)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
|
|
|
|
{
|
|
|
|
|
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
|
|
|
|
|
osg::RefMatrix* projectionMatrix = new osg::RefMatrix(*cv->getProjectionMatrix());
|
|
|
|
|
float fov, aspect, zNear, zFar;
|
|
|
|
|
if (projectionMatrix->getPerspective(fov, aspect, zNear, zFar))
|
|
|
|
|
{
|
|
|
|
|
fov = mFov;
|
|
|
|
|
projectionMatrix->makePerspective(fov, aspect, zNear, zFar);
|
|
|
|
|
cv->pushProjectionMatrix(projectionMatrix);
|
|
|
|
|
traverse(node, nv);
|
|
|
|
|
cv->popProjectionMatrix();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
traverse(node, nv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
float mFov;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void NpcAnimation::setRenderBin()
|
|
|
|
|
{
|
|
|
|
|
if (mViewMode == VM_FirstPerson)
|
|
|
|
@ -445,6 +479,7 @@ void NpcAnimation::updateNpcBase()
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mObjectRoot->setNodeMask(Mask_FirstPerson);
|
|
|
|
|
mObjectRoot->addCullCallback(new OverrideFieldOfViewCallback(mFirstPersonFieldOfView));
|
|
|
|
|
if(isWerewolf)
|
|
|
|
|
addAnimSource(smodel);
|
|
|
|
|
else
|
|
|
|
|