AssetImporter

Engine/source/T3D/assets/assetImporter.h

AssetImporter is a SimObject derived object that processed and imports files and turns them into assets if they are of valid types.

More...

Private Types

Parent 

Private Attributes

The import configuration that is currently being utilized

A log of all the actions that have been performed by the importer

bool

Has the heirarchy of asset import items changed due to processing

only used for passing up the result of an import action for a script-side handled type

A list of AssetImportObjects that are to be imported

bool

Are there any issues with any of the current import asset items

char

A string used for writing into the importLog

bool

Is this import action a reimport of an existing asset

A list of file paths that are to be imported.

The Id of the module the assets are to be imported into

The path any imported assets are placed in as their destination

Public Functions

addImportingAsset(String assetType, Torque::Path filePath, AssetImportObject * parentItem, String assetNameOverride)

Adds an importing asset to the current session

Adds an existing AssetImportObject to our import session.

Processes a file into an AssetImportObject and adds it to the session for importing

Runs the import process on a single file in-place.

bool
checkAssetForCollision(AssetImportObject * assetItemToCheckFor, AssetImportObject * assetItem)

Checks asset items for any collisions in the current import session

Declare Console Object.

Deletes the asset item from the import session.

Dumps the entire current activity log to the console.

Finds an asset item in the session if it exists, by name

Gets the log line at a given index

Get the number of lines in the activity log

Get the top-level asset item in the current import session at the requested index

Get the child asset item of a specific AssetImportObject at the requested index

Gets the number of child asset items of a given AssetImportObject

