|
|
@ -364,6 +364,7 @@ public:
|
|
|
|
Sun(osg::Group* parentNode, Resource::TextureManager& textureManager)
|
|
|
|
Sun(osg::Group* parentNode, Resource::TextureManager& textureManager)
|
|
|
|
: CelestialBody(parentNode, 1.0f, 1)
|
|
|
|
: CelestialBody(parentNode, 1.0f, 1)
|
|
|
|
, mUpdater(new Updater)
|
|
|
|
, mUpdater(new Updater)
|
|
|
|
|
|
|
|
, mInitialFlashScale(2.6f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mTransform->addUpdateCallback(mUpdater);
|
|
|
|
mTransform->addUpdateCallback(mUpdater);
|
|
|
|
|
|
|
|
|
|
|
@ -384,6 +385,8 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
mOcclusionQueryVisiblePixels = createOcclusionQueryNode(queryTransform, true);
|
|
|
|
mOcclusionQueryVisiblePixels = createOcclusionQueryNode(queryTransform, true);
|
|
|
|
mOcclusionQueryTotalPixels = createOcclusionQueryNode(queryTransform, false);
|
|
|
|
mOcclusionQueryTotalPixels = createOcclusionQueryNode(queryTransform, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createSunFlash(textureManager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~Sun()
|
|
|
|
~Sun()
|
|
|
@ -447,6 +450,34 @@ private:
|
|
|
|
return oqn;
|
|
|
|
return oqn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void createSunFlash(Resource::TextureManager& textureManager)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Texture2D> tex = textureManager.getTexture2D("textures/tx_sun_flash_grey_05.dds",
|
|
|
|
|
|
|
|
osg::Texture::CLAMP,
|
|
|
|
|
|
|
|
osg::Texture::CLAMP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> transform (new osg::PositionAttitudeTransform);
|
|
|
|
|
|
|
|
transform->setScale(osg::Vec3f(mInitialFlashScale, mInitialFlashScale, mInitialFlashScale));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mTransform->addChild(transform);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
|
|
|
|
|
|
|
transform->addChild(geode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
geode->addDrawable(createTexturedQuad());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osg::StateSet* stateset = geode->getOrCreateStateSet();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stateset->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
|
|
|
|
|
|
|
|
stateset->setAttributeAndModes(createUnlitMaterial(),
|
|
|
|
|
|
|
|
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
|
|
|
|
|
|
|
|
stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
|
|
|
|
|
|
|
|
stateset->setRenderBinDetails(RenderBin_SunGlare, "RenderBin");
|
|
|
|
|
|
|
|
stateset->setNestRenderBins(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: change size depending on occlusion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct Updater : public SceneUtil::StateSetUpdater
|
|
|
|
struct Updater : public SceneUtil::StateSetUpdater
|
|
|
|
{
|
|
|
|
{
|
|
|
|
osg::Vec4f mColor;
|
|
|
|
osg::Vec4f mColor;
|
|
|
@ -472,6 +503,7 @@ private:
|
|
|
|
osg::ref_ptr<Updater> mUpdater;
|
|
|
|
osg::ref_ptr<Updater> mUpdater;
|
|
|
|
osg::ref_ptr<osg::OcclusionQueryNode> mOcclusionQueryVisiblePixels;
|
|
|
|
osg::ref_ptr<osg::OcclusionQueryNode> mOcclusionQueryVisiblePixels;
|
|
|
|
osg::ref_ptr<osg::OcclusionQueryNode> mOcclusionQueryTotalPixels;
|
|
|
|
osg::ref_ptr<osg::OcclusionQueryNode> mOcclusionQueryTotalPixels;
|
|
|
|
|
|
|
|
float mInitialFlashScale;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Moon : public CelestialBody
|
|
|
|
class Moon : public CelestialBody
|
|
|
|