mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Includes required support functions for ImageAsset
This commit is contained in:
parent
4f319d3d2c
commit
4978538490
3 changed files with 66 additions and 16 deletions
|
|
@ -239,6 +239,50 @@ const char* ImageAsset::getImageInfo()
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type)
|
||||||
|
{
|
||||||
|
// must match ImageTypes order
|
||||||
|
static const char* _names[] = {
|
||||||
|
"Albedo"
|
||||||
|
"Normal"
|
||||||
|
"Composite"
|
||||||
|
"GUI"
|
||||||
|
"Roughness"
|
||||||
|
"AO"
|
||||||
|
"Metalness"
|
||||||
|
"Glow"
|
||||||
|
"Particle"
|
||||||
|
"Decal"
|
||||||
|
"Cubemap"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (type < 0 || type >= ImageTypeCount)
|
||||||
|
{
|
||||||
|
Con::errorf("ImageAsset::getAdapterNameFromType - Invalid ImageType, defaulting to Albedo");
|
||||||
|
return _names[Albedo];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _names[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageAsset::ImageTypes ImageAsset::getImageTypeFromName(const char* name)
|
||||||
|
{
|
||||||
|
S32 ret = -1;
|
||||||
|
for (S32 i = 0; i < ImageTypeCount; i++)
|
||||||
|
{
|
||||||
|
if (!dStricmp(getImageTypeNameFromType((ImageTypes)i), name))
|
||||||
|
ret = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
Con::errorf("ImageAsset::getImageTypeFromName - Invalid ImageType name, defaulting to Albedo");
|
||||||
|
ret = Albedo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ImageTypes)ret;
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(ImageAsset, getImageFilename, const char*, (), ,
|
DefineEngineMethod(ImageAsset, getImageFilename, const char*, (), ,
|
||||||
"Creates an instance of the given GameObject given the asset definition.\n"
|
"Creates an instance of the given GameObject given the asset definition.\n"
|
||||||
"@return The GameObject entity created from the asset.")
|
"@return The GameObject entity created from the asset.")
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ public:
|
||||||
Particle = 8,
|
Particle = 8,
|
||||||
Decal = 9,
|
Decal = 9,
|
||||||
Cubemap = 10,
|
Cubemap = 10,
|
||||||
|
ImageTypeCount = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -100,6 +101,11 @@ public:
|
||||||
|
|
||||||
const char* getImageInfo();
|
const char* getImageInfo();
|
||||||
|
|
||||||
|
static const char* getImageTypeNameFromType(ImageTypes type);
|
||||||
|
static ImageTypes getImageTypeFromName(const char* name);
|
||||||
|
|
||||||
|
void setImageType(ImageTypes type) { mImageType = type; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initializeAsset(void);
|
virtual void initializeAsset(void);
|
||||||
virtual void onAssetRefresh(void);
|
virtual void onAssetRefresh(void);
|
||||||
|
|
|
||||||
|
|
@ -896,12 +896,12 @@ void AssetImporter::processImportAssets(AssetImportObject* assetItem)
|
||||||
processImageAsset(item);
|
processImageAsset(item);
|
||||||
else if (item->assetType == String("ShapeAsset"))
|
else if (item->assetType == String("ShapeAsset"))
|
||||||
processShapeAsset(item);
|
processShapeAsset(item);
|
||||||
else if (item->assetType == String("SoundAsset"))
|
/*else if (item->assetType == String("SoundAsset"))
|
||||||
SoundAsset::prepareAssetForImport(this, item);
|
SoundAsset::prepareAssetForImport(this, item);*/
|
||||||
else if (item->assetType == String("MaterialAsset"))
|
else if (item->assetType == String("MaterialAsset"))
|
||||||
processMaterialAsset(item);
|
processMaterialAsset(item);
|
||||||
else if (item->assetType == String("ShapeAnimationAsset"))
|
/*else if (item->assetType == String("ShapeAnimationAsset"))
|
||||||
ShapeAnimationAsset::prepareAssetForImport(this, item);
|
ShapeAnimationAsset::prepareAssetForImport(this, item);*/
|
||||||
|
|
||||||
item->processed = true;
|
item->processed = true;
|
||||||
}
|
}
|
||||||
|
|
@ -933,12 +933,12 @@ void AssetImporter::processImportAssets(AssetImportObject* assetItem)
|
||||||
processImageAsset(childItem);
|
processImageAsset(childItem);
|
||||||
else if (childItem->assetType == String("ShapeAsset"))
|
else if (childItem->assetType == String("ShapeAsset"))
|
||||||
processShapeAsset(childItem);
|
processShapeAsset(childItem);
|
||||||
else if (childItem->assetType == String("SoundAsset"))
|
/*else if (childItem->assetType == String("SoundAsset"))
|
||||||
SoundAsset::prepareAssetForImport(this, childItem);
|
SoundAsset::prepareAssetForImport(this, childItem);*/
|
||||||
else if (childItem->assetType == String("MaterialAsset"))
|
else if (childItem->assetType == String("MaterialAsset"))
|
||||||
processMaterialAsset(childItem);
|
processMaterialAsset(childItem);
|
||||||
else if (childItem->assetType == String("ShapeAnimationAsset"))
|
/*else if (childItem->assetType == String("ShapeAnimationAsset"))
|
||||||
ShapeAnimationAsset::prepareAssetForImport(this, childItem);
|
ShapeAnimationAsset::prepareAssetForImport(this, childItem);*/
|
||||||
|
|
||||||
childItem->processed = true;
|
childItem->processed = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1549,12 +1549,12 @@ void AssetImporter::importAssets(AssetImportObject* assetItem)
|
||||||
assetPath = importImageAsset(importingAssets[i]);
|
assetPath = importImageAsset(importingAssets[i]);
|
||||||
else if (importingAssets[i]->assetType == String("ShapeAsset"))
|
else if (importingAssets[i]->assetType == String("ShapeAsset"))
|
||||||
assetPath = importShapeAsset(importingAssets[i]);
|
assetPath = importShapeAsset(importingAssets[i]);
|
||||||
else if (importingAssets[i]->assetType == String("SoundAsset"))
|
/*else if (importingAssets[i]->assetType == String("SoundAsset"))
|
||||||
assetPath = SoundAsset::importAsset(importingAssets[i]);
|
assetPath = SoundAsset::importAsset(importingAssets[i]);*/
|
||||||
else if (importingAssets[i]->assetType == String("MaterialAsset"))
|
else if (importingAssets[i]->assetType == String("MaterialAsset"))
|
||||||
assetPath = importMaterialAsset(importingAssets[i]);
|
assetPath = importMaterialAsset(importingAssets[i]);
|
||||||
else if (importingAssets[i]->assetType == String("ShapeAnimationAsset"))
|
/*else if (importingAssets[i]->assetType == String("ShapeAnimationAsset"))
|
||||||
assetPath = ShapeAnimationAsset::importAsset(importingAssets[i]);
|
assetPath = ShapeAnimationAsset::importAsset(importingAssets[i]);*/
|
||||||
|
|
||||||
//If we got a valid filepath back from the import action, then we know we're good to go and we can go ahead and register the asset!
|
//If we got a valid filepath back from the import action, then we know we're good to go and we can go ahead and register the asset!
|
||||||
if (!assetPath.isEmpty() && !isReimport)
|
if (!assetPath.isEmpty() && !isReimport)
|
||||||
|
|
@ -1587,12 +1587,12 @@ void AssetImporter::importAssets(AssetImportObject* assetItem)
|
||||||
assetPath = importImageAsset(childItem);
|
assetPath = importImageAsset(childItem);
|
||||||
else if (childItem->assetType == String("ShapeAsset"))
|
else if (childItem->assetType == String("ShapeAsset"))
|
||||||
assetPath = importShapeAsset(childItem);
|
assetPath = importShapeAsset(childItem);
|
||||||
else if (childItem->assetType == String("SoundAsset"))
|
/*else if (childItem->assetType == String("SoundAsset"))
|
||||||
assetPath = SoundAsset::importAsset(childItem);
|
assetPath = SoundAsset::importAsset(childItem);*/
|
||||||
else if (childItem->assetType == String("MaterialAsset"))
|
else if (childItem->assetType == String("MaterialAsset"))
|
||||||
assetPath = importMaterialAsset(childItem);
|
assetPath = importMaterialAsset(childItem);
|
||||||
else if (childItem->assetType == String("ShapeAnimationAsset"))
|
/*else if (childItem->assetType == String("ShapeAnimationAsset"))
|
||||||
assetPath = ShapeAnimationAsset::importAsset(childItem);
|
assetPath = ShapeAnimationAsset::importAsset(childItem);*/
|
||||||
|
|
||||||
//If we got a valid filepath back from the import action, then we know we're good to go and we can go ahead and register the asset!
|
//If we got a valid filepath back from the import action, then we know we're good to go and we can go ahead and register the asset!
|
||||||
if (!assetPath.isEmpty() && !isReimport)
|
if (!assetPath.isEmpty() && !isReimport)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue