Changeset 4368 for OpenSceneGraph/trunk/examples/osgpoints/osgpoints.cpp
- Timestamp:
- 07/01/05 11:10:37 (8 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgpoints/osgpoints.cpp
r4360 r4368 15 15 16 16 #include <osg/Point> 17 #include <osg/BlendFunc> 18 #include <osg/Texture2D> 19 #include <osg/PointSprite> 17 20 18 21 class KeyboardEventHandler : public osgGA::GUIEventHandler … … 24 27 { 25 28 _point = new osg::Point; 26 _point->setDistanceAttenuation(osg::Vec3(0.0,0.0005,0.0f));27 29 _point->setDistanceAttenuation(osg::Vec3(0.0,0.0000,0.05f)); 28 30 _stateset->setAttribute(_point.get()); … … 45 47 return true; 46 48 } 47 else if (ea.getKey()==' *')49 else if (ea.getKey()=='<') 48 50 { 49 51 changePointAttenuation(1.1f); 50 52 return true; 51 53 } 52 else if (ea.getKey()==' /')54 else if (ea.getKey()=='>') 53 55 { 54 56 changePointAttenuation(1.0f/1.1f); … … 109 111 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 110 112 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 113 arguments.getApplicationUsage()->addCommandLineOption("--sprites","Point sprites."); 111 114 112 115 … … 126 129 return 1; 127 130 } 131 132 bool usePointSprites = false; 133 while (arguments.read("--sprites")) { usePointSprites = true; }; 128 134 129 135 // any option left unread are converted into errors to write out later. … … 167 173 // set the scene to render 168 174 viewer.setSceneData(loadedModel.get()); 175 176 177 if (usePointSprites) 178 { 179 osg::StateSet* stateset = loadedModel->getOrCreateStateSet(); 180 181 /// Setup cool blending 182 osg::BlendFunc *fn = new osg::BlendFunc(); 183 stateset->setAttributeAndModes(fn, osg::StateAttribute::ON); 184 185 /// Setup the point sprites 186 osg::PointSprite *sprite = new osg::PointSprite(); 187 stateset->setTextureAttributeAndModes(0, sprite, osg::StateAttribute::ON); 188 189 /// The texture for the sprites 190 osg::Texture2D *tex = new osg::Texture2D(); 191 tex->setImage(osgDB::readImageFile("Images/particle.rgb")); 192 stateset->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON); 193 } 194 169 195 170 196 // register the handler for modifying the point size
