Ignore:
Timestamp:
Aug 2, 2011, 11:38:09 PM (13 years ago)
Author:
Torben Dannhauer
Message:

first try to select a vertex in a mesh.
Nextstep: catch mouse drags from the GA, transform into mesh CF and modify vertex.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/main.cpp

    r308 r309  
    1717*/
    1818
     19#include "distortionNG.h"
     20
    1921#include <osg/ArgumentParser>
     22#include <osg/PolygonOffset>
     23
    2024#include <osgDB/ReadFile>
    2125
     
    9397    if (!rootnode)
    9498    {
    95         osg::notify(osg::WARN)<<"Warning: no valid data loaded, please specify a database on the command line."<<std::endl;
    96         return 1;
     99                rootnode = osgDB::readNodeFile("cow.osgt");
     100                if(!rootnode)
     101                {
     102                        osg::notify(osg::WARN)<<"Warning: no valid data loaded, please specify a database on the command line."<<std::endl;
     103                        return 1;
     104                }
    97105    }
    98106
     107        osg::ref_ptr<osg::Geode> geode = new osg::Geode;
     108        geode->addDrawable( distortionNG::createMesh(16, 9) );
     109        geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
     110        geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) );
    99111
    100     // add a viewport to the viewer and attach the scene graph.
    101     viewer.setSceneData( rootnode );
     112        osg::ref_ptr<distortionHandler> selector = new distortionHandler( viewer.getCamera() );
    102113
     114        osg::ref_ptr<osg::Group> root = new osg::Group;
     115        root->addChild( geode.get() );
     116        root->addChild( selector->createVertexHighlighter() );
    103117
    104     // run the viewers main loop
    105     return viewer.run();
     118        viewer.addEventHandler( selector.get() );
     119        viewer.setSceneData( root.get() );
    106120
     121        // Avoid that the highlighter is culled away
     122        osg::CullSettings::CullingMode mode = viewer.getCamera()->getCullingMode();
     123        viewer.getCamera()->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) );
     124       
     125        // run the viewers main loop
     126        return viewer.run();
    107127}
Note: See TracChangeset for help on using the changeset viewer.