Changeset 8430

Show
Ignore:
Timestamp:
06/12/08 17:57:36
Author:
robert
Message:

Added partial implementation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph-TrainingMaterials/trunk/Sources/Exercises/06_nodes/6h_TexGenNode/6h_TexGenNode.cpp

    r8100 r8430  
    22#include <osg/ClipNode> 
    33#include <osg/PositionAttitudeTransform> 
     4#include <osg/Texture2D> 
    45 
    56#include <osgDB/ReadFile> 
     
    4849    if (!model) 
    4950    { 
    50         std::cout<<"Usage: 6h_TexGenNode earth/earth.ive"<<std::endl; 
     51        std::cout<<"Usage: 6h_TexGenNode Earth/earth.ive"<<std::endl; 
    5152        return 1; 
    5253    } 
     
    5657        //     the projection should be from above looking down the Z axis, with the 
    5758        //     the projected texture covering about 1/4 of the model. 
     59         
     60        osg::Image* image = osgDB::readImageFile("Images/lz.rgb"); 
     61        if (!image) 
     62        { 
     63            std::cout<<"Could not load Images/lz.rgb"<<std::endl; 
     64            return 1; 
     65        } 
     66         
     67        osg::Group* group = new osg::Group; 
     68         
     69        group->addChild(model.get()); 
     70         
     71        osg::StateSet* stateset = group->getOrCreateStateSet(); 
     72        stateset->setTextureAttributeAndModes(0,new osg::Texture2D(image), osg::StateAttribute::ON);  
     73         
     74        viewer.setSceneData(group); 
    5875    } 
    5976