PageRenderTime 317ms CodeModel.GetById 81ms app.highlight 200ms RepoModel.GetById 21ms app.codeStats 1ms

/Source/System/Image/WS/OSGImageBase.cpp

https://github.com/msteners/OpenSGDevMaster_Toolbox
C++ | 2395 lines | 1796 code | 441 blank | 158 comment | 167 complexity | 00628be84e1444698b02ee72c428c3dc MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*---------------------------------------------------------------------------*\
   2 *                                OpenSG                                     *
   3 *                                                                           *
   4 *                                                                           *
   5 *               Copyright (C) 2000-2006 by the OpenSG Forum                 *
   6 *                                                                           *
   7 *                            www.opensg.org                                 *
   8 *                                                                           *
   9 *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
  10 *                                                                           *
  11\*---------------------------------------------------------------------------*/
  12/*---------------------------------------------------------------------------*\
  13 *                                License                                    *
  14 *                                                                           *
  15 * This library is free software; you can redistribute it and/or modify it   *
  16 * under the terms of the GNU Library General Public License as published    *
  17 * by the Free Software Foundation, version 2.                               *
  18 *                                                                           *
  19 * This library is distributed in the hope that it will be useful, but       *
  20 * WITHOUT ANY WARRANTY; without even the implied warranty of                *
  21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
  22 * Library General Public License for more details.                          *
  23 *                                                                           *
  24 * You should have received a copy of the GNU Library General Public         *
  25 * License along with this library; if not, write to the Free Software       *
  26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
  27 *                                                                           *
  28\*---------------------------------------------------------------------------*/
  29/*---------------------------------------------------------------------------*\
  30 *                                Changes                                    *
  31 *                                                                           *
  32 *                                                                           *
  33 *                                                                           *
  34 *                                                                           *
  35 *                                                                           *
  36 *                                                                           *
  37\*---------------------------------------------------------------------------*/
  38
  39/*****************************************************************************\
  40 *****************************************************************************
  41 **                                                                         **
  42 **                  This file is automatically generated.                  **
  43 **                                                                         **
  44 **          Any changes made to this file WILL be lost when it is          **
  45 **           regenerated, which can become necessary at any time.          **
  46 **                                                                         **
  47 **     Do not change this file, changes should be done in the derived      **
  48 **     class Image!
  49 **                                                                         **
  50 *****************************************************************************
  51\*****************************************************************************/
  52
  53#include <cstdlib>
  54#include <cstdio>
  55#include <boost/assign/list_of.hpp>
  56
  57#include "OSGConfig.h"
  58
  59
  60#include "OSGGL.h"                        // DataType default header
  61
  62#include "OSGFieldContainer.h"          // Parents Class
  63
  64#include "OSGImageBase.h"
  65#include "OSGImage.h"
  66
  67#include <boost/bind.hpp>
  68
  69#ifdef WIN32 // turn off 'this' : used in base member initializer list warning
  70#pragma warning(disable:4355)
  71#endif
  72
  73OSG_BEGIN_NAMESPACE
  74
  75/***************************************************************************\
  76 *                            Description                                  *
  77\***************************************************************************/
  78
  79/*! \class OSG::Image
  80    1D/2D/3D Image with various pixel types data, optionally also can hold
  81    mipMap and simple multi-frame data.
  82 */
  83
  84/***************************************************************************\
  85 *                        Field Documentation                              *
  86\***************************************************************************/
  87
  88/*! \var FieldContainer * ImageBase::_mfParents
  89    
  90*/
  91
  92/*! \var Int32           ImageBase::_sfDimension
  93    Image dimension, 0 for invalid, 1 for 1D, 2 for 2D and 3 for 3D data.
  94*/
  95
  96/*! \var Int32           ImageBase::_sfWidth
  97    
  98*/
  99
 100/*! \var Int32           ImageBase::_sfHeight
 101    
 102*/
 103
 104/*! \var Int32           ImageBase::_sfDepth
 105    
 106*/
 107
 108/*! \var Int32           ImageBase::_sfBpp
 109    Bytes of data per pixel.
 110*/
 111
 112/*! \var Int32           ImageBase::_sfMipMapCount
 113    
 114*/
 115
 116/*! \var Int32           ImageBase::_sfFrameCount
 117    The number of frames in the data.
 118*/
 119
 120/*! \var Time            ImageBase::_sfFrameDelay
 121    Time between frames.  Determines the frame rate.
 122*/
 123
 124/*! \var UInt32          ImageBase::_sfPixelFormat
 125    
 126*/
 127
 128/*! \var UInt8           ImageBase::_mfPixel
 129    The pixel data buffer. This is where the data for the image is stored.
 130*/
 131
 132/*! \var Int32           ImageBase::_sfFrameSize
 133    
 134*/
 135
 136/*! \var std::string     ImageBase::_sfName
 137    Texture file path.
 138*/
 139
 140/*! \var Int32           ImageBase::_sfDataType
 141    Type of image data.
 142*/
 143
 144/*! \var Int32           ImageBase::_sfComponentSize
 145    Size (in byte) of a single component of the image. Necessary
 146    for High Dynamic Range and other higher-level image types.
 147*/
 148
 149/*! \var Int32           ImageBase::_sfSideCount
 150    
 151*/
 152
 153/*! \var Int32           ImageBase::_sfSideSize
 154    
 155*/
 156
 157/*! \var bool            ImageBase::_sfForceCompressedData
 158    Set to true if using the image to keep unknown data for textures.
 159    Generally used in conjunction with TextureChunk::externalFormat.
 160*/
 161
 162/*! \var bool            ImageBase::_sfForceAlphaChannel
 163    Set to true if using the image to keep unknown data for textures.
 164    Generally used in conjunction with TextureChunk::externalFormat.
 165*/
 166
 167/*! \var bool            ImageBase::_sfForceColorChannel
 168    Set to true if using the image to keep unknown data for textures.
 169    Generally used in conjunction with TextureChunk::externalFormat.
 170*/
 171
 172/*! \var bool            ImageBase::_sfForceAlphaBinary
 173    Set to true if using the image to prevent depth sorting for 
 174    SimpleTexturedMaterials using this Image.
 175*/
 176
 177/*! \var Real32          ImageBase::_sfResX
 178    
 179*/
 180
 181/*! \var Real32          ImageBase::_sfResY
 182    
 183*/
 184
 185/*! \var UInt16          ImageBase::_sfResUnit
 186    resolution unit (invalid=0, none=1, inch=2)
 187*/
 188
 189/*! \var bool            ImageBase::_sfClearOnLoad
 190    Set to true if the image data should be cleared after it has been uploaded to the graphics
 191    card and is no longer needed in main memory.
 192*/
 193
 194
 195/***************************************************************************\
 196 *                      FieldType/FieldTrait Instantiation                 *
 197\***************************************************************************/
 198
 199#if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
 200DataType FieldTraits<Image *>::_type("ImagePtr", "AttachmentContainerPtr");
 201#endif
 202
 203OSG_FIELDTRAITS_GETTYPE(Image *)
 204
 205OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
 206                           Image *,
 207                           0);
 208
 209OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
 210                           Image *,
 211                           0);
 212
 213DataType &FieldTraits< Image *, 1 >::getType(void)
 214{
 215    return FieldTraits<Image *, 0>::getType();
 216}
 217
 218
 219OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
 220                      Image *,
 221                      UnrecordedRefCountPolicy,
 222                      1);
 223
 224
 225/***************************************************************************\
 226 *                         Field Description                               *
 227\***************************************************************************/
 228
 229void ImageBase::classDescInserter(TypeObject &oType)
 230{
 231    FieldDescriptionBase *pDesc = NULL;
 232
 233
 234    pDesc = new MFParentFieldContainerPtr::Description(
 235        MFParentFieldContainerPtr::getClassType(),
 236        "parents",
 237        "",
 238        ParentsFieldId, ParentsFieldMask,
 239        true,
 240        (Field::MFDefaultFlags | Field::FStdAccess),
 241        static_cast     <FieldEditMethodSig>(&Image::invalidEditField),
 242        static_cast     <FieldGetMethodSig >(&Image::invalidGetField));
 243
 244    oType.addInitialDesc(pDesc);
 245
 246    pDesc = new SFInt32::Description(
 247        SFInt32::getClassType(),
 248        "dimension",
 249        "Image dimension, 0 for invalid, 1 for 1D, 2 for 2D and 3 for 3D data.\n",
 250        DimensionFieldId, DimensionFieldMask,
 251        false,
 252        (Field::SFDefaultFlags | Field::FStdAccess),
 253        static_cast<FieldEditMethodSig>(&Image::editHandleDimension),
 254        static_cast<FieldGetMethodSig >(&Image::getHandleDimension));
 255
 256    oType.addInitialDesc(pDesc);
 257
 258    pDesc = new SFInt32::Description(
 259        SFInt32::getClassType(),
 260        "width",
 261        "",
 262        WidthFieldId, WidthFieldMask,
 263        false,
 264        (Field::SFDefaultFlags | Field::FStdAccess),
 265        static_cast<FieldEditMethodSig>(&Image::editHandleWidth),
 266        static_cast<FieldGetMethodSig >(&Image::getHandleWidth));
 267
 268    oType.addInitialDesc(pDesc);
 269
 270    pDesc = new SFInt32::Description(
 271        SFInt32::getClassType(),
 272        "height",
 273        "",
 274        HeightFieldId, HeightFieldMask,
 275        false,
 276        (Field::SFDefaultFlags | Field::FStdAccess),
 277        static_cast<FieldEditMethodSig>(&Image::editHandleHeight),
 278        static_cast<FieldGetMethodSig >(&Image::getHandleHeight));
 279
 280    oType.addInitialDesc(pDesc);
 281
 282    pDesc = new SFInt32::Description(
 283        SFInt32::getClassType(),
 284        "depth",
 285        "",
 286        DepthFieldId, DepthFieldMask,
 287        false,
 288        (Field::SFDefaultFlags | Field::FStdAccess),
 289        static_cast<FieldEditMethodSig>(&Image::editHandleDepth),
 290        static_cast<FieldGetMethodSig >(&Image::getHandleDepth));
 291
 292    oType.addInitialDesc(pDesc);
 293
 294    pDesc = new SFInt32::Description(
 295        SFInt32::getClassType(),
 296        "bpp",
 297        "Bytes of data per pixel.\n",
 298        BppFieldId, BppFieldMask,
 299        false,
 300        (Field::SFDefaultFlags | Field::FStdAccess),
 301        static_cast<FieldEditMethodSig>(&Image::editHandleBpp),
 302        static_cast<FieldGetMethodSig >(&Image::getHandleBpp));
 303
 304    oType.addInitialDesc(pDesc);
 305
 306    pDesc = new SFInt32::Description(
 307        SFInt32::getClassType(),
 308        "mipMapCount",
 309        "",
 310        MipMapCountFieldId, MipMapCountFieldMask,
 311        false,
 312        (Field::SFDefaultFlags | Field::FStdAccess),
 313        static_cast<FieldEditMethodSig>(&Image::editHandleMipMapCount),
 314        static_cast<FieldGetMethodSig >(&Image::getHandleMipMapCount));
 315
 316    oType.addInitialDesc(pDesc);
 317
 318    pDesc = new SFInt32::Description(
 319        SFInt32::getClassType(),
 320        "frameCount",
 321        "The number of frames in the data.\n",
 322        FrameCountFieldId, FrameCountFieldMask,
 323        false,
 324        (Field::SFDefaultFlags | Field::FStdAccess),
 325        static_cast<FieldEditMethodSig>(&Image::editHandleFrameCount),
 326        static_cast<FieldGetMethodSig >(&Image::getHandleFrameCount));
 327
 328    oType.addInitialDesc(pDesc);
 329
 330    pDesc = new SFTime::Description(
 331        SFTime::getClassType(),
 332        "frameDelay",
 333        "Time between frames.  Determines the frame rate.\n",
 334        FrameDelayFieldId, FrameDelayFieldMask,
 335        false,
 336        (Field::SFDefaultFlags | Field::FStdAccess),
 337        static_cast<FieldEditMethodSig>(&Image::editHandleFrameDelay),
 338        static_cast<FieldGetMethodSig >(&Image::getHandleFrameDelay));
 339
 340    oType.addInitialDesc(pDesc);
 341
 342    pDesc = new SFUInt32::Description(
 343        SFUInt32::getClassType(),
 344        "pixelFormat",
 345        "",
 346        PixelFormatFieldId, PixelFormatFieldMask,
 347        false,
 348        (Field::SFDefaultFlags | Field::FStdAccess),
 349        static_cast<FieldEditMethodSig>(&Image::editHandlePixelFormat),
 350        static_cast<FieldGetMethodSig >(&Image::getHandlePixelFormat));
 351
 352    oType.addInitialDesc(pDesc);
 353
 354    pDesc = new MFUInt8::Description(
 355        MFUInt8::getClassType(),
 356        "pixel",
 357        "The pixel data buffer. This is where the data for the image is stored.\n",
 358        PixelFieldId, PixelFieldMask,
 359        false,
 360        (Field::MFDefaultFlags | Field::FStdAccess),
 361        static_cast<FieldEditMethodSig>(&Image::editHandlePixel),
 362        static_cast<FieldGetMethodSig >(&Image::getHandlePixel));
 363
 364    oType.addInitialDesc(pDesc);
 365
 366    pDesc = new SFInt32::Description(
 367        SFInt32::getClassType(),
 368        "frameSize",
 369        "",
 370        FrameSizeFieldId, FrameSizeFieldMask,
 371        true,
 372        (Field::SFDefaultFlags | Field::FStdAccess),
 373        static_cast<FieldEditMethodSig>(&Image::editHandleFrameSize),
 374        static_cast<FieldGetMethodSig >(&Image::getHandleFrameSize));
 375
 376    oType.addInitialDesc(pDesc);
 377
 378    pDesc = new SFString::Description(
 379        SFString::getClassType(),
 380        "name",
 381        "Texture file path.\n",
 382        NameFieldId, NameFieldMask,
 383        false,
 384        (Field::SFDefaultFlags | Field::FStdAccess),
 385        static_cast<FieldEditMethodSig>(&Image::editHandleName),
 386        static_cast<FieldGetMethodSig >(&Image::getHandleName));
 387
 388    oType.addInitialDesc(pDesc);
 389
 390    pDesc = new SFInt32::Description(
 391        SFInt32::getClassType(),
 392        "dataType",
 393        "Type of image data.\n",
 394        DataTypeFieldId, DataTypeFieldMask,
 395        false,
 396        (Field::SFDefaultFlags | Field::FStdAccess),
 397        static_cast<FieldEditMethodSig>(&Image::editHandleDataType),
 398        static_cast<FieldGetMethodSig >(&Image::getHandleDataType));
 399
 400    oType.addInitialDesc(pDesc);
 401
 402    pDesc = new SFInt32::Description(
 403        SFInt32::getClassType(),
 404        "componentSize",
 405        "Size (in byte) of a single component of the image. Necessary\n"
 406        "for High Dynamic Range and other higher-level image types.\n",
 407        ComponentSizeFieldId, ComponentSizeFieldMask,
 408        true,
 409        (Field::SFDefaultFlags | Field::FStdAccess),
 410        static_cast<FieldEditMethodSig>(&Image::editHandleComponentSize),
 411        static_cast<FieldGetMethodSig >(&Image::getHandleComponentSize));
 412
 413    oType.addInitialDesc(pDesc);
 414
 415    pDesc = new SFInt32::Description(
 416        SFInt32::getClassType(),
 417        "sideCount",
 418        "",
 419        SideCountFieldId, SideCountFieldMask,
 420        false,
 421        (Field::SFDefaultFlags | Field::FStdAccess),
 422        static_cast<FieldEditMethodSig>(&Image::editHandleSideCount),
 423        static_cast<FieldGetMethodSig >(&Image::getHandleSideCount));
 424
 425    oType.addInitialDesc(pDesc);
 426
 427    pDesc = new SFInt32::Description(
 428        SFInt32::getClassType(),
 429        "sideSize",
 430        "",
 431        SideSizeFieldId, SideSizeFieldMask,
 432        true,
 433        (Field::SFDefaultFlags | Field::FStdAccess),
 434        static_cast<FieldEditMethodSig>(&Image::editHandleSideSize),
 435        static_cast<FieldGetMethodSig >(&Image::getHandleSideSize));
 436
 437    oType.addInitialDesc(pDesc);
 438
 439    pDesc = new SFBool::Description(
 440        SFBool::getClassType(),
 441        "forceCompressedData",
 442        "Set to true if using the image to keep unknown data for textures.\n"
 443        "Generally used in conjunction with TextureChunk::externalFormat.\n",
 444        ForceCompressedDataFieldId, ForceCompressedDataFieldMask,
 445        false,
 446        (Field::SFDefaultFlags | Field::FStdAccess),
 447        static_cast<FieldEditMethodSig>(&Image::editHandleForceCompressedData),
 448        static_cast<FieldGetMethodSig >(&Image::getHandleForceCompressedData));
 449
 450    oType.addInitialDesc(pDesc);
 451
 452    pDesc = new SFBool::Description(
 453        SFBool::getClassType(),
 454        "forceAlphaChannel",
 455        "Set to true if using the image to keep unknown data for textures.\n"
 456        "Generally used in conjunction with TextureChunk::externalFormat.\n",
 457        ForceAlphaChannelFieldId, ForceAlphaChannelFieldMask,
 458        false,
 459        (Field::SFDefaultFlags | Field::FStdAccess),
 460        static_cast<FieldEditMethodSig>(&Image::editHandleForceAlphaChannel),
 461        static_cast<FieldGetMethodSig >(&Image::getHandleForceAlphaChannel));
 462
 463    oType.addInitialDesc(pDesc);
 464
 465    pDesc = new SFBool::Description(
 466        SFBool::getClassType(),
 467        "forceColorChannel",
 468        "Set to true if using the image to keep unknown data for textures.\n"
 469        "Generally used in conjunction with TextureChunk::externalFormat.\n",
 470        ForceColorChannelFieldId, ForceColorChannelFieldMask,
 471        false,
 472        (Field::SFDefaultFlags | Field::FStdAccess),
 473        static_cast<FieldEditMethodSig>(&Image::editHandleForceColorChannel),
 474        static_cast<FieldGetMethodSig >(&Image::getHandleForceColorChannel));
 475
 476    oType.addInitialDesc(pDesc);
 477
 478    pDesc = new SFBool::Description(
 479        SFBool::getClassType(),
 480        "forceAlphaBinary",
 481        "Set to true if using the image to prevent depth sorting for \n"
 482        "SimpleTexturedMaterials using this Image.\n",
 483        ForceAlphaBinaryFieldId, ForceAlphaBinaryFieldMask,
 484        false,
 485        (Field::SFDefaultFlags | Field::FStdAccess),
 486        static_cast<FieldEditMethodSig>(&Image::editHandleForceAlphaBinary),
 487        static_cast<FieldGetMethodSig >(&Image::getHandleForceAlphaBinary));
 488
 489    oType.addInitialDesc(pDesc);
 490
 491    pDesc = new SFReal32::Description(
 492        SFReal32::getClassType(),
 493        "resX",
 494        "",
 495        ResXFieldId, ResXFieldMask,
 496        false,
 497        (Field::SFDefaultFlags | Field::FStdAccess),
 498        static_cast<FieldEditMethodSig>(&Image::editHandleResX),
 499        static_cast<FieldGetMethodSig >(&Image::getHandleResX));
 500
 501    oType.addInitialDesc(pDesc);
 502
 503    pDesc = new SFReal32::Description(
 504        SFReal32::getClassType(),
 505        "resY",
 506        "",
 507        ResYFieldId, ResYFieldMask,
 508        false,
 509        (Field::SFDefaultFlags | Field::FStdAccess),
 510        static_cast<FieldEditMethodSig>(&Image::editHandleResY),
 511        static_cast<FieldGetMethodSig >(&Image::getHandleResY));
 512
 513    oType.addInitialDesc(pDesc);
 514
 515    pDesc = new SFUInt16::Description(
 516        SFUInt16::getClassType(),
 517        "resUnit",
 518        "resolution unit (invalid=0, none=1, inch=2)\n",
 519        ResUnitFieldId, ResUnitFieldMask,
 520        false,
 521        (Field::SFDefaultFlags | Field::FStdAccess),
 522        static_cast<FieldEditMethodSig>(&Image::editHandleResUnit),
 523        static_cast<FieldGetMethodSig >(&Image::getHandleResUnit));
 524
 525    oType.addInitialDesc(pDesc);
 526
 527    pDesc = new SFBool::Description(
 528        SFBool::getClassType(),
 529        "clearOnLoad",
 530        "Set to true if the image data should be cleared after it has been uploaded to the graphics\n"
 531        "card and is no longer needed in main memory.\n",
 532        ClearOnLoadFieldId, ClearOnLoadFieldMask,
 533        false,
 534        (Field::SFDefaultFlags | Field::FStdAccess),
 535        static_cast<FieldEditMethodSig>(&Image::editHandleClearOnLoad),
 536        static_cast<FieldGetMethodSig >(&Image::getHandleClearOnLoad));
 537
 538    oType.addInitialDesc(pDesc);
 539}
 540
 541
 542ImageBase::TypeObject ImageBase::_type(
 543    ImageBase::getClassname(),
 544    Inherited::getClassname(),
 545    "NULL",
 546    0,
 547    reinterpret_cast<PrototypeCreateF>(&ImageBase::createEmptyLocal),
 548    Image::initMethod,
 549    Image::exitMethod,
 550    reinterpret_cast<InitalInsertDescFunc>(&Image::classDescInserter),
 551    false,
 552    (ComponentSizeFieldMask | SideSizeFieldMask | FrameSizeFieldMask),
 553    "<?xml version=\"1.0\"?>\n"
 554    "\n"
 555    "<FieldContainer\n"
 556    "\tname=\"Image\"\n"
 557    "\tparent=\"AttachmentContainer\"\n"
 558    "\tlibrary=\"System\"\n"
 559    "\tpointerfieldtypes=\"both\"\n"
 560    "\tstructure=\"concrete\"\n"
 561    "\tsystemcomponent=\"true\"\n"
 562    "\tparentsystemcomponent=\"true\"\n"
 563    "\tdecoratable=\"false\"\n"
 564    "\tuseLocalIncludes=\"false\"\n"
 565    "        fieldsUnmarkedOnCreate=\"(ComponentSizeFieldMask | SideSizeFieldMask | FrameSizeFieldMask)\"\n"
 566    "        childFields=\"single\"\n"
 567    ">\n"
 568    "1D/2D/3D Image with various pixel types data, optionally also can hold\n"
 569    "mipMap and simple multi-frame data.\n"
 570    "\t<Field\n"
 571    "\t\tname=\"parents\"\n"
 572    "\t\ttype=\"FieldContainer\"\n"
 573    "\t\tcardinality=\"multi\"\n"
 574    "\t\tvisibility=\"internal\"\n"
 575    "\t\taccess=\"none\"\n"
 576    "                category=\"parentpointer\"\n"
 577    "\t>\n"
 578    "\t</Field>\n"
 579    "\t<Field\n"
 580    "\t\tname=\"dimension\"\n"
 581    "\t\ttype=\"Int32\"\n"
 582    "\t\tcardinality=\"single\"\n"
 583    "\t\tvisibility=\"external\"\n"
 584    "\t\tdefaultValue=\"0\"\n"
 585    "\t\taccess=\"public\"\n"
 586    "\t>\n"
 587    "\tImage dimension, 0 for invalid, 1 for 1D, 2 for 2D and 3 for 3D data.\n"
 588    "\t</Field>\n"
 589    "\t<Field\n"
 590    "\t\tname=\"width\"\n"
 591    "\t\ttype=\"Int32\"\n"
 592    "\t\tcardinality=\"single\"\n"
 593    "\t\tvisibility=\"external\"\n"
 594    "\t\tdefaultValue=\"0\"\n"
 595    "\t\taccess=\"public\"\n"
 596    "\t>\n"
 597    "\t</Field>\n"
 598    "\t<Field\n"
 599    "\t\tname=\"height\"\n"
 600    "\t\ttype=\"Int32\"\n"
 601    "\t\tcardinality=\"single\"\n"
 602    "\t\tvisibility=\"external\"\n"
 603    "\t\tdefaultValue=\"1\"\n"
 604    "\t\taccess=\"public\"\n"
 605    "\t>\n"
 606    "\t</Field>\n"
 607    "\t<Field\n"
 608    "\t\tname=\"depth\"\n"
 609    "\t\ttype=\"Int32\"\n"
 610    "\t\tcardinality=\"single\"\n"
 611    "\t\tvisibility=\"external\"\n"
 612    "\t\tdefaultValue=\"1\"\n"
 613    "\t\taccess=\"public\"\n"
 614    "\t>\n"
 615    "\t</Field>\n"
 616    "\t<Field\n"
 617    "\t\tname=\"bpp\"\n"
 618    "\t\ttype=\"Int32\"\n"
 619    "\t\tcardinality=\"single\"\n"
 620    "\t\tvisibility=\"external\"\n"
 621    "\t\tdefaultValue=\"1\"\n"
 622    "\t\taccess=\"public\"\n"
 623    "\t>\n"
 624    "        Bytes of data per pixel.\n"
 625    "\t</Field>\n"
 626    "\t<Field\n"
 627    "\t\tname=\"mipMapCount\"\n"
 628    "\t\ttype=\"Int32\"\n"
 629    "\t\tcardinality=\"single\"\n"
 630    "\t\tvisibility=\"external\"\n"
 631    "\t\tdefaultValue=\"1\"\n"
 632    "\t\taccess=\"public\"\n"
 633    "\t>\n"
 634    "\t</Field>\n"
 635    "\t<Field\n"
 636    "\t\tname=\"frameCount\"\n"
 637    "\t\ttype=\"Int32\"\n"
 638    "\t\tcardinality=\"single\"\n"
 639    "\t\tvisibility=\"external\"\n"
 640    "\t\tdefaultValue=\"1\"\n"
 641    "\t\taccess=\"public\"\n"
 642    "\t>\n"
 643    "        The number of frames in the data.\n"
 644    "\t</Field>\n"
 645    "\t<Field\n"
 646    "\t\tname=\"frameDelay\"\n"
 647    "\t\ttype=\"Time\"\n"
 648    "\t\tcardinality=\"single\"\n"
 649    "\t\tvisibility=\"external\"\n"
 650    "\t\tdefaultValue=\"0\"\n"
 651    "\t\taccess=\"public\"\n"
 652    "\t>\n"
 653    "        Time between frames.  Determines the frame rate.\n"
 654    "\t</Field>\n"
 655    "\t<Field\n"
 656    "\t\tname=\"pixelFormat\"\n"
 657    "\t\ttype=\"UInt32\"\n"
 658    "\t\tcardinality=\"single\"\n"
 659    "\t\tvisibility=\"external\"\n"
 660    "\t\tdefaultValue=\"Image::OSG_INVALID_PF\"\n"
 661    "\t\taccess=\"public\"\n"
 662    "\t>\n"
 663    "\t</Field>\n"
 664    "\t<Field\n"
 665    "\t\tname=\"pixel\"\n"
 666    "\t\ttype=\"UInt8\"\n"
 667    "\t\tcardinality=\"multi\"\n"
 668    "\t\tvisibility=\"external\"\n"
 669    "\t\taccess=\"public\"\n"
 670    "\t>\n"
 671    "        The pixel data buffer. This is where the data for the image is stored.\n"
 672    "\t</Field>\n"
 673    "\t<Field\n"
 674    "\t\tname=\"frameSize\"\n"
 675    "\t\ttype=\"Int32\"\n"
 676    "\t\tcardinality=\"single\"\n"
 677    "\t\tvisibility=\"internal\"\n"
 678    "\t\tdefaultValue=\"0\"\n"
 679    "\t\taccess=\"public\"\n"
 680    "\t>\n"
 681    "\t</Field>\n"
 682    "\t<Field\n"
 683    "\t\tname=\"name\"\n"
 684    "\t\ttype=\"std::string\"\n"
 685    "\t\tcardinality=\"single\"\n"
 686    "\t\tvisibility=\"external\"\n"
 687    "\t\taccess=\"public\"\n"
 688    "\t>\n"
 689    "\tTexture file path.\n"
 690    "\t</Field>\n"
 691    "\t<Field\n"
 692    "\t\tname=\"dataType\"\n"
 693    "\t\ttype=\"Int32\"\n"
 694    "\t\tcardinality=\"single\"\n"
 695    "\t\tvisibility=\"external\"\n"
 696    "\t\tdefaultValue=\"GL_UNSIGNED_BYTE\"\n"
 697    "\t\tdefaultHeader=\"&quot;OSGGL.h&quot;\"\n"
 698    "\t\taccess=\"public\"\n"
 699    "\t>\n"
 700    "\tType of image data.\n"
 701    "\t</Field>\n"
 702    "\t<Field\n"
 703    "\t\tname=\"componentSize\"\n"
 704    "\t\ttype=\"Int32\"\n"
 705    "\t\tcardinality=\"single\"\n"
 706    "\t\tvisibility=\"internal\"\n"
 707    "\t\tdefaultValue=\"1\"\n"
 708    "\t\taccess=\"protected\"\n"
 709    "\t>\n"
 710    "\tSize (in byte) of a single component of the image. Necessary\n"
 711    "        for High Dynamic Range and other higher-level image types.\n"
 712    "\t</Field>\n"
 713    "\t<Field\n"
 714    "\t\tname=\"sideCount\"\n"
 715    "\t\ttype=\"Int32\"\n"
 716    "\t\tcardinality=\"single\"\n"
 717    "\t\tvisibility=\"external\"\n"
 718    "\t\tdefaultValue=\"1\"\n"
 719    "\t\taccess=\"public\"\n"
 720    "\t>\n"
 721    "\t</Field>\n"
 722    "\t<Field\n"
 723    "\t\tname=\"sideSize\"\n"
 724    "\t\ttype=\"Int32\"\n"
 725    "\t\tcardinality=\"single\"\n"
 726    "\t\tvisibility=\"internal\"\n"
 727    "\t\tdefaultValue=\"0\"\n"
 728    "\t\taccess=\"public\"\n"
 729    "\t>\n"
 730    "\t</Field>\n"
 731    "\t<Field\n"
 732    "\t\tname=\"forceCompressedData\"\n"
 733    "\t\ttype=\"bool\"\n"
 734    "\t\tcardinality=\"single\"\n"
 735    "\t\tvisibility=\"external\"\n"
 736    "\t\tdefaultValue=\"false\"\n"
 737    "\t\taccess=\"public\"\n"
 738    "\t>\n"
 739    "        Set to true if using the image to keep unknown data for textures.\n"
 740    "        Generally used in conjunction with TextureChunk::externalFormat.\n"
 741    "\t</Field>\n"
 742    "\t<Field\n"
 743    "\t\tname=\"forceAlphaChannel\"\n"
 744    "\t\ttype=\"bool\"\n"
 745    "\t\tcardinality=\"single\"\n"
 746    "\t\tvisibility=\"external\"\n"
 747    "\t\tdefaultValue=\"false\"\n"
 748    "\t\taccess=\"public\"\n"
 749    "\t>\n"
 750    "        Set to true if using the image to keep unknown data for textures.\n"
 751    "        Generally used in conjunction with TextureChunk::externalFormat.\n"
 752    "\t</Field>\n"
 753    "\t<Field\n"
 754    "\t\tname=\"forceColorChannel\"\n"
 755    "\t\ttype=\"bool\"\n"
 756    "\t\tcardinality=\"single\"\n"
 757    "\t\tvisibility=\"external\"\n"
 758    "\t\tdefaultValue=\"false\"\n"
 759    "\t\taccess=\"public\"\n"
 760    "\t>\n"
 761    "        Set to true if using the image to keep unknown data for textures.\n"
 762    "        Generally used in conjunction with TextureChunk::externalFormat.\n"
 763    "\t</Field>\n"
 764    "\t<Field\n"
 765    "\t\tname=\"forceAlphaBinary\"\n"
 766    "\t\ttype=\"bool\"\n"
 767    "\t\tcardinality=\"single\"\n"
 768    "\t\tvisibility=\"external\"\n"
 769    "\t\tdefaultValue=\"false\"\n"
 770    "\t\taccess=\"public\"\n"
 771    "\t>\n"
 772    "        Set to true if using the image to prevent depth sorting for \n"
 773    "        SimpleTexturedMaterials using this Image.\n"
 774    "\t</Field>\n"
 775    "\t<Field\n"
 776    "\t\tname=\"resX\"\n"
 777    "\t\ttype=\"Real32\"\n"
 778    "\t\tcardinality=\"single\"\n"
 779    "\t\tvisibility=\"external\"\n"
 780    "\t\tdefaultValue=\"72.0f\"\n"
 781    "\t\taccess=\"public\"\n"
 782    "\t>\n"
 783    "\t</Field>\n"
 784    "\t<Field\n"
 785    "\t\tname=\"resY\"\n"
 786    "\t\ttype=\"Real32\"\n"
 787    "\t\tcardinality=\"single\"\n"
 788    "\t\tvisibility=\"external\"\n"
 789    "\t\tdefaultValue=\"72.0f\"\n"
 790    "\t\taccess=\"public\"\n"
 791    "\t>\n"
 792    "\t</Field>\n"
 793    "\t<Field\n"
 794    "\t\tname=\"resUnit\"\n"
 795    "\t\ttype=\"UInt16\"\n"
 796    "\t\tcardinality=\"single\"\n"
 797    "\t\tvisibility=\"external\"\n"
 798    "\t\tdefaultValue=\"2\"\n"
 799    "\t\taccess=\"public\"\n"
 800    "\t>\n"
 801    "\tresolution unit (invalid=0, none=1, inch=2)\n"
 802    "\t</Field>\t\n"
 803    "        <Field\n"
 804    "\t\tname=\"clearOnLoad\"\n"
 805    "\t\ttype=\"bool\"\n"
 806    "\t\tcardinality=\"single\"\n"
 807    "\t\tvisibility=\"external\"\n"
 808    "\t\tdefaultValue=\"false\"\n"
 809    "\t\taccess=\"public\"\n"
 810    "\t>\n"
 811    "        Set to true if the image data should be cleared after it has been uploaded to the graphics\n"
 812    "        card and is no longer needed in main memory.\n"
 813    "\t</Field>\n"
 814    "</FieldContainer>\n",
 815    "1D/2D/3D Image with various pixel types data, optionally also can hold\n"
 816    "mipMap and simple multi-frame data.\n"
 817    );
 818
 819/*------------------------------ get -----------------------------------*/
 820
 821FieldContainerType &ImageBase::getType(void)
 822{
 823    return _type;
 824}
 825
 826const FieldContainerType &ImageBase::getType(void) const
 827{
 828    return _type;
 829}
 830
 831UInt32 ImageBase::getContainerSize(void) const
 832{
 833    return sizeof(Image);
 834}
 835
 836/*------------------------- decorator get ------------------------------*/
 837
 838
 839
 840SFInt32 *ImageBase::editSFDimension(void)
 841{
 842    editSField(DimensionFieldMask);
 843
 844    return &_sfDimension;
 845}
 846
 847const SFInt32 *ImageBase::getSFDimension(void) const
 848{
 849    return &_sfDimension;
 850}
 851
 852
 853SFInt32 *ImageBase::editSFWidth(void)
 854{
 855    editSField(WidthFieldMask);
 856
 857    return &_sfWidth;
 858}
 859
 860const SFInt32 *ImageBase::getSFWidth(void) const
 861{
 862    return &_sfWidth;
 863}
 864
 865
 866SFInt32 *ImageBase::editSFHeight(void)
 867{
 868    editSField(HeightFieldMask);
 869
 870    return &_sfHeight;
 871}
 872
 873const SFInt32 *ImageBase::getSFHeight(void) const
 874{
 875    return &_sfHeight;
 876}
 877
 878
 879SFInt32 *ImageBase::editSFDepth(void)
 880{
 881    editSField(DepthFieldMask);
 882
 883    return &_sfDepth;
 884}
 885
 886const SFInt32 *ImageBase::getSFDepth(void) const
 887{
 888    return &_sfDepth;
 889}
 890
 891
 892SFInt32 *ImageBase::editSFBpp(void)
 893{
 894    editSField(BppFieldMask);
 895
 896    return &_sfBpp;
 897}
 898
 899const SFInt32 *ImageBase::getSFBpp(void) const
 900{
 901    return &_sfBpp;
 902}
 903
 904
 905SFInt32 *ImageBase::editSFMipMapCount(void)
 906{
 907    editSField(MipMapCountFieldMask);
 908
 909    return &_sfMipMapCount;
 910}
 911
 912const SFInt32 *ImageBase::getSFMipMapCount(void) const
 913{
 914    return &_sfMipMapCount;
 915}
 916
 917
 918SFInt32 *ImageBase::editSFFrameCount(void)
 919{
 920    editSField(FrameCountFieldMask);
 921
 922    return &_sfFrameCount;
 923}
 924
 925const SFInt32 *ImageBase::getSFFrameCount(void) const
 926{
 927    return &_sfFrameCount;
 928}
 929
 930
 931SFTime *ImageBase::editSFFrameDelay(void)
 932{
 933    editSField(FrameDelayFieldMask);
 934
 935    return &_sfFrameDelay;
 936}
 937
 938const SFTime *ImageBase::getSFFrameDelay(void) const
 939{
 940    return &_sfFrameDelay;
 941}
 942
 943
 944SFUInt32 *ImageBase::editSFPixelFormat(void)
 945{
 946    editSField(PixelFormatFieldMask);
 947
 948    return &_sfPixelFormat;
 949}
 950
 951const SFUInt32 *ImageBase::getSFPixelFormat(void) const
 952{
 953    return &_sfPixelFormat;
 954}
 955
 956
 957MFUInt8 *ImageBase::editMFPixel(void)
 958{
 959    editMField(PixelFieldMask, _mfPixel);
 960
 961    return &_mfPixel;
 962}
 963
 964const MFUInt8 *ImageBase::getMFPixel(void) const
 965{
 966    return &_mfPixel;
 967}
 968
 969
 970SFInt32 *ImageBase::editSFFrameSize(void)
 971{
 972    editSField(FrameSizeFieldMask);
 973
 974    return &_sfFrameSize;
 975}
 976
 977const SFInt32 *ImageBase::getSFFrameSize(void) const
 978{
 979    return &_sfFrameSize;
 980}
 981
 982
 983SFString *ImageBase::editSFName(void)
 984{
 985    editSField(NameFieldMask);
 986
 987    return &_sfName;
 988}
 989
 990const SFString *ImageBase::getSFName(void) const
 991{
 992    return &_sfName;
 993}
 994
 995
 996SFInt32 *ImageBase::editSFDataType(void)
 997{
 998    editSField(DataTypeFieldMask);
 999
1000    return &_sfDataType;
1001}
1002
1003const SFInt32 *ImageBase::getSFDataType(void) const
1004{
1005    return &_sfDataType;
1006}
1007
1008
1009SFInt32 *ImageBase::editSFComponentSize(void)
1010{
1011    editSField(ComponentSizeFieldMask);
1012
1013    return &_sfComponentSize;
1014}
1015
1016const SFInt32 *ImageBase::getSFComponentSize(void) const
1017{
1018    return &_sfComponentSize;
1019}
1020
1021
1022SFInt32 *ImageBase::editSFSideCount(void)
1023{
1024    editSField(SideCountFieldMask);
1025
1026    return &_sfSideCount;
1027}
1028
1029const SFInt32 *ImageBase::getSFSideCount(void) const
1030{
1031    return &_sfSideCount;
1032}
1033
1034
1035SFInt32 *ImageBase::editSFSideSize(void)
1036{
1037    editSField(SideSizeFieldMask);
1038
1039    return &_sfSideSize;
1040}
1041
1042const SFInt32 *ImageBase::getSFSideSize(void) const
1043{
1044    return &_sfSideSize;
1045}
1046
1047
1048SFBool *ImageBase::editSFForceCompressedData(void)
1049{
1050    editSField(ForceCompressedDataFieldMask);
1051
1052    return &_sfForceCompressedData;
1053}
1054
1055const SFBool *ImageBase::getSFForceCompressedData(void) const
1056{
1057    return &_sfForceCompressedData;
1058}
1059
1060
1061SFBool *ImageBase::editSFForceAlphaChannel(void)
1062{
1063    editSField(ForceAlphaChannelFieldMask);
1064
1065    return &_sfForceAlphaChannel;
1066}
1067
1068const SFBool *ImageBase::getSFForceAlphaChannel(void) const
1069{
1070    return &_sfForceAlphaChannel;
1071}
1072
1073
1074SFBool *ImageBase::editSFForceColorChannel(void)
1075{
1076    editSField(ForceColorChannelFieldMask);
1077
1078    return &_sfForceColorChannel;
1079}
1080
1081const SFBool *ImageBase::getSFForceColorChannel(void) const
1082{
1083    return &_sfForceColorChannel;
1084}
1085
1086
1087SFBool *ImageBase::editSFForceAlphaBinary(void)
1088{
1089    editSField(ForceAlphaBinaryFieldMask);
1090
1091    return &_sfForceAlphaBinary;
1092}
1093
1094const SFBool *ImageBase::getSFForceAlphaBinary(void) const
1095{
1096    return &_sfForceAlphaBinary;
1097}
1098
1099
1100SFReal32 *ImageBase::editSFResX(void)
1101{
1102    editSField(ResXFieldMask);
1103
1104    return &_sfResX;
1105}
1106
1107const SFReal32 *ImageBase::getSFResX(void) const
1108{
1109    return &_sfResX;
1110}
1111
1112
1113SFReal32 *ImageBase::editSFResY(void)
1114{
1115    editSField(ResYFieldMask);
1116
1117    return &_sfResY;
1118}
1119
1120const SFReal32 *ImageBase::getSFResY(void) const
1121{
1122    return &_sfResY;
1123}
1124
1125
1126SFUInt16 *ImageBase::editSFResUnit(void)
1127{
1128    editSField(ResUnitFieldMask);
1129
1130    return &_sfResUnit;
1131}
1132
1133const SFUInt16 *ImageBase::getSFResUnit(void) const
1134{
1135    return &_sfResUnit;
1136}
1137
1138
1139SFBool *ImageBase::editSFClearOnLoad(void)
1140{
1141    editSField(ClearOnLoadFieldMask);
1142
1143    return &_sfClearOnLoad;
1144}
1145
1146const SFBool *ImageBase::getSFClearOnLoad(void) const
1147{
1148    return &_sfClearOnLoad;
1149}
1150
1151
1152
1153
1154
1155
1156/*------------------------------ access -----------------------------------*/
1157
1158UInt32 ImageBase::getBinSize(ConstFieldMaskArg whichField)
1159{
1160    UInt32 returnValue = Inherited::getBinSize(whichField);
1161
1162    if(FieldBits::NoField != (ParentsFieldMask & whichField))
1163    {
1164        returnValue += _mfParents.getBinSize();
1165    }
1166    if(FieldBits::NoField != (DimensionFieldMask & whichField))
1167    {
1168        returnValue += _sfDimension.getBinSize();
1169    }
1170    if(FieldBits::NoField != (WidthFieldMask & whichField))
1171    {
1172        returnValue += _sfWidth.getBinSize();
1173    }
1174    if(FieldBits::NoField != (HeightFieldMask & whichField))
1175    {
1176        returnValue += _sfHeight.getBinSize();
1177    }
1178    if(FieldBits::NoField != (DepthFieldMask & whichField))
1179    {
1180        returnValue += _sfDepth.getBinSize();
1181    }
1182    if(FieldBits::NoField != (BppFieldMask & whichField))
1183    {
1184        returnValue += _sfBpp.getBinSize();
1185    }
1186    if(FieldBits::NoField != (MipMapCountFieldMask & whichField))
1187    {
1188        returnValue += _sfMipMapCount.getBinSize();
1189    }
1190    if(FieldBits::NoField != (FrameCountFieldMask & whichField))
1191    {
1192        returnValue += _sfFrameCount.getBinSize();
1193    }
1194    if(FieldBits::NoField != (FrameDelayFieldMask & whichField))
1195    {
1196        returnValue += _sfFrameDelay.getBinSize();
1197    }
1198    if(FieldBits::NoField != (PixelFormatFieldMask & whichField))
1199    {
1200        returnValue += _sfPixelFormat.getBinSize();
1201    }
1202    if(FieldBits::NoField != (PixelFieldMask & whichField))
1203    {
1204        returnValue += _mfPixel.getBinSize();
1205    }
1206    if(FieldBits::NoField != (FrameSizeFieldMask & whichField))
1207    {
1208        returnValue += _sfFrameSize.getBinSize();
1209    }
1210    if(FieldBits::NoField != (NameFieldMask & whichField))
1211    {
1212        returnValue += _sfName.getBinSize();
1213    }
1214    if(FieldBits::NoField != (DataTypeFieldMask & whichField))
1215    {
1216        returnValue += _sfDataType.getBinSize();
1217    }
1218    if(FieldBits::NoField != (ComponentSizeFieldMask & whichField))
1219    {
1220        returnValue += _sfComponentSize.getBinSize();
1221    }
1222    if(FieldBits::NoField != (SideCountFieldMask & whichField))
1223    {
1224        returnValue += _sfSideCount.getBinSize();
1225    }
1226    if(FieldBits::NoField != (SideSizeFieldMask & whichField))
1227    {
1228        returnValue += _sfSideSize.getBinSize();
1229    }
1230    if(FieldBits::NoField != (ForceCompressedDataFieldMask & whichField))
1231    {
1232        returnValue += _sfForceCompressedData.getBinSize();
1233    }
1234    if(FieldBits::NoField != (ForceAlphaChannelFieldMask & whichField))
1235    {
1236        returnValue += _sfForceAlphaChannel.getBinSize();
1237    }
1238    if(FieldBits::NoField != (ForceColorChannelFieldMask & whichField))
1239    {
1240        returnValue += _sfForceColorChannel.getBinSize();
1241    }
1242    if(FieldBits::NoField != (ForceAlphaBinaryFieldMask & whichField))
1243    {
1244        returnValue += _sfForceAlphaBinary.getBinSize();
1245    }
1246    if(FieldBits::NoField != (ResXFieldMask & whichField))
1247    {
1248        returnValue += _sfResX.getBinSize();
1249    }
1250    if(FieldBits::NoField != (ResYFieldMask & whichField))
1251    {
1252        returnValue += _sfResY.getBinSize();
1253    }
1254    if(FieldBits::NoField != (ResUnitFieldMask & whichField))
1255    {
1256        returnValue += _sfResUnit.getBinSize();
1257    }
1258    if(FieldBits::NoField != (ClearOnLoadFieldMask & whichField))
1259    {
1260        returnValue += _sfClearOnLoad.getBinSize();
1261    }
1262
1263    return returnValue;
1264}
1265
1266void ImageBase::copyToBin(BinaryDataHandler &pMem,
1267                                  ConstFieldMaskArg  whichField)
1268{
1269    Inherited::copyToBin(pMem, whichField);
1270
1271    if(FieldBits::NoField != (ParentsFieldMask & whichField))
1272    {
1273        _mfParents.copyToBin(pMem);
1274    }
1275    if(FieldBits::NoField != (DimensionFieldMask & whichField))
1276    {
1277        _sfDimension.copyToBin(pMem);
1278    }
1279    if(FieldBits::NoField != (WidthFieldMask & whichField))
1280    {
1281        _sfWidth.copyToBin(pMem);
1282    }
1283    if(FieldBits::NoField != (HeightFieldMask & whichField))
1284    {
1285        _sfHeight.copyToBin(pMem);
1286    }
1287    if(FieldBits::NoField != (DepthFieldMask & whichField))
1288    {
1289        _sfDepth.copyToBin(pMem);
1290    }
1291    if(FieldBits::NoField != (BppFieldMask & whichField))
1292    {
1293        _sfBpp.copyToBin(pMem);
1294    }
1295    if(FieldBits::NoField != (MipMapCountFieldMask & whichField))
1296    {
1297        _sfMipMapCount.copyToBin(pMem);
1298    }
1299    if(FieldBits::NoField != (FrameCountFieldMask & whichField))
1300    {
1301        _sfFrameCount.copyToBin(pMem);
1302    }
1303    if(FieldBits::NoField != (FrameDelayFieldMask & whichField))
1304    {
1305        _sfFrameDelay.copyToBin(pMem);
1306    }
1307    if(FieldBits::NoField != (PixelFormatFieldMask & whichField))
1308    {
1309        _sfPixelFormat.copyToBin(pMem);
1310    }
1311    if(FieldBits::NoField != (PixelFieldMask & whichField))
1312    {
1313        _mfPixel.copyToBin(pMem);
1314    }
1315    if(FieldBits::NoField != (FrameSizeFieldMask & whichField))
1316    {
1317        _sfFrameSize.copyToBin(pMem);
1318    }
1319    if(FieldBits::NoField != (NameFieldMask & whichField))
1320    {
1321        _sfName.copyToBin(pMem);
1322    }
1323    if(FieldBits::NoField != (DataTypeFieldMask & whichField))
1324    {
1325        _sfDataType.copyToBin(pMem);
1326    }
1327    if(FieldBits::NoField != (ComponentSizeFieldMask & whichField))
1328    {
1329        _sfComponentSize.copyToBin(pMem);
1330    }
1331    if(FieldBits::NoField != (SideCountFieldMask & whichField))
1332    {
1333        _sfSideCount.copyToBin(pMem);
1334    }
1335    if(FieldBits::NoField != (SideSizeFieldMask & whichField))
1336    {
1337        _sfSideSize.copyToBin(pMem);
1338    }
1339    if(FieldBits::NoField != (ForceCompressedDataFieldMask & whichField))
1340    {
1341        _sfForceCompressedData.copyToBin(pMem);
1342    }
1343    if(FieldBits::NoField != (ForceAlphaChannelFieldMask & whichField))
1344    {
1345        _sfForceAlphaChannel.copyToBin(pMem);
1346    }
1347    if(FieldBits::NoField != (ForceColorChannelFieldMask & whichField))
1348    {
1349        _sfForceColorChannel.copyToBin(pMem);
1350    }
1351    if(FieldBits::NoField != (ForceAlphaBinaryFieldMask & whichField))
1352    {
1353        _sfForceAlphaBinary.copyToBin(pMem);
1354    }
1355    if(FieldBits::NoField != (ResXFieldMask & whichField))
1356    {
1357        _sfResX.copyToBin(pMem);
1358    }
1359    if(FieldBits::NoField != (ResYFieldMask & whichField))
1360    {
1361        _sfResY.copyToBin(pMem);
1362    }
1363    if(FieldBits::NoField != (ResUnitFieldMask & whichField))
1364    {
1365        _sfResUnit.copyToBin(pMem);
1366    }
1367    if(FieldBits::NoField != (ClearOnLoadFieldMask & whichField))
1368    {
1369        _sfClearOnLoad.copyToBin(pMem);
1370    }
1371}
1372
1373void ImageBase::copyFromBin(BinaryDataHandler &pMem,
1374                                    ConstFieldMaskArg  whichField)
1375{
1376    Inherited::copyFromBin(pMem, whichField);
1377
1378    if(FieldBits::NoField != (ParentsFieldMask & whichField))
1379    {
1380        _mfParents.copyFromBin(pMem);
1381    }
1382    if(FieldBits::NoField != (DimensionFieldMask & whichField))
1383    {
1384        _sfDimension.copyFromBin(pMem);
1385    }
1386    if(FieldBits::NoField != (WidthFieldMask & whichField))
1387    {
1388        _sfWidth.copyFromBin(pMem);
1389    }
1390    if(FieldBits::NoField != (HeightFieldMask & whichField))
1391    {
1392        _sfHeight.copyFromBin(pMem);
1393    }
1394    if(FieldBits::NoField != (DepthFieldMask & whichField))
1395    {
1396        _sfDepth.copyFromBin(pMem);
1397    }
1398    if(FieldBits::NoField != (BppFieldMask & whichField))
1399    {
1400        _sfBpp.copyFromBin(pMem);
1401    }
1402    if(FieldBits::NoField != (MipMapCountFieldMask & whichField))
1403    {
1404        _sfMipMapCount.copyFromBin(pMem);
1405    }
1406    if(FieldBits::NoField != (FrameCountFieldMask & whichField))
1407    {
1408        _sfFrameCount.copyFromBin(pMem);
1409    }
1410    if(FieldBits::NoField != (FrameDelayFieldMask & whichField))
1411    {
1412        _sfFrameDelay.copyFromBin(pMem);
1413    }
1414    if(FieldBits::NoField != (PixelFormatFieldMask & whichField))
1415    {
1416        _sfPixelFormat.copyFromBin(pMem);
1417    }
1418    if(FieldBits::NoField != (PixelFieldMask & whichField))
1419    {
1420        _mfPixel.copyFromBin(pMem);
1421    }
1422    if(FieldBits::NoField != (FrameSizeFieldMask & whichField))
1423    {
1424        _sfFrameSize.copyFromBin(pMem);
1425    }
1426    if(FieldBits::NoField != (NameFieldMask & whichField))
1427    {
1428        _sfName.copyFromBin(pMem);
1429    }
1430    if(FieldBits::NoField != (DataTypeFieldMask & whichField))
1431    {
1432        _sfDataType.copyFromBin(pMem);
1433    }
1434    if(FieldBits::NoField != (ComponentSizeFieldMask & whichField))
1435    {
1436        _sfComponentSize.copyFromBin(pMem);
1437    }
1438    if(FieldBits::NoField != (SideCountFieldMask & whichField))
1439    {
1440        _sfSideCount.copyFromBin(pMem);
1441    }
1442    if(FieldBits::NoField != (SideSizeFieldMask & whichField))
1443    {
1444        _sfSideSize.copyFromBin(pMem);
1445    }
1446    if(FieldBits::NoField != (ForceCompressedDataFieldMask & whichField))
1447    {
1448        _sfForceCompressedData.copyFromBin(pMem);
1449    }
1450    if(FieldBits::NoField != (ForceAlphaChannelFieldMask & whichField))
1451    {
1452        _sfForceAlphaChannel.copyFromBin(pMem);
1453    }
1454    if(FieldBits::NoField != (ForceColorChannelFieldMask & whichField))
1455    {
1456        _sfForceColorChannel.copyFromBin(pMem);
1457    }
1458    if(FieldBits::NoField != (ForceAlphaBinaryFieldMask & whichField))
1459    {
1460        _sfForceAlphaBinary.copyFromBin(pMem);
1461    }
1462    if(FieldBits::NoField != (ResXFieldMask & whichField))
1463    {
1464        _sfResX.copyFromBin(pMem);
1465    }
1466    if(FieldBits::NoField != (ResYFieldMask & whichField))
1467    {
1468        _sfResY.copyFromBin(pMem);
1469    }
1470    if(FieldBits::NoField != (ResUnitFieldMask & whichField))
1471    {
1472        _sfResUnit.copyFromBin(pMem);
1473    }
1474    if(FieldBits::NoField != (ClearOnLoadFieldMask & whichField))
1475    {
1476        _sfClearOnLoad.copyFromBin(pMem);
1477    }
1478}
1479
1480//! create a new instance of the class
1481ImageTransitPtr ImageBase::createLocal(BitVector bFlags)
1482{
1483    ImageTransitPtr fc;
1484
1485    if(getClassType().getPrototype() != NULL)
1486    {
1487        FieldContainerTransitPtr tmpPtr =
1488            getClassType().getPrototype()-> shallowCopyLocal(bFlags);
1489
1490        fc = dynamic_pointer_cast<Image>(tmpPtr);
1491    }
1492
1493    return fc;
1494}
1495
1496//! create a new instance of the class, copy the container flags
1497ImageTransitPtr ImageBase::createDependent(BitVector bFlags)
1498{
1499    ImageTransitPtr fc;
1500
1501    if(getClassType().getPrototype() != NULL)
1502    {
1503        FieldContainerTransitPtr tmpPtr =
1504            getClassType().getPrototype()-> shallowCopyDependent(bFlags);
1505
1506        fc = dynamic_pointer_cast<Image>(tmpPtr);
1507    }
1508
1509    return fc;
1510}
1511
1512//! create a new instance of the class
1513ImageTransitPtr ImageBase::create(void)
1514{
1515    ImageTransitPtr fc;
1516
1517    if(getClassType().getPrototype() != NULL)
1518    {
1519        FieldContainerTransitPtr tmpPtr =
1520            getClassType().getPrototype()-> shallowCopy();
1521
1522        fc = dynamic_pointer_cast<Image>(tmpPtr);
1523    }
1524
1525    return fc;
1526}
1527
1528Image *ImageBase::createEmptyLocal(BitVector bFlags)
1529{
1530    Image *returnValue;
1531
1532    newPtr<Image>(returnValue, bFlags);
1533
1534    returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
1535
1536    return returnValue;
1537}
1538
1539//! create an empty new instance of the class, do not copy the prototype
1540Image *ImageBase::createEmpty(void)
1541{
1542    Image *returnValue;
1543
1544    newPtr<Image>(returnValue, Thread::getCurrentLocalFlags());
1545
1546    returnValue->_pFieldFlags->_bNamespaceMask &=
1547        ~Thread::getCurrentLocalFlags();
1548
1549    return returnValue;
1550}
1551
1552
1553FieldContainerTransitPtr ImageBase::shallowCopyLocal(
1554    BitVector bFlags) const
1555{
1556    Image *tmpPtr;
1557
1558    newPtr(tmpPtr, dynamic_cast<const Image *>(this), bFlags);
1559
1560    FieldContainerTransitPtr returnValue(tmpPtr);
1561
1562    tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
1563
1564    return returnValue;
1565}
1566
1567FieldContainerTransitPtr ImageBase::shallowCopyDependent(
1568    BitVector bFlags) const
1569{
1570    Image *tmpPtr;
1571
1572    newPtr(tmpPtr, dynamic_cast<const Image *>(this), ~bFlags);
1573
1574    FieldContainerTransitPtr returnValue(tmpPtr);
1575
1576    tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
1577
1578    return returnValue;
1579}
1580
1581FieldContainerTransitPtr ImageBase::shallowCopy(void) const
1582{
1583    Image *tmpPtr;
1584
1585    newPtr(tmpPtr,
1586           dynamic_cast<const Image *>(this),
1587           Thread::getCurrentLocalFlags());
1588
1589    tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
1590
1591    FieldContainerTransitPtr returnValue(tmpPtr);
1592
1593    return returnValue;
1594}
1595
1596
1597
1598
1599/*------------------------- constructors ----------------------------------*/
1600
1601ImageBase::ImageBase(void) :
1602    Inherited(),
1603    _mfParents                (),
1604    _sfDimension              (Int32(0)),
1605    _sfWidth                  (Int32(0)),
1606    _sfHeight                 (Int32(1)),
1607    _sfDepth                  (Int32(1)),
1608    _sfBpp                    (Int32(1)),
1609    _sfMipMapCount            (Int32(1)),
1610    _sfFrameCount             (Int32(1)),
1611    _sfFrameDelay             (Time(0)),
1612    _sfPixelFormat            (UInt32(Image::OSG_INVALID_PF)),
1613    _mfPixel                  (),
1614    _sfFrameSize              (Int32(0)),
1615    _sfName                   (),
1616    _sfDataType               (Int32(GL_UNSIGNED_BYTE)),
1617    _sfComponentSize          (Int32(1)),
1618    _sfSideCount              (Int32(1)),
1619    _sfSideSize               (Int32(0)),
1620    _sfForceCompressedData    (bool(false)),
1621    _sfForceAlphaChannel      (bool(false)),
1622    _sfForceColorChannel      (bool(false)),
1623    _sfForceAlphaBinary       (bool(false)),
1624    _sfResX                   (Real32(72.0f)),
1625    _sfResY                   (Real32(72.0f)),
1626    _sfResUnit                (UInt16(2)),
1627    _sfClearOnLoad            (bool(false))
1628{
1629}
1630
1631ImageBase::ImageBase(const ImageBase &source) :
1632    Inherited(source),
1633    _mfParents                (),
1634    _sfDimension              (source._sfDimension              ),
1635    _sfWidth                  (source._sfWidth                  ),
1636    _sfHeight                 (source._sfHeight                 ),
1637    _sfDepth                  (source._sfDepth                  ),
1638    _sfBpp                    (source._sfBpp                    ),
1639    _sfMipMapCount            (source._sfMipMapCount            ),
1640    _sfFrameCount             (source._sfFrameCount             ),
1641    _sfFrameDelay             (source._sfFrameDelay             ),
1642    _sfPixelFormat            (source._sfPixelFormat            ),
1643    _mfPixel                  (source._mfPixel                  ),
1644    _sfFrameSize              (source._sfFrameSize              ),
1645    _sfName                   (source._sfName                   ),
1646    _sfDataType               (source._sfDataType               ),
1647    _sfComponentSize          (source._sfComponentSize          ),
1648    _sfSideCount              (source._sfSideCount              ),
1649    _sfSideSize               (source._sfSideSize               ),
1650    _sfForceCompressedData    (source._sfForceCompressedData    ),
1651    _sfForceAlphaChannel      (source._sfForceAlphaChannel      ),
1652    _sfForceColorChannel      (source._sfForceColorChannel      ),
1653    _sfForceAlphaBinary       (source._sfForceAlphaBinary       ),
1654    _sfResX                   (source._sfResX                   ),
1655    _sfResY                   (source._sfResY                   ),
1656    _sfResUnit                (source._sfResUnit                ),
1657    _sfClearOnLoad            (source._sfClearOnLoad            )
1658{
1659}
1660
1661
1662/*-------------------------- destructors ----------------------------------*/
1663
1664ImageBase::~ImageBase(void)
1665{
1666}
1667/*-------------------------------------------------------------------------*/
1668/* Parent linking                                                          */
1669
1670bool ImageBase::linkParent(
1671    FieldContainer * const pParent,
1672    UInt16           const childFieldId,
1673    UInt16           const parentFieldId )
1674{
1675    if(parentFieldId == ParentsFieldId)
1676    {
1677        FieldContainer * pTypedParent =
1678            dynamic_cast< FieldContainer * >(pParent);
1679
1680        if(pTypedParent != NULL)
1681        {
1682            editMField(ParentsFieldMask, _mfParents);
1683
1684            _mfParents.push_back(pParent, childFieldId);
1685
1686            return true;
1687        }
1688
1689        return false;
1690    }
1691
1692    return Inherited::linkParent(pParent, childFieldId, parentFieldId);
1693}
1694
1695bool ImageBase::unlinkParent(
1696    FieldContainer * const pParent,
1697    UInt16           const parentFieldId)
1698{
1699    if(parentFieldId == ParentsFieldId)
1700    {
1701        FieldContainer * pTypedParent =
1702            dynamic_cast< FieldContainer * >(pParent);
1703
1704        if(pTypedParent != NULL)
1705        {
1706            Int32 iParentIdx = _mfParents.findIndex(pParent);
1707
1708            if(iParentIdx != -1)
1709            {
1710                editMField(ParentsFieldMask, _mfParents);
1711
1712                _mfParents.erase(iParentIdx);
1713
1714                return true;
1715            }
1716
1717            FWARNING(("ImageBase::unlinkParent: "
1718                      "Child <-> Parent link inconsistent.\n")

Large files files are truncated, but you can click here to view the full file