Changeset 8255

Show
Ignore:
Timestamp:
04/28/08 21:03:21
Author:
robert
Message:

Implemented 7a, 7b and 7c exercise shells

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph-TrainingMaterials/trunk/Sources/Exercises/07_databases/7a_ReadWriteFiles/7a_ReadWriteFiles.cpp

    r8120 r8255  
    66int main( int argc, char **argv ) 
    77{ 
    8     std::cout<<"TODO "<<argv[0]<<std::endl; 
     8    // This exercises introduces the read*File and write*File methods 
     9    // 
     10    // 
     11     
     12    { 
     13        std::cout<<std::endl<<"Block 1: read cow.osg and write it out to cow.ive"<<std::endl; 
     14    } 
     15 
     16     
     17    { 
     18        std::cout<<std::endl<<"Block 2: read Images/lz.rgb and write it out to local.rgb"<<std::endl; 
     19    } 
     20     
     21    // Test to see if the code works by running: 
     22    // 
     23    //      osgviewer cow.ive 
     24    // 
     25    //      osgviewer --image lz.rgb 
    926     
    1027    return 0; 
  • OpenSceneGraph-TrainingMaterials/trunk/Sources/Exercises/07_databases/7b_ReadWriteStreams/7b_ReadWriteStreams.cpp

    r8120 r8255  
    1 #include <osg/ArgumentParser> 
    2 #include <osgDB/ReadFile
     1#include <osgViewer/Viewer> 
     2#include <osgDB/Registry
    33 
    44#include <iostream> 
     
    66int main( int argc, char **argv ) 
    77{ 
    8     std::cout<<"TODO "<<argv[0]<<std::endl; 
     8    // This exercises introduces the read*(istream*) and write*(ostream*) methods 
     9 
     10    osgViewer::Viewer viewer; 
    911     
    10     return 0; 
     12    { 
     13        // First load the appropriate reader writer 
     14        osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension("osg"); 
     15 
     16        // Read cow.osg into memory buffer,  
     17        // then stream this in via reader writer 
     18        // assigned this scene graph to viewer 
     19         
     20    } 
     21 
     22    if (!viewer.getSceneData()) 
     23    { 
     24        std::cout<<"Error: now scene graph assigned to viewer, please complete missing code."<<std::endl; 
     25        return 1; 
     26    }     
     27     
     28    return viewer.run();     
    1129} 
  • OpenSceneGraph-TrainingMaterials/trunk/Sources/Exercises/07_databases/7c_FilePaths/7c_FilePaths.cpp

    r8120 r8255  
    1 #include <osg/ArgumentParser
     1#include <osgDB/FileUtils
    22#include <osgDB/ReadFile> 
     3#include <osgViewer/Viewer> 
    34 
    45#include <iostream> 
     
    67int main( int argc, char **argv ) 
    78{ 
    8     std::cout<<"TODO "<<argv[0]<<std::endl; 
     9    // This exercise illustrates how DataFilePath 
     10    // is set used programatically 
     11    // 
     12    // prepare the data by : 
     13    // 
     14    //      mkdir Temp 
     15    //      cp ${DATA_DIR}/OpenSceneGraph-Data/glider.osg Temp/cow.osg 
     16 
     17    { 
     18        // print out the data file path 
     19    } 
    920     
    10     return 0; 
     21    { 
     22        // programatically prepend a local temp directory  
     23        // to file path 
     24    } 
     25     
     26    // read node "cow.osg" and run viewer, if everything works 
     27    // then you should see glider.osg 
     28    // 
     29    osgViewer::Viewer viewer; 
     30    viewer.setSceneData(osgDB::readNodeFile("cow.osg"));     
     31    return viewer.run(); 
    1132}