|
|
@ -5,6 +5,7 @@
|
|
|
|
#include <osg/Depth>
|
|
|
|
#include <osg/Depth>
|
|
|
|
|
|
|
|
|
|
|
|
#include <osgUtil/RenderBin>
|
|
|
|
#include <osgUtil/RenderBin>
|
|
|
|
|
|
|
|
#include <osgUtil/CullVisitor>
|
|
|
|
|
|
|
|
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
|
|
|
|
|
|
|
@ -274,13 +275,15 @@ NpcAnimation::~NpcAnimation()
|
|
|
|
mPtr.getClass().getInventoryStore(mPtr).setListener(NULL, mPtr);
|
|
|
|
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),
|
|
|
|
: Animation(ptr, parentNode, resourceSystem),
|
|
|
|
mListenerDisabled(disableListener),
|
|
|
|
mListenerDisabled(disableListener),
|
|
|
|
mViewMode(viewMode),
|
|
|
|
mViewMode(viewMode),
|
|
|
|
mShowWeapons(false),
|
|
|
|
mShowWeapons(false),
|
|
|
|
mShowCarriedLeft(true),
|
|
|
|
mShowCarriedLeft(true),
|
|
|
|
mNpcType(Type_Normal),
|
|
|
|
mNpcType(Type_Normal),
|
|
|
|
|
|
|
|
mFirstPersonFieldOfView(firstPersonFieldOfView),
|
|
|
|
mSoundsDisabled(disableSounds),
|
|
|
|
mSoundsDisabled(disableSounds),
|
|
|
|
mAccurateAiming(false),
|
|
|
|
mAccurateAiming(false),
|
|
|
|
mAimingFactor(0.f)
|
|
|
|
mAimingFactor(0.f)
|
|
|
@ -336,6 +339,37 @@ public:
|
|
|
|
osg::ref_ptr<osg::Depth> mDepth;
|
|
|
|
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()
|
|
|
|
void NpcAnimation::setRenderBin()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mViewMode == VM_FirstPerson)
|
|
|
|
if (mViewMode == VM_FirstPerson)
|
|
|
@ -445,6 +479,7 @@ void NpcAnimation::updateNpcBase()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mObjectRoot->setNodeMask(Mask_FirstPerson);
|
|
|
|
mObjectRoot->setNodeMask(Mask_FirstPerson);
|
|
|
|
|
|
|
|
mObjectRoot->addCullCallback(new OverrideFieldOfViewCallback(mFirstPersonFieldOfView));
|
|
|
|
if(isWerewolf)
|
|
|
|
if(isWerewolf)
|
|
|
|
addAnimSource(smodel);
|
|
|
|
addAnimSource(smodel);
|
|
|
|
else
|
|
|
|
else
|
|
|
|