assetImporter.h
Engine/source/T3D/assets/assetImporter.h
Classes:
class
AssetImportConfig is a SimObject derived object intended to act as a container for all the necessary configuration data when running the Asset Importer.
class
AssetImporter is a SimObject derived object that processed and imports files and turns them into assets if they are of valid types.
class
AssetImportConfig is a SimObject derived object that represents and holds information for an importing asset.
Detailed Description
1 2#pragma once 3 4#include "assets/assetPtr.h" 5#include "assets/assetManager.h" 6#include "module/moduleManager.h" 7#include "util/settings.h" 8#include "gui/controls/guiTreeViewCtrl.h" 9 10/// <summary> 11/// AssetImportConfig is a SimObject derived object intended to act as a container for all the necessary configuration data when running the Asset Importer. 12/// It dictates if and how any given asset type will be processed when running an import action. This is because the Asset Importer utilizes a lot of informed logic 13/// to try and automate as much of the import process as possible. In theory, you would run the import on a given file, and based on your config the importer will do 14/// everything from importing the designated file, as well as finding and importing any associated files such as images or materials, and prepping the objects at time 15/// of import to avoid as much manual post-processing as possible. 16/// </summary> 17class AssetImportConfig : public SimObject 18{ 19 typedef SimObject Parent; 20 21 //General Settings 22public: 23 /// <summary> 24 /// Duplicate Asset Auto-Resolution Action. Options are None, AutoPrune, AutoRename 25 /// </summary> 26 String DuplicatAutoResolution; 27 28 /// <summary> 29 /// Indicates if warnings should be treated as errors. 30 /// </summary> 31 bool WarningsAsErrors; 32 33 /// <summary> 34 /// Indicates if importing should be prevented from completing if any errors are detected at all 35 /// </summary> 36 bool PreventImportWithErrors; 37 38 /// <summary> 39 /// Should the importer automatically prompt to find missing files if they are not detected automatically by the importer 40 /// </summary> 41 bool AutomaticallyPromptMissingFiles; 42 // 43 44 // 45 //Mesh Settings 46 /// <summary> 47 /// Indicates if this config supports importing meshes 48 /// </summary> 49 bool ImportMesh; 50 51 /// <summary> 52 /// When importing a shape, this indicates if it should automatically add a standard suffix onto the name 53 /// </summary> 54 bool AlwaysAddShapeSuffix; 55 56 /// <summary> 57 /// If AlwaysAddShapeSuffix is on, this is the suffix to be added 58 /// </summary> 59 String AddedShapeSuffix; 60 61 /// <summary> 62 /// Indicates if this config should override the per-format sis files with the config's specific settings 63 /// </summary> 64 bool UseManualShapeConfigRules; 65 66 /// <summary> 67 /// Indicates if the up axis in the model file should be overridden 68 /// </summary> 69 bool DoUpAxisOverride; 70 71 /// <summary> 72 /// If overriding, what axis should be used as up. Options are X_AXIS, Y_AXIS, Z_AXIS 73 /// </summary> 74 String UpAxisOverride; 75 76 /// <summary> 77 /// Indicates if the scale in the model file should be overridden 78 /// </summary> 79 bool DoScaleOverride; 80 81 /// <summary> 82 /// If overriding, what scale should be used 83 /// </summary> 84 F32 ScaleOverride; 85 86 /// <summary> 87 /// Indicates if scale of nodes should be ignored 88 /// </summary> 89 bool IgnoreNodeScale; 90 91 /// <summary> 92 /// Indicates if the center of the model file should be automatically recentered 93 /// </summary> 94 bool AdjustCenter; 95 96 /// <summary> 97 /// Indicates if the floor height of the model file should be automatically zero'd 98 /// </summary> 99 bool AdjustFloor; 100 101 /// <summary> 102 /// Indicates if submeshes should be collapsed down into a single main mesh 103 /// </summary> 104 bool CollapseSubmeshes; 105 106 /// <summary> 107 /// Indicates what LOD mode the model file should utilize to process out LODs. Options are TrailingNumber, DetectDTS, SingleSize 108 /// </summary> 109 String LODType; 110 111 //ImportAssetConfigSettingsList.addNewConfigSetting("TrailingNumber", "Trailing Number", "float", "", "2", "", "Mesh"); 112 /// <summary> 113 /// A list of what nodes should be guaranteed to be imported if found in the model file. Separated by either , or ; 114 /// </summary> 115 String AlwaysImportedNodes; 116 117 /// <summary> 118 /// A list of what nodes should be guaranteed to not be imported if found in the model file. Separated by either , or ; 119 /// </summary> 120 String AlwaysIgnoreNodes; 121 122 /// <summary> 123 /// A list of what mesh objects should be guaranteed to be imported if found in the model file. Separated by either , or ; 124 /// </summary> 125 String AlwaysImportMeshes; 126 127 /// <summary> 128 /// A list of what mesh objects should be guaranteed to not be imported if found in the model file. Separated by either , or ; 129 /// </summary> 130 String AlwaysIgnoreMeshes; 131 132 //Assimp/Collada params 133 /// <summary> 134 /// Flag to indicate the shape loader should convert to a left-handed coordinate system 135 /// </summary> 136 bool convertLeftHanded; 137 138 /// <summary> 139 /// Should the shape loader calculate tangent space values 140 /// </summary> 141 bool calcTangentSpace; 142 143 /// <summary> 144 /// Should the shape loader automatically prune redundant/duplicate materials 145 /// </summary> 146 bool removeRedundantMats; 147 148 /// <summary> 149 /// Should the shape loader auto-generate UV Coordinates for the mesh. 150 /// </summary> 151 bool genUVCoords; 152 153 /// <summary> 154 /// Should the UV coordinates be transformed. 155 /// </summary> 156 bool TransformUVs; 157 158 /// <summary> 159 /// Should the UV coordinates be flipped 160 /// </summary> 161 bool flipUVCoords; 162 163 /// <summary> 164 /// Should the shape loader automatically look for instanced submeshes in the model file 165 /// </summary> 166 bool findInstances; 167 168 /// <summary> 169 /// Should the shape loader limit the bone weights 170 /// </summary> 171 bool limitBoneWeights; 172 173 /// <summary> 174 /// Should the shape loader automatically merge identical/duplicate verts 175 /// </summary> 176 bool JoinIdenticalVerts; 177 178 /// <summary> 179 /// Should the shape loader reverse the winding order of the mesh's face indicies 180 /// </summary> 181 bool reverseWindingOrder; 182 183 /// <summary> 184 /// Should the normals on the model be inverted 185 /// </summary> 186 bool invertNormals; 187 // 188 189 // 190 //Materials 191 /// <summary> 192 /// Does this config allow for importing of materials 193 /// </summary> 194 bool ImportMaterials; 195 196 /// <summary> 197 /// When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map 198 /// </summary> 199 bool CreateORMConfig; 200 201 /// <summary> 202 /// When creating a material on import, this indicates if it should automatically add a standard suffix onto the name 203 /// </summary> 204 bool AlwaysAddMaterialSuffix; 205 206 /// <summary> 207 /// If AlwaysAddMaterialSuffix is on, this is the suffix to be added 208 /// </summary> 209 String AddedMaterialSuffix; 210 211 /// <summary> 212 /// When generating a material off of an importing image, should the importer force appending a diffusemap suffix onto the end to avoid potential naming confusion. 213 /// e.g. MyCoolStuff.png is imported, generating MyCoolStuff material asset and MyCoolStuff_Diffuse image asset 214 /// </summary> 215 bool UseDiffuseSuffixOnOriginImage; 216 217 /// <summary> 218 /// Should the importer try and use existing material assets in the game directory if at all possible. (Not currently utilized) 219 /// </summary> 220 bool UseExistingMaterials; 221 222 /// <summary> 223 /// A list of material names that should not be imported. Separated by either , or ; 224 /// </summary> 225 String IgnoreMaterials; 226 227 /// <summary> 228 /// When processing a material asset, should the importer attempt to populate the various material maps on it by looking up common naming conventions for potentially relevent image files 229 /// e.g. If MyCoolStuff_Diffuse.png is imported, generating MyCoolStuff material, it would also find MyCoolStuff_Normal and MyCoolStuff_PBR images and map them to the normal and ORMConfig maps respectively automatically 230 /// </summary> 231 bool PopulateMaterialMaps; 232 233 // 234 //Animations 235 /// <summary> 236 /// Does this config allow for importing Shape Animations 237 /// </summary> 238 bool ImportAnimations; 239 240 /// <summary> 241 /// When importing a shape file, should the animations within be separated out into unique files 242 /// </summary> 243 bool SeparateAnimations; 244 245 /// <summary> 246 /// If separating animations out from a source file, what prefix should be added to the names for grouping association 247 /// </summary> 248 String SeparateAnimationPrefix; 249 250 /// <summary> 251 /// Defines the animation timing for the given animation sequence. Options are FrameTime, Seconds, Milliseconds 252 /// </summary> 253 String animTiming; 254 255 /// <summary> 256 /// The FPS of the animation sequence 257 /// </summary> 258 F32 animFPS; 259 260 // 261 //Collision 262 /// <summary> 263 /// Does this configuration generate collision geometry when importing. (Not currently enabled) 264 /// </summary> 265 bool GenerateCollisions; 266 267 /// <summary> 268 /// What sort of collision geometry is generated. (Not currently enabled) 269 /// </summary> 270 String GenCollisionType; 271 272 /// <summary> 273 /// What prefix is added to the collision geometry generated. (Not currently enabled) 274 /// </summary> 275 String CollisionMeshPrefix; 276 277 /// <summary> 278 /// Does this configuration generate Line of Sight collision geometry. (Not currently enabled) 279 /// </summary> 280 bool GenerateLOSCollisions; 281 282 /// <summary> 283 /// What sort of Line of Sight collision geometry is generated. (Not currently enabled) 284 /// </summary> 285 String GenLOSCollisionType; 286 287 /// <summary> 288 /// What prefix is added to the Line of Sight collision geometry generated. (Not currently enabled) 289 /// </summary> 290 String LOSCollisionMeshPrefix; 291 292 // 293 //Images 294 /// <summary> 295 /// Does this configuration support importing images. 296 /// </summary> 297 bool importImages; 298 299 /// <summary> 300 /// When importing an image, this indicates if it should automatically add a standard suffix onto the name 301 /// </summary> 302 bool AlwaysAddImageSuffix; 303 304 /// <summary> 305 /// If AlwaysAddImageSuffix is on, this is the suffix to be added 306 /// </summary> 307 String AddedImageSuffix; 308 309 /// <summary> 310 /// What is the default ImageType images are imported as. Options are: N/A, Diffuse, Normal, Metalness, Roughness, AO, ORMConfig, GUI, Cubemap 311 /// </summary> 312 String ImageType; 313 314 /// <summary> 315 /// What type of suffixes are scanned to detect if an importing image is a diffuse map. 316 /// e.g. _Albedo or _Color 317 /// </summary> 318 String DiffuseTypeSuffixes; 319 320 /// <summary> 321 /// What type of suffixes are scanned to detect if an importing image is a normal map. 322 /// e.g. _Normal or _Norm 323 /// </summary> 324 String NormalTypeSuffixes; 325 326 /// <summary> 327 /// What type of suffixes are scanned to detect if an importing image is a metalness map. 328 /// e.g. _Metalness or _Metal 329 /// </summary> 330 String MetalnessTypeSuffixes; 331 332 /// <summary> 333 /// What type of suffixes are scanned to detect if an importing image is a roughness map. 334 /// e.g. _roughness or _rough 335 /// </summary> 336 String RoughnessTypeSuffixes; 337 338 /// <summary> 339 /// What type of suffixes are scanned to detect if an importing image is a smoothness map. 340 /// e.g. _smoothness or _smooth 341 /// </summary> 342 String SmoothnessTypeSuffixes; 343 344 /// <summary> 345 /// What type of suffixes are scanned to detect if an importing image is a ambient occlusion map. 346 /// e.g. _ambient or _ao 347 /// </summary> 348 String AOTypeSuffixes; 349 350 /// <summary> 351 /// What type of suffixes are scanned to detect if an importing image is a ORMConfig map. 352 /// e.g. _Composite or _PBR 353 /// </summary> 354 String PBRTypeSuffixes; 355 356 /// <summary> 357 /// Indicates what filter mode images imported with this configuration utilizes. Options are Linear, Bilinear, Trilinear 358 /// </summary> 359 String TextureFilteringMode; 360 361 /// <summary> 362 /// Indicates if images imported with this configuration utilize mipmaps 363 /// </summary> 364 bool UseMips; 365 366 /// <summary> 367 /// Indicates if images imported with this configuration are in an HDR format 368 /// </summary> 369 bool IsHDR; 370 371 /// <summary> 372 /// Indicates what amount of scaling images imported with this configuration use 373 /// </summary> 374 F32 Scaling; 375 376 /// <summary> 377 /// Indicates if images imported with this configuration are compressed 378 /// </summary> 379 bool ImagesCompressed; 380 381 /// <summary> 382 /// Indicates if images imported with this configuration generate a parent material for it as well 383 /// </summary> 384 bool GenerateMaterialOnImport; 385 386 // 387 //Sounds 388 /// <summary> 389 /// Indicates if sounds are imported with this configuration 390 /// </summary> 391 bool importSounds; 392 393 /// <summary> 394 /// Indicates what amount the volume is adjusted on sounds imported with this configuration 395 /// </summary> 396 F32 VolumeAdjust; 397 398 /// <summary> 399 /// Indicates what amount the pitch is adjusted on sounds imported with this configuration 400 /// </summary> 401 F32 PitchAdjust; 402 403 /// <summary> 404 /// Indicates if sounds imported with this configuration are compressed 405 /// </summary> 406 bool SoundsCompressed; 407 408public: 409 AssetImportConfig(); 410 virtual ~AssetImportConfig(); 411 412 virtual bool onAdd(); 413 virtual void onRemove(); 414 415 /// Engine. 416 static void initPersistFields(); 417 418 /// <summary> 419 /// Loads a configuration from a Settings object 420 /// @param configSettings, The Settings object to load from 421 /// @param configName, The name of the configuration setting to load from the setting object 422 /// </summary> 423 void loadImportConfig(Settings* configSettings, String configName); 424 425 void CopyTo(AssetImportConfig* target) const; 426 427 /// Declare Console Object. 428 DECLARE_CONOBJECT(AssetImportConfig); 429 430 void loadSISFile(Torque::Path filePath); 431}; 432 433/// <summary> 434/// AssetImportConfig is a SimObject derived object that represents and holds information for an importing asset. They are generated and processed by the AssetImporter 435/// </summary> 436class AssetImportObject : public SimObject 437{ 438 typedef SimObject Parent; 439 440public: 441 /// <summary> 442 /// What type is the importing asset 443 /// </summary> 444 String assetType; 445 446 /// <summary> 447 /// What is the source file path of the importing asset 448 /// </summary> 449 Torque::Path filePath; 450 451 /// <summary> 452 /// What is the source file path of the importing asset in string form 453 /// </summary> 454 StringTableEntry filePathString; 455 456 /// <summary> 457 /// What is the asset's name 458 /// </summary> 459 String assetName; 460 461 /// <summary> 462 /// What is the original, unmodified by processing, asset name 463 /// </summary> 464 String cleanAssetName; 465 466 /// <summary> 467 /// What is the name of the module this asset will be importing into 468 /// </summary> 469 String moduleName; 470 471 /// <summary> 472 /// What is the current status of this asset item in it's import process 473 /// </summary> 474 String status; 475 476 /// <summary> 477 /// If there is a warning or error status, what type is the condition for this asset item 478 /// </summary> 479 String statusType; 480 481 /// <summary> 482 /// What is the articulated information of the status of the asset. Contains the error or warning log data. 483 /// </summary> 484 String statusInfo; 485 486 /// <summary> 487 /// Is the asset item currently flagged as dirty 488 /// </summary> 489 bool dirty; 490 491 /// <summary> 492 /// Is this asset item marked to be skipped. If it is, it's usually due to being marked as deleted 493 /// </summary> 494 bool skip; 495 496 /// <summary> 497 /// Has the asset item been processed 498 /// </summary> 499 bool processed; 500 501 /// <summary> 502 /// Is this specific asset item generated as part of the import process of another item 503 /// </summary> 504 bool generatedAsset; 505 506 /// <summary> 507 /// What, if any, importing asset item is this item's parent 508 /// </summary> 509 AssetImportObject* parentAssetItem; 510 511 /// <summary> 512 /// What, if any, importing asset item are children of this item 513 /// </summary> 514 Vector< AssetImportObject*> childAssetItems; 515 516 /// <summary> 517 /// What is the ultimate asset taml file path for this import item 518 /// </summary> 519 String tamlFilePath; 520 521 // 522 /// <summary> 523 /// Specific to ImageAsset type 524 /// What is the image asset's suffix type. Options are: Albedo, Normal, Roughness, AO, Metalness, ORMConfig 525 /// </summary> 526 String imageSuffixType; 527 528 // 529 /// <summary> 530 /// Specific to ShapeAsset type 531 /// Processed information about the shape file. Contains numbers and lists of meshes, materials and animations 532 /// </summary> 533 GuiTreeViewCtrl* shapeInfo; 534 535public: 536 AssetImportObject(); 537 virtual ~AssetImportObject(); 538 539 virtual bool onAdd(); 540 virtual void onRemove(); 541 542 /// Engine. 543 static void initPersistFields(); 544 545 /// Declare Console Object. 546 DECLARE_CONOBJECT(AssetImportObject); 547 548 static bool _setFilePath(void* obj, const char* index, const char* data); 549 550 void setFilePath(StringTableEntry pFilePath); 551 552 bool operator ==(const AssetImportObject& o) const 553 { 554 return o.getId() == this->getId(); 555 } 556}; 557 558/// <summary> 559/// AssetImporter is a SimObject derived object that processed and imports files and turns them into assets if they are of valid types. 560/// Utilizes an AssetImportConfig to inform the importing process's behavior. 561/// </summary> 562class AssetImporter : public SimObject 563{ 564 typedef SimObject Parent; 565 566 /// <summary> 567 /// The import configuration that is currently being utilized 568 /// </summary> 569 AssetImportConfig* activeImportConfig; 570 571 /// <summary> 572 /// A log of all the actions that have been performed by the importer 573 /// </summary> 574 Vector<String> activityLog; 575 576 /// <summary> 577 /// A list of AssetImportObjects that are to be imported 578 /// </summary> 579 Vector<AssetImportObject*> importingAssets; 580 581 /// <summary> 582 /// A list of file paths that are to be imported. These are only used for resetting purposes; 583 /// </summary> 584 Vector<Torque::Path> originalImportingFiles; 585 586 /// <summary> 587 /// The Id of the module the assets are to be imported into 588 /// </summary> 589 String targetModuleId; 590 591 /// <summary> 592 /// The path any imported assets are placed in as their destination 593 /// </summary> 594 String targetPath; 595 596 /// <summary> 597 /// Are there any issues with any of the current import asset items 598 /// </summary> 599 bool importIssues; 600 601 /// <summary> 602 /// Is this import action a reimport of an existing asset 603 /// </summary> 604 bool isReimport; 605 606 /// <summary> 607 /// Has the heirarchy of asset import items changed due to processing 608 /// </summary> 609 bool assetHeirarchyChanged; 610 611 /// <summary> 612 /// A string used for writing into the importLog 613 /// </summary> 614 char importLogBuffer[1024]; 615 616 /// <summary> 617 /// only used for passing up the result of an import action for a script-side handled type 618 /// </summary> 619 String finalImportedAssetPath; 620 621public: 622 AssetImporter(); 623 virtual ~AssetImporter(); 624 625 virtual bool onAdd(); 626 virtual void onRemove(); 627 628 /// Engine. 629 static void initPersistFields(); 630 631 /// Declare Console Object. 632 DECLARE_CONOBJECT(AssetImporter); 633 634 /// <summary> 635 /// Sets the target path for the assets being imported to be deposited into 636 /// <para>@param pTargetPath, The filePath of the destination point assets are imported into</para> 637 /// </summary> 638 void setTargetPath(Torque::Path pTargetPath) { targetPath = pTargetPath; } 639 640 /// <summary> 641 /// Processes a file into an AssetImportObject and adds it to the session for importing 642 /// <para>@param filePath, The filePath of the file to be imported in as an asset</para> 643 /// <para>@return AssetImportObject that was created</para> 644 /// </summary> 645 AssetImportObject* addImportingFile(Torque::Path filePath); 646 647 /// <summary> 648 /// Adds an existing AssetImportObject to our import session. Generally this would be created in a script somewhere 649 /// <para>@param assetItem, The asset item to be added to the import session</para> 650 /// <para>@param parentItem (Optional), The asset item that will be the parent of the assetItem being added</para> 651 /// </summary> 652 void addImportingAssetItem(AssetImportObject* assetItem, AssetImportObject* parentItem); 653 654 /// <summary> 655 /// Adds an importing asset to the current session 656 /// <para>@param assetType, Type of the asset being imported</para> 657 /// <para>@param filePath, path of the file to be imported</para> 658 /// <para>@param parentItem, AssetImportObject that the new item is a child of. null if no parent</para> 659 /// <para>@param assetNameOverride, If not blank, will be the new item's assetName instead of being created off of the filePath</para> 660 /// <para>@return AssetImportObject that was created</para> 661 /// </summary> 662 AssetImportObject* addImportingAsset(String assetType, Torque::Path filePath, AssetImportObject* parentItem, String assetNameOverride); 663 664 /// <summary> 665 /// Deletes the asset item from the import session. Affects the item's children as well 666 /// <para>@param assetItem, asset item to be marked as deleted</para> 667 /// </summary> 668 void deleteImportingAsset(AssetImportObject* assetItem); 669 670 /// <summary> 671 /// Finds an asset item in the session if it exists, by name 672 /// <para>@param assetName, Asset name to find</para> 673 /// <para>@param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children</para> 674 /// <para>@return AssetImportObject that was found</para> 675 /// </summary> 676 AssetImportObject* findImportingAssetByName(String assetName, AssetImportObject* assetItem = nullptr); 677 678 /// <summary> 679 /// Finds the module associated with a given file path 680 /// <para>@param filePath, File path to parse the the module from</para> 681 /// <para>@return ModuleDefinition that was found</para> 682 /// </summary> 683 static ModuleDefinition* getModuleFromPath(Torque::Path filePath); 684 685 /// <summary> 686 /// Parses an asset's name to try and find if any of the import config's suffix lists match to it 687 /// <para>@param assetName, Asset name to parse any image suffix out of</para> 688 /// <para>@param suffixType, output, The suffix type that was matched to the asset name</para> 689 /// <para>@return suffix that matched to the asset name</para> 690 /// </summary> 691 String parseImageSuffixes(String assetName, String* suffixType); 692 693 /// <summary> 694 /// Parses a file path to determine its asset type 695 /// <para>@param filePath, File path to parse</para> 696 /// <para>@return The asset type as a string</para> 697 /// </summary> 698 String getAssetTypeByFile(Torque::Path filePath); 699 700 /// <summary> 701 /// Resets the import session to a clean slate. This will clear all existing AssetImportObjects and the activity log 702 /// and then re-process the original filePaths again. 703 /// <para>@param hardClearSession, Defaults to false. If true, will also clear the original filePaths</para> 704 /// </summary> 705 void resetImportSession(bool hardClearSession = false); 706 707 /// <summary> 708 /// Get the number of lines in the activity log 709 /// <para>@return Line count as S32</para> 710 /// </summary> 711 S32 getActivityLogLineCount(); 712 713 /// <summary> 714 /// Gets the log line at a given index 715 /// <para>@param line, line in the log to get</para> 716 /// <para>@return The log line as a string</para> 717 /// </summary> 718 String getActivityLogLine(U32 line); 719 720 /// <summary> 721 /// Dumps the entire current activity log to the console. 722 /// </summary> 723 void dumpActivityLog(); 724 725 /// <summary> 726 /// Gets the number of top-level asset items in the current import session(doesn't count children) 727 /// <para>@return Number of children</para> 728 /// </summary> 729 S32 getAssetItemCount(); 730 731 /// <summary> 732 /// Get the top-level asset item in the current import session at the requested index 733 /// <para>@param index, The index of the item array to get</para> 734 /// <para>@return The AssetImportObject at the index</para> 735 /// </summary> 736 AssetImportObject* getAssetItem(U32 index); 737 738 /// <summary> 739 /// Gets the number of child asset items of a given AssetImportObject 740 /// <para>@param assetItem, The AssetImportObject to get the number of child items for</para> 741 /// <para>@return Number of children</para> 742 /// </summary> 743 S32 getAssetItemChildCount(AssetImportObject* assetItem); 744 745 /// <summary> 746 /// Get the child asset item of a specific AssetImportObject at the requested index 747 /// <para>@param assetItem, The AssetImportObject to get the number of child items for</para> 748 /// <para>@param index, The index of the child item array to get</para> 749 /// <para>@return The AssetImportObject at the index</para> 750 /// </summary> 751 AssetImportObject* getAssetItemChild(AssetImportObject* assetItem, U32 index); 752 753 /// <summary> 754 /// Process AssetImportObject's to prepare them for importing. 755 /// <para>@param assetItem, If null, will loop over the top-level asset items list, if a specific item is provided, will process it's children</para> 756 /// </summary> 757 void processImportAssets(AssetImportObject* assetItem = nullptr); 758 759 /// <summary> 760 /// Process a specific AssetImportObject that is an ImageAsset type to prepare it for importing 761 /// <para>@param assetItem, The AssetImportObject to process</para> 762 /// </summary> 763 void processImageAsset(AssetImportObject* assetItem); 764 765 /// <summary> 766 /// Process a specific AssetImportObject that is an MaterialAsset type to prepare it for importing 767 /// <para>@param assetItem, The AssetImportObject to process</para> 768 /// </summary> 769 void processMaterialAsset(AssetImportObject* assetItem); 770 771 /// <summary> 772 /// Process a specific AssetImportObject that is an ShapeAsset type to prepare it for importing 773 /// <para>@param assetItem, The AssetImportObject to process</para> 774 /// </summary> 775 void processShapeAsset(AssetImportObject* assetItem); 776 777 /// <summary> 778 /// Process a specific ShapeAsset AssetImportObject with a material id in order to parse and handle the materials listed in the shape file 779 /// <para>@param assetItem, The AssetImportObject to process</para> 780 /// <para>@param materialItemId, The materialItemId in the shapeInfo to process</para> 781 /// </summary> 782 void processShapeMaterialInfo(AssetImportObject* assetItem, S32 materialItemId); 783 784 /// <summary> 785 /// Process a specific AssetImportObject that is an SoundAsset type to prepare it for importing 786 /// <para>@param assetItem, The AssetImportObject to process</para> 787 /// </summary> 788 void processSoundAsset(AssetImportObject* assetItem); 789 790 /// <summary> 791 /// Run through and validate assets for issues, such as name collisions 792 /// </summary> 793 bool validateAssets(); 794 795 /// <summary> 796 /// Validate a specific asset item 797 /// <para>@param assetItem, The AssetImportObject to validate</para> 798 /// </summary> 799 void validateAsset(AssetImportObject* assetItem); 800 801 /// <summary> 802 /// Reset the validation status of asset items 803 /// <para>@param assetItem, If null, will loop over the top-level asset items list, if a specific item is provided, will reset it's children</para> 804 /// </summary> 805 void resetAssetValidationStatus(AssetImportObject* assetItem = nullptr); 806 807 /// <summary> 808 /// Checks asset items for any collisions in the current import session 809 /// <para>@param assetItemToCheckFor, The asset to check for collisions with</para> 810 /// <para>@param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children</para> 811 /// <para>@return If a collision was detected</para> 812 /// </summary> 813 bool checkAssetForCollision(AssetImportObject* assetItemToCheckFor, AssetImportObject* assetItem = nullptr); 814 815 /// <summary> 816 /// Attempts to automatically resolve import issues according to the import config settings 817 /// <para>@param assetItem, The AssetImportObject to resolve</para> 818 /// </summary> 819 void resolveAssetItemIssues(AssetImportObject* assetItem); 820 821 /// <summary> 822 /// Runs the import process on a single file in-place. Intended primarily for autoimporting a loose file that's in the game directory. 823 /// <para>@param filePath, The filePath of the file to be imported in as an asset</para> 824 /// <para>@return AssetId of the asset that was imported. If import failed, it will be empty.</para> 825 /// </summary> 826 StringTableEntry autoImportFile(Torque::Path filePath); 827 828 /// <summary> 829 /// Runs the import process in the current session 830 /// <para>@param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children</para> 831 /// </summary> 832 void importAssets(AssetImportObject* assetItem = nullptr); 833 834 /// <summary> 835 /// Runs the import processing on a specific ImageAsset item 836 /// <para>@param assetItem, The asset item to import</para> 837 /// <para>@return TAML File path of the new asset that was imported. If import failed, it will be empty.</para> 838 /// </summary> 839 Torque::Path importImageAsset(AssetImportObject* assetItem); 840 841 /// <summary> 842 /// Runs the import processing on a specific MaterialAsset item 843 /// <para>@param assetItem, The asset item to import</para> 844 /// <para>@return TAML File path of the new asset that was imported. If import failed, it will be empty.</para> 845 /// </summary> 846 Torque::Path importMaterialAsset(AssetImportObject* assetItem); 847 848 /// <summary> 849 /// Runs the import processing on a specific ShapeAsset item 850 /// <para>@param assetItem, The asset item to import</para> 851 /// <para>@return TAML File path of the new asset that was imported. If import failed, it will be empty.</para> 852 /// </summary> 853 Torque::Path importShapeAsset(AssetImportObject* assetItem); 854 855 /// <summary> 856 /// Runs the import processing on a specific SoundAsset item 857 /// <para>@param assetItem, The asset item to import</para> 858 /// <para>@return TAML File path of the new asset that was imported. If import failed, it will be empty.</para> 859 /// </summary> 860 Torque::Path importSoundAsset(AssetImportObject* assetItem); 861 862 /// <summary> 863 /// Runs the import processing on a specific ShapeAnimationAsset item 864 /// <para>@param assetItem, The asset item to import</para> 865 /// <para>@return TAML File path of the new asset that was imported. If import failed, it will be empty.</para> 866 /// </summary> 867 Torque::Path importShapeAnimationAsset(AssetImportObject* assetItem); 868 869 // 870 /// <summary> 871 /// Gets the currently active import configuration 872 /// <para>@return Current AssetImportConfig the importer is using</para> 873 /// </summary> 874 AssetImportConfig* getImportConfig() { return activeImportConfig; } 875 876 void setImportConfig(AssetImportConfig* importConfig) { 877 if(importConfig != nullptr) 878 activeImportConfig = importConfig; 879 } 880 881 /// <summary> 882 /// Resets the active import config to whatever the default is. Either a clean slate if one isn't defined 883 /// or loading one if defined via the editor config 884 /// </summary> 885 void resetImportConfig(); 886 887 // 888 static String getTrueFilename(const String& fileName); 889 890 // 891 /// <summary> 892 /// </summary> 893 static inline String findImagePath(const String &testPath) 894 { 895 896 String imagePath; 897 if (Platform::isFile(testPath + String(".jpg"))) 898 imagePath = testPath + String(".jpg"); 899 else if (Platform::isFile(testPath + String(".png"))) 900 imagePath = testPath + String(".png"); 901 else if (Platform::isFile(testPath + String(".dds"))) 902 imagePath = testPath + String(".dds"); 903 else if (Platform::isFile(testPath + String(".tif"))) 904 imagePath = testPath + String(".tif"); 905 906 if(imagePath.isNotEmpty()) 907 //This ensures case-correct for the filename 908 imagePath = getTrueFilename(imagePath); 909 910 return imagePath; 911 } 912 913 static inline const char* makeFullPath(const String& path) 914 { 915 char qualifiedFilePath[2048]; 916 917 Platform::makeFullPathName(path.c_str(), qualifiedFilePath, sizeof(qualifiedFilePath)); 918 919 return qualifiedFilePath; 920 } 921 922 // 923 void setTargetModuleId(const String& moduleId) { targetModuleId = moduleId; } 924 const String& getTargetModuleId() { return targetModuleId; } 925}; 926