|
|
|
@ -39,6 +39,7 @@
|
|
|
|
|
#include <components/sceneutil/statesetupdater.hpp>
|
|
|
|
|
#include <components/sceneutil/controller.hpp>
|
|
|
|
|
#include <components/sceneutil/visitor.hpp>
|
|
|
|
|
#include <components/nifosg/particle.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
@ -46,6 +47,8 @@
|
|
|
|
|
#include "vismask.hpp"
|
|
|
|
|
#include "renderbin.hpp"
|
|
|
|
|
|
|
|
|
|
#define PARTICLE_WIDTH 600.0
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -1091,8 +1094,9 @@ private:
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneManager)
|
|
|
|
|
SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneManager, MWRender::RenderingManager *renderingManager)
|
|
|
|
|
: mSceneManager(sceneManager)
|
|
|
|
|
, mRendering(renderingManager)
|
|
|
|
|
, mAtmosphereNightRoll(0.f)
|
|
|
|
|
, mCreated(false)
|
|
|
|
|
, mIsStorm(false)
|
|
|
|
@ -1337,6 +1341,43 @@ protected:
|
|
|
|
|
osg::Uniform* mRainIntensityUniform;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class WeatherParticleDrawCallback : public osg::Drawable::DrawCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
WeatherParticleDrawCallback(MWRender::RenderingManager *renderingManager) : osg::Drawable::DrawCallback()
|
|
|
|
|
{
|
|
|
|
|
mRendering = renderingManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void drawImplementation(osg::RenderInfo& renderInfo, const osg::Drawable *drawable) const
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3 cameraPos = mRendering->getCameraPosition();
|
|
|
|
|
osg::Vec3 cameraOffset = osg::Vec3(
|
|
|
|
|
PARTICLE_WIDTH - fmod(cameraPos.x(), PARTICLE_WIDTH / 2),
|
|
|
|
|
PARTICLE_WIDTH - fmod(cameraPos.y(), PARTICLE_WIDTH / 2),
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
osgParticle::ParticleSystem *ps = (osgParticle::ParticleSystem *) drawable;
|
|
|
|
|
|
|
|
|
|
for (int xOff = 0; xOff < 3; xOff++)
|
|
|
|
|
for (int yOff = 0; yOff < 3; yOff++)
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3 offset = cameraOffset + osg::Vec3(-1 * xOff * PARTICLE_WIDTH, -1 * yOff * PARTICLE_WIDTH,0);
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < ps->numParticles(); i++)
|
|
|
|
|
ps->getParticle(i)->setPosition(ps->getParticle(i)->getPosition() + offset);
|
|
|
|
|
|
|
|
|
|
ps->drawImplementation(renderInfo);
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < ps->numParticles(); i++)
|
|
|
|
|
ps->getParticle(i)->setPosition(ps->getParticle(i)->getPosition() - offset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
MWRender::RenderingManager *mRendering;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void SkyManager::createRain()
|
|
|
|
|
{
|
|
|
|
|
if (mRainNode)
|
|
|
|
@ -1345,6 +1386,8 @@ void SkyManager::createRain()
|
|
|
|
|
mRainNode = new osg::Group;
|
|
|
|
|
|
|
|
|
|
mRainParticleSystem = new osgParticle::ParticleSystem;
|
|
|
|
|
mRainParticleSystem->setDrawCallback(new WeatherParticleDrawCallback(mRendering));
|
|
|
|
|
|
|
|
|
|
mRainParticleSystem->setParticleAlignment(osgParticle::ParticleSystem::FIXED);
|
|
|
|
|
mRainParticleSystem->setAlignVectorX(osg::Vec3f(0.1,0,0));
|
|
|
|
|
mRainParticleSystem->setAlignVectorY(osg::Vec3f(0,0,1));
|
|
|
|
@ -1370,8 +1413,8 @@ void SkyManager::createRain()
|
|
|
|
|
emitter->setParticleSystem(mRainParticleSystem);
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osgParticle::BoxPlacer> placer (new osgParticle::BoxPlacer);
|
|
|
|
|
placer->setXRange(-300, 300); // Rain_Diameter
|
|
|
|
|
placer->setYRange(-300, 300);
|
|
|
|
|
placer->setXRange(-PARTICLE_WIDTH / 2, PARTICLE_WIDTH / 2); // Rain_Diameter
|
|
|
|
|
placer->setYRange(-PARTICLE_WIDTH / 2, PARTICLE_WIDTH / 2);
|
|
|
|
|
placer->setZRange(300, 300);
|
|
|
|
|
emitter->setPlacer(placer);
|
|
|
|
|
|
|
|
|
@ -1559,6 +1602,12 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|
|
|
|
|
|
|
|
|
SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
|
|
|
|
|
mParticleEffect->accept(disableFreezeOnCullVisitor);
|
|
|
|
|
|
|
|
|
|
osgParticle::ParticleSystem *ps = (osgParticle::ParticleSystem *)
|
|
|
|
|
(mParticleEffect->asGroup()->getChild(1)->asGroup()->getChild(0)
|
|
|
|
|
->asGroup()->getChild(2));
|
|
|
|
|
|
|
|
|
|
ps->setDrawCallback(new WeatherParticleDrawCallback(mRendering));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|