ImageAsset.cc 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _CONSOLE_H_
  23. #include "console/console.h"
  24. #endif
  25. #ifndef _CONSOLEINTERNAL_H_
  26. #include "console/consoleInternal.h"
  27. #endif
  28. #ifndef _CONSOLETYPES_H_
  29. #include "console/consoleTypes.h"
  30. #endif
  31. #ifndef _PLATFORM_H_
  32. #include "platform/platform.h"
  33. #endif
  34. #ifndef _GBITMAP_H_
  35. #include "graphics/gBitmap.h"
  36. #endif
  37. #ifndef _UTILITY_H_
  38. #include "2d/core/Utility.h"
  39. #endif
  40. #ifndef _SCENE_OBJECT_H_
  41. #include "2d/sceneobject/SceneObject.h"
  42. #endif
  43. #ifndef _IMAGE_ASSET_H_
  44. #include "2d/assets/ImageAsset.h"
  45. #endif
  46. // Script bindings.
  47. #include "ImageAsset_ScriptBinding.h"
  48. // Debug Profiling.
  49. #include "debug/profiler.h"
  50. //------------------------------------------------------------------------------
  51. ImageAsset::FrameArea BadFrameArea(0, 0, 0, 0, 0.0f, 0.0f);
  52. //------------------------------------------------------------------------------
  53. ConsoleType( imageAssetPtr, TypeImageAssetPtr, sizeof(AssetPtr<ImageAsset>), ASSET_ID_FIELD_PREFIX )
  54. //-----------------------------------------------------------------------------
  55. ConsoleGetType( TypeImageAssetPtr )
  56. {
  57. // Fetch asset Id.
  58. return (*((AssetPtr<ImageAsset>*)dptr)).getAssetId();
  59. }
  60. //-----------------------------------------------------------------------------
  61. ConsoleSetType( TypeImageAssetPtr )
  62. {
  63. // Was a single argument specified?
  64. if( argc == 1 )
  65. {
  66. // Yes, so fetch field value.
  67. const char* pFieldValue = argv[0];
  68. // Fetch asset pointer.
  69. AssetPtr<ImageAsset>* pAssetPtr = dynamic_cast<AssetPtr<ImageAsset>*>((AssetPtrBase*)(dptr));
  70. // Is the asset pointer the correct type?
  71. if ( pAssetPtr == NULL )
  72. {
  73. // No, so fail.
  74. Con::warnf( "(TypeImageAssetPtr) - Failed to set asset Id '%d'.", pFieldValue );
  75. return;
  76. }
  77. // Set asset.
  78. pAssetPtr->setAssetId( pFieldValue );
  79. return;
  80. }
  81. // Warn.
  82. Con::warnf( "(TypeImageAssetPtr) - Cannot set multiple args to a single asset." );
  83. }
  84. //------------------------------------------------------------------------------
  85. IMPLEMENT_CONOBJECT(ImageAsset);
  86. //------------------------------------------------------------------------------
  87. static StringTableEntry cellCustomNodeName = StringTable->insert( "Cells" );
  88. static StringTableEntry cellNodeName = StringTable->insert( "Cell" );
  89. static StringTableEntry cellOffsetName = StringTable->insert( "Offset" );
  90. static StringTableEntry cellWidthName = StringTable->insert( "Width" );
  91. static StringTableEntry cellHeightName = StringTable->insert( "Height" );
  92. //------------------------------------------------------------------------------
  93. static EnumTable::Enums textureFilterLookup[] =
  94. {
  95. { ImageAsset::FILTER_NEAREST, "NEAREST" },
  96. { ImageAsset::FILTER_BILINEAR, "BILINEAR" },
  97. };
  98. EnumTable textureFilterTable(sizeof(textureFilterLookup) / sizeof(EnumTable::Enums), &textureFilterLookup[0]);
  99. //------------------------------------------------------------------------------
  100. ImageAsset::TextureFilterMode ImageAsset::getFilterModeEnum(const char* label)
  101. {
  102. // Search for Mnemonic.
  103. for(U32 i = 0; i < (sizeof(textureFilterLookup) / sizeof(EnumTable::Enums)); i++)
  104. if( dStricmp(textureFilterLookup[i].label, label) == 0)
  105. return((ImageAsset::TextureFilterMode)textureFilterLookup[i].index);
  106. // Warn.
  107. Con::warnf("ImageAsset::getFilterModeEnum() - Invalid filter-mode '%s'", label );
  108. return ImageAsset::FILTER_INVALID;
  109. }
  110. //------------------------------------------------------------------------------
  111. const char* ImageAsset::getFilterModeDescription( ImageAsset::TextureFilterMode filterMode )
  112. {
  113. // Search for Mode.
  114. for(U32 i = 0; i < (sizeof(textureFilterLookup) / sizeof(EnumTable::Enums)); i++)
  115. if( textureFilterLookup[i].index == filterMode )
  116. return textureFilterLookup[i].label;
  117. // Warn.
  118. Con::warnf("ImageAsset::getFilterModeDescription() - Invalid filter-mode." );
  119. return StringTable->EmptyString;
  120. }
  121. //------------------------------------------------------------------------------
  122. ImageAsset::ImageAsset() : mImageFile(StringTable->EmptyString),
  123. mForce16Bit(false),
  124. mLocalFilterMode(FILTER_INVALID),
  125. mExplicitMode(false),
  126. mCellRowOrder(true),
  127. mCellOffsetX(0),
  128. mCellOffsetY(0),
  129. mCellStrideX(0),
  130. mCellStrideY(0),
  131. mCellCountX(0),
  132. mCellCountY(0),
  133. mCellWidth(0),
  134. mCellHeight(0),
  135. mImageTextureHandle(NULL)
  136. {
  137. // Set Vector Associations.
  138. VECTOR_SET_ASSOCIATION( mFrames );
  139. VECTOR_SET_ASSOCIATION( mExplicitFrames );
  140. }
  141. //------------------------------------------------------------------------------
  142. ImageAsset::~ImageAsset()
  143. {
  144. }
  145. //------------------------------------------------------------------------------
  146. void ImageAsset::initPersistFields()
  147. {
  148. // Call parent.
  149. Parent::initPersistFields();
  150. // Fields.
  151. addProtectedField("ImageFile", TypeAssetLooseFilePath, Offset(mImageFile, ImageAsset), &setImageFile, &getImageFile, &defaultProtectedWriteFn, "");
  152. addProtectedField("Force16bit", TypeBool, Offset(mForce16Bit, ImageAsset), &setForce16Bit, &defaultProtectedGetFn, &writeForce16Bit, "");
  153. addProtectedField("FilterMode", TypeEnum, Offset(mLocalFilterMode, ImageAsset), &setFilterMode, &defaultProtectedGetFn, &writeFilterMode, 1, &textureFilterTable);
  154. addProtectedField("ExplicitMode", TypeBool, Offset(mExplicitMode, ImageAsset), &setExplicitMode, &defaultProtectedGetFn, &defaultProtectedNotWriteFn, "");
  155. addProtectedField("CellRowOrder", TypeBool, Offset(mCellRowOrder, ImageAsset), &setCellRowOrder, &defaultProtectedGetFn, &writeCellRowOrder, "");
  156. addProtectedField("CellOffsetX", TypeS32, Offset(mCellOffsetX, ImageAsset), &setCellOffsetX, &defaultProtectedGetFn, &writeCellOffsetX, "");
  157. addProtectedField("CellOffsetY", TypeS32, Offset(mCellOffsetY, ImageAsset), &setCellOffsetY, &defaultProtectedGetFn, &writeCellOffsetY, "");
  158. addProtectedField("CellStrideX", TypeS32, Offset(mCellStrideX, ImageAsset), &setCellStrideX, &defaultProtectedGetFn, &writeCellStrideX, "");
  159. addProtectedField("CellStrideY", TypeS32, Offset(mCellStrideY, ImageAsset), &setCellStrideY, &defaultProtectedGetFn, &writeCellStrideY, "");
  160. addProtectedField("CellCountX", TypeS32, Offset(mCellCountX, ImageAsset), &setCellCountX, &defaultProtectedGetFn, &writeCellCountX, "");
  161. addProtectedField("CellCountY", TypeS32, Offset(mCellCountY, ImageAsset), &setCellCountY, &defaultProtectedGetFn, &writeCellCountY, "");
  162. addProtectedField("CellWidth", TypeS32, Offset(mCellWidth, ImageAsset), &setCellWidth, &defaultProtectedGetFn, &writeCellWidth, "");
  163. addProtectedField("CellHeight", TypeS32, Offset(mCellHeight, ImageAsset), &setCellHeight, &defaultProtectedGetFn, &writeCellHeight, "");
  164. }
  165. //------------------------------------------------------------------------------
  166. bool ImageAsset::onAdd()
  167. {
  168. // Call Parent.
  169. if (!Parent::onAdd())
  170. return false;
  171. return true;
  172. }
  173. //------------------------------------------------------------------------------
  174. void ImageAsset::onRemove()
  175. {
  176. // Call Parent.
  177. Parent::onRemove();
  178. }
  179. //------------------------------------------------------------------------------
  180. void ImageAsset::setImageFile( const char* pImageFile )
  181. {
  182. // Sanity!
  183. AssertFatal( pImageFile != NULL, "Cannot use a NULL image file." );
  184. // Fetch image file.
  185. pImageFile = StringTable->insert( pImageFile );
  186. // Ignore no change,
  187. if ( pImageFile == mImageFile )
  188. return;
  189. // Update.
  190. mImageFile = getOwned() ? expandAssetFilePath( pImageFile ) : StringTable->insert( pImageFile );
  191. // Refresh the asset.
  192. refreshAsset();
  193. }
  194. //------------------------------------------------------------------------------
  195. void ImageAsset::copyTo(SimObject* object)
  196. {
  197. // Call to parent.
  198. Parent::copyTo(object);
  199. // Cast to asset.
  200. ImageAsset* pAsset = static_cast<ImageAsset*>(object);
  201. // Sanity!
  202. AssertFatal(pAsset != NULL, "ImageAsset::copyTo() - Object is not the correct type.");
  203. // Copy state.
  204. pAsset->setImageFile( getImageFile() );
  205. pAsset->setForce16Bit( getForce16Bit() );
  206. pAsset->setFilterMode( getFilterMode() );
  207. pAsset->setExplicitMode( getExplicitMode() );
  208. pAsset->setCellRowOrder( getCellRowOrder() );
  209. pAsset->setCellOffsetX( getCellCountX() );
  210. pAsset->setCellOffsetY( getCellCountY() );
  211. pAsset->setCellStrideX( getCellStrideX() );
  212. pAsset->setCellStrideY( getCellStrideY() );
  213. pAsset->setCellCountX( getCellCountX() );
  214. pAsset->setCellCountY( getCellCountY() );
  215. pAsset->setCellWidth( getCellWidth() );
  216. pAsset->setCellHeight( getCellHeight() );
  217. // Finish if not in explicit mode.
  218. if ( !getExplicitMode() )
  219. return;
  220. // Fetch the explicit cell count.
  221. const S32 explicitCellCount = getExplicitCellCount();
  222. // Finish if no explicit cells exist.
  223. if ( explicitCellCount == 0 )
  224. return;
  225. // Copy explicit cells.
  226. pAsset->clearExplicitCells();
  227. for( S32 index = 0; index < explicitCellCount; ++index )
  228. {
  229. // Fetch the cell pixel area.
  230. const FrameArea::PixelArea& pixelArea = getImageFrameArea( index ).mPixelArea;
  231. // Add the explicit cell.
  232. pAsset->addExplicitCell( pixelArea.mPixelOffset.x, pixelArea.mPixelOffset.y, pixelArea.mPixelWidth, pixelArea.mPixelHeight );
  233. }
  234. }
  235. //------------------------------------------------------------------------------
  236. void ImageAsset::setForce16Bit( const bool force16Bit )
  237. {
  238. // Ignore no change,
  239. if ( force16Bit == mForce16Bit )
  240. return;
  241. // Update.
  242. mForce16Bit = force16Bit;
  243. // Refresh the asset.
  244. refreshAsset();
  245. }
  246. //------------------------------------------------------------------------------
  247. void ImageAsset::setFilterMode( const ImageAsset::TextureFilterMode filterMode )
  248. {
  249. // Ignore no change,
  250. if ( filterMode == mLocalFilterMode )
  251. return;
  252. // Invalid filter mode?
  253. if ( filterMode == FILTER_INVALID )
  254. {
  255. // Yes, so warn.
  256. Con::warnf( "Cannot set an invalid filter mode." );
  257. return;
  258. }
  259. // Update.
  260. mLocalFilterMode = filterMode;
  261. // Refresh the asset.
  262. refreshAsset();
  263. }
  264. //------------------------------------------------------------------------------
  265. void ImageAsset::setExplicitMode( const bool explicitMode )
  266. {
  267. // Ignore no change,
  268. if ( explicitMode == mExplicitMode )
  269. return;
  270. // Update.
  271. mExplicitMode = explicitMode;
  272. // Refresh the asset.
  273. refreshAsset();
  274. }
  275. //------------------------------------------------------------------------------
  276. void ImageAsset::setCellRowOrder( const bool cellRowOrder )
  277. {
  278. // Ignore no change.
  279. if ( cellRowOrder == mCellRowOrder )
  280. return;
  281. // Update.
  282. mCellRowOrder = cellRowOrder;
  283. // Refresh the asset.
  284. refreshAsset();
  285. }
  286. //------------------------------------------------------------------------------
  287. void ImageAsset::setCellOffsetX( const S32 cellOffsetX )
  288. {
  289. // Ignore no change.
  290. if ( cellOffsetX == mCellOffsetX )
  291. return;
  292. // Valid?
  293. if ( cellOffsetX < 0 )
  294. {
  295. // No, so warn.
  296. Con::warnf( "Invalid CELL offset X '%d'.", cellOffsetX );
  297. return;
  298. }
  299. // Update.
  300. mCellOffsetX = cellOffsetX;
  301. // Refresh the asset.
  302. refreshAsset();
  303. }
  304. //------------------------------------------------------------------------------
  305. void ImageAsset::setCellOffsetY( const S32 cellOffsetY )
  306. {
  307. // Ignore no change.
  308. if ( cellOffsetY == mCellOffsetY )
  309. return;
  310. // Valid?
  311. if ( cellOffsetY < 0 )
  312. {
  313. // No, so warn.
  314. Con::warnf( "Invalid CELL offset Y '%d'.", cellOffsetY );
  315. return;
  316. }
  317. // Update.
  318. mCellOffsetY = cellOffsetY;
  319. // Refresh the asset.
  320. refreshAsset();
  321. }
  322. //------------------------------------------------------------------------------
  323. void ImageAsset::setCellStrideX( const S32 cellStrideX )
  324. {
  325. // Ignore no change.
  326. if ( cellStrideX == mCellStrideX )
  327. return;
  328. // Valid?
  329. if ( cellStrideX < 0 )
  330. {
  331. // No, so warn.
  332. Con::warnf( "Invalid CELL stride X '%d'.", cellStrideX );
  333. return;
  334. }
  335. // Update.
  336. mCellStrideX = cellStrideX;
  337. // Refresh the asset.
  338. refreshAsset();
  339. }
  340. //------------------------------------------------------------------------------
  341. void ImageAsset::setCellStrideY( const S32 cellStrideY )
  342. {
  343. // Ignore no change.
  344. if ( cellStrideY == mCellStrideY )
  345. return;
  346. // Valid?
  347. if ( cellStrideY < 0 )
  348. {
  349. // No, so warn.
  350. Con::warnf( "Invalid CELL stride Y '%d'.", cellStrideY );
  351. return;
  352. }
  353. // Update.
  354. mCellStrideY = cellStrideY;
  355. // Refresh the asset.
  356. refreshAsset();
  357. }
  358. //------------------------------------------------------------------------------
  359. void ImageAsset::setCellCountX( const S32 cellCountX )
  360. {
  361. // Ignore no change.
  362. if ( cellCountX == mCellCountX )
  363. return;
  364. // Valid?
  365. if ( cellCountX < 0 )
  366. {
  367. // No, so warn.
  368. Con::warnf( "Invalid CELL count X '%d'.", cellCountX );
  369. return;
  370. }
  371. // Update.
  372. mCellCountX = cellCountX;
  373. // Refresh the asset.
  374. refreshAsset();
  375. }
  376. //------------------------------------------------------------------------------
  377. void ImageAsset::setCellCountY( const S32 cellCountY )
  378. {
  379. // Ignore no change.
  380. if ( cellCountY == mCellCountY )
  381. return;
  382. // Valid?
  383. if ( cellCountY < 0 )
  384. {
  385. // No, so warn.
  386. Con::warnf( "Invalid CELL count Y '%d'.", cellCountY );
  387. return;
  388. }
  389. // Update.
  390. mCellCountY = cellCountY;
  391. // Refresh the asset.
  392. refreshAsset();
  393. }
  394. //------------------------------------------------------------------------------
  395. void ImageAsset::setCellWidth( const S32 cellWidth )
  396. {
  397. // Ignore no change.
  398. if ( cellWidth == mCellWidth )
  399. return;
  400. // Valid?
  401. if ( cellWidth < 0 )
  402. {
  403. // No, so warn.
  404. Con::warnf( "Invalid CELL width '%d'.", cellWidth );
  405. return;
  406. }
  407. // Update.
  408. mCellWidth = cellWidth;
  409. // Refresh the asset.
  410. refreshAsset();
  411. }
  412. //------------------------------------------------------------------------------
  413. void ImageAsset::setCellHeight( const S32 cellheight )
  414. {
  415. // Ignore no change.
  416. if ( cellheight == mCellHeight )
  417. return;
  418. // Valid?
  419. if ( cellheight < 0 )
  420. {
  421. // No, so warn.
  422. Con::warnf( "Invalid CELL height '%d'.", cellheight );
  423. return;
  424. }
  425. // Update.
  426. mCellHeight = cellheight;
  427. // Refresh the asset.
  428. refreshAsset();
  429. }
  430. //------------------------------------------------------------------------------
  431. bool ImageAsset::clearExplicitCells( void )
  432. {
  433. // Are we in explicit mode?
  434. if ( !getExplicitMode() )
  435. {
  436. // No, so warn.
  437. Con::warnf( "ImageAsset() - Cannot perform explicit cell operation when not in explicit mode." );
  438. return false;
  439. }
  440. // Clear explicit frames.
  441. mExplicitFrames.clear();
  442. // Refresh the asset.
  443. refreshAsset();
  444. return true;
  445. }
  446. //------------------------------------------------------------------------------
  447. bool ImageAsset::addExplicitCell( const S32 cellOffsetX, const S32 cellOffsetY, const S32 cellWidth, const S32 cellHeight )
  448. {
  449. // Are we in explicit mode?
  450. if ( !getExplicitMode() )
  451. {
  452. // No, so warn.
  453. Con::warnf( "ImageAsset::addCell() - Cannot perform explicit cell operation when not in explicit mode." );
  454. return false;
  455. }
  456. // Fetch the original image dimensions.
  457. const S32 imageWidth = getImageWidth();
  458. const S32 imageHeight = getImageHeight();
  459. // The Cell Offset X needs to be within the image.
  460. if ( cellOffsetX < 0 || cellOffsetX >= imageWidth )
  461. {
  462. // Warn.
  463. Con::warnf("ImageAsset::addCell() - Invalid Cell OffsetX of %d.", cellOffsetX );
  464. return false;
  465. }
  466. // The Cell Offset Y needs to be within the image.
  467. if ( cellOffsetY < 0 || cellOffsetY >= imageWidth )
  468. {
  469. // Warn.
  470. Con::warnf("ImageAsset::addCell() - Invalid Cell OffsetY of %d.", cellOffsetY );
  471. return false;
  472. }
  473. // The Cell Width needs to be within the image.
  474. if ( cellWidth <= 0 || (cellOffsetX+cellWidth) > imageWidth )
  475. {
  476. // Warn.
  477. Con::warnf("ImageAsset::addCell() - Invalid Cell Width of %d.", cellWidth );
  478. return false;
  479. }
  480. // The Cell Height needs to be within the image.
  481. if ( cellHeight <= 0 || (cellOffsetY+cellHeight) > imageHeight )
  482. {
  483. // Warn.
  484. Con::warnf("ImageAsset::addCell() - Invalid Cell Width of %d.", cellHeight );
  485. return false;
  486. }
  487. // Store frame.
  488. FrameArea::PixelArea pixelArea( cellOffsetX, cellOffsetY, cellWidth, cellHeight );
  489. mExplicitFrames.push_back( pixelArea );
  490. // Refresh the asset.
  491. refreshAsset();
  492. return true;
  493. }
  494. //------------------------------------------------------------------------------
  495. bool ImageAsset::insertExplicitCell( const S32 cellIndex, const S32 cellOffsetX, const S32 cellOffsetY, const S32 cellWidth, const S32 cellHeight )
  496. {
  497. // Are we in explicit mode?
  498. if ( !getExplicitMode() )
  499. {
  500. // No, so warn.
  501. Con::warnf( "ImageAsset::insertCell() - Cannot perform explicit cell operation when not in explicit mode." );
  502. return false;
  503. }
  504. // Fetch the original image dimensions.
  505. const S32 imageWidth = getImageWidth();
  506. const S32 imageHeight = getImageHeight();
  507. // Fetch the explicit frame count.
  508. const S32 explicitFramelCount = mExplicitFrames.size();
  509. // The cell index needs to be in range.
  510. if ( cellIndex < 0 )
  511. {
  512. // Warn.
  513. Con::warnf("ImageAsset::insertCell() - Invalid Cell Index of %d.", cellIndex );
  514. return false;
  515. }
  516. // The Cell Offset X needs to be within the image.
  517. if ( cellOffsetX < 0 || cellOffsetX >= imageWidth )
  518. {
  519. // Warn.
  520. Con::warnf("ImageAsset::insertCell() - Invalid Cell OffsetX of %d.", cellOffsetX );
  521. return false;
  522. }
  523. // The Cell Offset Y needs to be within the image.
  524. if ( cellOffsetY < 0 || cellOffsetY >= imageWidth )
  525. {
  526. // Warn.
  527. Con::warnf("ImageAsset::insertCell() - Invalid Cell OffsetY of %d.", cellOffsetY );
  528. return false;
  529. }
  530. // The Cell Width needs to be within the image.
  531. if ( cellWidth <= 0 || (cellOffsetX+cellWidth) > imageWidth )
  532. {
  533. // Warn.
  534. Con::warnf("ImageAsset::insertCell() - Invalid Cell Width of %d.", cellWidth );
  535. return false;
  536. }
  537. // The Cell Height needs to be within the image.
  538. if ( cellHeight <= 0 || (cellOffsetY+cellHeight) > imageHeight )
  539. {
  540. // Warn.
  541. Con::warnf("ImageAsset::insertCell() - Invalid Cell Width of %d.", cellHeight );
  542. return false;
  543. }
  544. // Configure frame.
  545. FrameArea::PixelArea pixelArea( cellOffsetX, cellOffsetY, cellWidth, cellHeight );
  546. // Insert frame appropriately.
  547. if ( cellIndex >= explicitFramelCount )
  548. {
  549. mExplicitFrames.push_back( pixelArea );
  550. }
  551. else
  552. {
  553. mExplicitFrames.insert( cellIndex );
  554. mExplicitFrames[cellIndex] = pixelArea;
  555. }
  556. // Refresh the asset.
  557. refreshAsset();
  558. return true;
  559. }
  560. //------------------------------------------------------------------------------
  561. bool ImageAsset::setExplicitCell( const S32 cellIndex, const S32 cellOffsetX, const S32 cellOffsetY, const S32 cellWidth, const S32 cellHeight )
  562. {
  563. // Are we in explicit mode?
  564. if ( !getExplicitMode() )
  565. {
  566. // No, so warn.
  567. Con::warnf( "ImageAsset::setCell() - Cannot perform explicit cell operation when not in explicit mode." );
  568. return false;
  569. }
  570. // Fetch the original image dimensions.
  571. const S32 imageWidth = getImageWidth();
  572. const S32 imageHeight = getImageHeight();
  573. // Fetch the explicit frame count.
  574. const S32 explicitFrameCount = mExplicitFrames.size();
  575. // The cell index needs to be in range.
  576. if ( cellIndex < 0 || cellIndex >= explicitFrameCount )
  577. {
  578. // Warn.
  579. Con::warnf("ImageAsset::setCell() - Invalid Cell Index of %d.", cellIndex );
  580. return false;
  581. }
  582. // The Cell Offset X needs to be within the image.
  583. if ( cellOffsetX < 0 || cellOffsetX >= imageWidth )
  584. {
  585. // Warn.
  586. Con::warnf("ImageAsset::setCell() - Invalid Cell OffsetX of %d.", cellOffsetX );
  587. return false;
  588. }
  589. // The Cell Offset Y needs to be within the image.
  590. if ( cellOffsetY < 0 || cellOffsetY >= imageWidth )
  591. {
  592. // Warn.
  593. Con::warnf("ImageAsset::setCell() - Invalid Cell OffsetY of %d.", cellOffsetY );
  594. return false;
  595. }
  596. // The Cell Width needs to be within the image.
  597. if ( cellWidth <= 0 || (cellOffsetX+cellWidth) > imageWidth )
  598. {
  599. // Warn.
  600. Con::warnf("ImageAsset::setCell() - Invalid Cell Width of %d.", cellWidth );
  601. return false;
  602. }
  603. // The Cell Height needs to be within the image.
  604. if ( cellHeight <= 0 || (cellOffsetY+cellHeight) > imageHeight )
  605. {
  606. // Warn.
  607. Con::warnf("ImageAsset::setCell() - Invalid Cell Width of %d.", cellHeight );
  608. return false;
  609. }
  610. // Configure frame.
  611. FrameArea::PixelArea pixelArea( cellOffsetX, cellOffsetY, cellWidth, cellHeight );
  612. // Set cell.
  613. mExplicitFrames[cellIndex] = pixelArea;
  614. // Refresh the asset.
  615. refreshAsset();
  616. return true;
  617. }
  618. //------------------------------------------------------------------------------
  619. bool ImageAsset::removeExplicitCell( const S32 cellIndex )
  620. {
  621. // Are we in explicit mode?
  622. if ( !getExplicitMode() )
  623. {
  624. // No, so warn.
  625. Con::warnf( "ImageAsset::removeCell() - Cannot perform explicit cell operation when not in explicit mode." );
  626. return false;
  627. }
  628. // Fetch the explicit frame count.
  629. const S32 explicitFrameCount = mExplicitFrames.size();
  630. // The cell index needs to be in range.
  631. if ( cellIndex < 0 || cellIndex >= explicitFrameCount )
  632. {
  633. // Warn.
  634. Con::warnf("ImageAsset::removeCell() - Invalid Cell Index of %d.", cellIndex );
  635. return false;
  636. }
  637. // Remove cell.
  638. mExplicitFrames.erase(cellIndex);
  639. // Refresh the asset.
  640. refreshAsset();
  641. return true;
  642. }
  643. //------------------------------------------------------------------------------
  644. void ImageAsset::setTextureFilter( const TextureFilterMode filterMode )
  645. {
  646. // Finish if no texture.
  647. if ( mImageTextureHandle.IsNull() )
  648. return;
  649. // Select Hardware Filter Mode.
  650. GLint glFilterMode;
  651. switch( filterMode )
  652. {
  653. // Nearest ("none").
  654. case FILTER_NEAREST:
  655. {
  656. glFilterMode = GL_NEAREST;
  657. } break;
  658. // Bilinear ("smooth").
  659. case FILTER_BILINEAR:
  660. {
  661. glFilterMode = GL_LINEAR;
  662. } break;
  663. // Huh?
  664. default:
  665. // Oh well...
  666. glFilterMode = GL_LINEAR;
  667. };
  668. // Set the texture objects filter mode.
  669. mImageTextureHandle.setFilter( glFilterMode );
  670. }
  671. //------------------------------------------------------------------------------
  672. void ImageAsset::initializeAsset( void )
  673. {
  674. // Call parent.
  675. Parent::initializeAsset();
  676. // Ensure the image-file is expanded.
  677. mImageFile = expandAssetFilePath( mImageFile );
  678. // Calculate the image.
  679. calculateImage();
  680. }
  681. //------------------------------------------------------------------------------
  682. void ImageAsset::onAssetRefresh( void )
  683. {
  684. // Ignore if not yet added to the sim.
  685. if ( !isProperlyAdded() )
  686. return;
  687. // Call parent.
  688. Parent::onAssetRefresh();
  689. // Compile image.
  690. calculateImage();
  691. }
  692. //-----------------------------------------------------------------------------
  693. void ImageAsset::onTamlPreWrite( void )
  694. {
  695. // Call parent.
  696. Parent::onTamlPreWrite();
  697. // Ensure the image-file is collapsed.
  698. mImageFile = collapseAssetFilePath( mImageFile );
  699. }
  700. //-----------------------------------------------------------------------------
  701. void ImageAsset::onTamlPostWrite( void )
  702. {
  703. // Call parent.
  704. Parent::onTamlPostWrite();
  705. // Ensure the image-file is expanded.
  706. mImageFile = expandAssetFilePath( mImageFile );
  707. }
  708. //------------------------------------------------------------------------------
  709. void ImageAsset::onTamlCustomWrite( TamlCustomNodes& customNodes )
  710. {
  711. // Debug Profiling.
  712. PROFILE_SCOPE(ImageAsset_OnTamlCustomWrite);
  713. // Call parent.
  714. Parent::onTamlCustomWrite( customNodes );
  715. // Finish if not in explicit mode.
  716. if ( !mExplicitMode )
  717. return;
  718. // Add cell custom node.
  719. TamlCustomNode* pCustomCellNodes = customNodes.addNode( cellCustomNodeName );
  720. // Iterate explicit frames.
  721. for( typeExplicitFrameAreaVector::iterator frameItr = mExplicitFrames.begin(); frameItr != mExplicitFrames.end(); ++frameItr )
  722. {
  723. // Fetch pixel area.
  724. const FrameArea::PixelArea& pixelArea = *frameItr;
  725. // Add cell alias.
  726. TamlCustomNode* pCellNode = pCustomCellNodes->addNode( cellNodeName );
  727. // Add cell properties.
  728. pCellNode->addField( cellOffsetName, pixelArea.mPixelOffset );
  729. pCellNode->addField( cellWidthName, pixelArea.mPixelWidth );
  730. pCellNode->addField( cellHeightName, pixelArea.mPixelHeight );
  731. }
  732. }
  733. //-----------------------------------------------------------------------------
  734. void ImageAsset::onTamlCustomRead( const TamlCustomNodes& customNodes )
  735. {
  736. // Debug Profiling.
  737. PROFILE_SCOPE(ImageAsset_OnTamlCustomRead);
  738. // Call parent.
  739. Parent::onTamlCustomRead( customNodes );
  740. // Find cell custom node.
  741. const TamlCustomNode* pCustomCellNodes = customNodes.findNode( cellCustomNodeName );
  742. // Finish if we don't have explicit cells.
  743. if ( pCustomCellNodes == NULL )
  744. return;
  745. // Set explicit mode.
  746. mExplicitMode = true;
  747. // Fetch children cell nodes.
  748. const TamlCustomNodeVector& cellNodes = pCustomCellNodes->getChildren();
  749. // Iterate cells.
  750. for( TamlCustomNodeVector::const_iterator cellNodeItr = cellNodes.begin(); cellNodeItr != cellNodes.end(); ++cellNodeItr )
  751. {
  752. // Fetch cell node.
  753. TamlCustomNode* pCellNode = *cellNodeItr;
  754. // Fetch node name.
  755. StringTableEntry nodeName = pCellNode->getNodeName();
  756. // Is this a valid alias?
  757. if ( nodeName != cellNodeName )
  758. {
  759. // No, so warn.
  760. Con::warnf( "ImageAsset::onTamlCustomRead() - Encountered an unknown custom name of '%s'. Only '%s' is valid.", nodeName, cellNodeName );
  761. continue;
  762. }
  763. Point2I cellOffset(-1, -1);
  764. S32 cellWidth = 0;
  765. S32 cellHeight = 0;
  766. // Fetch fields.
  767. const TamlCustomFieldVector& fields = pCellNode->getFields();
  768. // Iterate property fields.
  769. for ( TamlCustomFieldVector::const_iterator fieldItr = fields.begin(); fieldItr != fields.end(); ++fieldItr )
  770. {
  771. // Fetch field.
  772. const TamlCustomField* pField = *fieldItr;
  773. // Fetch field name.
  774. StringTableEntry fieldName = pField->getFieldName();
  775. // Check common fields.
  776. if ( fieldName == cellOffsetName )
  777. {
  778. pField->getFieldValue( cellOffset );
  779. }
  780. else if ( fieldName == cellWidthName )
  781. {
  782. pField->getFieldValue( cellWidth );
  783. }
  784. else if ( fieldName == cellHeightName )
  785. {
  786. pField->getFieldValue( cellHeight );
  787. }
  788. else
  789. {
  790. // Unknown name so warn.
  791. Con::warnf( "ImageAsset::onTamlCustomRead() - Encountered an unknown custom field name of '%s'.", fieldName );
  792. continue;
  793. }
  794. }
  795. // Is cell offset valid?
  796. if ( cellOffset.x < 0 || cellOffset.y < 0 )
  797. {
  798. // No, so warn.
  799. Con::warnf( "ImageAsset::onTamlCustomRead() - Cell offset of '(%d,%d)' is invalid or was not set.", cellOffset.x, cellOffset.y );
  800. continue;
  801. }
  802. // Is cell width valid?
  803. if ( cellWidth <= 0 )
  804. {
  805. // No, so warn.
  806. Con::warnf( "ImageAsset::onTamlCustomRead() - Cell width of '%d' is invalid or was not set.", cellWidth );
  807. continue;
  808. }
  809. // Is cell height valid?
  810. if ( cellHeight <= 0 )
  811. {
  812. // No, so warn.
  813. Con::warnf( "ImageAsset::onTamlCustomRead() - Cell height of '%d' is invalid or was not set.", cellHeight );
  814. continue;
  815. }
  816. // Add explicit frame.
  817. FrameArea::PixelArea pixelArea( cellOffset.x, cellOffset.y, cellWidth, cellHeight );
  818. mExplicitFrames.push_back( pixelArea );
  819. }
  820. }
  821. //------------------------------------------------------------------------------
  822. void ImageAsset::calculateImage( void )
  823. {
  824. // Debug Profiling.
  825. PROFILE_SCOPE(ImageAsset_CalculateImage);
  826. // Clear frames.
  827. mFrames.clear();
  828. // If we have an existing texture and we're setting to the same bitmap then force the texture manager
  829. // to refresh the texture itself.
  830. if ( !mImageTextureHandle.IsNull() && dStricmp(mImageTextureHandle.getTextureKey(), mImageFile) == 0 )
  831. TextureManager::refresh( mImageFile );
  832. // Get image texture.
  833. mImageTextureHandle.set( mImageFile, TextureHandle::BitmapTexture, true, getForce16Bit() );
  834. // Is the texture valid?
  835. if ( mImageTextureHandle.IsNull() )
  836. {
  837. // No, so warn.
  838. Con::warnf( "Image '%s' could not load texture '%s'.", getAssetId(), mImageFile );
  839. return;
  840. }
  841. // Is the local filter mode specified?
  842. if ( mLocalFilterMode != FILTER_INVALID )
  843. {
  844. // Yes, so set filter mode.
  845. setTextureFilter( mLocalFilterMode );
  846. }
  847. else
  848. {
  849. TextureFilterMode filterMode = FILTER_NEAREST;
  850. // No, so fetch the global filter.
  851. const char* pGlobalFilter = Con::getVariable( "$pref::T2D::imageAssetGlobalFilterMode" );
  852. // Fetch the global filter mode.
  853. if ( pGlobalFilter != NULL && dStrlen(pGlobalFilter) > 0 )
  854. filterMode = getFilterModeEnum( pGlobalFilter );
  855. // If global filter mode is invalid then use local filter mode.
  856. if ( filterMode == FILTER_INVALID )
  857. filterMode = FILTER_NEAREST;
  858. // Set filter mode.
  859. setTextureFilter( filterMode );
  860. }
  861. // Calculate according to mode.
  862. if ( mExplicitMode )
  863. {
  864. calculateExplicitMode();
  865. }
  866. else
  867. {
  868. calculateImplicitMode();
  869. }
  870. }
  871. //------------------------------------------------------------------------------
  872. void ImageAsset::calculateImplicitMode( void )
  873. {
  874. // Debug Profiling.
  875. PROFILE_SCOPE(ImageAsset_CalculateImplicitMode);
  876. // Sanity!
  877. AssertFatal( !mExplicitMode, "Cannot calculate implicit cells when in explicit mode." );
  878. // Fetch the texture object.
  879. TextureObject* pTextureObject = ((TextureObject*)mImageTextureHandle);
  880. // Calculate texel scales.
  881. const F32 texelWidthScale = 1.0f / (F32)pTextureObject->getTextureWidth();
  882. const F32 texelHeightScale = 1.0f / (F32)pTextureObject->getTextureHeight();
  883. // Fetch the original image dimensions.
  884. const S32 imageWidth = getImageWidth();
  885. const S32 imageHeight = getImageHeight();
  886. // Set full-frame as default.
  887. FrameArea frameArea( 0, 0, imageWidth, imageHeight, texelWidthScale, texelHeightScale );
  888. mFrames.push_back( frameArea );
  889. // Finish if no cell counts are specified. This is how we default to full-frame mode.
  890. if ( mCellCountX < 1 || mCellCountY < 1 )
  891. return;
  892. // The cell width needs to be at maximum the image width!
  893. if ( mCellWidth < 1 || mCellWidth > imageWidth )
  894. {
  895. // Warn.
  896. Con::warnf("ImageAsset::calculateImage() - Invalid Cell Width of %d.", mCellWidth );
  897. return;
  898. }
  899. // The cell height needs to be at maximum the image height!
  900. if ( mCellHeight < 1 || mCellHeight > imageWidth )
  901. {
  902. // Warn.
  903. Con::warnf("ImageAsset::calculateImage() - Invalid Cell Height of %d.", mCellHeight );
  904. return;
  905. }
  906. // The Cell Offset X needs to be within the image.
  907. if ( mCellOffsetX < 0 || mCellOffsetX >= imageWidth )
  908. {
  909. // Warn.
  910. Con::warnf("ImageAsset::calculateImage() - Invalid Cell OffsetX of %d.", mCellOffsetX );
  911. return;
  912. }
  913. // The Cell Offset Y needs to be within the image.
  914. if ( mCellOffsetY < 0 || mCellOffsetY >= imageWidth )
  915. {
  916. // Warn.
  917. Con::warnf("ImageAsset::calculateImage() - Invalid Cell OffsetY of %d.", mCellOffsetY );
  918. return;
  919. }
  920. // Are we using Cell-StrideX?
  921. S32 cellStepX;
  922. if ( mCellStrideX != 0 )
  923. {
  924. // Yes, so set stepX to be StrideX.
  925. cellStepX = mCellStrideX;
  926. }
  927. else
  928. {
  929. // No, so set stepY to be Cell Width.
  930. cellStepX = mCellWidth;
  931. }
  932. // Are we using Cell-StrideY?
  933. S32 cellStepY;
  934. if ( mCellStrideY != 0 )
  935. {
  936. // Yes, so set stepY to be StrideY.
  937. cellStepY = mCellStrideY;
  938. }
  939. else
  940. {
  941. // No, so set stepY to be Cell Height.
  942. cellStepY = mCellHeight;
  943. }
  944. // Calculate Final Cell Position X.
  945. S32 cellFinalPositionX = mCellOffsetX + ((mCellCountX-((cellStepX<0)?1:0))*cellStepX);
  946. // Off Left?
  947. if ( cellFinalPositionX < 0 )
  948. {
  949. // Warn.
  950. Con::warnf("ImageAsset::calculateImage() - Invalid Cell OffsetX(%d)/Width(%d)/CountX(%d); off image left-hand-side.", mCellOffsetX, mCellWidth, mCellCountX );
  951. return;
  952. }
  953. // Off Right?
  954. else if ( cellFinalPositionX > imageWidth )
  955. {
  956. // Warn.
  957. Con::warnf("ImageAsset::calculateImage() - Invalid Cell OffsetX(%d)/Width(%d)/CountX(%d); off image right-hand-side.", mCellOffsetX, mCellWidth, mCellCountX );
  958. return;
  959. }
  960. // Calculate Final Cell Position Y.
  961. S32 cellFinalPositionY = mCellOffsetY + ((mCellCountY-((cellStepY<0)?1:0))*cellStepY);
  962. // Off Top?
  963. if ( cellFinalPositionY < 0 )
  964. {
  965. // Warn.
  966. Con::warnf("ImageAsset::calculateImage() - Invalid Cell OffsetY(%d)/Height(%d)/CountY(%d); off image top-side.", mCellOffsetY, mCellHeight, mCellCountY );
  967. return;
  968. }
  969. // Off Bottom?
  970. else if ( cellFinalPositionY > imageHeight )
  971. {
  972. // Warn.
  973. Con::warnf("ImageAsset::calculateImage() - Invalid Cell OffsetY(%d)/Height(%d)/CountY(%d); off image bottom-side.", mCellOffsetY, mCellHeight, mCellCountY );
  974. return;
  975. }
  976. // Clear default frame.
  977. mFrames.clear();
  978. // Cell Row Order?
  979. if ( mCellRowOrder )
  980. {
  981. // Yes, so RowRow Order.
  982. for ( S32 y = 0, cellPositionY = mCellOffsetY; y < mCellCountY; y++, cellPositionY+=cellStepY )
  983. {
  984. for ( S32 x = 0, cellPositionX = mCellOffsetX; x < mCellCountX; x++, cellPositionX+=cellStepX )
  985. {
  986. // Set frame area.
  987. frameArea.setArea( cellPositionX, cellPositionY, mCellWidth, mCellHeight, texelWidthScale, texelHeightScale );
  988. // Store fame.
  989. mFrames.push_back( frameArea );
  990. }
  991. }
  992. return;
  993. }
  994. // No, so Column Order.
  995. for ( S32 x = 0, cellPositionX = mCellOffsetX; x < mCellCountX; x++, cellPositionX+=cellStepX )
  996. {
  997. for ( S32 y = 0, cellPositionY = mCellOffsetY; y < mCellCountY; y++, cellPositionY+=cellStepY )
  998. {
  999. // Set frame area.
  1000. frameArea.setArea( cellPositionX, cellPositionY, mCellWidth, mCellHeight, texelWidthScale, texelHeightScale );
  1001. // Store fame.
  1002. mFrames.push_back( frameArea );
  1003. }
  1004. }
  1005. }
  1006. //------------------------------------------------------------------------------
  1007. void ImageAsset::calculateExplicitMode( void )
  1008. {
  1009. // Debug Profiling.
  1010. PROFILE_SCOPE(ImageAsset_CalculateExplicitMode);
  1011. // Sanity!
  1012. AssertFatal( mExplicitMode, "Cannot calculate explicit cells when not in explicit mode." );
  1013. // Fetch the texture object.
  1014. TextureObject* pTextureObject = ((TextureObject*)mImageTextureHandle);
  1015. // Calculate texel scales.
  1016. const F32 texelWidthScale = 1.0f / (F32)pTextureObject->getTextureWidth();
  1017. const F32 texelHeightScale = 1.0f / (F32)pTextureObject->getTextureHeight();
  1018. // Fetch the original image dimensions.
  1019. const S32 imageWidth = getImageWidth();
  1020. const S32 imageHeight = getImageHeight();
  1021. // Clear default frame.
  1022. mFrames.clear();
  1023. // Are any explicit frames set.
  1024. if ( mExplicitFrames.size() == 0 )
  1025. {
  1026. // No, so set full-frame as default.
  1027. FrameArea frameArea( 0, 0, imageWidth, imageHeight, texelWidthScale, texelHeightScale );
  1028. mFrames.push_back( frameArea );
  1029. return;
  1030. }
  1031. // Iterate explicit frames.
  1032. for( typeExplicitFrameAreaVector::iterator frameItr = mExplicitFrames.begin(); frameItr != mExplicitFrames.end(); ++frameItr )
  1033. {
  1034. // Fetch pixel area.
  1035. const FrameArea::PixelArea& pixelArea = *frameItr;
  1036. // Set frame area.
  1037. FrameArea frameArea( pixelArea.mPixelOffset.x, pixelArea.mPixelOffset.y, pixelArea.mPixelWidth, pixelArea.mPixelHeight, texelWidthScale, texelHeightScale );
  1038. // Store frame.
  1039. mFrames.push_back( frameArea );
  1040. }
  1041. }
  1042. //------------------------------------------------------------------------------
  1043. bool ImageAsset::setFilterMode( void* obj, const char* data )
  1044. {
  1045. static_cast<ImageAsset*>(obj)->setFilterMode(getFilterModeEnum(data));
  1046. return false;
  1047. }