|
使用osgocean生成的水面是黑色的,添加雾效和反射均无效果,效果图和代码已贴上,望大佬帮我看看!
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
//添加海洋
osg::ref_ptr<osgOcean::FFTOceanSurface> oceanSurface = new osgOcean::FFTOceanSurface(64, 256, 17, osg::Vec2f(1.1f, 1.1f), 12.0f, 1000.0f, 0.8, 1e-8, true, 2.5, 10.f, 256);
osg::ref_ptr<osgOcean::OceanScene> oceanScene = new osgOcean::OceanScene(oceanSurface.get());
viewer->addEventHandler(oceanSurface->getEventHandler());
viewer->addEventHandler(oceanScene->getEventHandler());
//添加天空盒
osg::ref_ptr<osg::TextureCubeMap> cubMap = loadCubeMapTexture();
osg::ref_ptr<SkyDome> skyDome = new SkyDome(1900.0f, 16, 16, cubMap);
skyDome->setNodeMask(oceanScene->getReflectedSceneMask() | oceanScene->getNormalSceneMask());
osg::MatrixTransform *transform = new osg::MatrixTransform;
transform->setDataVariance(osg::Object:YNAMIC);
transform->setMatrix(osg::Matrixf::translate(osg::Vec3f(0, 0, 0)));
transform->setCullCallback(new CameraTrackCallback);
transform->addChild(skyDome);
oceanScene->addChild(transform);
//添加雾效与反射
oceanScene->setAboveWaterFog(0.0012, osg::Vec4f(0.67, 0.87, 0.98, 1.0)); //雾浓度 雾颜色
oceanScene->enableReflections(true);
oceanSurface->setEnvironmentMap(cubMap);
osgGA::TrackballManipulator* tb = new osgGA::TrackballManipulator;
tb->setHomePosition(osg::Vec3f(0.0, 0.0f, 20.0f), osg::Vec3f(0.0f, 20.0f, 20.0f), osg::Vec3f(0, 0, 1));
viewer->setCameraManipulator(tb);
viewer->setSceneData(oceanScene);
viewer->run();
return 0;
|
-
-
|