mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Updates macromagic to properly set up for init'ing when image assets are set in material and terrain materials
This commit is contained in:
parent
8e4edc3545
commit
f0068c2435
6 changed files with 569 additions and 8 deletions
|
|
@ -84,6 +84,34 @@ ConsoleSetType(TypeImageAssetPtr)
|
||||||
Con::warnf("(TypeImageAssetPtr) - Cannot set multiple args to a single asset.");
|
Con::warnf("(TypeImageAssetPtr) - Cannot set multiple args to a single asset.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConsoleType(assetIdString, TypeImageAssetId, String, ASSET_ID_FIELD_PREFIX)
|
||||||
|
|
||||||
|
ConsoleGetType(TypeImageAssetId)
|
||||||
|
{
|
||||||
|
// Fetch asset Id.
|
||||||
|
return *((const char**)(dptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleSetType(TypeImageAssetId)
|
||||||
|
{
|
||||||
|
// Was a single argument specified?
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
// Yes, so fetch field value.
|
||||||
|
const char* pFieldValue = argv[0];
|
||||||
|
|
||||||
|
// Fetch asset Id.
|
||||||
|
StringTableEntry* assetId = (StringTableEntry*)(dptr);
|
||||||
|
|
||||||
|
// Update asset value.
|
||||||
|
*assetId = StringTable->insert(pFieldValue);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn.
|
||||||
|
Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset.");
|
||||||
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ImplementEnumType(ImageAssetType,
|
ImplementEnumType(ImageAssetType,
|
||||||
|
|
@ -222,6 +250,22 @@ StringTableEntry ImageAsset::getAssetIdByFilename(StringTableEntry fileName)
|
||||||
return imageAssetId;
|
return imageAssetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImageAsset::getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* imageAsset)
|
||||||
|
{
|
||||||
|
(*imageAsset) = assetId;
|
||||||
|
|
||||||
|
if (!imageAsset->isNull())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//Didn't work, so have us fall back to a placeholder asset
|
||||||
|
StringTableEntry noImageId = StringTable->insert("Core_Rendering:noMaterial");
|
||||||
|
imageAsset->setAssetId(noImageId);
|
||||||
|
|
||||||
|
if (!imageAsset->isNull())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void ImageAsset::copyTo(SimObject* object)
|
void ImageAsset::copyTo(SimObject* object)
|
||||||
{
|
{
|
||||||
|
|
@ -233,15 +277,15 @@ void ImageAsset::loadImage()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(mImage);
|
SAFE_DELETE(mImage);
|
||||||
|
|
||||||
if (mImageFileName)
|
if (mImagePath)
|
||||||
{
|
{
|
||||||
if (!Platform::isFile(mImageFileName))
|
if (!Platform::isFile(mImagePath))
|
||||||
{
|
{
|
||||||
Con::errorf("ImageAsset::initializeAsset: Attempted to load file %s but it was not valid!", mImageFileName);
|
Con::errorf("ImageAsset::initializeAsset: Attempted to load file %s but it was not valid!", mImageFileName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mImage.set(mImageFileName, &GFXStaticTextureSRGBProfile, avar("%s() - mImage (line %d)", __FUNCTION__, __LINE__));
|
mImage.set(mImagePath, &GFXStaticTextureSRGBProfile, avar("%s() - mImage (line %d)", __FUNCTION__, __LINE__));
|
||||||
|
|
||||||
if (mImage)
|
if (mImage)
|
||||||
{
|
{
|
||||||
|
|
@ -292,6 +336,9 @@ GFXTexHandle ImageAsset::getImage(GFXTextureProfile requestedProfile)
|
||||||
return newImage;
|
return newImage;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
if (mImage.isValid())
|
||||||
|
return mImage;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,3 +413,100 @@ DefineEngineMethod(ImageAsset, getImageInfo, const char*, (), ,
|
||||||
{
|
{
|
||||||
return object->getImageInfo();
|
return object->getImageInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// GuiInspectorTypeAssetId
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_CONOBJECT(GuiInspectorTypeImageAssetPtr);
|
||||||
|
|
||||||
|
ConsoleDocClass(GuiInspectorTypeImageAssetPtr,
|
||||||
|
"@brief Inspector field type for Shapes\n\n"
|
||||||
|
"Editor use only.\n\n"
|
||||||
|
"@internal"
|
||||||
|
);
|
||||||
|
|
||||||
|
void GuiInspectorTypeImageAssetPtr::consoleInit()
|
||||||
|
{
|
||||||
|
Parent::consoleInit();
|
||||||
|
|
||||||
|
ConsoleBaseType::getType(TypeImageAssetPtr)->setInspectorFieldType("GuiInspectorTypeImageAssetPtr");
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiControl* GuiInspectorTypeImageAssetPtr::constructEditControl()
|
||||||
|
{
|
||||||
|
// Create base filename edit controls
|
||||||
|
GuiControl* retCtrl = Parent::constructEditControl();
|
||||||
|
if (retCtrl == NULL)
|
||||||
|
return retCtrl;
|
||||||
|
|
||||||
|
// Change filespec
|
||||||
|
char szBuffer[512];
|
||||||
|
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"ImageAsset\", \"AssetBrowser.changeAsset\", %s, %s);",
|
||||||
|
mInspector->getInspectObject()->getIdString(), mCaption);
|
||||||
|
mBrowseButton->setField("Command", szBuffer);
|
||||||
|
|
||||||
|
const char* id = mInspector->getInspectObject()->getIdString();
|
||||||
|
|
||||||
|
setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString());
|
||||||
|
|
||||||
|
// Create "Open in ShapeEditor" button
|
||||||
|
mImageEdButton = new GuiBitmapButtonCtrl();
|
||||||
|
|
||||||
|
dSprintf(szBuffer, sizeof(szBuffer), "ShapeEditorPlugin.openShapeAssetId(%d.getText());", retCtrl->getId());
|
||||||
|
mImageEdButton->setField("Command", szBuffer);
|
||||||
|
|
||||||
|
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
|
||||||
|
mImageEdButton->setBitmap(bitmapName);
|
||||||
|
|
||||||
|
mImageEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||||
|
mImageEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||||
|
mImageEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
||||||
|
mImageEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the Shape Editor");
|
||||||
|
|
||||||
|
mImageEdButton->registerObject();
|
||||||
|
addObject(mImageEdButton);
|
||||||
|
|
||||||
|
return retCtrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GuiInspectorTypeImageAssetPtr::updateRects()
|
||||||
|
{
|
||||||
|
S32 dividerPos, dividerMargin;
|
||||||
|
mInspector->getDivider(dividerPos, dividerMargin);
|
||||||
|
Point2I fieldExtent = getExtent();
|
||||||
|
Point2I fieldPos = getPosition();
|
||||||
|
|
||||||
|
mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
|
||||||
|
mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
|
||||||
|
|
||||||
|
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||||
|
if (mBrowseButton != NULL)
|
||||||
|
{
|
||||||
|
mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
|
||||||
|
resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mImageEdButton != NULL)
|
||||||
|
{
|
||||||
|
RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
|
||||||
|
resized |= mImageEdButton->resize(shapeEdRect.point, shapeEdRect.extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resized;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLEMENT_CONOBJECT(GuiInspectorTypeImageAssetId);
|
||||||
|
|
||||||
|
ConsoleDocClass(GuiInspectorTypeImageAssetId,
|
||||||
|
"@brief Inspector field type for Shapes\n\n"
|
||||||
|
"Editor use only.\n\n"
|
||||||
|
"@internal"
|
||||||
|
);
|
||||||
|
|
||||||
|
void GuiInspectorTypeImageAssetId::consoleInit()
|
||||||
|
{
|
||||||
|
Parent::consoleInit();
|
||||||
|
|
||||||
|
ConsoleBaseType::getType(TypeImageAssetId)->setInspectorFieldType("GuiInspectorTypeImageAssetId");
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@
|
||||||
#include "gfx/bitmap/gBitmap.h"
|
#include "gfx/bitmap/gBitmap.h"
|
||||||
#include "gfx/gfxTextureHandle.h"
|
#include "gfx/gfxTextureHandle.h"
|
||||||
|
|
||||||
|
#include "gui/editor/guiInspectorTypes.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
class ImageAsset : public AssetBase
|
class ImageAsset : public AssetBase
|
||||||
{
|
{
|
||||||
|
|
@ -109,36 +111,61 @@ public:
|
||||||
|
|
||||||
void setImageType(ImageTypes type) { mImageType = type; }
|
void setImageType(ImageTypes type) { mImageType = type; }
|
||||||
|
|
||||||
bool getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsset>* imageAsset);
|
static bool getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsset>* imageAsset);
|
||||||
StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
||||||
|
static bool getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* imageAsset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initializeAsset(void);
|
virtual void initializeAsset(void);
|
||||||
virtual void onAssetRefresh(void);
|
virtual void onAssetRefresh(void);
|
||||||
|
|
||||||
static bool setImageFileName(void *obj, const char *index, const char *data) { static_cast<ImageAsset*>(obj)->setImageFileName(data); return false; }
|
static bool setImageFileName(void* obj, const char* index, const char* data) { static_cast<ImageAsset*>(obj)->setImageFileName(data); return false; }
|
||||||
static const char* getImageFileName(void* obj, const char* data) { return static_cast<ImageAsset*>(obj)->getImageFileName(); }
|
static const char* getImageFileName(void* obj, const char* data) { return static_cast<ImageAsset*>(obj)->getImageFileName(); }
|
||||||
|
|
||||||
void loadImage();
|
void loadImage();
|
||||||
};
|
};
|
||||||
|
|
||||||
DefineConsoleType(TypeImageAssetPtr, ImageAsset)
|
DefineConsoleType(TypeImageAssetPtr, ImageAsset)
|
||||||
|
DefineConsoleType(TypeImageAssetId, String)
|
||||||
|
|
||||||
typedef ImageAsset::ImageTypes ImageAssetType;
|
typedef ImageAsset::ImageTypes ImageAssetType;
|
||||||
DefineEnumType(ImageAssetType);
|
DefineEnumType(ImageAssetType);
|
||||||
|
|
||||||
|
class GuiInspectorTypeImageAssetPtr : public GuiInspectorTypeFileName
|
||||||
|
{
|
||||||
|
typedef GuiInspectorTypeFileName Parent;
|
||||||
|
public:
|
||||||
|
|
||||||
|
GuiBitmapButtonCtrl* mImageEdButton;
|
||||||
|
|
||||||
|
DECLARE_CONOBJECT(GuiInspectorTypeImageAssetPtr);
|
||||||
|
static void consoleInit();
|
||||||
|
|
||||||
|
virtual GuiControl* constructEditControl();
|
||||||
|
virtual bool updateRects();
|
||||||
|
};
|
||||||
|
|
||||||
|
class GuiInspectorTypeImageAssetId : public GuiInspectorTypeImageAssetPtr
|
||||||
|
{
|
||||||
|
typedef GuiInspectorTypeImageAssetPtr Parent;
|
||||||
|
public:
|
||||||
|
|
||||||
|
DECLARE_CONOBJECT(GuiInspectorTypeImageAssetId);
|
||||||
|
static void consoleInit();
|
||||||
|
};
|
||||||
|
|
||||||
#define assetText(x,suff) std::string(std::string(#x) + std::string(#suff)).c_str()
|
#define assetText(x,suff) std::string(std::string(#x) + std::string(#suff)).c_str()
|
||||||
|
|
||||||
#define initMapSlot(name) m##name##Filename = String::EmptyString; m##name##AssetId = StringTable->EmptyString(); m##name##Asset = NULL;
|
#define initMapSlot(name) m##name##Filename = String::EmptyString; m##name##AssetId = StringTable->EmptyString(); m##name##Asset = NULL;
|
||||||
#define bindMapSlot(name) if (m##name##AssetId != String::EmptyString) m##name##Asset = m##name##AssetId;
|
#define bindMapSlot(name) if (m##name##AssetId != String::EmptyString) m##name##Asset = m##name##AssetId;
|
||||||
|
|
||||||
#define scriptBindMapSlot(name, consoleClass, docs) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), assetText(name, docs)); \
|
#define scriptBindMapSlot(name, consoleClass, docs) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), assetText(name, docs)); \
|
||||||
addField(assetText(name,Asset), TypeImageAssetPtr, Offset(m##name##AssetId, consoleClass), assetText(name,asset reference.));
|
addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), consoleClass::_set##name##Asset, & defaultProtectedGetFn, assetText(name, asset reference.));
|
||||||
|
|
||||||
#define initMapArraySlot(name,id) m##name##Filename[id] = String::EmptyString; m##name##AssetId[id] = StringTable->EmptyString(); m##name##Asset[id] = NULL;
|
#define initMapArraySlot(name,id) m##name##Filename[id] = String::EmptyString; m##name##AssetId[id] = StringTable->EmptyString(); m##name##Asset[id] = NULL;
|
||||||
#define bindMapArraySlot(name,id) if (m##name##AssetId[id] != String::EmptyString) m##name##Asset[id] = m##name##AssetId[id];
|
#define bindMapArraySlot(name,id) if (m##name##AssetId[id] != String::EmptyString) m##name##Asset[id] = m##name##AssetId[id];
|
||||||
#define scriptBindMapArraySlot(name, arraySize, consoleClass, docs) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), arraySize, assetText(name, docs)); \
|
#define scriptBindMapArraySlot(name, arraySize, consoleClass, docs) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), arraySize, assetText(name, docs)); \
|
||||||
addField(assetText(name,Asset), TypeImageAssetPtr, Offset(m##name##AssetId, consoleClass), arraySize, assetText(name,asset reference.));
|
addProtectedField(assetText(name,Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), consoleClass::_set##name##Asset, &defaultProtectedGetFn, arraySize, assetText(name,asset reference.));
|
||||||
|
|
||||||
#define DECLARE_TEXTUREMAP(name) protected: \
|
#define DECLARE_TEXTUREMAP(name) protected: \
|
||||||
FileName m##name##Filename;\
|
FileName m##name##Filename;\
|
||||||
|
|
|
||||||
|
|
@ -502,6 +502,282 @@ void Material::initPersistFields()
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Material::_setDiffuseMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mDiffuseMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mDiffuseMapAssetId[idx], &mat->mDiffuseMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mDiffuseMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mDiffuseMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setOverlayMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mOverlayMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mOverlayMapAssetId[idx], &mat->mOverlayMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mOverlayMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mOverlayMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setLightMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mLightMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mLightMapAssetId[idx], &mat->mLightMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mLightMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mLightMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setToneMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mToneMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mToneMapAssetId[idx], &mat->mToneMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mToneMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mToneMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setDetailMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mDetailMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mDetailMapAssetId[idx], &mat->mDetailMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mDetailMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mDetailMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setNormalMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mNormalMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mNormalMapAssetId[idx], &mat->mNormalMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mNormalMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mNormalMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setORMConfigMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mORMConfigMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mORMConfigMapAssetId[idx], &mat->mORMConfigMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mORMConfigMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mORMConfigMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setRoughMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mRoughMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mRoughMapAssetId[idx], &mat->mRoughMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mRoughMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mRoughMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setAOMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mAOMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mAOMapAssetId[idx], &mat->mAOMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mAOMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mAOMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setMetalMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mMetalMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mMetalMapAssetId[idx], &mat->mMetalMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mMetalMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mMetalMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setGlowMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mGlowMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mGlowMapAssetId[idx], &mat->mGlowMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mGlowMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mGlowMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Material::_setDetailNormalMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
Material* mat = static_cast<Material*>(obj);
|
||||||
|
|
||||||
|
U32 idx = dAtoi(index);
|
||||||
|
if (idx >= MAX_STAGES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mat->mDetailNormalMapAssetId[idx] = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mDetailNormalMapAssetId[idx], &mat->mDetailNormalMapAsset[idx]))
|
||||||
|
{
|
||||||
|
if (mat->mDetailNormalMapAsset[idx].getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mDetailNormalMapFilename[idx] = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Material::writeField( StringTableEntry fieldname, const char *value )
|
bool Material::writeField( StringTableEntry fieldname, const char *value )
|
||||||
{
|
{
|
||||||
// Never allow the old field names to be written.
|
// Never allow the old field names to be written.
|
||||||
|
|
|
||||||
|
|
@ -412,6 +412,19 @@ protected:
|
||||||
/// in the "mapTo" data variable.
|
/// in the "mapTo" data variable.
|
||||||
virtual void _mapMaterial();
|
virtual void _mapMaterial();
|
||||||
|
|
||||||
|
static bool _setDiffuseMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setOverlayMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setLightMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setToneMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setDetailMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setNormalMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setORMConfigMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setRoughMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setAOMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setMetalMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setGlowMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setDetailNormalMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static GFXCubemapHandle smNormalizeCube;
|
static GFXCubemapHandle smNormalizeCube;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,101 @@ void TerrainMaterial::initPersistFields()
|
||||||
Sim::getTerrainMaterialSet();
|
Sim::getTerrainMaterialSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TerrainMaterial::_setDiffuseMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
TerrainMaterial* mat = static_cast<TerrainMaterial*>(obj);
|
||||||
|
|
||||||
|
mat->mDiffuseMapAssetId = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mDiffuseMapAssetId, &mat->mDiffuseMapAsset))
|
||||||
|
{
|
||||||
|
if (mat->mDiffuseMapAsset.getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mDiffuseMapFilename = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerrainMaterial::_setNormalMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
TerrainMaterial* mat = static_cast<TerrainMaterial*>(obj);
|
||||||
|
|
||||||
|
mat->mNormalMapAssetId = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mNormalMapAssetId, &mat->mNormalMapAsset))
|
||||||
|
{
|
||||||
|
if (mat->mNormalMapAsset.getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mNormalMapFilename = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerrainMaterial::_setDetailMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
TerrainMaterial* mat = static_cast<TerrainMaterial*>(obj);
|
||||||
|
|
||||||
|
mat->mDetailMapAssetId = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mDetailMapAssetId, &mat->mDetailMapAsset))
|
||||||
|
{
|
||||||
|
if (mat->mDetailMapAsset.getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mDetailMapFilename = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerrainMaterial::_setORMConfigMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
TerrainMaterial* mat = static_cast<TerrainMaterial*>(obj);
|
||||||
|
|
||||||
|
mat->mORMConfigMapAssetId = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mORMConfigMapAssetId, &mat->mORMConfigMapAsset))
|
||||||
|
{
|
||||||
|
if (mat->mORMConfigMapAsset.getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mORMConfigMapFilename = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerrainMaterial::_setMacroMapAsset(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
TerrainMaterial* mat = static_cast<TerrainMaterial*>(obj);
|
||||||
|
|
||||||
|
mat->mMacroMapAssetId = StringTable->insert(data);
|
||||||
|
|
||||||
|
if (ImageAsset::getAssetById(mat->mMacroMapAssetId, &mat->mMacroMapAsset))
|
||||||
|
{
|
||||||
|
if (mat->mMacroMapAsset.getAssetId() != StringTable->insert("Core_Rendering:noMaterial"))
|
||||||
|
{
|
||||||
|
mat->mMacroMapFilename = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool TerrainMaterial::onAdd()
|
bool TerrainMaterial::onAdd()
|
||||||
{
|
{
|
||||||
if ( !Parent::onAdd() )
|
if ( !Parent::onAdd() )
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,12 @@ public:
|
||||||
bool onAdd();
|
bool onAdd();
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
|
|
||||||
|
static bool _setDiffuseMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setNormalMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setDetailMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setORMConfigMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
static bool _setMacroMapAsset(void* obj, const char* index, const char* data);
|
||||||
|
|
||||||
DECLARE_CONOBJECT( TerrainMaterial );
|
DECLARE_CONOBJECT( TerrainMaterial );
|
||||||
|
|
||||||
/// This method locates the TerrainMaterial if it exists, tries
|
/// This method locates the TerrainMaterial if it exists, tries
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue