Updates ImageAsset usage to utilize AssetRef, and standardizes the setter/getter functions and naming conventions, as well as the ability to use and bind named targets.

This commit is contained in:
JeffR 2026-06-16 17:39:30 -05:00
parent a858d8624e
commit 34e3f78a22
82 changed files with 1451 additions and 951 deletions

View file

@ -181,14 +181,14 @@ void AssimpAppMaterial::initMaterial(const Torque::Path& path, Material* mat) co
{
torquePath = texName.C_Str();
if (!torquePath.isEmpty())
mat->_setDiffuseMap(cleanTextureName(torquePath, cleanFile, path, false), 0);
mat->setDiffuseMap(cleanTextureName(torquePath, cleanFile, path, false), 0);
}
if (AI_SUCCESS == mAIMat->Get(AI_MATKEY_TEXTURE(aiTextureType_NORMALS, 0), texName))
{
torquePath = texName.C_Str();
if (!torquePath.isEmpty())
mat->_setNormalMap(cleanTextureName(torquePath, cleanFile, path, false), 0);
mat->setNormalMap(cleanTextureName(torquePath, cleanFile, path, false), 0);
}
#ifdef TORQUE_PBR_MATERIALS
@ -205,20 +205,20 @@ void AssimpAppMaterial::initMaterial(const Torque::Path& path, Material* mat) co
{ // If we have either map, fill all three slots
if (rmName.isNotEmpty())
{
mat->_setRoughMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Roughness
mat->setRoughMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Roughness
mat->mRoughnessChan[0] = 1;
mat->mInvertRoughness[0] = false;
mat->_setMetalMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Metallic
mat->setMetalMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Metallic
mat->mMetalChan[0] = 2;
}
if (aoName.isNotEmpty())
{
mat->_setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion
mat->setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion
mat->mAOChan[0] = 0;
}
else
{
mat->_setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion
mat->setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion
mat->mAOChan[0] = 0.0f;
}
}

View file

@ -208,8 +208,8 @@ Material *ColladaAppMaterial::createMaterial(const Torque::Path& path) const
Material *newMat = MATMGR->allocateAndRegister( cleanName, getName() );
Con::setVariable("$Con::File", oldScriptFile); // restore script path
newMat->_setDiffuseMap(diffuseMap, 0);
newMat->_setNormalMap(normalMap, 0);
newMat->setDiffuseMap(diffuseMap, 0);
newMat->setNormalMap(normalMap, 0);
newMat->mDiffuse[0] = diffuseColor;
newMat->mRoughness[0] = roughness;

View file

@ -1030,7 +1030,7 @@ void ColladaUtils::exportColladaMaterials(tinyxml2::XMLElement* rootNode, const
{
Torque::Path diffusePath;
if (mat->getDiffuseMap(0))
if (mat->getDiffuseMapAsset(0).notNull())
diffusePath = Torque::Path(mat->getDiffuseMapAsset(0)->getImageFile());
else
diffusePath = String("warningMat");
@ -1040,7 +1040,7 @@ void ColladaUtils::exportColladaMaterials(tinyxml2::XMLElement* rootNode, const
}
else
{
if (mat->getDiffuseMap(0))
if (mat->getDiffuseMapAsset(0).notNull())
diffuseMap += Torque::Path(mat->getDiffuseMapAsset(0)->getImageFile());
else
diffuseMap += "warningMat";
@ -1316,7 +1316,7 @@ void ColladaUtils::exportColladaMaterials(tinyxml2::XMLElement* rootNode, const
{
Torque::Path diffusePath;
if (mat->getDiffuseMap(0))
if (mat->getDiffuseMapAsset(0).notNull())
diffusePath = Torque::Path(mat->getDiffuseMapAsset(0)->getImageFile());
else
diffusePath = String("warningMat");
@ -1326,7 +1326,7 @@ void ColladaUtils::exportColladaMaterials(tinyxml2::XMLElement* rootNode, const
}
else
{
if (mat->getDiffuseMap(0))
if (mat->getDiffuseMapAsset(0).notNull())
diffuseMap += Torque::Path(mat->getDiffuseMapAsset(0)->getImageFile());
else
diffuseMap += "warningMat";

View file

@ -188,6 +188,11 @@ void TSLastDetail::render( const TSRenderState &rdata, F32 alpha )
renderPass->addInst( ri );
}
StringTableEntry TSLastDetail::_getImposterAssetId( const String &filePath )
{
return ImageAsset::getAssetIdFromFilePath( StringTable->insert( filePath.c_str() ) );
}
void TSLastDetail::update( bool forceUpdate )
{
// This should never be called on a dedicated server or
@ -252,8 +257,8 @@ void TSLastDetail::update( bool forceUpdate )
// Setup the material for this imposter.
mMaterial = MATMGR->allocateAndRegister( String::EmptyString );
mMaterial->mAutoGenerated = true;
mMaterial->_setDiffuseMap(diffuseMapPath, 0);
mMaterial->_setNormalMap(_getNormalMapPath(), 0);
mMaterial->setDiffuseMap(_getImposterAssetId(diffuseMapPath), 0);
mMaterial->setNormalMap(_getImposterAssetId(_getNormalMapPath()), 0);
mMaterial->mImposterLimits.set( (mNumPolarSteps * 2) + 1, mNumEquatorSteps, mPolarAngle, mIncludePoles );
mMaterial->mTranslucent = true;

View file

@ -156,6 +156,10 @@ protected:
/// Helper which returns the imposter normal map path.
String _getNormalMapPath() const { return mNormalPath; }
/// Helper which returns the assetId associated to the imposter file,
/// generating a private one if required for generated imposters
static StringTableEntry _getImposterAssetId( const String &filePath );
public:
TSLastDetail( TSShape *shape,