Changeset 1210

Show
Ignore:
Timestamp:
05/08/08 13:53:36 (3 days ago)
Author:
cneumann
Message:

enable support for embedded textures in osb files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/System/FileIO/OSB/OSGNFIOOptions.cpp

    r785 r1210  
    6969/*----------------------------- constructors  -----------------------------*/ 
    7070 
    71 NFIOOptions::NFIOOptions(void) : 
    72 _inlineTextures(true), 
    73 _compressTextures(false), 
    74 _texturesCompressionQuality(75), 
    75 _quantizePositions(Quantizer::QRES_OFF), 
    76 _quantizeNormals(Quantizer::QRES_OFF), 
    77 _quantizeTexCoords(Quantizer::QRES_OFF), 
    78 _packIndices(false), 
    79 _unpack16BitIndices(true) 
     71NFIOOptions::NFIOOptions(void) 
     72    : _inlineTextures(true), 
     73      _compressTextures(false), 
     74      _texturesCompressionQuality(75), 
     75      _texturesImageType("jpeg"), 
     76      _quantizePositions(Quantizer::QRES_OFF), 
     77      _quantizeNormals(Quantizer::QRES_OFF), 
     78      _quantizeTexCoords(Quantizer::QRES_OFF), 
     79      _packIndices(false), 
     80      _unpack16BitIndices(true) 
    8081{ 
    8182} 
     
    9596    _compressTextures = false; 
    9697    _texturesCompressionQuality = 75; 
     98    _texturesImageType = "jpeg", 
    9799    _quantizePositions = Quantizer::QRES_OFF; 
    98100    _quantizeNormals = Quantizer::QRES_OFF; 
     
    119121        _texturesCompressionQuality = getInteger(options.substr(i+option.size())); 
    120122     
     123    option = "texturesImageType="; 
     124    if((i = options.find(option)) != std::string::npos) 
     125        _texturesImageType = getString(options.substr(i + option.size())); 
     126         
    121127    if(options.find("quantizePositions=0") != std::string::npos) 
    122128        _quantizePositions = Quantizer::QRES_OFF; 
     
    172178{ 
    173179    return _texturesCompressionQuality; 
     180} 
     181 
     182std::string NFIOOptions::texturesImageType(void) const 
     183{ 
     184    return _texturesImageType; 
    174185} 
    175186 
     
    214225    return r; 
    215226} 
     227 
     228std::string NFIOOptions::getString(const std::string &str) 
     229{ 
     230    std::string rstr; 
     231    UInt32 i = 0; 
     232    while(i < str.length() && str[i] != ',') 
     233    { 
     234        rstr += str[i++]; 
     235    } 
     236    return rstr; 
     237} 
  • trunk/Source/System/FileIO/OSB/OSGNFIOOptions.h

    r785 r1210  
    8383    /*! \{                                                                 */ 
    8484     
    85     bool inlineTextures(void) const; 
    86     bool compressTextures(void) const; 
    87     UInt32 texturesCompressionQuality(void) const; 
     85    bool        inlineTextures(void) const; 
     86    bool        compressTextures(void) const; 
     87    UInt32      texturesCompressionQuality(void) const; 
     88    std::string texturesImageType(void) const; 
    8889     
    8990    UInt8 quantizePositions(void) const; 
     
    101102private: 
    102103     
    103     Int32 getInteger(const std::string &str); 
     104    Int32       getInteger(const std::string &str); 
     105    std::string getString (const std::string &str); 
    104106 
    105     bool    _inlineTextures; 
    106     bool    _compressTextures; 
    107     UInt32  _texturesCompressionQuality; 
    108     UInt8   _quantizePositions; 
    109     UInt8   _quantizeNormals; 
    110     UInt8   _quantizeTexCoords; 
    111     bool    _packIndices; 
    112     bool    _unpack16BitIndices; 
     107    bool        _inlineTextures; 
     108    bool        _compressTextures; 
     109    UInt32      _texturesCompressionQuality; 
     110    std::string _texturesImageType; 
     111     
     112    UInt8       _quantizePositions; 
     113    UInt8       _quantizeNormals; 
     114    UInt8       _quantizeTexCoords; 
     115     
     116    bool        _packIndices; 
     117    bool        _unpack16BitIndices; 
    113118}; 
    114119 
  • trunk/Source/System/FileIO/OSB/OSGOSBImageElement.cpp

    r1198 r1210  
    274274 
    275275    Image       *img       = dynamic_cast<Image *>(getContainer()); 
    276     //std::string imageType = root->getOptions().textureImageType(); 
    277     std::string imageType = "jpeg"; 
     276    std::string imageType = root->getOptions().texturesImageType(); 
     277//     std::string imageType = "jpeg"; 
    278278 
    279279    std::vector<UInt8> buffer; 
     
    285285 
    286286    // some extra space is needed for the image header 
    287     UInt32 bufferSize = 0; 
    288 //        ImageFileHandler::the().getDefaultType()->maxBufferSize(img) * factor + 
    289 //            16384; 
     287    UInt32 bufferSize = 
     288       ImageFileHandler::the()->getDefaultType()->maxBufferSize(img) * factor + 
     289           16384; 
    290290 
    291291    buffer.resize(bufferSize); 
    292 //    UInt64 compressedSize = img->store(imageType.c_str(), &buffer.front()); 
    293     UInt64 compressedSize = 0; 
     292    UInt64 compressedSize = img->store(imageType.c_str(), &buffer.front()); 
     293//     UInt64 compressedSize = 0; 
    294294 
    295295    UInt32 byteSize  = static_cast<UInt32>(compressedSize); 
    296296    UInt32 fieldSize = sizeof(UInt32) + sizeof(UInt8) * byteSize; 
    297297 
    298     wh->putValue(fieldSize); 
    299     wh->putValue(byteSize ); 
     298    wh->putValue (fieldSize                ); 
     299    wh->putValue (byteSize                ); 
    300300    wh->putValues(&buffer.front(), byteSize); 
    301301}