Changeset 9527
- Timestamp:
- 01/21/09 19:23:55 (4 years ago)
- Location:
- OpenSceneGraph/trunk/src/osgPlugins
- Files:
-
- 21 modified
-
3ds/ReaderWriter3DS.cpp (modified) (2 diffs)
-
OpenFlight/PaletteRecords.cpp (modified) (2 diffs)
-
ac/ac3d.cpp (modified) (1 diff)
-
bsp/Q3BSPReader.cpp (modified) (2 diffs)
-
bsp/VBSPReader.cpp (modified) (3 diffs)
-
dae/daeRMaterials.cpp (modified) (3 diffs)
-
dw/ReaderWriterDW.cpp (modified) (3 diffs)
-
geo/ReaderWriterGEO.cpp (modified) (5 diffs)
-
ive/DataInputStream.cpp (modified) (2 diffs)
-
logo/ReaderWriterLOGO.cpp (modified) (1 diff)
-
lwo/ReaderWriterLWO.cpp (modified) (2 diffs)
-
lwo/Surface.cpp (modified) (1 diff)
-
lwo/old_Lwo2.cpp (modified) (1 diff)
-
md2/ReaderWriterMD2.cpp (modified) (6 diffs)
-
mdl/MDLReader.cpp (modified) (2 diffs)
-
obj/ReaderWriterOBJ.cpp (modified) (2 diffs)
-
osgViewer/View.cpp (modified) (1 diff)
-
osgVolume/ImageLayer.cpp (modified) (1 diff)
-
txp/TXPArchive.cpp (modified) (1 diff)
-
vrml/ReaderWriterVRML2.cpp (modified) (1 diff)
-
x/ReaderWriterDirectX.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/3ds/ReaderWriter3DS.cpp
r8578 r9527 716 716 osg::notify(osg::DEBUG_INFO) << " LIB3DS_RGB_TINT "<<((texture->flags)&LIB3DS_RGB_TINT)<< std::endl; 717 717 718 osg:: Image* osg_image = osgDB::readImageFile(fileName.c_str());719 if ( osg_image==NULL)718 osg::ref_ptr<osg::Image> osg_image = osgDB::readRefImageFile(fileName.c_str()); 719 if (!osg_image) 720 720 { 721 721 osg::notify(osg::NOTICE) << "Warning: Cannot create texture "<<texture->name<< std::endl; … … 724 724 725 725 osg::Texture2D* osg_texture = new osg::Texture2D; 726 osg_texture->setImage(osg_image );726 osg_texture->setImage(osg_image.get()); 727 727 728 728 // does the texture support transparancy? -
OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/PaletteRecords.cpp
r9493 r9527 291 291 osg::StateSet* readTexture(const std::string& filename, const Document& document) const 292 292 { 293 osg:: Image* image = osgDB::readImageFile(filename,document.getOptions());293 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename,document.getOptions()); 294 294 if (!image) return NULL; 295 295 … … 301 301 texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT); 302 302 texture->setResizeNonPowerOfTwoHint(true); 303 texture->setImage(image );303 texture->setImage(image.get()); 304 304 stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); 305 305 -
OpenSceneGraph/trunk/src/osgPlugins/ac/ac3d.cpp
r9475 r9527 352 352 return false; 353 353 } 354 mImage = osgDB::read ImageFile(absFileName, options);354 mImage = osgDB::readRefImageFile(absFileName, options); 355 355 if (!mImage.valid()) 356 356 { -
OpenSceneGraph/trunk/src/osgPlugins/bsp/Q3BSPReader.cpp
r9426 r9527 449 449 jpgExtendedName+=".jpg"; 450 450 451 osg:: Image* image = osgDB::readImageFile(tgaExtendedName);451 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(tgaExtendedName); 452 452 if (!image) 453 453 { 454 image = osgDB::read ImageFile(jpgExtendedName);454 image = osgDB::readRefImageFile(jpgExtendedName); 455 455 if (!image) 456 456 { … … 461 461 462 462 osg::Texture2D* texture= new osg::Texture2D; 463 texture->setImage(image );463 texture->setImage(image.get()); 464 464 texture->setDataVariance(osg::Object::DYNAMIC); // protect from being optimized away as static state. 465 465 texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT); -
OpenSceneGraph/trunk/src/osgPlugins/bsp/VBSPReader.cpp
r9434 r9527 560 560 std::string texFile; 561 561 std::string texPath; 562 Image *texImage;563 Texture *texture;562 osg::ref_ptr<Image> texImage; 563 osg::ref_ptr<Texture> texture; 564 564 565 565 // Find the texture's image file … … 586 586 if (!texPath.empty()) 587 587 { 588 texImage = read ImageFile(texPath);588 texImage = readRefImageFile(texPath); 589 589 590 590 // If we got the image, create the texture attribute … … 594 594 if (texImage->t() == 1) 595 595 { 596 texture = new Texture1D(); 597 ((Texture1D *)texture)->setImage(texImage); 596 texture = new Texture1D(texImage.get()); 598 597 } 599 598 else if (texImage->r() == 1) 600 599 { 601 texture = new Texture2D(); 602 ((Texture2D *)texture)->setImage(texImage); 600 texture = new Texture2D(texImage.get()); 603 601 } 604 602 else 605 603 { 606 texture = new Texture3D(); 607 ((Texture3D *)texture)->setImage(texImage); 604 texture = new Texture3D(texImage.get()); 608 605 } 609 606 -
OpenSceneGraph/trunk/src/osgPlugins/dae/daeRMaterials.cpp
r9240 r9527 736 736 } 737 737 //Got a sampler and a surface and an imaged. Time to create the texture stuff for osg 738 osg:: Image *img = NULL;738 osg::ref_ptr<osg::Image> img; 739 739 if ( dImg->getInit_from() != NULL ) 740 740 { … … 766 766 const char* filename = path.c_str(); 767 767 #endif 768 img = osgDB::read ImageFile( filename );768 img = osgDB::readRefImageFile( filename ); 769 769 770 770 osg::notify(osg::INFO)<<" processTexture(..) - readImage("<<filename<<")"<<std::endl; … … 787 787 } 788 788 789 osg::Texture2D *t2D = new osg::Texture2D( img );789 osg::Texture2D *t2D = new osg::Texture2D( img.get() ); 790 790 //set texture parameters 791 791 if ( sampler != NULL ) -
OpenSceneGraph/trunk/src/osgPlugins/dw/ReaderWriterDW.cpp
r9475 r9527 55 55 if (!ctx || !tx) { // new texture needed 56 56 if (fname.length()>0) { 57 ctx=osgDB::read ImageFile(fname.c_str(),options);58 if (ctx ) {57 ctx=osgDB::readRefImageFile(fname.c_str(),options); 58 if (ctx.valid()) { 59 59 ctx->setFileName(fname); 60 tx=new Texture2D; 61 tx->setImage(ctx); 60 tx=new Texture2D(ctx.get()); 62 61 tx->setWrap(Texture2D::WRAP_S, Texture2D::REPEAT); 63 62 tx->setWrap(Texture2D::WRAP_T, Texture2D::REPEAT); … … 68 67 } 69 68 } 70 if (ctx && tx) { // texture exists71 dstate->setTextureAttributeAndModes(0,tx ,osg::StateAttribute::ON);69 if (ctx.valid() && tx.valid()) { // texture exists 70 dstate->setTextureAttributeAndModes(0,tx.get(),osg::StateAttribute::ON); 72 71 } 73 72 } … … 176 175 enum atten {NONE, INVERSE_DIST, INVERSE_SQUARE} atyp; 177 176 float bright,halfIn,halfOut,falloff; // light brightness 178 Image *ctx;179 Texture2D *tx;177 osg::ref_ptr<osg::Image> ctx; 178 osg::ref_ptr<osg::Texture2D> tx; 180 179 int _lightnum; 181 180 StateSet *dstate; // used to represent the dw material in OSG -
OpenSceneGraph/trunk/src/osgPlugins/geo/ReaderWriterGEO.cpp
r9459 r9527 667 667 dstate->setAttribute(pt); 668 668 if (txidx>=0 && (unsigned int)txidx<txlist.size()) { 669 dstate->setTextureAttribute(0, txenvlist[txidx] );670 dstate->setTextureAttributeAndModes(0,txlist[txidx] ,osg::StateAttribute::ON);669 dstate->setTextureAttribute(0, txenvlist[txidx].get() ); 670 dstate->setTextureAttributeAndModes(0,txlist[txidx].get(),osg::StateAttribute::ON); 671 671 const Image *txim=txlist[txidx]->getImage(); 672 672 if (txim) { … … 685 685 dstate->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON); 686 686 } 687 dstate->setAttribute(matlist[imat] );687 dstate->setAttribute(matlist[imat].get()); 688 688 Vec4 col=matlist[imat]->getAmbient(Material::FRONT); 689 689 if (col[3]<0.99) { … … 1467 1467 const char *name = gfd->getChar(); 1468 1468 if (name) { 1469 Texture2D *tx=new Texture2D;1470 Image *ctx=osgDB::readImageFile(name,options);1471 if (ctx ) {1469 osg::ref_ptr<osg::Texture2D> tx = new Texture2D; 1470 osg::ref_ptr<osg::Image> ctx = osgDB::readImageFile(name,options); 1471 if (ctx.valid()) { 1472 1472 ctx->setFileName(name); 1473 tx->setImage(ctx );1473 tx->setImage(ctx.get()); 1474 1474 } 1475 1475 gfd=gr->getField(GEO_DB_TEX_WRAPS); … … 1487 1487 } 1488 1488 tx->setWrap(Texture2D::WRAP_T, wm); 1489 txlist.push_back(tx );1489 txlist.push_back(tx.get()); 1490 1490 osg::TexEnv* texenv = new osg::TexEnv; 1491 1491 osg::TexEnv::Mode md=osg::TexEnv::MODULATE; … … 2015 2015 std::vector<georecord *> geotxlist; // list of geo::textures for this model 2016 2016 std::vector<georecord *> geomatlist; // list of geo::materials for this model 2017 std::vector< osg::Texture2D *> txlist; // list of osg::textures for this model2018 std::vector< osg::TexEnv *> txenvlist; // list of texture environments for the textures2019 std::vector< osg::Material *> matlist; // list of materials for current model2017 std::vector< osg::ref_ptr<osg::Texture2D> > txlist; // list of osg::textures for this model 2018 std::vector< osg::ref_ptr<osg::TexEnv> > txenvlist; // list of texture environments for the textures 2019 std::vector< osg::ref_ptr<osg::Material> > matlist; // list of materials for current model 2020 2020 georecord *cpalrec; // colour palette record 2021 2021 }; -
OpenSceneGraph/trunk/src/osgPlugins/ive/DataInputStream.cpp
r9199 r9527 1129 1129 // Image is not in list. 1130 1130 // Read it from disk, 1131 osg:: Image* image = osgDB::readImageFile(filename.c_str(),_options.get());1131 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(filename.c_str(),_options.get()); 1132 1132 1133 1133 // add it to the imageList, … … 1137 1137 if (_verboseOutput) std::cout<<"read/writeImage() ["<<image<<"]"<<std::endl; 1138 1138 1139 return image ;1139 return image.release(); 1140 1140 } 1141 1141 -
OpenSceneGraph/trunk/src/osgPlugins/logo/ReaderWriterLOGO.cpp
r9397 r9527 159 159 void addLogo( RelativePosition pos, std::string name ) 160 160 { 161 osg:: Image *image = osgDB::readImageFile( name.c_str() );162 if( image != NULL)163 logos[pos].push_back( image );161 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile( name.c_str() ); 162 if( image.valid()) 163 logos[pos].push_back( image.get() ); 164 164 else 165 165 osg::notify(osg::WARN)<< "Logos::addLogo image file not found : " << name << ".\n"; -
OpenSceneGraph/trunk/src/osgPlugins/lwo/ReaderWriterLWO.cpp
r9343 r9527 243 243 { 244 244 osg::notify(osg::INFO) << "ctex " << lw_material.ctex.name << std::endl; 245 osg:: Image* image = osgDB::readImageFile(lw_material.ctex.name);246 if (image )245 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(lw_material.ctex.name); 246 if (image.valid()) 247 247 { 248 248 // create state … … 251 251 // create texture 252 252 osg::Texture2D* texture = new osg::Texture2D; 253 texture->setImage(image );253 texture->setImage(image.get()); 254 254 255 255 // texture wrap mode -
OpenSceneGraph/trunk/src/osgPlugins/lwo/Surface.cpp
r8648 r9527 196 196 break; 197 197 } 198 199 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(image_file, db_options); 200 if (!image) break; 198 201 199 202 osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D; 200 203 if (force_arb_compression) 201 204 texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION); 202 texture->setImage( osgDB::readImageFile(image_file, db_options));205 texture->setImage(image.get()); 203 206 texture->setWrap(osg::Texture::WRAP_S, osg_wrap_mode(block.get_image_map().width_wrap)); 204 207 texture->setWrap(osg::Texture::WRAP_T, osg_wrap_mode(block.get_image_map().height_wrap)); -
OpenSceneGraph/trunk/src/osgPlugins/lwo/old_Lwo2.cpp
r9397 r9527 708 708 if (surface->image_index >= 0) 709 709 { 710 Image* image = osgDB::readImageFile(_images[surface->image_index]);710 osg::ref_ptr<Image> image = osgDB::readRefImageFile(_images[surface->image_index]); 711 711 notify(DEBUG_INFO) << "\tloaded image '" << _images[surface->image_index] << "'" << std::endl; 712 712 notify(DEBUG_INFO) << "\tresult - " << image << std::endl; 713 if (image )713 if (image.valid()) 714 714 { 715 715 // create texture 716 716 Texture2D* texture = new osg::Texture2D; 717 texture->setImage(image );717 texture->setImage(image.get()); 718 718 state_set->setTextureAttributeAndModes(0, texture, StateAttribute::ON); 719 719 -
OpenSceneGraph/trunk/src/osgPlugins/md2/ReaderWriterMD2.cpp
r9475 r9527 225 225 std::vector<osg::Texture2D*> skin_textures; 226 226 227 for (int si = 0; si < md2_header->numSkins; si++) { 228 osg::Image *img; 229 osg::Texture2D *tex; 227 for (int si = 0; si < md2_header->numSkins; si++) 228 { 229 osg::ref_ptr<osg::Image> img; 230 osg::ref_ptr<osg::Texture2D> tex; 230 231 std::string imgname (md2_skins[si].name); 231 232 232 233 // first try loading the imgname straight 233 img = osgDB::read ImageFile (imgname, options);234 if (img ) {234 img = osgDB::readRefImageFile (imgname, options); 235 if (img.valid()) { 235 236 tex = new osg::Texture2D; 236 237 tex->setImage (img); … … 245 246 // it's a pcx, so try bmp and tga, since pcx sucks 246 247 std::string basename = imgname.substr (0, imgname.size() - 3); 247 img = osgDB::read ImageFile (basename + "bmp", options);248 if (img ) {248 img = osgDB::readRefImageFile (basename + "bmp", options); 249 if (img.valid()) { 249 250 tex = new osg::Texture2D; 250 tex->setImage (img );251 tex->setImage (img.get()); 251 252 skin_textures.push_back (tex); 252 253 continue; 253 254 } 254 255 255 img = osgDB::read ImageFile (basename + "tga", options);256 if (img ) {256 img = osgDB::readRefImageFile (basename + "tga", options); 257 if (img.valid()) { 257 258 tex = new osg::Texture2D; 258 tex->setImage (img );259 tex->setImage (img,get()); 259 260 skin_textures.push_back (tex); 260 261 continue; … … 268 269 #else 269 270 // load the single skin 270 osg:: Image *skin_image = NULL;271 osg:: Texture2D *skin_texture = NULL;271 osg::ref_ptr<osg::Image> skin_image; 272 osg::ref_ptr<osg::Texture2D> skin_texture = NULL; 272 273 273 274 if (md2_header->numSkins > 0) { … … 276 277 do { 277 278 // first try loading the imgname straight 278 skin_image = osgDB::read ImageFile(imgname, options);279 if (skin_image ) break;279 skin_image = osgDB::readRefImageFile(imgname, options); 280 if (skin_image.valid()) break; 280 281 281 282 // we failed, so check if it's a PCX image … … 285 286 // it's a pcx, so try bmp and tga, since pcx sucks 286 287 std::string basename = imgname.substr (0, imgname.size() - 3); 287 skin_image = osgDB::read ImageFile (basename + "bmp", options);288 if (skin_image ) break;289 290 skin_image = osgDB::read ImageFile (basename + "tga", options);291 if (skin_image ) break;288 skin_image = osgDB::readRefImageFile (basename + "bmp", options); 289 if (skin_image.valid()) break; 290 291 skin_image = osgDB::readRefImageFile (basename + "tga", options); 292 if (skin_image.valid()) break; 292 293 } 293 294 } while (0); 294 295 295 if (skin_image ) {296 if (skin_image.valid()) { 296 297 skin_texture = new osg::Texture2D; 297 skin_texture->setImage (skin_image );298 skin_texture->setImage (skin_image.get()); 298 299 skin_texture->setFilter (osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST); 299 300 } else { … … 408 409 409 410 if (skin_texture != NULL) { 410 state->setTextureAttributeAndModes (0, skin_texture , osg::StateAttribute::ON);411 state->setTextureAttributeAndModes (0, skin_texture.get(), osg::StateAttribute::ON); 411 412 } 412 413 base_switch->setStateSet (state); -
OpenSceneGraph/trunk/src/osgPlugins/mdl/MDLReader.cpp
r9459 r9527 85 85 ref_ptr<Texture> MDLReader::readTextureFile(std::string textureName) 86 86 { 87 std::string texFile;88 std::string texPath;89 Image *texImage;90 Texture *texture;87 std::string texFile; 88 std::string texPath; 89 osg::ref_ptr<Image> texImage; 90 osg::ref_ptr<Texture> texture; 91 91 92 92 // Find the texture's image file … … 125 125 if (!texPath.empty()) 126 126 { 127 texImage = read ImageFile(texPath);127 texImage = readRefImageFile(texPath); 128 128 129 129 // If we got the image, create the texture attribute 130 if (texImage != NULL)130 if (texImage.valid()) 131 131 { 132 132 // Create the texture 133 133 if (texImage->t() == 1) 134 134 { 135 texture = new Texture1D(); 136 ((Texture1D *)texture)->setImage(texImage); 135 texture = new Texture1D(texImage.get()); 137 136 } 138 137 else if (texImage->r() == 1) 139 138 { 140 texture = new Texture2D(); 141 ((Texture2D *)texture)->setImage(texImage); 139 texture = new Texture2D(texImage.get()); 142 140 } 143 141 else 144 142 { 145 texture = new Texture3D(); 146 ((Texture3D *)texture)->setImage(texImage); 143 texture = new Texture3D(texImage.get()); 147 144 } 148 145 -
OpenSceneGraph/trunk/src/osgPlugins/obj/ReaderWriterOBJ.cpp
r9475 r9527 198 198 { 199 199 // first try with database path of parent. 200 image = osgDB::read ImageFile(model.getDatabasePath()+'/'+filename);200 image = osgDB::readRefImageFile(model.getDatabasePath()+'/'+filename); 201 201 } 202 202 … … 204 204 { 205 205 // if not already set then try the filename as is. 206 image = osgDB::read ImageFile(filename);206 image = osgDB::readRefImageFile(filename); 207 207 } 208 208 -
OpenSceneGraph/trunk/src/osgPlugins/osgViewer/View.cpp
r9389 r9527 186 186 if (!filename.empty()) 187 187 { 188 intensityMap = osgDB::read ImageFile(filename);188 intensityMap = osgDB::readRefImageFile(filename); 189 189 } 190 190 -
OpenSceneGraph/trunk/src/osgPlugins/osgVolume/ImageLayer.cpp
r9501 r9527 58 58 if (fileType == osgDB::DIRECTORY) 59 59 { 60 image = osgDB::read ImageFile(filename+".dicom");60 image = osgDB::readRefImageFile(filename+".dicom"); 61 61 62 62 } 63 63 else if (fileType == osgDB::REGULAR_FILE) 64 64 { 65 image = osgDB::read ImageFile( filename );65 image = osgDB::readRefImageFile( filename ); 66 66 } 67 67 -
OpenSceneGraph/trunk/src/osgPlugins/txp/TXPArchive.cpp
r9392 r9527 392 392 393 393 std::string theFile = path + filename ; 394 osg:: Image* image = osgDB::readImageFile(theFile);395 if (image )396 { 397 osg_texture->setImage(image );394 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(theFile); 395 if (image.valid()) 396 { 397 osg_texture->setImage(image.get()); 398 398 } 399 399 else -
OpenSceneGraph/trunk/src/osgPlugins/vrml/ReaderWriterVRML2.cpp
r8442 r9527 297 297 const std::string &url = mfs.value[0]; 298 298 299 osg::ref_ptr<osg::Image> image = osgDB::read ImageFile(url);299 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(url); 300 300 301 301 if (image != 0) { -
OpenSceneGraph/trunk/src/osgPlugins/x/ReaderWriterDirectX.cpp
r8624 r9527 228 228 osg::Texture2D* texture = texForImage[mtl.texture[j]]; 229 229 if (!texture) { 230 osg:: Image* image = osgDB::readImageFile(mtl.texture[j],options);230 osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile(mtl.texture[j],options); 231 231 if (!image) 232 232 continue; … … 236 236 texForImage[mtl.texture[j]] = texture; 237 237 238 texture->setImage(image );238 texture->setImage(image.get()); 239 239 texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT); 240 240 texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT);
