mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-27 15:25:40 +00:00
Fixes mapping of imposter images to be packed as part of the shape asset, and fixes paths to be formatted more sanely.
This commit is contained in:
parent
bd876e427a
commit
a8b3d874a1
7 changed files with 186 additions and 7 deletions
|
|
@ -129,6 +129,13 @@ ShapeAsset::ShapeAsset()
|
|||
mConstructorFileName = StringTable->EmptyString();
|
||||
mFilePath = StringTable->EmptyString();
|
||||
mConstructorFilePath = StringTable->EmptyString();
|
||||
|
||||
mDiffuseImposterFileName = StringTable->EmptyString();
|
||||
mDiffuseImposterPath = StringTable->EmptyString();
|
||||
mNormalImposterFileName = StringTable->EmptyString();
|
||||
mNormalImposterPath = StringTable->EmptyString();
|
||||
|
||||
|
||||
mLoadedState = AssetErrCode::NotLoaded;
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +169,12 @@ void ShapeAsset::initPersistFields()
|
|||
&setShapeFile, &getShapeFile, "Path to the shape file we want to render");
|
||||
addProtectedField("constuctorFileName", TypeAssetLooseFilePath, Offset(mConstructorFileName, ShapeAsset),
|
||||
&setShapeConstructorFile, &getShapeConstructorFile, "Path to the shape file we want to render");
|
||||
|
||||
addProtectedField("diffuseImposterFileName", TypeAssetLooseFilePath, Offset(mDiffuseImposterFileName, ShapeAsset),
|
||||
&setDiffuseImposterFile, &getDiffuseImposterFile, "Path to the diffuse imposter file we want to render");
|
||||
addProtectedField("normalImposterFileName", TypeAssetLooseFilePath, Offset(mNormalImposterFileName, ShapeAsset),
|
||||
&setNormalImposterFile, &getNormalImposterFile, "Path to the normal imposter file we want to render");
|
||||
|
||||
}
|
||||
|
||||
void ShapeAsset::setDataField(StringTableEntry slotName, StringTableEntry array, StringTableEntry value)
|
||||
|
|
@ -193,6 +206,20 @@ void ShapeAsset::initializeAsset()
|
|||
|
||||
mConstructorFilePath = getOwned() ? expandAssetFilePath(mConstructorFilePath) : mConstructorFilePath;
|
||||
|
||||
mDiffuseImposterPath = getOwned() ? expandAssetFilePath(mDiffuseImposterFileName) : mDiffuseImposterFileName;
|
||||
if (mDiffuseImposterPath == StringTable->EmptyString())
|
||||
{
|
||||
String diffusePath = String(mFilePath) + "_imposter.dds";
|
||||
mDiffuseImposterPath = StringTable->insert(diffusePath.c_str());
|
||||
}
|
||||
|
||||
mNormalImposterPath = getOwned() ? expandAssetFilePath(mNormalImposterFileName) : mNormalImposterFileName;
|
||||
if (mNormalImposterPath == StringTable->EmptyString())
|
||||
{
|
||||
String normalPath = String(mFilePath) + "_imposter_normals.dds";
|
||||
mNormalImposterPath = StringTable->insert(normalPath.c_str());
|
||||
}
|
||||
|
||||
loadShape();
|
||||
}
|
||||
|
||||
|
|
@ -232,6 +259,42 @@ void ShapeAsset::setShapeConstructorFile(const char* pShapeConstructorFile)
|
|||
refreshAsset();
|
||||
}
|
||||
|
||||
void ShapeAsset::setDiffuseImposterFile(const char* pImageFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pImageFile != NULL, "Cannot use a NULL image file.");
|
||||
|
||||
// Fetch image file.
|
||||
pImageFile = StringTable->insert(pImageFile, true);
|
||||
|
||||
// Ignore no change,
|
||||
if (pImageFile == mDiffuseImposterFileName)
|
||||
return;
|
||||
|
||||
mDiffuseImposterFileName = getOwned() ? expandAssetFilePath(pImageFile) : pImageFile;
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void ShapeAsset::setNormalImposterFile(const char* pImageFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pImageFile != NULL, "Cannot use a NULL image file.");
|
||||
|
||||
// Fetch image file.
|
||||
pImageFile = StringTable->insert(pImageFile, true);
|
||||
|
||||
// Ignore no change,
|
||||
if (pImageFile == mNormalImposterFileName)
|
||||
return;
|
||||
|
||||
mNormalImposterFileName = getOwned() ? expandAssetFilePath(pImageFile) : pImageFile;
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void ShapeAsset::_onResourceChanged(const Torque::Path &path)
|
||||
{
|
||||
if (path != Torque::Path(mFilePath) )
|
||||
|
|
@ -292,6 +355,10 @@ bool ShapeAsset::loadShape()
|
|||
return false; //if it failed to load, bail out
|
||||
}
|
||||
|
||||
mShape->setupBillboardDetails(mFilePath, mDiffuseImposterPath, mNormalImposterPath);
|
||||
|
||||
//If they exist, grab our imposters here and bind them to our shapeAsset
|
||||
|
||||
bool hasBlends = false;
|
||||
|
||||
//Now that we've successfully loaded our shape and have any materials and animations loaded
|
||||
|
|
|
|||
|
|
@ -73,6 +73,12 @@ protected:
|
|||
StringTableEntry mConstructorFilePath;
|
||||
Resource<TSShape> mShape;
|
||||
|
||||
StringTableEntry mDiffuseImposterFileName;
|
||||
StringTableEntry mDiffuseImposterPath;
|
||||
|
||||
StringTableEntry mNormalImposterFileName;
|
||||
StringTableEntry mNormalImposterPath;
|
||||
|
||||
//Material assets we're dependent on and use
|
||||
Vector<StringTableEntry> mMaterialAssetIds;
|
||||
Vector<AssetPtr<MaterialAsset>> mMaterialAssets;
|
||||
|
|
@ -170,6 +176,15 @@ public:
|
|||
inline StringTableEntry getShapeFilePath(void) const { return mFilePath; };
|
||||
inline StringTableEntry getShapeConstructorFilePath(void) const { return mConstructorFilePath; };
|
||||
|
||||
//Imposter images
|
||||
void setDiffuseImposterFile(const char* pImageFile);
|
||||
inline StringTableEntry getDiffuseImposterFile(void) const { return mDiffuseImposterFileName; };
|
||||
inline StringTableEntry getDiffuseImposterFilePath(void) const { return mDiffuseImposterPath; };
|
||||
|
||||
void setNormalImposterFile(const char* pImageFile);
|
||||
inline StringTableEntry getNormalImposterFile(void) const { return mNormalImposterFileName; };
|
||||
inline StringTableEntry getNormalImposterFilePath(void) const { return mNormalImposterPath; };
|
||||
|
||||
static U32 getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
|
||||
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
||||
|
|
@ -188,6 +203,10 @@ protected:
|
|||
static bool setShapeConstructorFile(void* obj, const char* index, const char* data) { static_cast<ShapeAsset*>(obj)->setShapeConstructorFile(data); return false; }
|
||||
static const char* getShapeConstructorFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getShapeConstructorFile(); }
|
||||
|
||||
static bool setDiffuseImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setDiffuseImposterFile(data); return false; }
|
||||
static const char* getDiffuseImposterFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getDiffuseImposterFile(); }
|
||||
static bool setNormalImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setNormalImposterFile(data); return false; }
|
||||
static const char* getNormalImposterFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getNormalImposterFile(); }
|
||||
};
|
||||
|
||||
#ifdef TORQUE_TOOLS
|
||||
|
|
|
|||
|
|
@ -3062,6 +3062,15 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
|
|||
}
|
||||
}
|
||||
|
||||
if (Con::getBoolVariable("$TSLastDetail::dumpImposters", false))
|
||||
{
|
||||
String imposterPath = assetItem->assetName + "_imposter.png";
|
||||
String normalsPath = assetItem->assetName + "_imposter_normals.png";
|
||||
|
||||
newAsset->setDiffuseImposterFile(imposterPath.c_str());
|
||||
newAsset->setNormalImposterFile(normalsPath.c_str());
|
||||
}
|
||||
|
||||
Taml tamlWriter;
|
||||
bool importSuccessful = tamlWriter.write(newAsset, tamlPath.c_str());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue