PageRenderTime 64ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.0, BSD-3-Clause

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

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