Changeset 10396

Show
Ignore:
Timestamp:
06/24/09 18:03:49 (5 years ago)
Author:
robert
Message:

Refactored preset3D/p3d plugin so that common scene graph extensions and classes now live in a separate osgPresenttation NodeKit?.

Location:
OpenSceneGraph/trunk
Files:
2 added
10 removed
11 modified
10 moved

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/applications/present3D/CMakeLists.txt

    r10389 r10396  
    11SET(TARGET_SRC 
    2     AnimationMaterial.cpp 
    32    Cluster.cpp 
    4     CompileSlideCallback.cpp 
    53    ExportHTML.cpp 
    6     PickEventHandler.cpp 
    74    PointsEventHandler.cpp 
    85    present3D.cpp 
    9     ReaderWriterP3D.cpp 
    10     ReaderWriterPaths.cpp 
    116    ReadShowFile.cpp 
    127    ShowEventHandler.cpp 
    13     SlideEventHandler.cpp 
    14     SlideShowConstructor.cpp 
    158) 
    169 
    1710SET(TARGET_H 
    18     AnimationMaterial.h 
    1911    Cluster.h 
    20     CompileSlideCallback.h 
    2112    ExportHTML.h 
    22     PickEventHandler.h 
    2313    PointsEventHandler.h 
    2414    ReadShowFile.h 
    2515    ShowEventHandler.h 
    26     SlideEventHandler.h 
    27     SlideShowConstructor.h 
    2816) 
    2917 
     
    5341ENDIF() 
    5442 
    55 SET(TARGET_ADDED_LIBRARIES osgVolume osgFX) 
     43SET(TARGET_ADDED_LIBRARIES osgVolume osgFX osgPresentation) 
    5644 
    5745IF (NOT DYNAMIC_OPENSCENEGRAPH) 
  • OpenSceneGraph/trunk/applications/present3D/ExportHTML.h

    r10117 r10396  
    1414#define EXPORTHTML_H 1 
    1515 
    16 #include "SlideEventHandler.h" 
     16#include <osgPresentation/SlideEventHandler> 
    1717#include <osgViewer/Viewer> 
    1818 
  • OpenSceneGraph/trunk/applications/present3D/ReadShowFile.cpp

    r10122 r10396  
    1414#include "ShowEventHandler.h" 
    1515 
     16#include <osgPresentation/SlideEventHandler> 
     17 
    1618#include <osg/ImageStream> 
    1719#include <osg/Shape> 
     
    161163} 
    162164 
     165osgDB::Options* createOptions(const osgDB::ReaderWriter::Options* options) 
     166{ 
     167    osg::ref_ptr<osgDB::Options> local_options = options ? options->cloneOptions() : 0; 
     168    if (!local_options) 
     169    { 
     170        local_options = osgDB::Registry::instance()->getOptions() ? 
     171                osgDB::Registry::instance()->getOptions()->cloneOptions() : 
     172                new osgDB::Options; 
     173    } 
     174 
     175    local_options->setPluginStringData("P3D_EVENTHANDLER","none"); 
     176    return local_options.release(); 
     177} 
     178 
    163179osg::Node* p3d::readHoldingSlide(const std::string& filename) 
    164180{ 
     
    170186    options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE); 
    171187    options->setOptionString("holding_slide"); 
    172  
    173     osgDB::ReaderWriter::ReadResult readResult = osgDB::Registry::instance()->readNode(filename, options.get()); 
    174     if (readResult.validNode()) return readResult.takeNode(); 
    175     else return 0; 
     188    options->setPluginStringData("P3D_EVENTHANDLER","none"); 
     189 
     190    return osgDB::readNodeFile(filename, options.get()); 
    176191} 
    177192 
     
    181196    if (!osgDB::equalCaseInsensitive(ext,"xml") && 
    182197        !osgDB::equalCaseInsensitive(ext,"p3d")) return 0; 
    183     return osgDB::readNodeFile(filename, options); 
     198 
     199    osg::ref_ptr<osgDB::Options> local_options = createOptions(options); 
     200    return osgDB::readNodeFile(filename, local_options.get()); 
    184201} 
    185202 
    186203osg::Node* p3d::readShowFiles(osg::ArgumentParser& arguments,const osgDB::ReaderWriter::Options* options) 
    187204{ 
     205    osg::ref_ptr<osgDB::Options> local_options = createOptions(options); 
    188206 
    189207    typedef std::vector< osg::ref_ptr<osg::Node> > NodeList; 
     
    193211    while (arguments.read("--image",filename)) 
    194212    { 
    195         osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), options); 
     213        osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get()); 
    196214        if (image.valid()) nodeList.push_back(osg::createGeodeForImage(image.get())); 
    197215    } 
     
    199217    while (arguments.read("--movie",filename)) 
    200218    { 
    201         osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), options); 
     219        osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get()); 
    202220        osg::ref_ptr<osg::ImageStream> imageStream = dynamic_cast<osg::ImageStream*>(image.get()); 
    203221        if (image.valid()) 
     
    210228    while (arguments.read("--dem",filename)) 
    211229    { 
    212         osg::HeightField* hf = readHeightFieldFile(filename.c_str(), options); 
     230        osg::HeightField* hf = readHeightFieldFile(filename.c_str(), local_options.get()); 
    213231        if (hf) 
    214232        { 
     
    225243        { 
    226244            // not an option so assume string is a filename. 
    227             osg::Node *node = osgDB::readNodeFile( arguments[pos], options); 
     245            osg::Node *node = osgDB::readNodeFile( arguments[pos], local_options); 
    228246 
    229247            if(node) 
     
    232250                nodeList.push_back(node); 
    233251            } 
    234  
    235252        } 
    236253    } 
  • OpenSceneGraph/trunk/applications/present3D/ReaderWriterP3D.cpp

    r10378 r10396  
    2121#include <osgWidget/PdfReader> 
    2222 
    23 #include "SlideShowConstructor.h" 
     23#include <osgPresentation/SlideShowConstructor> 
    2424 
    2525#include <stdio.h> 
  • OpenSceneGraph/trunk/applications/present3D/ReaderWriterPaths.cpp

    r10378 r10396  
    2121#include <osgWidget/PdfReader> 
    2222 
    23 #include "SlideShowConstructor.h" 
    24 #include "AnimationMaterial.h" 
     23#include <osgPresentation/SlideShowConstructor> 
     24#include <osgPresentation/AnimationMaterial> 
    2525 
    2626#include <stdio.h> 
  • OpenSceneGraph/trunk/applications/present3D/present3D.cpp

    r10389 r10396  
    3737#include <osgGA/StateSetManipulator> 
    3838 
     39#include <osgPresentation/SlideEventHandler> 
     40#include <osgPresentation/SlideShowConstructor> 
     41 
    3942#include "ReadShowFile.h" 
    40 #include "SlideEventHandler.h" 
    4143#include "PointsEventHandler.h" 
    42 #include "SlideShowConstructor.h" 
    4344#include "Cluster.h" 
    4445#include "ExportHTML.h" 
     
    347348    while (arguments.read("--loop")) loopPresentation = true; 
    348349 
     350 
    349351    // register the slide event handler - which moves the presentation from slide to slide, layer to layer. 
    350352    osgPresentation::SlideEventHandler* seh = new osgPresentation::SlideEventHandler(&viewer); 
  • OpenSceneGraph/trunk/include/osgDB/Options

    r10227 r10396  
    8585        META_Object(osgDB,Options); 
    8686 
     87        Options* cloneOptions() const { return new Options(*this); } 
     88 
    8789        /** Set the general Options string.*/ 
    8890        void setOptionString(const std::string& str) { _str = str; } 
  • OpenSceneGraph/trunk/include/osgPresentation/AnimationMaterial

    r10113 r10396  
    1717#include <osg/NodeCallback> 
    1818 
     19#include <osgPresentation/Export> 
     20 
    1921#include <map> 
    2022#include <float.h> 
    2123 
    22 namespace ss3d { 
     24namespace osgPresentation { 
    2325 
    2426/** AnimationMaterial for specify the time varying transformation pathway to use when update camera and model objects. 
     
    2628  * be attached directly to Transform nodes to move subgraphs around the scene. 
    2729*/ 
    28 class AnimationMaterial : public virtual osg::Object 
     30class OSGPRESENTATION_EXPORT AnimationMaterial : public virtual osg::Object 
    2931{ 
    3032    public: 
  • OpenSceneGraph/trunk/include/osgPresentation/CompileSlideCallback

    r10113 r10396  
    1515 
    1616#include <osgViewer/Viewer> 
     17#include <osgPresentation/Export> 
    1718 
    18 namespace ss3d { 
     19namespace osgPresentation { 
    1920 
    20 class CompileSlideCallback : public osg::Camera::DrawCallback 
     21class OSGPRESENTATION_EXPORT CompileSlideCallback : public osg::Camera::DrawCallback 
    2122{ 
    2223    public: 
  • OpenSceneGraph/trunk/include/osgPresentation/PickEventHandler

    r10117 r10396  
    1919#include <osgGA/GUIEventHandler> 
    2020 
    21 #include "SlideEventHandler.h" 
     21#include <osgPresentation/SlideEventHandler> 
    2222 
    2323namespace osgPresentation 
    2424{ 
    2525 
    26 class PickEventHandler : public osgGA::GUIEventHandler 
     26class OSGPRESENTATION_EXPORT PickEventHandler : public osgGA::GUIEventHandler 
    2727{ 
    2828    public: 
  • OpenSceneGraph/trunk/include/osgPresentation/SlideEventHandler

    r10132 r10396  
    2020#include <osgViewer/Viewer> 
    2121 
    22 #include "CompileSlideCallback.h" 
     22#include <osgPresentation/CompileSlideCallback> 
    2323 
    2424namespace osgPresentation 
     
    7373}; 
    7474 
    75 struct LayerAttributes : public virtual osg::Referenced 
     75struct OSGPRESENTATION_EXPORT LayerAttributes : public virtual osg::Referenced 
    7676{ 
    7777    LayerAttributes():_duration(0),_relativeJump(true),_slideNum(0),_layerNum(0) {} 
     
    158158}; 
    159159 
    160 class ActiveOperators 
     160class OSGPRESENTATION_EXPORT ActiveOperators 
    161161{ 
    162162public: 
     
    192192}; 
    193193 
    194 class SlideEventHandler : public osgGA::GUIEventHandler 
     194class OSGPRESENTATION_EXPORT SlideEventHandler : public osgGA::GUIEventHandler 
    195195{ 
    196196public: 
     
    320320    ActiveOperators                         _activeOperators; 
    321321     
    322     osg::ref_ptr<ss3d::CompileSlideCallback>  _compileSlideCallback; 
     322    osg::ref_ptr<CompileSlideCallback>      _compileSlideCallback; 
    323323 
    324324    void updateOperators(); 
  • OpenSceneGraph/trunk/include/osgPresentation/SlideShowConstructor

    r10207 r10396  
    2626#include <osgDB/FileUtils> 
    2727 
    28 #include "AnimationMaterial.h" 
    29 #include "SlideEventHandler.h" 
     28#include <osgPresentation/AnimationMaterial> 
     29#include <osgPresentation/SlideEventHandler> 
    3030 
    3131namespace osgPresentation 
    3232{ 
    3333 
    34 class SlideShowConstructor 
     34class OSGPRESENTATION_EXPORT SlideShowConstructor 
    3535{ 
    3636public: 
     
    129129            animation_material_time_offset(0.0), 
    130130            animation_material_time_multiplier(1.0), 
    131             animation_material_loop_mode(ss3d::AnimationMaterial::NO_LOOPING) {} 
     131            animation_material_loop_mode(AnimationMaterial::NO_LOOPING) {} 
    132132     
    133133        bool requiresPosition() const 
     
    170170        double                                  animation_material_time_offset; 
    171171        double                                  animation_material_time_multiplier; 
    172         ss3d::AnimationMaterial::LoopMode       animation_material_loop_mode; 
     172        AnimationMaterial::LoopMode             animation_material_loop_mode; 
    173173        std::string                             animation_material_filename; 
    174174        std::string                             fade; 
  • OpenSceneGraph/trunk/src/CMakeLists.txt

    r9949 r10396  
    1212        osgManipulator 
    1313        osgParticle 
     14        osgPresentation 
    1415        osgShadow 
    1516        osgSim 
  • OpenSceneGraph/trunk/src/osgPlugins/p3d/CMakeLists.txt

    r10203 r10396  
    11SET(TARGET_SRC 
    2     SlideShowConstructor.cpp 
    32    ReaderWriterP3D.cpp 
    43    ReaderWriterPaths.cpp 
    5     PickEventHandler.cpp 
    6     AnimationMaterial.cpp 
    7     SlideEventHandler.cpp 
    8     CompileSlideCallback.cpp 
    9 ) 
    10 SET(TARGET_H 
    11     SlideShowConstructor.h 
    12     PickEventHandler.h 
    13     AnimationMaterial.h 
    14     SlideEventHandler.h 
    15     CompileSlideCallback.h 
    164) 
    175 
    18 SET(TARGET_ADDED_LIBRARIES osgGA osgText osgVolume osgFX osgViewer) 
     6SET(TARGET_ADDED_LIBRARIES osgGA osgText osgVolume osgFX osgViewer osgPresentation) 
    197 
    208#### end var setup  ### 
  • OpenSceneGraph/trunk/src/osgPlugins/p3d/ReaderWriterP3D.cpp

    r10378 r10396  
    2121#include <osgWidget/PdfReader> 
    2222 
    23 #include "SlideShowConstructor.h" 
     23#include <osgPresentation/SlideShowConstructor> 
    2424 
    2525#include <stdio.h> 
     
    648648    { 
    649649        osg::notify(_notifyLevel)<<"animation_material_loop_mode "<<str<<std::endl; 
    650         if (str=="LOOP") value.animation_material_loop_mode=ss3d::AnimationMaterial::LOOP; 
    651         else if (str=="SWING") value.animation_material_loop_mode=ss3d::AnimationMaterial::SWING; 
    652         else if (str=="NO_LOOPING") value.animation_material_loop_mode=ss3d::AnimationMaterial::NO_LOOPING; 
     650        if (str=="LOOP") value.animation_material_loop_mode=osgPresentation::AnimationMaterial::LOOP; 
     651        else if (str=="SWING") value.animation_material_loop_mode=osgPresentation::AnimationMaterial::SWING; 
     652        else if (str=="NO_LOOPING") value.animation_material_loop_mode=osgPresentation::AnimationMaterial::NO_LOOPING; 
    653653        propertiesRead = true; 
    654654    } 
     
    17421742    doc->read(input); 
    17431743 
    1744  
    1745     osg::notify(osg::NOTICE)<<"P3D parsing"<<std::endl; 
     1744    osg::notify(osg::INFO)<<"P3D xml file read, now building presentation scene graph."<<std::endl; 
    17461745 
    17471746    // doc->write(std::cout); 
     
    19651964    osg::ref_ptr<osg::Node> presentation_node = constructor.takePresentation(); 
    19661965 
    1967     osgPresentation::SlideEventHandler* seh = new osgPresentation::SlideEventHandler; 
    1968     seh->set(presentation_node.get()); 
    1969     presentation_node->setEventCallback(seh); 
    1970  
     1966 
     1967    if (!options || options->getPluginStringData("P3D_EVENTHANDLER")!="none") 
     1968    { 
     1969        osgPresentation::SlideEventHandler* seh = new osgPresentation::SlideEventHandler; 
     1970        seh->set(presentation_node.get()); 
     1971        presentation_node->setEventCallback(seh); 
     1972    } 
    19711973    return presentation_node.release(); 
    19721974} 
  • OpenSceneGraph/trunk/src/osgPlugins/p3d/ReaderWriterPaths.cpp

    r10378 r10396  
    2121#include <osgWidget/PdfReader> 
    2222 
    23 #include "SlideShowConstructor.h" 
    24 #include "AnimationMaterial.h" 
     23#include <osgPresentation/SlideShowConstructor> 
     24#include <osgPresentation/AnimationMaterial> 
    2525 
    2626#include <stdio.h> 
     
    126126osgDB::ReaderWriter::ReadResult ReaderWriterPaths::read_material(std::istream& fin, const osgDB::Options* options) const 
    127127{ 
    128     osg::ref_ptr<ss3d::AnimationMaterial> animationMaterial = new ss3d::AnimationMaterial; 
     128    osg::ref_ptr<osgPresentation::AnimationMaterial> animationMaterial = new osgPresentation::AnimationMaterial; 
    129129    animationMaterial->read(fin); 
    130130 
  • OpenSceneGraph/trunk/src/osgPresentation/AnimationMaterial.cpp

    r10113 r10396  
    1111*/ 
    1212 
    13 #include "AnimationMaterial.h" 
     13#include <osgPresentation/AnimationMaterial> 
     14 
    1415#include <osg/MatrixTransform> 
    1516#include <osg/PositionAttitudeTransform> 
     
    1718#include <osg/io_utils> 
    1819 
    19 using namespace ss3d; 
     20using namespace osgPresentation; 
    2021 
    2122void AnimationMaterial::insert(double time,osg::Material* material) 
  • OpenSceneGraph/trunk/src/osgPresentation/CompileSlideCallback.cpp

    r10113 r10396  
    1111*/ 
    1212 
    13 #include "CompileSlideCallback.h" 
     13#include <osgPresentation/CompileSlideCallback> 
    1414 
    1515#include <osgUtil/GLObjectsVisitor> 
    1616 
    17 using namespace ss3d; 
     17using namespace osgPresentation; 
    1818 
    1919void CompileSlideCallback::operator()(const osg::Camera & camera) const 
  • OpenSceneGraph/trunk/src/osgPresentation/PickEventHandler.cpp

    r10207 r10396  
    1111*/ 
    1212 
    13 #include "PickEventHandler.h" 
    14 #include "SlideEventHandler.h" 
     13#include <osgPresentation/PickEventHandler> 
     14#include <osgPresentation/SlideEventHandler> 
    1515 
    1616#include <osgViewer/Viewer> 
  • OpenSceneGraph/trunk/src/osgPresentation/SlideEventHandler.cpp

    r10207 r10396  
    1111*/ 
    1212 
    13 #include "SlideEventHandler.h" 
    14 #include "SlideShowConstructor.h" 
     13#include <osgPresentation/SlideEventHandler> 
     14#include <osgPresentation/SlideShowConstructor> 
    1515 
    1616#include <osg/AnimationPath> 
     
    2626#include <osgGA/AnimationPathManipulator> 
    2727 
    28 #include "AnimationMaterial.h" 
     28#include <osgPresentation/AnimationMaterial> 
    2929 
    3030#include <iostream> 
     
    139139        osg::AnimationPathCallback* apc = dynamic_cast<osg::AnimationPathCallback*>(_callback.get()); 
    140140        osgUtil::TransformCallback* tc = dynamic_cast<osgUtil::TransformCallback*>(_callback.get()); 
    141         ss3d::AnimationMaterialCallback* amc = dynamic_cast<ss3d::AnimationMaterialCallback*>(_callback.get()); 
     141        AnimationMaterialCallback* amc = dynamic_cast<AnimationMaterialCallback*>(_callback.get()); 
    142142        if (apc) 
    143143        { 
     
    161161        osg::AnimationPathCallback* apc = dynamic_cast<osg::AnimationPathCallback*>(_callback.get()); 
    162162        osgUtil::TransformCallback* tc = dynamic_cast<osgUtil::TransformCallback*>(_callback.get()); 
    163         ss3d::AnimationMaterialCallback* amc = dynamic_cast<ss3d::AnimationMaterialCallback*>(_callback.get()); 
     163        AnimationMaterialCallback* amc = dynamic_cast<AnimationMaterialCallback*>(_callback.get()); 
    164164        if (apc) 
    165165        { 
     
    12951295    if (!_compileSlideCallback) 
    12961296    { 
    1297         _compileSlideCallback = new ss3d::CompileSlideCallback(); 
     1297        _compileSlideCallback = new CompileSlideCallback(); 
    12981298 
    12991299        osgViewer::Viewer::Cameras cameras; 
  • OpenSceneGraph/trunk/src/osgPresentation/SlideShowConstructor.cpp

    r10207 r10396  
    1111*/ 
    1212 
    13 #include "SlideShowConstructor.h" 
     13#include <osgPresentation/SlideShowConstructor> 
    1414 
    1515#include <osg/Geometry> 
     
    4848#include <algorithm> 
    4949 
    50 #include "AnimationMaterial.h" 
    51 #include "PickEventHandler.h" 
     50#include <osgPresentation/AnimationMaterial> 
     51#include <osgPresentation/PickEventHandler> 
    5252 
    5353using namespace osgPresentation; 
     
    15721572osg::Node* SlideShowConstructor::attachMaterialAnimation(osg::Node* model, const PositionData& positionData) 
    15731573{ 
    1574     ss3d::AnimationMaterial* animationMaterial = 0; 
     1574    AnimationMaterial* animationMaterial = 0; 
    15751575 
    15761576    if (!positionData.animation_material_filename.empty()) 
     
    15831583            if (!animation_filestream.eof()) 
    15841584            { 
    1585                 animationMaterial = new ss3d::AnimationMaterial; 
     1585                animationMaterial = new AnimationMaterial; 
    15861586                animationMaterial->read(animation_filestream); 
    15871587            } 
     
    15891589#else 
    15901590        osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(positionData.animation_material_filename, _options.get()); 
    1591         animationMaterial = dynamic_cast<ss3d::AnimationMaterial*>(object.get()); 
     1591        animationMaterial = dynamic_cast<AnimationMaterial*>(object.get()); 
    15921592#endif 
    15931593 
     
    15971597        std::istringstream iss(positionData.fade); 
    15981598         
    1599         animationMaterial = new ss3d::AnimationMaterial; 
     1599        animationMaterial = new AnimationMaterial; 
    16001600        while (!iss.fail() && !iss.eof()) 
    16011601        { 
     
    16161616        animationMaterial->setLoopMode(positionData.animation_material_loop_mode); 
    16171617 
    1618         ss3d::AnimationMaterialCallback* animationMaterialCallback = new ss3d::AnimationMaterialCallback(animationMaterial); 
     1618        AnimationMaterialCallback* animationMaterialCallback = new AnimationMaterialCallback(animationMaterial); 
    16191619        animationMaterialCallback->setTimeOffset(positionData.animation_material_time_offset); 
    16201620        animationMaterialCallback->setTimeMultiplier(positionData.animation_material_time_multiplier);