Changeset 305 for osgVisual/trunk


Ignore:
Timestamp:
Jul 19, 2011, 9:47:13 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/include/distortion/visual_distortion.h

    r221 r305  
    481481
    482482        /**
    483          * Target implementation which should be used to distort.
    484          */
    485         osg::Camera::RenderTargetImplementation renderImplementation;
    486 
    487         /**
    488483         * 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.
    489484         */
  • osgVisual/trunk/include/util/terrainQuery.h

    r300 r305  
    1515*/
    1616
    17 #ifndef OSGSIM_HEIGHTABOVETERRAIN
    18 #define OSGSIM_HEIGHTABOVETERRAIN 1
     17#ifndef osgVisual_HEIGHTABOVETERRAIN
     18#define osgVisual_HEIGHTABOVETERRAIN 1
    1919
    2020#include <osgUtil/IntersectionVisitor>
     
    2323#include <osgSim/LineOfSight>
    2424
    25 namespace osgSim {
     25namespace osgVisual {
    2626
    2727/** Helper class for setting up and acquiring height above terrain intersections with terrain.
    28   * By default assigns a osgSim::DatabaseCacheReadCallback that enables automatic loading
     28  * By default assigns a osgVisual::DatabaseCacheReadCallback that enables automatic loading
    2929  * of external PagedLOD tiles to ensure that the highest level of detail is used in intersections.
    3030  * This automatic loading of tiles is done by the intersection traversal that is done within
     
    3333  * The external loading of tiles can be disabled by removing the read callback, this is done by
    3434  * calling the setDatabaseCacheReadCallback(DatabaseCacheReadCallback*) method with a value of 0.*/
    35 class OSGSIM_EXPORT HeightAboveTerrain
     35class terrainQuery
    3636{
    3737    public :
    3838
     39                enum DataSource
     40                {
     41                        LOADED_SCENE,
     42                        PAGE_HIGHEST_LOD
     43                       
     44                };
    3945   
    40         HeightAboveTerrain(bool loadHighestLOD = true);
     46        terrainQuery();
    4147       
    4248   
     
    8187
    8288        /** 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);
    8490       
    8591                /** 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);
    8793
    8894       
     
    9399          * Note, if you have multiple LineOfSight or HeightAboveTerrain objects in use at one time then you should share a single
    94100          * DatabaseCacheReadCallback between all of them. */
    95         void setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc);
     101                void setDatabaseCacheReadCallback(osgSim::DatabaseCacheReadCallback* dcrc);
    96102
    97103        /** Get the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.*/
    98         DatabaseCacheReadCallback* getDatabaseCacheReadCallback() { return _dcrc.get(); }
     104                osgSim::DatabaseCacheReadCallback* getDatabaseCacheReadCallback() { return _dcrc.get(); }
    99105       
    100106    protected :
     
    118124        HATList                                 _HATList;
    119125
    120        
    121         osg::ref_ptr<DatabaseCacheReadCallback> _dcrc;
     126                osg::ref_ptr<osgSim::DatabaseCacheReadCallback> _dcrc;
    122127        osgUtil::IntersectionVisitor            _intersectionVisitor;
    123128
  • osgVisual/trunk/src/core/visual_core.cpp

    r273 r305  
    4747        // Configure osg to use KdTrees
    4848        osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
     49
     50        // Configure Multisampling
     51        osg::DisplaySettings::instance()->setNumMultiSamples(4);
    4952
    5053        // Setup pathes
     
    370373        else
    371374        {
    372                 OSG_ALWAYS << "BorderEqual activated" << std::endl;
    373                 terrain->setEqualizeBoundaries(true);
     375                //OSG_ALWAYS << "BorderEqual activated" << std::endl;
     376                //terrain->setEqualizeBoundaries(true);
    374377        }
    375378
  • osgVisual/trunk/src/distortion/visual_distortion.cpp

    r247 r305  
    9797                                                        OSG_NOTIFY(osg::WARN) << "WARNING: Unable to parse Frustum values from '" << pre_cfg<<channelname<<post_cfg << "' -- continue without valid frustum values." << std::endl;
    9898                                        }
    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" )
    113100                                        {
    114101                                                std::stringstream sstr(attr_value);
     
    185172        tex_width = 2048;
    186173    tex_height = 2048;
    187         renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT;
    188         useTextureRectangle = false;
    189174        useShaderDistortion = false;
    190175        useHDR = false;
     
    270255
    271256    // 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;
    293265
    294266    if (useHDR)
     
    328300        osg::Vec3 yAxis(0.0f,1.0f,0.0f);
    329301        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;
    332304        int noSteps = 128;
    333305        if (useShaderDistortion)
     
    423395        camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    424396        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               
    429399        // set the camera to render before the main camera.
    430400        camera->setRenderOrder(osg::Camera::POST_RENDER, 200);
    431 
     401               
    432402        // only clear the depth buffer
    433403        camera->setClearMask(0);
     
    495465
    496466        // tell the camera to use OpenGL frame buffer object where supported.
    497         camera->setRenderTargetImplementation(renderImplementation);
     467        camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
    498468
    499469        // attach the texture and use it as the color buffer.
    500         camera->attach(osg::Camera::COLOR_BUFFER, texture);     // No Multisampling/Antialiasing
    501                 //camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, 0, false, 4, 4); // 4x Multisampling/Antialiasing
     470        //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
    502472
    503473        // add subgraph to render
  • osgVisual/trunk/src/draw2D/visual_debug_hud.cpp

    r298 r305  
    1616
    1717#include <visual_debug_hud.h>
    18 #include <osgSim/HeightAboveTerrain>
     18#include <terrainQuery.h>
    1919
    2020using namespace osgVisual;
     
    142142
    143143        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);
    146146
    147         double x = 0;
     147        /*double x = 0;
    148148        double y = 0;
    149149        double z = 0;
    150150
    151151        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);*/
    154154
    155155
  • osgVisual/trunk/src/util/terrainQuery.cpp

    r302 r305  
    2121#include <osgUtil/LineSegmentIntersector>
    2222
     23using namespace osgVisual;
    2324using namespace osgSim;
    2425
    25 HeightAboveTerrain::HeightAboveTerrain(bool loadHighestLOD)
     26terrainQuery::terrainQuery()
    2627{
    2728    _lowestHeight = -1000.0;
    2829   
    29         if(loadHighestLOD)
    30                 setDatabaseCacheReadCallback(new DatabaseCacheReadCallback);
     30        setDatabaseCacheReadCallback(new DatabaseCacheReadCallback);
    3131}
    3232
    33 void HeightAboveTerrain::clear()
     33void terrainQuery::clear()
    3434{
    3535    _HATList.clear();
    3636}
    3737
    38 unsigned int HeightAboveTerrain::addPoint(const osg::Vec3d& point)
     38unsigned int terrainQuery::addPoint(const osg::Vec3d& point)
    3939{
    4040    unsigned int index = _HATList.size();
     
    4343}
    4444
    45 void HeightAboveTerrain::computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask)
     45void terrainQuery::computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask)
    4646{
    4747    osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(scene);
     
    128128}
    129129
    130 double HeightAboveTerrain::computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, bool loadHighestLOD, osg::Node::NodeMask traversalMask)
     130double terrainQuery::computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, DataSource pagingBehaviour, osg::Node::NodeMask traversalMask)
    131131{
    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);
    136138}
    137139
    138 double HeightAboveTerrain::computeHeightOfTerrain(osg::Node* scene, const osg::Vec3d& point, bool loadHighestLOD, osg::Node::NodeMask traversalMask)
     140double terrainQuery::computeHeightOfTerrain(osg::Node* scene, const osg::Vec3d& point, DataSource pagingBehaviour, osg::Node::NodeMask traversalMask)
    139141{
    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);
    144146}
    145147
    146 void HeightAboveTerrain::setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc)
     148void terrainQuery::setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc)
    147149{
    148150    _dcrc = dcrc;
Note: See TracChangeset for help on using the changeset viewer.