Changeset 9705 for OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
- Timestamp:
- 02/08/09 16:56:35 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
r9637 r9705 45 45 46 46 MovieEventHandler():_playToggle(true),_trackMouse(false) {} 47 47 48 48 void setMouseTracking(bool track) { _trackMouse = track; } 49 49 bool getMouseTracking() const { return _trackMouse; } 50 50 51 51 void set(osg::Node* node); 52 52 53 53 virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv); 54 54 55 55 virtual void getUsage(osg::ApplicationUsage& usage) const; 56 56 … … 66 66 FindImageStreamsVisitor(ImageStreamList& imageStreamList): 67 67 _imageStreamList(imageStreamList) {} 68 68 69 69 virtual void apply(osg::Geode& geode) 70 70 { … … 75 75 apply(geode.getDrawable(i)->getStateSet()); 76 76 } 77 77 78 78 traverse(geode); 79 79 } … … 84 84 traverse(node); 85 85 } 86 86 87 87 inline void apply(osg::StateSet* stateset) 88 88 { 89 89 if (!stateset) return; 90 90 91 91 osg::StateAttribute* attr = stateset->getTextureAttribute(0,osg::StateAttribute::TEXTURE); 92 92 if (attr) … … 99 99 } 100 100 } 101 101 102 102 inline void apply(osg::ImageStream* imagestream) 103 103 { 104 104 if (imagestream) 105 105 { 106 _imageStreamList.push_back(imagestream); 107 } 108 } 109 106 _imageStreamList.push_back(imagestream); 107 } 108 } 109 110 110 ImageStreamList& _imageStreamList; 111 111 112 112 protected: 113 113 114 114 FindImageStreamsVisitor& operator = (const FindImageStreamsVisitor&) { return *this; } 115 115 … … 120 120 bool _trackMouse; 121 121 ImageStreamList _imageStreamList; 122 122 123 123 }; 124 124 … … 151 151 (nv==0 ? view->computeIntersections(ea.getX(), ea.getY(), intersections) : 152 152 view->computeIntersections(ea.getX(), ea.getY(), nv->getNodePath(), intersections)); 153 153 154 154 if (foundIntersection) 155 155 { 156 156 157 // use the nearest intersection 157 // use the nearest intersection 158 158 const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin()); 159 159 osg::Drawable* drawable = intersection.drawable.get(); … … 180 180 if (texcoords_Vec2Array) 181 181 { 182 // we have tex coord array so now we can compute the final tex coord at the point of intersection. 182 // we have tex coord array so now we can compute the final tex coord at the point of intersection. 183 183 osg::Vec2 tc1 = (*texcoords_Vec2Array)[i1]; 184 184 osg::Vec2 tc2 = (*texcoords_Vec2Array)[i2]; … … 280 280 bool flip = image->getOrigin()==osg::Image::TOP_LEFT; 281 281 if (option_flip) flip = !flip; 282 282 283 283 if (useTextureRectangle) 284 284 { … … 291 291 texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); 292 292 texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); 293 294 293 294 295 295 pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, 296 296 texture, 297 297 osg::StateAttribute::ON); 298 298 299 299 return pictureQuad; 300 300 } … … 305 305 xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height), 306 306 0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f); 307 307 308 308 osg::Texture2D* texture = new osg::Texture2D(image); 309 309 texture->setResizeNonPowerOfTwoHint(false); … … 311 311 texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); 312 312 texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); 313 314 313 314 315 315 pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, 316 316 texture, … … 325 325 // use an ArgumentParser object to manage the program arguments. 326 326 osg::ArgumentParser arguments(&argc,argv); 327 327 328 328 // set up the usage document, in case we need to print out how to use this program. 329 329 arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); … … 335 335 arguments.getApplicationUsage()->addCommandLineOption("--interactive","Use camera manipulator to allow movement around movie."); 336 336 arguments.getApplicationUsage()->addCommandLineOption("--flip","Flip the movie so top becomes bottom."); 337 #if defined(WIN32) || defined(__APPLE__) 337 338 arguments.getApplicationUsage()->addCommandLineOption("--devices","Print the Video input capability via QuickTime and exit."); 338 339 #endif 340 339 341 bool useTextureRectangle = true; 340 342 bool useShader = false; … … 342 344 // construct the viewer. 343 345 osgViewer::Viewer viewer(arguments); 344 346 345 347 if (arguments.argc()<=1) 346 348 { … … 349 351 } 350 352 353 #if defined(WIN32) || defined(__APPLE__) 351 354 // if user requests devices video capability. 352 355 if (arguments.read("-devices") || arguments.read("--devices")) … … 356 359 return 1; 357 360 } 361 #endif 358 362 359 363 while (arguments.read("--texture2D")) useTextureRectangle=false; … … 361 365 362 366 bool mouseTracking = false; 363 while (arguments.read("--mouse")) mouseTracking=true; 367 while (arguments.read("--mouse")) mouseTracking=true; 364 368 365 369 … … 420 424 osg::Vec3 topleft = pos; 421 425 osg::Vec3 bottomright = pos; 422 426 423 427 bool xyPlane = fullscreen; 424 428 425 429 for(int i=1;i<arguments.argc();++i) 426 430 { … … 434 438 { 435 439 osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" image-t()="<<image->t()<<std::endl; 436 440 437 441 geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip)); 438 442 439 443 bottomright = pos + osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f); 440 444 … … 445 449 { 446 450 std::cout<<"Unable to read file "<<arguments[i]<<std::endl; 447 } 448 } 449 } 450 451 } 452 } 453 } 454 451 455 // set the scene to render 452 456 viewer.setSceneData(geode.get()); … … 497 501 } 498 502 } 503