Gets the number of top-level asset items in the current import session(doesn't count children)

Parses a file path to determine its asset type

Gets the currently active import configuration

Runs the import process in the current session

Runs the import processing on a specific ImageAsset item

Runs the import processing on a specific MaterialAsset item

Runs the import processing on a specific ShapeAnimationAsset item

Runs the import processing on a specific ShapeAsset item

Runs the import processing on a specific SoundAsset item

bool

Called when the object is added to the sim.

Called when the object is removed from the sim.

parseImageSuffixes(String assetName, String * suffixType)

Parses an asset's name to try and find if any of the import config's suffix lists match to it

Process a specific AssetImportObject that is an ImageAsset type to prepare it for importing

Process AssetImportObject's to prepare them for importing.

Process a specific AssetImportObject that is an MaterialAsset type to prepare it for importing

Process a specific AssetImportObject that is an ShapeAsset type to prepare it for importing

processShapeMaterialInfo(AssetImportObject * assetItem, S32 materialItemId)

Process a specific ShapeAsset AssetImportObject with a material id in order to parse and handle the materials listed in the shape file

Process a specific AssetImportObject that is an SoundAsset type to prepare it for importing

Reset the validation status of asset items

Resets the active import config to whatever the default is.

resetImportSession(bool hardClearSession)

Resets the import session to a clean slate.

Attempts to automatically resolve import issues according to the import config settings

Sets the target path for the assets being imported to be deposited into

Validate a specific asset item

bool

Run through and validate assets for issues, such as name collisions

Public Static Functions

Finds the module associated with a given file path

const char *

Detailed Description

AssetImporter is a SimObject derived object that processed and imports files and turns them into assets if they are of valid types.

Utilizes an AssetImportConfig to inform the importing process's behavior.

Private Types

typedef SimObject Parent 

Private Attributes

AssetImportConfig * activeImportConfig 

The import configuration that is currently being utilized

Vector< String > activityLog 

A log of all the actions that have been performed by the importer

bool assetHeirarchyChanged 

Has the heirarchy of asset import items changed due to processing

String finalImportedAssetPath 

only used for passing up the result of an import action for a script-side handled type

Vector< AssetImportObject * > importingAssets 

A list of AssetImportObjects that are to be imported

bool importIssues 

Are there any issues with any of the current import asset items

char importLogBuffer [1024]

A string used for writing into the importLog

bool isReimport 

Is this import action a reimport of an existing asset

Vector< Torque::Path > originalImportingFiles 

A list of file paths that are to be imported.

These are only used for resetting purposes;

String targetModuleId 

The Id of the module the assets are to be imported into

String targetPath 

The path any imported assets are placed in as their destination

Public Functions

AssetImporter()

~AssetImporter()

addImportingAsset(String assetType, Torque::Path filePath, AssetImportObject * parentItem, String assetNameOverride)

Adds an importing asset to the current session

Parameters:

Type

of the asset being imported

Parameters:

path

of the file to be imported

Parameters:

that the new item is a child of. null if no parent

Parameters:

If

not blank, will be the new item's assetName instead of being created off of the filePath

return:

AssetImportObject that was created

addImportingAssetItem(AssetImportObject * assetItem, AssetImportObject * parentItem)

Adds an existing AssetImportObject to our import session.

Generally this would be created in a script somewhere

Parameters:

The

asset item to be added to the import session

Parameters:

parentItem

(Optional), The asset item that will be the parent of the assetItem being added

addImportingFile(Torque::Path filePath)

Processes a file into an AssetImportObject and adds it to the session for importing

Parameters:

The

filePath of the file to be imported in as an asset

return:

AssetImportObject that was created

autoImportFile(Torque::Path filePath)

Runs the import process on a single file in-place.

Intended primarily for autoimporting a loose file that's in the game directory.

Parameters:

The

filePath of the file to be imported in as an asset

return:

AssetId of the asset that was imported. If import failed, it will be empty.

checkAssetForCollision(AssetImportObject * assetItemToCheckFor, AssetImportObject * assetItem)

Checks asset items for any collisions in the current import session

Parameters:

The

asset to check for collisions with

Parameters:

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

return:

If a collision was detected

DECLARE_CONOBJECT(AssetImporter )

Declare Console Object.

deleteImportingAsset(AssetImportObject * assetItem)

Deletes the asset item from the import session.

Affects the item's children as well

Parameters:

asset

item to be marked as deleted

dumpActivityLog()

Dumps the entire current activity log to the console.

findImportingAssetByName(String assetName, AssetImportObject * assetItem)

Finds an asset item in the session if it exists, by name

Parameters:

Asset

name to find

Parameters:

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

return:

AssetImportObject that was found

getActivityLogLine(U32 line)

Gets the log line at a given index

Parameters:

line

in the log to get

return:

The log line as a string

getActivityLogLineCount()

Get the number of lines in the activity log

return:

Line count as S32

getAssetItem(U32 index)

Get the top-level asset item in the current import session at the requested index

Parameters:

The

index of the item array to get

return:

The AssetImportObject at the index

getAssetItemChild(AssetImportObject * assetItem, U32 index)

Get the child asset item of a specific AssetImportObject at the requested index

Parameters:

The

AssetImportObject to get the number of child items for

Parameters:

The

index of the child item array to get

return:

The AssetImportObject at the index

getAssetItemChildCount(AssetImportObject * assetItem)

Gets the number of child asset items of a given AssetImportObject

Parameters:

The

AssetImportObject to get the number of child items for

return:

Number of children

getAssetItemCount()

Gets the number of top-level asset items in the current import session(doesn't count children)

return:

Number of children

getAssetTypeByFile(Torque::Path filePath)

Parses a file path to determine its asset type

Parameters:

path to parse

return:

The asset type as a string

getImportConfig()

Gets the currently active import configuration

return:

Current AssetImportConfig the importer is using

getTargetModuleId()

importAssets(AssetImportObject * assetItem)

Runs the import process in the current session

Parameters:

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

importImageAsset(AssetImportObject * assetItem)

Runs the import processing on a specific ImageAsset item

Parameters:

The

asset item to import

return:

TAML File path of the new asset that was imported. If import failed, it will be empty.

importMaterialAsset(AssetImportObject * assetItem)

Runs the import processing on a specific MaterialAsset item

Parameters:

The

asset item to import

return:

TAML File path of the new asset that was imported. If import failed, it will be empty.

importShapeAnimationAsset(AssetImportObject * assetItem)

Runs the import processing on a specific ShapeAnimationAsset item

Parameters:

The

asset item to import

return:

TAML File path of the new asset that was imported. If import failed, it will be empty.

importShapeAsset(AssetImportObject * assetItem)

Runs the import processing on a specific ShapeAsset item

Parameters:

The

asset item to import

return:

TAML File path of the new asset that was imported. If import failed, it will be empty.

importSoundAsset(AssetImportObject * assetItem)

Runs the import processing on a specific SoundAsset item

Parameters:

The

asset item to import

return:

TAML File path of the new asset that was imported. If import failed, it will be empty.

onAdd()

Reimplemented from: SimObject

onRemove()

Reimplemented from: SimObject

parseImageSuffixes(String assetName, String * suffixType)

Parses an asset's name to try and find if any of the import config's suffix lists match to it

Parameters:

Asset

name to parse any image suffix out of

Parameters:

The

suffix type that was matched to the asset name

return:

suffix that matched to the asset name

processImageAsset(AssetImportObject * assetItem)

Process a specific AssetImportObject that is an ImageAsset type to prepare it for importing

Parameters:

The

AssetImportObject to process

processImportAssets(AssetImportObject * assetItem)

Process AssetImportObject's to prepare them for importing.

Parameters:

If

null, will loop over the top-level asset items list, if a specific item is provided, will process it's children

processMaterialAsset(AssetImportObject * assetItem)

Process a specific AssetImportObject that is an MaterialAsset type to prepare it for importing

Parameters:

The

AssetImportObject to process

processShapeAsset(AssetImportObject * assetItem)

Process a specific AssetImportObject that is an ShapeAsset type to prepare it for importing

Parameters:

The

AssetImportObject to process

processShapeMaterialInfo(AssetImportObject * assetItem, S32 materialItemId)

Process a specific ShapeAsset AssetImportObject with a material id in order to parse and handle the materials listed in the shape file

Parameters:

The

AssetImportObject to process

Parameters:

The

materialItemId in the shapeInfo to process

processSoundAsset(AssetImportObject * assetItem)

Process a specific AssetImportObject that is an SoundAsset type to prepare it for importing

Parameters:

The

AssetImportObject to process

resetAssetValidationStatus(AssetImportObject * assetItem)

Reset the validation status of asset items

Parameters:

If

null, will loop over the top-level asset items list, if a specific item is provided, will reset it's children

resetImportConfig()

Resets the active import config to whatever the default is.

Either a clean slate if one isn't defined or loading one if defined via the editor config

resetImportSession(bool hardClearSession)

Resets the import session to a clean slate.

This will clear all existing AssetImportObjects and the activity log and then re-process the original filePaths again.

Parameters:

Defaults

to false. If true, will also clear the original filePaths

resolveAssetItemIssues(AssetImportObject * assetItem)

Attempts to automatically resolve import issues according to the import config settings

Parameters:

The

AssetImportObject to resolve

setImportConfig(AssetImportConfig * importConfig)

setTargetModuleId(const String & moduleId)

setTargetPath(Torque::Path pTargetPath)

Sets the target path for the assets being imported to be deposited into

Parameters:

The

filePath of the destination point assets are imported into

validateAsset(AssetImportObject * assetItem)

Validate a specific asset item

Parameters:

The

AssetImportObject to validate

validateAssets()

Run through and validate assets for issues, such as name collisions

Public Static Functions

findImagePath(const String & testPath)

getModuleFromPath(Torque::Path filePath)

Finds the module associated with a given file path

Parameters:

path to parse the the module from

return:

ModuleDefinition that was found

getTrueFilename(const String & fileName)

initPersistFields()

Engine.

makeFullPath(const String & path)