#pragma once #if 0 #include #include #include #include #include #include #include "scene/SkyDome.h" class OsgView; enum DrawMask { CAST_SHADOW = (0x1 << 30), RECEIVE_SHADOW = (0x1 << 29), }; class OsgScene : public osg::Referenced { public: enum SCENE_TYPE { CLEAR, DUSK, CLOUDY }; public: OsgScene( const osg::Vec2f& windDirection = osg::Vec2f(1.0f, 1.0f), float windSpeed = 12.f, float depth = 10000.f, float reflectionDamping = 0.35f, float scale = 1e-8, bool isChoppy = true, float choppyFactor = -2.5f, float crestFoamHeight = 2.2f, double oceanSurfaceHeight = 0.0f, bool testCollision = false, bool disableShaders = false, bool useVBO = false, bool useShadows = false, const std::string& terrain_shader_basename = "terrain"); void Build( const osg::Vec2f& windDirection, float windSpeed, float depth, float reflectionDamping, float waveScale, bool isChoppy, float choppyFactor, float crestFoamHeight, double oceanSurfaceHeight, bool testCollision, bool disableShaders, bool useVBO, bool useShadows, const std::string& terrain_shader_basename); void ChangeScene(SCENE_TYPE type); void UseShadows(bool useDebugDraw); void InitEventHandle(OsgView* view); void AttachView(OsgView* view); void DetachView(OsgView* view); osg::Node* LoadIslands(const std::string& terrain_shader_basename); osg::ref_ptr LoadCubeMapTextures(const std::string& dir); osg::Geode* SunDebug(const osg::Vec3f& position); inline osg::Vec4f IntColor(unsigned r, unsigned g, unsigned b, unsigned a = 255) { float div = 1.f / 255.f; return osg::Vec4f(div * (float)r, div * (float)g, div * float(b), div * (float)a); } inline osgOcean::OceanScene::EventHandler* GetOceanSceneEventHandler() { return oceanScene_->getEventHandler(); } inline osgOcean::OceanTechnique* GetOceanSurface(void) { return FFToceanSurface_.get(); } osg::Group* GetData(); inline osg::Group* GetScene(void) { return scene_.get(); } inline osgOcean::OceanScene* GetOceanScene() { return oceanScene_.get(); } void AddToOceanScene(osg::Node* node); osg::Light* GetLight() { return light_.get(); } void TestBuildModel(); private: SCENE_TYPE sceneType_; bool useVBO_{ true }; bool disableShaders_{ false }; bool useShadows_{ false }; double oceanSurfaceHeight_{ 0.0 }; osg::ref_ptr modeText_; osg::ref_ptr scene_; osg::ref_ptr entityRoot_; osg::ref_ptr oceanScene_; osg::ref_ptr FFToceanSurface_; osg::ref_ptr cubemap_; osg::ref_ptr skyDome_; std::vector cubemapDirs_; std::vector lightColors_; std::vector fogColors_; std::vector underwaterAttenuations_; std::vector underwaterDiffuse_; osg::ref_ptr light_; std::vector sunPositions_; std::vector sunDiffuse_; std::vector waterFogColors_; osg::ref_ptr islandSwitch_; }; #endif