mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-09 07:20: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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue