Show
Ignore:
Timestamp:
02/05/04 11:50:29 (10 years ago)
Author:
robert
Message:

From Tom Jolly, Fixes to osgSim::BlinkSequence? to enable proper saving and
loading.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osglightpoint/osglightpoint.cpp

    r1844 r2727  
    1717 
    1818 
     19 
    1920#define INTERPOLATE(member) lp.member = start.member*rstart + end.member*rend; 
    2021 
     
    5354    osgSim::LightPoint end; 
    5455 
    55     start._position.set(0.0f,0.0f,0.0f); 
     56    start._position.set(-500.0f,-500.0f,0.0f); 
    5657    start._color.set(1.0f,0.0f,0.0f,1.0f); 
    5758     
    58     end._position.set(1000.0f,0.0f,0.0f); 
     59    end._position.set(500.0f,-500.0f,0.0f); 
    5960    end._color.set(1.0f,1.0f,1.0f,1.0f); 
    6061     
     
    108109} 
    109110 
     111static osg::Node* CreateBlinkSequenceLightNode() 
     112{ 
     113   osgSim::LightPointNode*      lightPointNode = new osgSim::LightPointNode;; 
     114 
     115   osgSim::LightPointNode::LightPointList       lpList; 
     116 
     117   osg::ref_ptr<osgSim::SequenceGroup>   seq_0; 
     118   seq_0 = new osgSim::SequenceGroup; 
     119   seq_0->_baseTime = 0.0; 
     120 
     121   osg::ref_ptr<osgSim::SequenceGroup>   seq_1; 
     122   seq_1 = new osgSim::SequenceGroup; 
     123   seq_1->_baseTime = 0.5; 
     124 
     125   const int max_points = 32; 
     126   for( int i = 0; i < max_points; ++i ) 
     127   { 
     128      osgSim::LightPoint   lp; 
     129      double x = cos( (2.0*osg::PI*i)/max_points ); 
     130      double z = sin( (2.0*osg::PI*i)/max_points ); 
     131      lp._position.set( x, 0.0f, z + 100.0f ); 
     132      lp._blinkSequence = new osgSim::BlinkSequence; 
     133      for( int j = 10; j > 0; --j ) 
     134      { 
     135         float  intensity = j/10.0f; 
     136         lp._blinkSequence->addPulse( 1.0/max_points, 
     137                                     osg::Vec4( intensity, intensity, intensity, intensity ) ); 
     138      } 
     139      if( max_points > 10 ) 
     140      { 
     141         lp._blinkSequence->addPulse( 1.0 - 10.0/max_points, 
     142                                     osg::Vec4( 0.0f, 0.0f, 0.0f, 0.0f ) ); 
     143      } 
     144 
     145      if( i & 1 ) 
     146      { 
     147         lp._blinkSequence->setSequenceGroup( seq_1.get() ); 
     148      } 
     149      else 
     150      { 
     151         lp._blinkSequence->setSequenceGroup( seq_0.get() ); 
     152      } 
     153      lp._blinkSequence->setPhaseShift( i/(static_cast<double>(max_points)) ); 
     154      lpList.push_back( lp ); 
     155   } 
     156 
     157   lightPointNode->setLightPointList( lpList ); 
     158 
     159   return lightPointNode; 
     160} 
    110161 
    111162int main( int argc, char **argv ) 
     
    151202    rootnode->addChild(osgDB::readNodeFiles(arguments)); 
    152203    rootnode->addChild(createLightPointsDatabase()); 
    153      
     204    rootnode->addChild(CreateBlinkSequenceLightNode()); 
    154205     
    155206    // run optimization over the scene graph