|
|
@ -2,6 +2,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <osg/UserDataContainer>
|
|
|
|
#include <osg/UserDataContainer>
|
|
|
|
#include <osg/MatrixTransform>
|
|
|
|
#include <osg/MatrixTransform>
|
|
|
|
|
|
|
|
#include <osg/Depth>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <osgUtil/RenderBin>
|
|
|
|
|
|
|
|
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
|
|
|
|
|
|
|
@ -28,6 +31,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "camera.hpp"
|
|
|
|
#include "camera.hpp"
|
|
|
|
#include "rotatecontroller.hpp"
|
|
|
|
#include "rotatecontroller.hpp"
|
|
|
|
|
|
|
|
#include "renderbin.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -303,6 +307,50 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
|
|
|
|
|
|
|
|
|
|
|
mViewMode = viewMode;
|
|
|
|
mViewMode = viewMode;
|
|
|
|
rebuild();
|
|
|
|
rebuild();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setRenderBin();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief A RenderBin callback to clear the depth buffer before rendering.
|
|
|
|
|
|
|
|
class DepthClearCallback : public osgUtil::RenderBin::DrawCallback
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DepthClearCallback()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mDepth = new osg::Depth;
|
|
|
|
|
|
|
|
mDepth->setWriteMask(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void drawImplementation(osgUtil::RenderBin* bin, osg::RenderInfo& renderInfo, osgUtil::RenderLeaf*& previous)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
renderInfo.getState()->applyAttribute(mDepth);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bin->drawImplementation(renderInfo, previous);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Depth> mDepth;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NpcAnimation::setRenderBin()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mViewMode == VM_FirstPerson)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
static bool prototypeAdded = false;
|
|
|
|
|
|
|
|
if (!prototypeAdded)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
osg::ref_ptr<osgUtil::RenderBin> depthClearBin (new osgUtil::RenderBin);
|
|
|
|
|
|
|
|
depthClearBin->setDrawCallback(new DepthClearCallback);
|
|
|
|
|
|
|
|
osgUtil::RenderBin::addRenderBinPrototype("DepthClear", depthClearBin);
|
|
|
|
|
|
|
|
prototypeAdded = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::StateSet* stateset = mObjectRoot->getOrCreateStateSet();
|
|
|
|
|
|
|
|
stateset->setRenderBinDetails(RenderBin_FirstPerson, "DepthClear", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
Animation::setRenderBin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NpcAnimation::rebuild()
|
|
|
|
void NpcAnimation::rebuild()
|
|
|
|