Changeset 305 for osgVisual/trunk
- Timestamp:
- Jul 19, 2011, 9:47:13 PM (13 years ago)
- Location:
- osgVisual/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/trunk/include/distortion/visual_distortion.h
r221 r305 481 481 482 482 /** 483 * Target implementation which should be used to distort.484 */485 osg::Camera::RenderTargetImplementation renderImplementation;486 487 /**488 483 * Reference to the global ArgumentParser. The arguments are required to add the help entry for the toggle distortion key. All other configuration is located in the XML file. 489 484 */ -
osgVisual/trunk/include/util/terrainQuery.h
r300 r305 15 15 */ 16 16 17 #ifndef OSGSIM_HEIGHTABOVETERRAIN18 #define OSGSIM_HEIGHTABOVETERRAIN 117 #ifndef osgVisual_HEIGHTABOVETERRAIN 18 #define osgVisual_HEIGHTABOVETERRAIN 1 19 19 20 20 #include <osgUtil/IntersectionVisitor> … … 23 23 #include <osgSim/LineOfSight> 24 24 25 namespace osg Sim{25 namespace osgVisual { 26 26 27 27 /** Helper class for setting up and acquiring height above terrain intersections with terrain. 28 * By default assigns a osg Sim::DatabaseCacheReadCallback that enables automatic loading28 * By default assigns a osgVisual::DatabaseCacheReadCallback that enables automatic loading 29 29 * of external PagedLOD tiles to ensure that the highest level of detail is used in intersections. 30 30 * This automatic loading of tiles is done by the intersection traversal that is done within … … 33 33 * The external loading of tiles can be disabled by removing the read callback, this is done by 34 34 * calling the setDatabaseCacheReadCallback(DatabaseCacheReadCallback*) method with a value of 0.*/ 35 class OSGSIM_EXPORT HeightAboveTerrain35 class terrainQuery 36 36 { 37 37 public : 38 38 39 enum DataSource 40 { 41 LOADED_SCENE, 42 PAGE_HIGHEST_LOD 43 44 }; 39 45 40 HeightAboveTerrain(bool loadHighestLOD = true);46 terrainQuery(); 41 47 42 48 … … 81 87 82 88 /** Compute the vertical distance between the specified scene graph and a single HAT point. */ 83 static double computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, bool loadHighestLOD = true, osg::Node::NodeMask traversalMask=0xffffffff);89 static double computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, DataSource pagingBehaviour, osg::Node::NodeMask traversalMask=0xffffffff); 84 90 85 91 /** Compute the vertical position of the scene at a single HOT point. */ 86 static double computeHeightOfTerrain(osg::Node* scene, const osg::Vec3d& point, bool loadHighestLOD = true, osg::Node::NodeMask traversalMask=0xffffffff);92 static double computeHeightOfTerrain(osg::Node* scene, const osg::Vec3d& point, DataSource pagingBehaviour, osg::Node::NodeMask traversalMask=0xffffffff); 87 93 88 94 … … 93 99 * Note, if you have multiple LineOfSight or HeightAboveTerrain objects in use at one time then you should share a single 94 100 * DatabaseCacheReadCallback between all of them. */ 95 void setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc);101 void setDatabaseCacheReadCallback(osgSim::DatabaseCacheReadCallback* dcrc); 96 102 97 103 /** Get the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.*/ 98 104 osgSim::DatabaseCacheReadCallback* getDatabaseCacheReadCallback() { return _dcrc.get(); } 99 105 100 106 protected : … … 118 124 HATList _HATList; 119 125 120 121 osg::ref_ptr<DatabaseCacheReadCallback> _dcrc; 126 osg::ref_ptr<osgSim::DatabaseCacheReadCallback> _dcrc; 122 127 osgUtil::IntersectionVisitor _intersectionVisitor; 123 128 -
osgVisual/trunk/src/core/visual_core.cpp
r273 r305 47 47 // Configure osg to use KdTrees 48 48 osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES); 49 50 // Configure Multisampling 51 osg::DisplaySettings::instance()->setNumMultiSamples(4); 49 52 50 53 // Setup pathes … … 370 373 else 371 374 { 372 OSG_ALWAYS << "BorderEqual activated" << std::endl;373 terrain->setEqualizeBoundaries(true);375 //OSG_ALWAYS << "BorderEqual activated" << std::endl; 376 //terrain->setEqualizeBoundaries(true); 374 377 } 375 378 -
osgVisual/trunk/src/distortion/visual_distortion.cpp
r247 r305 97 97 OSG_NOTIFY(osg::WARN) << "WARNING: Unable to parse Frustum values from '" << pre_cfg<<channelname<<post_cfg << "' -- continue without valid frustum values." << std::endl; 98 98 } 99 if( attr_name == "renderimplementation" ) 100 { 101 if(attr_value=="fbo") 102 renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT; 103 if(attr_value=="pbuffer") 104 renderImplementation = osg::Camera::PIXEL_BUFFER; 105 if(attr_value=="pbuffer-rtt") 106 renderImplementation = osg::Camera::PIXEL_BUFFER_RTT; 107 if(attr_value=="fb") 108 renderImplementation = osg::Camera::FRAME_BUFFER; 109 if(attr_value=="window") 110 renderImplementation = osg::Camera::SEPERATE_WINDOW; 111 } 112 if( attr_name == "width" ) 99 if( attr_name == "width" ) 113 100 { 114 101 std::stringstream sstr(attr_value); … … 185 172 tex_width = 2048; 186 173 tex_height = 2048; 187 renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT;188 useTextureRectangle = false;189 174 useShaderDistortion = false; 190 175 useHDR = false; … … 270 255 271 256 // texture to render to and to use for rendering of flag. 272 osg::Texture* texture = 0; 273 if (useTextureRectangle) 274 { 275 osg::TextureRectangle* textureRect = new osg::TextureRectangle; 276 textureRect->setTextureSize(tex_width, tex_height); 277 textureRect->setInternalFormat(GL_RGBA); 278 textureRect->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); 279 textureRect->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); 280 281 texture = textureRect; 282 } 283 else 284 { 285 osg::Texture2D* texture2D = new osg::Texture2D; 286 texture2D->setTextureSize(tex_width, tex_height); 287 texture2D->setInternalFormat(GL_RGBA); 288 texture2D->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); 289 texture2D->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); 290 291 texture = texture2D; 292 } 257 //osg::Texture* texture = 0; 258 osg::Texture2D* texture = new osg::Texture2D; 259 texture->setTextureSize(tex_width, tex_height); 260 texture->setInternalFormat(GL_RGBA); 261 texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); 262 texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); 263 264 //texture = texture2D; 293 265 294 266 if (useHDR) … … 328 300 osg::Vec3 yAxis(0.0f,1.0f,0.0f); 329 301 osg::Vec3 zAxis(0.0f,0.0f,1.0f); 330 float height = 1024.0f;331 float width = 1280.0f;302 float width = 1600.0f; 303 float height = 900.0f; 332 304 int noSteps = 128; 333 305 if (useShaderDistortion) … … 423 395 camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); 424 396 camera->setViewMatrix(osg::Matrix::identity()); 425 //sceneCamera->setProjectionMatrixAsOrtho2D(0,viewer->getCamera()->getViewport()->width(),0,viewer->getCamera()->getViewport()->height()); 426 camera->setProjectionMatrixAsOrtho2D(0,1280,0,1024); 427 /** \todo: use screen size dynamically */ 428 397 camera->setProjectionMatrixAsOrtho2D(0,1600,0,900); /** \todo: use screen size dynamically */ 398 429 399 // set the camera to render before the main camera. 430 400 camera->setRenderOrder(osg::Camera::POST_RENDER, 200); 431 401 432 402 // only clear the depth buffer 433 403 camera->setClearMask(0); … … 495 465 496 466 // tell the camera to use OpenGL frame buffer object where supported. 497 camera->setRenderTargetImplementation( renderImplementation);467 camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); 498 468 499 469 // attach the texture and use it as the color buffer. 500 camera->attach(osg::Camera::COLOR_BUFFER, texture); // No Multisampling/Antialiasing501 //camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, 0, false, 4, 4); // 4x Multisampling/Antialiasing470 //camera->attach(osg::Camera::COLOR_BUFFER, texture); // No Multisampling/Antialiasing 471 camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, 0, false, 4, 4); // 4x Multisampling/Antialiasing 502 472 503 473 // add subgraph to render -
osgVisual/trunk/src/draw2D/visual_debug_hud.cpp
r298 r305 16 16 17 17 #include <visual_debug_hud.h> 18 #include < osgSim/HeightAboveTerrain>18 #include <terrainQuery.h> 19 19 20 20 using namespace osgVisual; … … 142 142 143 143 util::getWGS84ofCamera( sceneCamera, csn, lat, lon, alt ); 144 //util::queryHeightAboveTerrainInWGS84(hat, csn, lat, lon, alt);145 //util::queryHeightOfTerrain(hot, csn, lat, lon);144 util::queryHeightAboveTerrainInWGS84(hat, csn, lat, lon, alt); 145 util::queryHeightOfTerrain(hot, csn, lat, lon); 146 146 147 double x = 0;147 /*double x = 0; 148 148 double y = 0; 149 149 double z = 0; 150 150 151 151 util::getXYZofCamera( sceneCamera, x, y, z ); 152 hat = osgSim::HeightAboveTerrain::computeHeightAboveTerrain(csn, osg::Vec3d(x,y,z), false);153 hot = osgSim::HeightAboveTerrain::computeHeightOfTerrain(csn, osg::Vec3d(x,y,z), false);152 hat = terrainQuery::computeHeightAboveTerrain(csn, osg::Vec3d(x,y,z), terrainQuery::PAGE_HIGHEST_LOD); 153 hot = terrainQuery::computeHeightOfTerrain(csn, osg::Vec3d(x,y,z), terrainQuery::PAGE_HIGHEST_LOD);*/ 154 154 155 155 -
osgVisual/trunk/src/util/terrainQuery.cpp
r302 r305 21 21 #include <osgUtil/LineSegmentIntersector> 22 22 23 using namespace osgVisual; 23 24 using namespace osgSim; 24 25 25 HeightAboveTerrain::HeightAboveTerrain(bool loadHighestLOD)26 terrainQuery::terrainQuery() 26 27 { 27 28 _lowestHeight = -1000.0; 28 29 29 if(loadHighestLOD) 30 setDatabaseCacheReadCallback(new DatabaseCacheReadCallback); 30 setDatabaseCacheReadCallback(new DatabaseCacheReadCallback); 31 31 } 32 32 33 void HeightAboveTerrain::clear()33 void terrainQuery::clear() 34 34 { 35 35 _HATList.clear(); 36 36 } 37 37 38 unsigned int HeightAboveTerrain::addPoint(const osg::Vec3d& point)38 unsigned int terrainQuery::addPoint(const osg::Vec3d& point) 39 39 { 40 40 unsigned int index = _HATList.size(); … … 43 43 } 44 44 45 void HeightAboveTerrain::computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask)45 void terrainQuery::computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask) 46 46 { 47 47 osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(scene); … … 128 128 } 129 129 130 double HeightAboveTerrain::computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, bool loadHighestLOD, osg::Node::NodeMask traversalMask)130 double terrainQuery::computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, DataSource pagingBehaviour, osg::Node::NodeMask traversalMask) 131 131 { 132 HeightAboveTerrain hat(loadHighestLOD); 133 unsigned int index = hat.addPoint(point); 134 hat.computeIntersections(scene, traversalMask); 135 return hat.getHeightAboveTerrain(index); 132 terrainQuery qt; 133 /*if(!loadHighestLOD) 134 qt.setDatabaseCacheReadCallback(0);*/ 135 unsigned int index = qt.addPoint(point); 136 qt.computeIntersections(scene, traversalMask); 137 return qt.getHeightAboveTerrain(index); 136 138 } 137 139 138 double HeightAboveTerrain::computeHeightOfTerrain(osg::Node* scene, const osg::Vec3d& point, bool loadHighestLOD, osg::Node::NodeMask traversalMask)140 double terrainQuery::computeHeightOfTerrain(osg::Node* scene, const osg::Vec3d& point, DataSource pagingBehaviour, osg::Node::NodeMask traversalMask) 139 141 { 140 HeightAboveTerrain hat(loadHighestLOD);141 unsigned int index = hat.addPoint(point);142 hat.computeIntersections(scene, traversalMask);143 return hat.getHeightOfTerrain(index);142 terrainQuery qt; 143 unsigned int index = qt.addPoint(point); 144 qt.computeIntersections(scene, traversalMask); 145 return qt.getHeightOfTerrain(index); 144 146 } 145 147 146 void HeightAboveTerrain::setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc)148 void terrainQuery::setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc) 147 149 { 148 150 _dcrc = dcrc;
Note: See TracChangeset
for help on using the changeset viewer.