mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Merge pull request #1343 from marauder2k9-torque/imageAsset_refactor_rev3
Image Asset Refactor - For 4.2
This commit is contained in:
commit
5aa67f680f
133 changed files with 1717 additions and 2001 deletions
|
|
@ -83,24 +83,17 @@ AccumulationVolume::AccumulationVolume()
|
||||||
mObjToWorld.identity();
|
mObjToWorld.identity();
|
||||||
mWorldToObj.identity();
|
mWorldToObj.identity();
|
||||||
|
|
||||||
// Accumulation Texture.
|
|
||||||
INIT_ASSET(Texture);
|
|
||||||
|
|
||||||
resetWorldBox();
|
resetWorldBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccumulationVolume::~AccumulationVolume()
|
AccumulationVolume::~AccumulationVolume()
|
||||||
{
|
{
|
||||||
mTexture = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccumulationVolume::initPersistFields()
|
void AccumulationVolume::initPersistFields()
|
||||||
{
|
{
|
||||||
docsURL;
|
docsURL;
|
||||||
addProtectedField("textureAsset", TypeImageAssetId, Offset(mTextureAssetId, AccumulationVolume),
|
INITPERSISTFIELD_IMAGEASSET(Texture, AccumulationVolume, "Accumulation texture.")
|
||||||
&_setTexture, &defaultProtectedGetFn, "Accumulation texture.");
|
|
||||||
addProtectedField( "texture", TypeStringFilename, Offset( mTextureName, AccumulationVolume ),
|
|
||||||
&_setTexture, &defaultProtectedGetFn, "Accumulation texture." );
|
|
||||||
|
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
}
|
}
|
||||||
|
|
@ -236,7 +229,7 @@ U32 AccumulationVolume::packUpdate( NetConnection *connection, U32 mask, BitStre
|
||||||
|
|
||||||
if (stream->writeFlag(mask & InitialUpdateMask))
|
if (stream->writeFlag(mask & InitialUpdateMask))
|
||||||
{
|
{
|
||||||
PACK_ASSET(connection, Texture);
|
PACK_ASSET_REFACTOR(connection, Texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retMask;
|
return retMask;
|
||||||
|
|
@ -248,7 +241,7 @@ void AccumulationVolume::unpackUpdate( NetConnection *connection, BitStream *str
|
||||||
|
|
||||||
if (stream->readFlag())
|
if (stream->readFlag())
|
||||||
{
|
{
|
||||||
UNPACK_ASSET(connection, Texture);
|
UNPACK_ASSET_REFACTOR(connection, Texture);
|
||||||
//setTexture(mTextureName);
|
//setTexture(mTextureName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -307,7 +300,7 @@ void AccumulationVolume::refreshVolumes()
|
||||||
if ( object.isNull() ) continue;
|
if ( object.isNull() ) continue;
|
||||||
|
|
||||||
if ( volume->containsPoint(object->getPosition()) )
|
if ( volume->containsPoint(object->getPosition()) )
|
||||||
object->mAccuTex = volume->getTextureResource();
|
object->mAccuTex = volume->getTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -341,6 +334,6 @@ void AccumulationVolume::updateObject(SceneObject* object)
|
||||||
if ( volume.isNull() ) continue;
|
if ( volume.isNull() ) continue;
|
||||||
|
|
||||||
if ( volume->containsPoint(object->getPosition()) )
|
if ( volume->containsPoint(object->getPosition()) )
|
||||||
object->mAccuTex = volume->getTextureResource();
|
object->mAccuTex = volume->getTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,7 @@ class AccumulationVolume : public ScenePolyhedralSpace
|
||||||
// SceneSpace.
|
// SceneSpace.
|
||||||
void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ) override;
|
void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ) override;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(AccumulationVolume, Texture, onTextureChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET_NET(AccumulationVolume, Texture, GFXStaticTextureSRGBProfile, -1)
|
||||||
DECLARE_ASSET_NET_SETGET(AccumulationVolume, Texture, -1);
|
|
||||||
|
|
||||||
void onTextureChanged() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,34 +49,65 @@
|
||||||
|
|
||||||
#include "T3D/assets/assetImporter.h"
|
#include "T3D/assets/assetImporter.h"
|
||||||
#include "gfx/gfxDrawUtil.h"
|
#include "gfx/gfxDrawUtil.h"
|
||||||
|
#include "gfx/bitmap/ddsFile.h"
|
||||||
|
#ifdef __clang__
|
||||||
|
#define STBIWDEF static inline
|
||||||
|
#endif
|
||||||
|
#pragma warning( push )
|
||||||
|
#pragma warning( disable : 4505 ) // unreferenced function removed.
|
||||||
|
#ifndef STB_IMAGE_IMPLEMENTATION
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#define STB_IMAGE_STATIC
|
||||||
|
#include "stb_image.h"
|
||||||
|
#endif
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
StringTableEntry ImageAsset::smNoImageAssetFallback = NULL;
|
StringTableEntry ImageAsset::smNoImageAssetFallback = NULL;
|
||||||
|
StringTableEntry ImageAsset::smNamedTargetAssetFallback = NULL;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(ImageAsset);
|
IMPLEMENT_CONOBJECT(ImageAsset);
|
||||||
|
|
||||||
ConsoleType(ImageAssetPtr, TypeImageAssetPtr, const char*, "")
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
// REFACTOR
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_STRUCT(AssetPtr<ImageAsset>, AssetPtrImageAsset,, "")
|
||||||
|
END_IMPLEMENT_STRUCT
|
||||||
|
|
||||||
|
ConsoleType(ImageAssetPtr, TypeImageAssetPtr, AssetPtr<ImageAsset>, ASSET_ID_FIELD_PREFIX)
|
||||||
|
|
||||||
|
|
||||||
ConsoleGetType(TypeImageAssetPtr)
|
ConsoleGetType(TypeImageAssetPtr)
|
||||||
{
|
{
|
||||||
// Fetch asset Id.
|
// Fetch asset Id.
|
||||||
return *((const char**)(dptr));
|
return (*((AssetPtr<ImageAsset>*)dptr)).getAssetId();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ConsoleSetType(TypeImageAssetPtr)
|
ConsoleSetType(TypeImageAssetPtr)
|
||||||
{
|
{
|
||||||
// Was a single argument specified?
|
// Was a single argument specified?
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
// Yes, so fetch field value.
|
// Yes, so fetch field value.
|
||||||
*((const char**)dptr) = StringTable->insert(argv[0]);
|
const char* pFieldValue = argv[0];
|
||||||
|
|
||||||
|
// Fetch asset pointer.
|
||||||
|
AssetPtr<ImageAsset>* pAssetPtr = dynamic_cast<AssetPtr<ImageAsset>*>((AssetPtrBase*)(dptr));
|
||||||
|
|
||||||
|
// Is the asset pointer the correct type?
|
||||||
|
if (pAssetPtr == NULL)
|
||||||
|
{
|
||||||
|
Con::warnf("(TypeImageAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set asset.
|
||||||
|
pAssetPtr->setAssetId(pFieldValue);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -85,27 +116,8 @@ 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, const char*, "")
|
//-----------------------------------------------------------------------------
|
||||||
|
// REFACTOR END
|
||||||
ConsoleGetType(TypeImageAssetId)
|
|
||||||
{
|
|
||||||
// Fetch asset Id.
|
|
||||||
return *((const char**)(dptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
ConsoleSetType(TypeImageAssetId)
|
|
||||||
{
|
|
||||||
// Was a single argument specified?
|
|
||||||
if (argc == 1)
|
|
||||||
{
|
|
||||||
*((const char**)dptr) = StringTable->insert(argv[0]);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warn.
|
|
||||||
Con::warnf("(TypeImageAssetId) - Cannot set multiple args to a single asset.");
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ImplementEnumType(ImageAssetType,
|
ImplementEnumType(ImageAssetType,
|
||||||
|
|
@ -131,12 +143,20 @@ const String ImageAsset::mErrCodeStrings[] =
|
||||||
"UnKnown"
|
"UnKnown"
|
||||||
};
|
};
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
ImageAsset::ImageAsset() : AssetBase(), mIsValidImage(false), mUseMips(true), mIsHDRImage(false), mImageType(Albedo)
|
|
||||||
|
ImageAsset::ImageAsset() :
|
||||||
|
mImageFile(StringTable->EmptyString()),
|
||||||
|
mUseMips(true),
|
||||||
|
mIsHDRImage(false),
|
||||||
|
mImageType(Albedo),
|
||||||
|
mTextureHandle(NULL),
|
||||||
|
mIsNamedTarget(false),
|
||||||
|
mImageWidth(-1),
|
||||||
|
mImageHeight(-1),
|
||||||
|
mImageDepth(-1),
|
||||||
|
mImageChannels(-1)
|
||||||
{
|
{
|
||||||
mImageFileName = StringTable->EmptyString();
|
|
||||||
mImagePath = StringTable->EmptyString();
|
|
||||||
mLoadedState = AssetErrCode::NotLoaded;
|
mLoadedState = AssetErrCode::NotLoaded;
|
||||||
mChangeSignal.notify(this, &ImageAsset::onAssetRefresh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -153,7 +173,12 @@ void ImageAsset::consoleInit()
|
||||||
"The assetId of the texture to display when the requested image asset is missing.\n"
|
"The assetId of the texture to display when the requested image asset is missing.\n"
|
||||||
"@ingroup GFX\n");
|
"@ingroup GFX\n");
|
||||||
|
|
||||||
|
Con::addVariable("$Core::NamedTargetFallback", TypeString, &smNamedTargetAssetFallback,
|
||||||
|
"The assetId of the texture to display when the requested image asset is named target.\n"
|
||||||
|
"@ingroup GFX\n");
|
||||||
|
|
||||||
smNoImageAssetFallback = StringTable->insert(Con::getVariable("$Core::NoImageAssetFallback"));
|
smNoImageAssetFallback = StringTable->insert(Con::getVariable("$Core::NoImageAssetFallback"));
|
||||||
|
smNamedTargetAssetFallback = StringTable->insert(Con::getVariable("$Core::NamedTargetFallback"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -164,17 +189,28 @@ void ImageAsset::initPersistFields()
|
||||||
// Call parent.
|
// Call parent.
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
|
|
||||||
addProtectedField("imageFile", TypeAssetLooseFilePath, Offset(mImageFileName, ImageAsset),
|
addProtectedField("imageFile", TypeAssetLooseFilePath, Offset(mImageFile, ImageAsset), &setImageFile, &getImageFile, &writeImageFile, "Path to the image file.");
|
||||||
&setImageFileName, &getImageFileName, "Path to the image file.");
|
|
||||||
|
|
||||||
addField("useMips", TypeBool, Offset(mUseMips, ImageAsset), "Should the image use mips? (Currently unused).");
|
addProtectedField("useMips", TypeBool, Offset(mUseMips, ImageAsset), &setGenMips, &defaultProtectedGetFn, &writeGenMips, "Generate mip maps?");
|
||||||
addField("isHDRImage", TypeBool, Offset(mIsHDRImage, ImageAsset), "Is the image in an HDR format? (Currently unused)");
|
addProtectedField("isHDRImage", TypeBool, Offset(mIsHDRImage, ImageAsset), &setTextureHDR, &defaultProtectedGetFn, &writeTextureHDR, "HDR Image?");
|
||||||
|
|
||||||
addField("imageType", TypeImageAssetType, Offset(mImageType, ImageAsset), "What the main use-case for the image is for.");
|
addField("imageType", TypeImageAssetType, Offset(mImageType, ImageAsset), "What the main use-case for the image is for.");
|
||||||
}
|
}
|
||||||
|
bool ImageAsset::onAdd()
|
||||||
|
{
|
||||||
|
// Call Parent.
|
||||||
|
if (!Parent::onAdd())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::onRemove()
|
||||||
|
{
|
||||||
|
// Call Parent.
|
||||||
|
Parent::onRemove();
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
//Utility function to 'fill out' bindings and resources with a matching asset if one exists
|
|
||||||
U32 ImageAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsset>* imageAsset)
|
U32 ImageAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsset>* imageAsset)
|
||||||
{
|
{
|
||||||
AssetQuery query;
|
AssetQuery query;
|
||||||
|
|
@ -227,7 +263,38 @@ StringTableEntry ImageAsset::getAssetIdByFilename(StringTableEntry fileName)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AssetPtr<ImageAsset> imageAsset = imageAssetId; //ensures the fallback is loaded
|
foundAssetcount = AssetDatabase.findAssetType(&query, "ImageAsset");
|
||||||
|
if (foundAssetcount != 0)
|
||||||
|
{
|
||||||
|
// loop all image assets and see if we can find one
|
||||||
|
// using the same image file/named target.
|
||||||
|
for (auto imgAsset : query.mAssetList)
|
||||||
|
{
|
||||||
|
AssetPtr<ImageAsset> temp = imgAsset;
|
||||||
|
if (temp.notNull())
|
||||||
|
{
|
||||||
|
if (temp->getImageFile() == fileName)
|
||||||
|
{
|
||||||
|
return imgAsset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Torque::Path temp1 = temp->getImageFile();
|
||||||
|
Torque::Path temp2 = fileName;
|
||||||
|
|
||||||
|
if (temp1.getFileName() == temp2.getFileName())
|
||||||
|
{
|
||||||
|
return imgAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AssetPtr<ImageAsset> imageAsset = imageAssetId; //ensures the fallback is loaded
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageAssetId;
|
return imageAssetId;
|
||||||
|
|
@ -262,168 +329,238 @@ U32 ImageAsset::getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* ima
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageAsset::initializeAsset(void)
|
||||||
|
{
|
||||||
|
// Call parent.
|
||||||
|
Parent::initializeAsset();
|
||||||
|
|
||||||
|
// Ensure the image-file is expanded.
|
||||||
|
if (isNamedTarget())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mImageFile = expandAssetFilePath(mImageFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::onAssetRefresh(void)
|
||||||
|
{
|
||||||
|
// Ignore if not yet added to the sim.
|
||||||
|
if (!isProperlyAdded())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Call parent.
|
||||||
|
Parent::onAssetRefresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void ImageAsset::copyTo(SimObject* object)
|
void ImageAsset::copyTo(SimObject* object)
|
||||||
{
|
{
|
||||||
// Call to parent.
|
// Call to parent.
|
||||||
Parent::copyTo(object);
|
Parent::copyTo(object);
|
||||||
|
|
||||||
|
ImageAsset* pAsset = static_cast<ImageAsset*>(object);
|
||||||
|
|
||||||
|
// Sanity!
|
||||||
|
AssertFatal(pAsset != NULL, "ImageAsset::copyTo() - Object is not the correct type.");
|
||||||
|
|
||||||
|
pAsset->setImageFile(getImageFile());
|
||||||
|
pAsset->setGenMips(getGenMips());
|
||||||
|
pAsset->setTextureHDR(getTextureHDR());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::setImageFile(StringTableEntry pImageFile)
|
||||||
|
{
|
||||||
|
// Sanity!
|
||||||
|
AssertFatal(pImageFile != NULL, "Cannot use a NULL image file.");
|
||||||
|
|
||||||
|
pImageFile = StringTable->insert(pImageFile);
|
||||||
|
|
||||||
|
if (pImageFile == mImageFile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (String(pImageFile).startsWith("#") || String(pImageFile).startsWith("$"))
|
||||||
|
{
|
||||||
|
mImageFile = StringTable->insert(pImageFile);
|
||||||
|
mIsNamedTarget = true;
|
||||||
|
refreshAsset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mImageFile = getOwned() ? expandAssetFilePath(pImageFile) : StringTable->insert(pImageFile);
|
||||||
|
|
||||||
|
if (Torque::FS::IsFile(mImageFile))
|
||||||
|
{
|
||||||
|
if (dStrEndsWith(mImageFile, ".dds"))
|
||||||
|
{
|
||||||
|
DDSFile* tempFile = new DDSFile();
|
||||||
|
FileStream* ddsFs;
|
||||||
|
if ((ddsFs = FileStream::createAndOpen(mImageFile, Torque::FS::File::Read)) == NULL)
|
||||||
|
{
|
||||||
|
Con::errorf("ImageAsset::setImageFile Failed to open ddsfile: %s", mImageFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tempFile->readHeader(*ddsFs))
|
||||||
|
{
|
||||||
|
Con::errorf("ImageAsset::setImageFile Failed to read header of ddsfile: %s", mImageFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mImageWidth = tempFile->mWidth;
|
||||||
|
mImageHeight = tempFile->mHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
ddsFs->close();
|
||||||
|
delete tempFile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!stbi_info(mImageFile, &mImageWidth, &mImageHeight, &mImageChannels))
|
||||||
|
{
|
||||||
|
StringTableEntry stbErr = stbi_failure_reason();
|
||||||
|
if (stbErr == StringTable->EmptyString())
|
||||||
|
stbErr = "ImageAsset::Unkown Error!";
|
||||||
|
|
||||||
|
Con::errorf("ImageAsset::setImageFile STB Get file info failed: %s", stbErr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we only support 2d textures..... for no ;)
|
||||||
|
mImageDepth = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshAsset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::setGenMips(const bool pGenMips)
|
||||||
|
{
|
||||||
|
if (pGenMips == mUseMips)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mUseMips = pGenMips;
|
||||||
|
|
||||||
|
refreshAsset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ImageAsset::setTextureHDR(const bool pIsHDR)
|
||||||
|
{
|
||||||
|
if (pIsHDR == mIsHDRImage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mIsHDRImage = pIsHDR;
|
||||||
|
|
||||||
|
refreshAsset();
|
||||||
}
|
}
|
||||||
|
|
||||||
U32 ImageAsset::load()
|
U32 ImageAsset::load()
|
||||||
{
|
{
|
||||||
if (mLoadedState == AssetErrCode::Ok) return mLoadedState;
|
if (mLoadedState == Ok)
|
||||||
if (mImagePath)
|
return mLoadedState;
|
||||||
|
|
||||||
|
if (!Torque::FS::IsFile(mImageFile))
|
||||||
{
|
{
|
||||||
// this is a target.
|
if (isNamedTarget())
|
||||||
if (mImageFileName[0] == '$' || mImageFileName[0] == '#')
|
|
||||||
{
|
{
|
||||||
NamedTexTargetRef namedTarget = NamedTexTarget::find(mImageFileName + 1);
|
mLoadedState = Ok;
|
||||||
if (namedTarget) {
|
|
||||||
mLoadedState = Ok;
|
|
||||||
mIsValidImage = true;
|
|
||||||
return mLoadedState;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Con::errorf("ImageAsset::initializeAsset: Attempted find named target %s failed.", mImageFileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!Torque::FS::IsFile(mImagePath))
|
|
||||||
{
|
|
||||||
Con::errorf("ImageAsset::initializeAsset: Attempted to load file %s but it was not valid!", mImageFileName);
|
|
||||||
mLoadedState = BadFileReference;
|
|
||||||
return mLoadedState;
|
return mLoadedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLoadedState = Ok;
|
Con::errorf("ImageAsset::initializeAsset: Attempted to load file %s but it was not valid!", mImageFile);
|
||||||
mIsValidImage = true;
|
mLoadedState = BadFileReference;
|
||||||
return mLoadedState;
|
return mLoadedState;
|
||||||
}
|
}
|
||||||
mLoadedState = BadFileReference;
|
else
|
||||||
|
{
|
||||||
|
mLoadedState = Ok;
|
||||||
|
}
|
||||||
|
|
||||||
mIsValidImage = false;
|
|
||||||
return mLoadedState;
|
return mLoadedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageAsset::initializeAsset()
|
|
||||||
{
|
|
||||||
ResourceManager::get().getChangedSignal().notify(this, &ImageAsset::_onResourceChanged);
|
|
||||||
|
|
||||||
if (mImageFileName[0] != '$' && mImageFileName[0] != '#')
|
|
||||||
{
|
|
||||||
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mImagePath = mImageFileName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageAsset::onAssetRefresh()
|
|
||||||
{
|
|
||||||
if (mImageFileName[0] != '$' && mImageFileName[0] != '#')
|
|
||||||
{
|
|
||||||
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mImagePath = mImageFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
|
|
||||||
// Iterate all dependencies.
|
|
||||||
while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId)
|
|
||||||
{
|
|
||||||
StringTableEntry assetId = assetDependenciesItr->value;
|
|
||||||
AssetBase* dependent = AssetDatabase.acquireAsset<AssetBase>(assetId);
|
|
||||||
dependent->refreshAsset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageAsset::_onResourceChanged(const Torque::Path& path)
|
|
||||||
{
|
|
||||||
if (path != Torque::Path(mImagePath))
|
|
||||||
return;
|
|
||||||
|
|
||||||
refreshAsset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageAsset::setImageFileName(const char* pScriptFile)
|
|
||||||
{
|
|
||||||
// Sanity!
|
|
||||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL image file.");
|
|
||||||
|
|
||||||
// Update.
|
|
||||||
mImageFileName = StringTable->insert(pScriptFile, true);
|
|
||||||
|
|
||||||
// Refresh the asset.
|
|
||||||
refreshAsset();
|
|
||||||
}
|
|
||||||
|
|
||||||
GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
|
GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
if (mResourceMap.contains(requestedProfile))
|
|
||||||
|
if (isNamedTarget())
|
||||||
{
|
{
|
||||||
mLoadedState = Ok;
|
GFXTexHandle tex;
|
||||||
return mResourceMap.find(requestedProfile)->value;
|
AssetPtr<ImageAsset> fallbackAsset;
|
||||||
}
|
ImageAsset::getAssetById(smNamedTargetAssetFallback, &fallbackAsset);
|
||||||
else
|
if (getNamedTarget().isValid())
|
||||||
{
|
|
||||||
// this is a target.
|
|
||||||
if (mImageFileName[0] == '$' || mImageFileName[0] == '#')
|
|
||||||
{
|
{
|
||||||
mLoadedState = Ok;
|
tex = getNamedTarget()->getTexture();
|
||||||
NamedTexTargetRef namedTarget = NamedTexTarget::find(mImageFileName + 1);
|
if (tex.isNull())
|
||||||
if (namedTarget.isValid() && namedTarget->getTexture())
|
|
||||||
{
|
{
|
||||||
mNamedTarget = namedTarget;
|
return fallbackAsset->getTexture();
|
||||||
mIsValidImage = true;
|
|
||||||
mResourceMap.insert(requestedProfile, mNamedTarget->getTexture());
|
|
||||||
mChangeSignal.trigger();
|
|
||||||
return mNamedTarget->getTexture();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return tex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//If we don't have an existing map case to the requested format, we'll just create it and insert it in
|
return fallbackAsset->getTexture();
|
||||||
GFXTexHandle newTex = TEXMGR->createTexture(mImagePath, requestedProfile);
|
|
||||||
if (newTex)
|
|
||||||
{
|
|
||||||
mResourceMap.insert(requestedProfile, newTex);
|
|
||||||
mLoadedState = Ok;
|
|
||||||
return newTex;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
mLoadedState = BadFileReference;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mLoadedState == Ok)
|
||||||
|
{
|
||||||
|
if (mResourceMap.contains(requestedProfile))
|
||||||
|
{
|
||||||
|
return mResourceMap.find(requestedProfile)->value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
//If we don't have an existing map case to the requested format, we'll just create it and insert it in
|
||||||
|
GFXTexHandle newTex;
|
||||||
|
newTex.set(mImageFile, requestedProfile, avar("%s %s() - mTextureObject (line %d)", mImageFile, __FUNCTION__, __LINE__));
|
||||||
|
if (newTex)
|
||||||
|
{
|
||||||
|
mLoadedState = AssetErrCode::Ok;
|
||||||
|
mResourceMap.insert(requestedProfile, newTex);
|
||||||
|
return newTex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mLoadedState = AssetErrCode::Failed;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ImageAsset::getImageInfo()
|
void ImageAsset::generateTexture(void)
|
||||||
{
|
{
|
||||||
if (mIsValidImage)
|
// already have a generated texture, get out.
|
||||||
|
if (mTextureHandle.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// implement some defaults, eventually SRGB should be optional.
|
||||||
|
U32 flags = GFXTextureProfile::Static | GFXTextureProfile::SRGB;
|
||||||
|
|
||||||
|
// dont want mips?
|
||||||
|
if (!mUseMips)
|
||||||
{
|
{
|
||||||
static const U32 bufSize = 2048;
|
flags |= GFXTextureProfile::NoMipmap;
|
||||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
|
||||||
|
|
||||||
GFXTexHandle newTex = TEXMGR->createTexture(mImagePath, &GFXStaticTextureSRGBProfile);
|
|
||||||
if (newTex)
|
|
||||||
{
|
|
||||||
dSprintf(returnBuffer, bufSize, "%s %d %d %d", GFXStringTextureFormat[newTex->getFormat()], newTex->getHeight(), newTex->getWidth(), newTex->getDepth());
|
|
||||||
newTex = nullptr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dSprintf(returnBuffer, bufSize, "ImageAsset::getImageInfo() - Failed to get image info for %s", getAssetId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnBuffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
GFXTextureProfile::Types type = GFXTextureProfile::Types::DiffuseMap;
|
||||||
|
|
||||||
|
if (mImageType == ImageTypes::Normal) {
|
||||||
|
type = GFXTextureProfile::Types::NormalMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
GFXTextureProfile* genProfile = new GFXTextureProfile("ImageAssetGennedProfile", type, flags);
|
||||||
|
|
||||||
|
mTextureHandle.set(mImageFile, genProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||||
|
mResourceMap.insert(genProfile, mTextureHandle);
|
||||||
|
|
||||||
|
if (mTextureHandle.isValid())
|
||||||
|
mLoadedState = AssetErrCode::Ok;
|
||||||
|
else
|
||||||
|
mLoadedState = AssetErrCode::Failed;
|
||||||
|
|
||||||
|
ResourceManager::get().getChangedSignal().notify(this, &ImageAsset::_onResourceChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type)
|
const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type)
|
||||||
|
|
@ -452,7 +589,7 @@ const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type)
|
||||||
return _names[type];
|
return _names[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageAsset::ImageTypes ImageAsset::getImageTypeFromName(const char* name)
|
ImageAsset::ImageTypes ImageAsset::getImageTypeFromName(StringTableEntry name)
|
||||||
{
|
{
|
||||||
if (dStrIsEmpty(name))
|
if (dStrIsEmpty(name))
|
||||||
{
|
{
|
||||||
|
|
@ -475,11 +612,128 @@ ImageAsset::ImageTypes ImageAsset::getImageTypeFromName(const char* name)
|
||||||
return (ImageTypes)ret;
|
return (ImageTypes)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageAsset::_onResourceChanged(const Torque::Path& path)
|
||||||
|
{
|
||||||
|
if (path != Torque::Path(mImageFile))
|
||||||
|
return;
|
||||||
|
|
||||||
|
refreshAsset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::onTamlPreWrite(void)
|
||||||
|
{
|
||||||
|
// Call parent.
|
||||||
|
Parent::onTamlPreWrite();
|
||||||
|
|
||||||
|
if (isNamedTarget())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Ensure the image-file is collapsed.
|
||||||
|
mImageFile = collapseAssetFilePath(mImageFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::onTamlPostWrite(void)
|
||||||
|
{
|
||||||
|
// Call parent.
|
||||||
|
Parent::onTamlPostWrite();
|
||||||
|
|
||||||
|
if (isNamedTarget())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Ensure the image-file is expanded.
|
||||||
|
mImageFile = expandAssetFilePath(mImageFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::onTamlCustomWrite(TamlCustomNodes& customNodes)
|
||||||
|
{
|
||||||
|
// Debug Profiling.
|
||||||
|
PROFILE_SCOPE(ImageAsset_OnTamlCustomWrite);
|
||||||
|
|
||||||
|
// Call parent.
|
||||||
|
Parent::onTamlCustomWrite(customNodes);
|
||||||
|
|
||||||
|
TamlCustomNode* pImageMetaData = customNodes.addNode(StringTable->insert("ImageMetadata"));
|
||||||
|
TamlCustomNode* pImageInfoNode = pImageMetaData->addNode(StringTable->insert("ImageInfo"));
|
||||||
|
|
||||||
|
pImageInfoNode->addField(StringTable->insert("ImageWidth"), mImageWidth);
|
||||||
|
pImageInfoNode->addField(StringTable->insert("ImageHeight"), mImageHeight);
|
||||||
|
pImageInfoNode->addField(StringTable->insert("ImageDepth"), mImageDepth);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageAsset::onTamlCustomRead(const TamlCustomNodes& customNodes)
|
||||||
|
{
|
||||||
|
// Debug Profiling.
|
||||||
|
PROFILE_SCOPE(ImageAsset_OnTamlCustomRead);
|
||||||
|
|
||||||
|
// Call parent.
|
||||||
|
Parent::onTamlCustomRead(customNodes);
|
||||||
|
|
||||||
|
const TamlCustomNode* pImageMetaDataNode = customNodes.findNode(StringTable->insert("ImageMetadata"));
|
||||||
|
|
||||||
|
if (pImageMetaDataNode != NULL)
|
||||||
|
{
|
||||||
|
const TamlCustomNode* pImageInfoNode = pImageMetaDataNode->findNode(StringTable->insert("ImageInfo"));
|
||||||
|
// Fetch fields.
|
||||||
|
const TamlCustomFieldVector& fields = pImageInfoNode->getFields();
|
||||||
|
// Iterate property fields.
|
||||||
|
for (TamlCustomFieldVector::const_iterator fieldItr = fields.begin(); fieldItr != fields.end(); ++fieldItr)
|
||||||
|
{
|
||||||
|
// Fetch field.
|
||||||
|
const TamlCustomField* pField = *fieldItr;
|
||||||
|
// Fetch field name.
|
||||||
|
StringTableEntry fieldName = pField->getFieldName();
|
||||||
|
if (fieldName == StringTable->insert("ImageWidth"))
|
||||||
|
{
|
||||||
|
pField->getFieldValue(mImageWidth);
|
||||||
|
}
|
||||||
|
else if (fieldName == StringTable->insert("ImageHeight"))
|
||||||
|
{
|
||||||
|
pField->getFieldValue(mImageHeight);
|
||||||
|
}
|
||||||
|
else if (fieldName == StringTable->insert("ImageDepth"))
|
||||||
|
{
|
||||||
|
pField->getFieldValue(mImageDepth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Unknown name so warn.
|
||||||
|
Con::warnf("ImageAsset::onTamlCustomRead() - Encountered an unknown custom field name of '%s'.", fieldName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* ImageAsset::getImageInfo()
|
||||||
|
{
|
||||||
|
if (isAssetValid())
|
||||||
|
{
|
||||||
|
static const U32 bufSize = 2048;
|
||||||
|
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||||
|
|
||||||
|
GFXTexHandle newTex = TEXMGR->createTexture(mImageFile, &GFXStaticTextureSRGBProfile);
|
||||||
|
if (newTex)
|
||||||
|
{
|
||||||
|
dSprintf(returnBuffer, bufSize, "%s %d %d %d", GFXStringTextureFormat[newTex->getFormat()], newTex->getHeight(), newTex->getWidth(), newTex->getDepth());
|
||||||
|
newTex = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dSprintf(returnBuffer, bufSize, "ImageAsset::getImageInfo() - Failed to get image info for %s", getAssetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(ImageAsset, getImagePath, const char*, (), ,
|
DefineEngineMethod(ImageAsset, getImagePath, const char*, (), ,
|
||||||
"Gets the image filepath of this asset.\n"
|
"Gets the image filepath of this asset.\n"
|
||||||
"@return File path of the image file.")
|
"@return File path of the image file.")
|
||||||
{
|
{
|
||||||
return object->getImagePath();
|
return object->getImageFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod(ImageAsset, getImageInfo, const char*, (), ,
|
DefineEngineMethod(ImageAsset, getImageInfo, const char*, (), ,
|
||||||
|
|
@ -489,6 +743,14 @@ DefineEngineMethod(ImageAsset, getImageInfo, const char*, (), ,
|
||||||
return object->getImageInfo();
|
return object->getImageInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(ImageAsset, isNamedTarget, bool, (), ,
|
||||||
|
"Gets whether this image is a named target.\n"
|
||||||
|
"@return bool for isNamedTarget.")
|
||||||
|
{
|
||||||
|
return object->isNamedTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TORQUE_TOOLS
|
#ifdef TORQUE_TOOLS
|
||||||
DefineEngineStaticMethod(ImageAsset, getAssetIdByFilename, const char*, (const char* filePath), (""),
|
DefineEngineStaticMethod(ImageAsset, getAssetIdByFilename, const char*, (const char* filePath), (""),
|
||||||
"Queries the Asset Database to see if any asset exists that is associated with the provided file path.\n"
|
"Queries the Asset Database to see if any asset exists that is associated with the provided file path.\n"
|
||||||
|
|
@ -496,7 +758,7 @@ DefineEngineStaticMethod(ImageAsset, getAssetIdByFilename, const char*, (const c
|
||||||
{
|
{
|
||||||
return ImageAsset::getAssetIdByFilename(StringTable->insert(filePath));
|
return ImageAsset::getAssetIdByFilename(StringTable->insert(filePath));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// GuiInspectorTypeAssetId
|
// GuiInspectorTypeAssetId
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -652,7 +914,7 @@ bool GuiInspectorTypeImageAssetPtr::renderTooltip(const Point2I& hoverPos, const
|
||||||
if (imgAsset == NULL || assetState == ImageAsset::Failed)
|
if (imgAsset == NULL || assetState == ImageAsset::Failed)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
StringTableEntry filename = imgAsset->getImagePath();
|
StringTableEntry filename = imgAsset->getImageFile();
|
||||||
if (!filename || !filename[0])
|
if (!filename || !filename[0])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -665,7 +927,7 @@ bool GuiInspectorTypeImageAssetPtr::renderTooltip(const Point2I& hoverPos, const
|
||||||
if (AssetDatabase.isDeclaredAsset(previewFilename))
|
if (AssetDatabase.isDeclaredAsset(previewFilename))
|
||||||
{
|
{
|
||||||
ImageAsset* previewAsset = AssetDatabase.acquireAsset<ImageAsset>(previewFilename);
|
ImageAsset* previewAsset = AssetDatabase.acquireAsset<ImageAsset>(previewFilename);
|
||||||
previewFilename = previewAsset->getImagePath();
|
previewFilename = previewAsset->getImageFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -744,11 +1006,7 @@ void GuiInspectorTypeImageAssetPtr::updatePreviewImage()
|
||||||
{
|
{
|
||||||
if (AssetDatabase.isDeclaredAsset(previewImage))
|
if (AssetDatabase.isDeclaredAsset(previewImage))
|
||||||
{
|
{
|
||||||
ImageAsset* imgAsset = AssetDatabase.acquireAsset<ImageAsset>(previewImage);
|
mPreviewImage->_setBitmap(previewImage);
|
||||||
if (imgAsset && imgAsset->isAssetValid())
|
|
||||||
{
|
|
||||||
mPreviewImage->_setBitmap(imgAsset->getAssetId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -776,31 +1034,10 @@ void GuiInspectorTypeImageAssetPtr::setPreviewImage(StringTableEntry assetId)
|
||||||
{
|
{
|
||||||
if (AssetDatabase.isDeclaredAsset(assetId))
|
if (AssetDatabase.isDeclaredAsset(assetId))
|
||||||
{
|
{
|
||||||
ImageAsset* imgAsset = AssetDatabase.acquireAsset<ImageAsset>(assetId);
|
mPreviewImage->_setBitmap(assetId);
|
||||||
if (imgAsset && imgAsset->isAssetValid())
|
|
||||||
{
|
|
||||||
mPreviewImage->_setBitmap(imgAsset->getAssetId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPreviewImage->getBitmapAsset().isNull())
|
if (mPreviewImage->getBitmapAsset().isNull())
|
||||||
mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
|
mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(GuiInspectorTypeImageAssetId);
|
|
||||||
|
|
||||||
ConsoleDocClass(GuiInspectorTypeImageAssetId,
|
|
||||||
"@brief Inspector field type for Images\n\n"
|
|
||||||
"Editor use only.\n\n"
|
|
||||||
"@internal"
|
|
||||||
);
|
|
||||||
|
|
||||||
void GuiInspectorTypeImageAssetId::consoleInit()
|
|
||||||
{
|
|
||||||
Parent::consoleInit();
|
|
||||||
|
|
||||||
ConsoleBaseType::getType(TypeImageAssetId)->setInspectorFieldType("GuiInspectorTypeImageAssetId");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -25,36 +25,36 @@
|
||||||
#ifndef _ASSET_BASE_H_
|
#ifndef _ASSET_BASE_H_
|
||||||
#include "assets/assetBase.h"
|
#include "assets/assetBase.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _ASSET_DEFINITION_H_
|
#ifndef _ASSET_DEFINITION_H_
|
||||||
#include "assets/assetDefinition.h"
|
#include "assets/assetDefinition.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _STRINGUNIT_H_
|
#ifndef _STRINGUNIT_H_
|
||||||
#include "string/stringUnit.h"
|
#include "string/stringUnit.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _ASSET_FIELD_TYPES_H_
|
#ifndef _ASSET_FIELD_TYPES_H_
|
||||||
#include "assets/assetFieldTypes.h"
|
#include "assets/assetFieldTypes.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _ASSET_PTR_H_
|
#ifndef _ASSET_PTR_H_
|
||||||
#include "assets/assetPtr.h"
|
#include "assets/assetPtr.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _GBITMAP_H_
|
||||||
#include "gfx/bitmap/gBitmap.h"
|
#include "gfx/bitmap/gBitmap.h"
|
||||||
|
#endif
|
||||||
|
#ifndef _GFXTEXTUREHANDLE_H_
|
||||||
#include "gfx/gfxTextureHandle.h"
|
#include "gfx/gfxTextureHandle.h"
|
||||||
|
#endif
|
||||||
|
#ifndef _NETCONNECTION_H_
|
||||||
#include "sim/netConnection.h"
|
#include "sim/netConnection.h"
|
||||||
|
#endif
|
||||||
#include <string>
|
#ifndef _GFXDEVICE_H_
|
||||||
#include "assetMacroHelpers.h"
|
|
||||||
|
|
||||||
#include "gfx/gfxDevice.h"
|
#include "gfx/gfxDevice.h"
|
||||||
|
#endif
|
||||||
#ifndef _MATTEXTURETARGET_H_
|
#ifndef _MATTEXTURETARGET_H_
|
||||||
#include "materials/matTextureTarget.h"
|
#include "materials/matTextureTarget.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "assetMacroHelpers.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
class ImageAsset : public AssetBase
|
class ImageAsset : public AssetBase
|
||||||
{
|
{
|
||||||
|
|
@ -79,7 +79,41 @@ public:
|
||||||
ImageTypeCount = 11
|
ImageTypeCount = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Frame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Frame(const S32 pixelOffsetX, const S32 pixelOffsetY,
|
||||||
|
const U32 pixelWidth, const U32 pixelHeight,
|
||||||
|
const F32 texelWidthScale, const F32 texelHeightScale,
|
||||||
|
StringTableEntry inRegionName = StringTable->EmptyString())
|
||||||
|
: regionName(inRegionName)
|
||||||
|
{
|
||||||
|
pixelOffset.set(pixelOffsetY, pixelOffsetY);
|
||||||
|
pixelSize.set(pixelWidth, pixelHeight);
|
||||||
|
|
||||||
|
texelLower.set(pixelOffsetX * texelWidthScale, pixelOffsetY * texelHeightScale);
|
||||||
|
texelSize.set(pixelWidth * texelWidthScale, pixelHeight * texelHeightScale);
|
||||||
|
texelUpper.set(texelLower.x + texelSize.x, texelLower.y + texelSize.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFlip(bool flipX, bool flipY)
|
||||||
|
{
|
||||||
|
if (flipX) mSwap(texelLower.x, texelUpper.x);
|
||||||
|
if (flipY) mSwap(texelLower.y, texelUpper.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Point2I pixelOffset;
|
||||||
|
Point2I pixelSize;
|
||||||
|
|
||||||
|
Point2F texelLower;
|
||||||
|
Point2F texelUpper;
|
||||||
|
Point2F texelSize;
|
||||||
|
|
||||||
|
StringTableEntry regionName;
|
||||||
|
};
|
||||||
|
|
||||||
static StringTableEntry smNoImageAssetFallback;
|
static StringTableEntry smNoImageAssetFallback;
|
||||||
|
static StringTableEntry smNamedTargetAssetFallback;
|
||||||
|
|
||||||
enum ImageAssetErrCode
|
enum ImageAssetErrCode
|
||||||
{
|
{
|
||||||
|
|
@ -96,26 +130,21 @@ public:
|
||||||
if (errCode > ImageAssetErrCode::Extended) return "undefined error";
|
if (errCode > ImageAssetErrCode::Extended) return "undefined error";
|
||||||
return mErrCodeStrings[errCode - Parent::Extended];
|
return mErrCodeStrings[errCode - Parent::Extended];
|
||||||
};
|
};
|
||||||
|
private:
|
||||||
|
|
||||||
protected:
|
StringTableEntry mImageFile;
|
||||||
StringTableEntry mImageFileName;
|
bool mUseMips;
|
||||||
StringTableEntry mImagePath;
|
bool mIsHDRImage;
|
||||||
NamedTexTargetRef mNamedTarget;
|
GFXTexHandle mTextureHandle;
|
||||||
|
ImageTypes mImageType;
|
||||||
bool mIsValidImage;
|
|
||||||
bool mUseMips;
|
|
||||||
bool mIsHDRImage;
|
|
||||||
|
|
||||||
ImageTypes mImageType;
|
|
||||||
|
|
||||||
HashMap<GFXTextureProfile*, GFXTexHandle> mResourceMap;
|
HashMap<GFXTextureProfile*, GFXTexHandle> mResourceMap;
|
||||||
|
bool mIsNamedTarget;
|
||||||
|
S32 mImageWidth;
|
||||||
|
S32 mImageHeight;
|
||||||
|
S32 mImageDepth;
|
||||||
|
S32 mImageChannels;
|
||||||
|
|
||||||
typedef Signal<void()> ImageAssetChanged;
|
void generateTexture(void);
|
||||||
ImageAssetChanged mChangeSignal;
|
|
||||||
|
|
||||||
typedef Signal<void(S32 index)> ImageAssetArrayChanged;
|
|
||||||
ImageAssetArrayChanged mChangeArraySignal;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImageAsset();
|
ImageAsset();
|
||||||
virtual ~ImageAsset();
|
virtual ~ImageAsset();
|
||||||
|
|
@ -125,6 +154,10 @@ public:
|
||||||
|
|
||||||
/// Engine.
|
/// Engine.
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
|
|
||||||
|
/// Sim
|
||||||
|
bool onAdd() override;
|
||||||
|
void onRemove() override;
|
||||||
void copyTo(SimObject* object) override;
|
void copyTo(SimObject* object) override;
|
||||||
|
|
||||||
/// Declare Console Object.
|
/// Declare Console Object.
|
||||||
|
|
@ -132,414 +165,288 @@ public:
|
||||||
|
|
||||||
void _onResourceChanged(const Torque::Path& path);
|
void _onResourceChanged(const Torque::Path& path);
|
||||||
|
|
||||||
ImageAssetChanged& getChangedSignal() { return mChangeSignal; }
|
// asset Base load
|
||||||
ImageAssetArrayChanged& getChangedArraySignal() { return mChangeArraySignal; }
|
U32 load() override;
|
||||||
|
|
||||||
void setImageFileName(StringTableEntry pScriptFile);
|
void setImageFile(StringTableEntry pImageFile);
|
||||||
inline StringTableEntry getImageFileName(void) const { return mImageFileName; };
|
inline StringTableEntry getImageFile(void) const { return mImageFile; };
|
||||||
|
inline StringTableEntry getRelativeImageFile(void) const { return collapseAssetFilePath(mImageFile); };
|
||||||
|
|
||||||
inline StringTableEntry getImagePath(void) const { return mImagePath; };
|
void setGenMips(const bool pGenMips);
|
||||||
|
inline bool getGenMips(void) const { return mUseMips; };
|
||||||
|
|
||||||
bool isValid() { return mIsValidImage; }
|
void setTextureHDR(const bool pIsHDR);
|
||||||
|
inline bool getTextureHDR(void) const { return mIsHDRImage; };
|
||||||
|
|
||||||
GFXTexHandle getTexture(GFXTextureProfile* requestedProfile);
|
inline GFXTexHandle& getTexture(void) { load(); generateTexture(); return mTextureHandle; }
|
||||||
|
GFXTexHandle getTexture(GFXTextureProfile* requestedProfile);
|
||||||
StringTableEntry getImageInfo();
|
|
||||||
|
|
||||||
static StringTableEntry getImageTypeNameFromType(ImageTypes type);
|
static StringTableEntry getImageTypeNameFromType(ImageTypes type);
|
||||||
static ImageTypes getImageTypeFromName(StringTableEntry name);
|
static ImageTypes getImageTypeFromName(StringTableEntry name);
|
||||||
|
|
||||||
void setImageType(ImageTypes type) { mImageType = type; }
|
void setImageType(ImageTypes type) { mImageType = type; }
|
||||||
ImageTypes getImageType() { return mImageType; }
|
ImageTypes getImageType() { return mImageType; }
|
||||||
|
|
||||||
|
inline U32 getTextureWidth(void) const { return isAssetValid() ? mTextureHandle->getWidth() : 0; }
|
||||||
|
inline U32 getTextureHeight(void) const { return isAssetValid() ? mTextureHandle->getHeight() : 0; }
|
||||||
|
inline U32 getTextureDepth(void) const { return isAssetValid() ? mTextureHandle->getDepth() : 0; }
|
||||||
|
|
||||||
|
inline U32 getTextureBitmapWidth(void) const { return mImageWidth; }
|
||||||
|
inline U32 getTextureBitmapHeight(void) const { return mImageHeight; }
|
||||||
|
inline U32 getTextureBitmapDepth(void) const { return mImageDepth; }
|
||||||
|
bool isAssetValid(void) const override { return !mTextureHandle.isNull(); }
|
||||||
|
|
||||||
|
bool isNamedTarget(void) const { return mIsNamedTarget; }
|
||||||
|
NamedTexTargetRef getNamedTarget(void) const { return NamedTexTarget::find(mImageFile + 1); }
|
||||||
|
|
||||||
static U32 getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsset>* imageAsset);
|
static U32 getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsset>* imageAsset);
|
||||||
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
||||||
static U32 getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* imageAsset);
|
static U32 getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* imageAsset);
|
||||||
static U32 getAssetById(String assetId, AssetPtr<ImageAsset>* imageAsset) { return getAssetById(assetId.c_str(), imageAsset); };
|
static U32 getAssetById(String assetId, AssetPtr<ImageAsset>* imageAsset) { return getAssetById(assetId.c_str(), imageAsset); };
|
||||||
|
|
||||||
U32 load() override;
|
|
||||||
|
const char* getImageInfo();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initializeAsset(void) override;
|
// Asset Base callback
|
||||||
void onAssetRefresh(void) override;
|
void initializeAsset(void) override;
|
||||||
|
void onAssetRefresh(void) override;
|
||||||
|
|
||||||
static bool setImageFileName(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ImageAsset*>(obj)->setImageFileName(data); return false; }
|
/// Taml callbacks.
|
||||||
static StringTableEntry getImageFileName(void* obj, StringTableEntry data) { return static_cast<ImageAsset*>(obj)->getImageFileName(); }
|
void onTamlPreWrite(void) override;
|
||||||
|
void onTamlPostWrite(void) override;
|
||||||
|
void onTamlCustomWrite(TamlCustomNodes& customNodes) override;
|
||||||
|
void onTamlCustomRead(const TamlCustomNodes& customNodes) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Texture file
|
||||||
|
static bool setImageFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ImageAsset*>(obj)->setImageFile(data); return false; }
|
||||||
|
static const char* getImageFile(void* obj, StringTableEntry data) { return static_cast<ImageAsset*>(obj)->getImageFile(); }
|
||||||
|
static bool writeImageFile(void* obj, StringTableEntry pFieldName) { return static_cast<ImageAsset*>(obj)->getImageFile() != StringTable->EmptyString(); }
|
||||||
|
|
||||||
|
// Gen mips?
|
||||||
|
static bool setGenMips(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ImageAsset*>(obj)->setGenMips(dAtob(data)); return false; }
|
||||||
|
static bool writeGenMips(void* obj, StringTableEntry pFieldName) { return static_cast<ImageAsset*>(obj)->getGenMips() == true; }
|
||||||
|
|
||||||
|
// Texture Is Hdr?
|
||||||
|
static bool setTextureHDR(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ImageAsset*>(obj)->setTextureHDR(dAtob(data)); return false; }
|
||||||
|
static bool writeTextureHDR(void* obj, StringTableEntry pFieldName) { return static_cast<ImageAsset*>(obj)->getTextureHDR() == true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
DefineConsoleType(TypeImageAssetPtr, ImageAsset)
|
DECLARE_STRUCT(AssetPtr<ImageAsset>)
|
||||||
DefineConsoleType(TypeImageAssetId, String)
|
DefineConsoleType(TypeImageAssetPtr, AssetPtr<ImageAsset> )
|
||||||
|
|
||||||
typedef ImageAsset::ImageTypes ImageAssetType;
|
typedef ImageAsset::ImageTypes ImageAssetType;
|
||||||
DefineEnumType(ImageAssetType);
|
DefineEnumType(ImageAssetType);
|
||||||
|
|
||||||
#pragma region Singular Asset Macros
|
#pragma region Refactor Asset Macros
|
||||||
|
|
||||||
//Singular assets
|
#define DECLARE_IMAGEASSET(className, name, profile) \
|
||||||
/// <Summary>
|
private: \
|
||||||
/// Declares an image asset
|
AssetPtr<ImageAsset> m##name##Asset; \
|
||||||
/// This establishes the assetId, asset and legacy filepath fields, along with supplemental getter and setter functions
|
public: \
|
||||||
/// </Summary>
|
void _set##name(StringTableEntry _in){ \
|
||||||
#define DECLARE_IMAGEASSET(className, name, changeFunc, profile) public: \
|
if(m##name##Asset.getAssetId() == _in) \
|
||||||
GFXTexHandle m##name = NULL;\
|
return; \
|
||||||
StringTableEntry m##name##Name; \
|
\
|
||||||
StringTableEntry m##name##AssetId;\
|
if(!AssetDatabase.isDeclaredAsset(_in)) \
|
||||||
AssetPtr<ImageAsset> m##name##Asset;\
|
{ \
|
||||||
GFXTextureProfile* m##name##Profile = &profile;\
|
StringTableEntry imageAssetId = StringTable->EmptyString(); \
|
||||||
public: \
|
AssetQuery query; \
|
||||||
const StringTableEntry get##name##File() const { return m##name##Name; }\
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
||||||
void set##name##File(const FileName &_in) { m##name##Name = StringTable->insert(_in.c_str());}\
|
if (foundAssetcount != 0) \
|
||||||
const AssetPtr<ImageAsset> & get##name##Asset() const { return m##name##Asset; }\
|
{ \
|
||||||
void set##name##Asset(const AssetPtr<ImageAsset> &_in) { m##name##Asset = _in;}\
|
imageAssetId = query.mAssetList[0]; \
|
||||||
\
|
} \
|
||||||
bool _set##name(StringTableEntry _in)\
|
else if(Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
||||||
{\
|
{ \
|
||||||
if(m##name##AssetId != _in || m##name##Name != _in)\
|
imageAssetId = ImageAsset::getAssetIdByFilename(_in); \
|
||||||
{\
|
if (imageAssetId == ImageAsset::smNoImageAssetFallback) \
|
||||||
if (m##name##Asset.notNull())\
|
{ \
|
||||||
{\
|
ImageAsset* privateImage = new ImageAsset(); \
|
||||||
m##name##Asset->getChangedSignal().remove(this, &className::changeFunc);\
|
privateImage->setImageFile(_in); \
|
||||||
}\
|
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||||
if (_in == NULL || _in == StringTable->EmptyString())\
|
} \
|
||||||
{\
|
} \
|
||||||
m##name##Name = StringTable->EmptyString();\
|
else \
|
||||||
m##name##AssetId = StringTable->EmptyString();\
|
{ \
|
||||||
m##name##Asset = NULL;\
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||||
m##name.free();\
|
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||||
m##name = NULL;\
|
} \
|
||||||
return true;\
|
m##name##Asset = imageAssetId; \
|
||||||
}\
|
} \
|
||||||
else if(_in[0] == '$' || _in[0] == '#')\
|
else \
|
||||||
{\
|
{ \
|
||||||
m##name##Name = _in;\
|
m##name##Asset = _in; \
|
||||||
m##name##AssetId = StringTable->EmptyString();\
|
} \
|
||||||
m##name##Asset = NULL;\
|
}; \
|
||||||
m##name.free();\
|
\
|
||||||
m##name = NULL;\
|
inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
|
||||||
return true;\
|
GFXTexHandle get##name() { return m##name##Asset.notNull() ? m##name##Asset->getTexture(&profile) : NULL; } \
|
||||||
}\
|
AssetPtr<ImageAsset> get##name##Asset(void) { return m##name##Asset; } \
|
||||||
\
|
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false;}
|
||||||
if (AssetDatabase.isDeclaredAsset(_in))\
|
|
||||||
{\
|
|
||||||
m##name##AssetId = _in;\
|
|
||||||
\
|
|
||||||
U32 assetState = ImageAsset::getAssetById(m##name##AssetId, &m##name##Asset);\
|
|
||||||
\
|
|
||||||
if (ImageAsset::Ok == assetState)\
|
|
||||||
{\
|
|
||||||
m##name##Name = StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
else\
|
|
||||||
{\
|
|
||||||
StringTableEntry assetId = ImageAsset::getAssetIdByFilename(_in);\
|
|
||||||
if (assetId != StringTable->EmptyString())\
|
|
||||||
{\
|
|
||||||
m##name##AssetId = assetId;\
|
|
||||||
if (ImageAsset::getAssetById(m##name##AssetId, &m##name##Asset) == ImageAsset::Ok)\
|
|
||||||
{\
|
|
||||||
m##name##Name = StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
else\
|
|
||||||
{\
|
|
||||||
m##name##Name = _in;\
|
|
||||||
m##name##AssetId = StringTable->EmptyString();\
|
|
||||||
m##name##Asset = NULL;\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
if (get##name() != StringTable->EmptyString() && m##name##Name != StringTable->insert("texhandle"))\
|
|
||||||
{\
|
|
||||||
if (m##name##Asset.notNull())\
|
|
||||||
{\
|
|
||||||
m##name##Asset->getChangedSignal().notify(this, &className::changeFunc);\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
if (get##name()[0] != '$' && get##name()[0] != '#') {\
|
|
||||||
m##name.set(get##name(), m##name##Profile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
else\
|
|
||||||
{\
|
|
||||||
m##name.free();\
|
|
||||||
m##name = NULL;\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
if(get##name() == StringTable->EmptyString())\
|
|
||||||
return true;\
|
|
||||||
\
|
|
||||||
if (m##name##Asset.notNull() && m##name##Asset->getStatus() != ImageAsset::Ok)\
|
|
||||||
{\
|
|
||||||
Con::errorf("%s(%s)::_set%s() - image asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name), _in, ImageAsset::getAssetErrstrn(m##name##Asset->getStatus()).c_str());\
|
|
||||||
return false; \
|
|
||||||
}\
|
|
||||||
else if (!m##name)\
|
|
||||||
{\
|
|
||||||
if (GFX->getAdapterType() != NullDevice)\
|
|
||||||
Con::errorf("%s(%s)::_set%s() - Couldn't load image \"%s\"", macroText(className), getName(), macroText(name), _in);\
|
|
||||||
return false;\
|
|
||||||
}\
|
|
||||||
return true;\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
const StringTableEntry get##name() const\
|
|
||||||
{\
|
|
||||||
if (m##name##Asset && (m##name##Asset->getImageFileName() != StringTable->EmptyString()))\
|
|
||||||
if (m##name##Asset->getImageFileName()[0] == '#' || m##name##Asset->getImageFileName()[0] == '$')\
|
|
||||||
return m##name##Asset->getImageFileName();\
|
|
||||||
else\
|
|
||||||
return Platform::makeRelativePathName(m##name##Asset->getImagePath(), Platform::getMainDotCsDir());\
|
|
||||||
else if (m##name##AssetId != StringTable->EmptyString())\
|
|
||||||
return m##name##AssetId;\
|
|
||||||
else if (m##name##Name != StringTable->EmptyString())\
|
|
||||||
return StringTable->insert(Platform::makeRelativePathName(m##name##Name, Platform::getMainDotCsDir()));\
|
|
||||||
else\
|
|
||||||
return StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
GFXTexHandle get##name##Resource() \
|
|
||||||
{\
|
|
||||||
if (m##name##Asset && (m##name##Asset->getImageFileName() != StringTable->EmptyString()))\
|
|
||||||
return m##name##Asset->getTexture(m##name##Profile);\
|
|
||||||
return m##name;\
|
|
||||||
}\
|
|
||||||
bool name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); }
|
|
||||||
|
|
||||||
#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
|
|
||||||
|
|
||||||
#define INITPERSISTFIELD_IMAGEASSET(name, consoleClass, docs) \
|
|
||||||
addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, docs)); \
|
|
||||||
addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.));
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define INITPERSISTFIELD_IMAGEASSET(name, consoleClass, docs) \
|
|
||||||
addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
|
|
||||||
addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.));
|
|
||||||
|
|
||||||
#endif // SHOW_LEGACY_FILE_FIELDS
|
|
||||||
|
|
||||||
#define LOAD_IMAGEASSET(name)\
|
|
||||||
if (m##name##AssetId != StringTable->EmptyString())\
|
|
||||||
{\
|
|
||||||
S32 assetState = ImageAsset::getAssetById(m##name##AssetId, &m##name##Asset);\
|
|
||||||
if (assetState == ImageAsset::Ok )\
|
|
||||||
{\
|
|
||||||
m##name##Name = StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
else Con::warnf("Warning: %s::LOAD_IMAGEASSET(%s)-%s", mClassName, m##name##AssetId, ImageAsset::getAssetErrstrn(assetState).c_str());\
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma endregion
|
#define DECLARE_IMAGEASSET_NET(className, name, profile, mask) \
|
||||||
|
private: \
|
||||||
|
AssetPtr<ImageAsset> m##name##Asset; \
|
||||||
|
public: \
|
||||||
|
void _set##name(StringTableEntry _in){ \
|
||||||
|
if(m##name##Asset.getAssetId() == _in) \
|
||||||
|
return; \
|
||||||
|
if(!AssetDatabase.isDeclaredAsset(_in)) \
|
||||||
|
{ \
|
||||||
|
StringTableEntry imageAssetId = StringTable->EmptyString(); \
|
||||||
|
AssetQuery query; \
|
||||||
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
||||||
|
if (foundAssetcount != 0) \
|
||||||
|
{ \
|
||||||
|
imageAssetId = query.mAssetList[0]; \
|
||||||
|
} \
|
||||||
|
else if(Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
||||||
|
{ \
|
||||||
|
imageAssetId = ImageAsset::getAssetIdByFilename(_in); \
|
||||||
|
if (imageAssetId == ImageAsset::smNoImageAssetFallback) \
|
||||||
|
{ \
|
||||||
|
ImageAsset* privateImage = new ImageAsset(); \
|
||||||
|
privateImage->setImageFile(_in); \
|
||||||
|
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||||
|
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||||
|
} \
|
||||||
|
m##name##Asset = imageAssetId; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
m##name##Asset = _in; \
|
||||||
|
} \
|
||||||
|
setMaskBits(mask); \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
inline StringTableEntry _get##name(void) const { return m##name##Asset.getAssetId(); } \
|
||||||
|
GFXTexHandle get##name() { return m##name##Asset.notNull() ? m##name##Asset->getTexture(&profile) : NULL; } \
|
||||||
|
AssetPtr<ImageAsset> get##name##Asset(void) { return m##name##Asset; } \
|
||||||
|
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false;}
|
||||||
|
|
||||||
#pragma region Arrayed Asset Macros
|
|
||||||
|
|
||||||
//Arrayed Assets
|
#define INITPERSISTFIELD_IMAGEASSET(name, consoleClass, docs) \
|
||||||
#define DECLARE_IMAGEASSET_ARRAY(className, name, max, changeFunc) public: \
|
addProtectedField(assetText(name, Asset), TypeImageAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.));
|
||||||
static const U32 sm##name##Count = max;\
|
|
||||||
GFXTexHandle m##name[max];\
|
|
||||||
StringTableEntry m##name##Name[max]; \
|
|
||||||
StringTableEntry m##name##AssetId[max];\
|
|
||||||
AssetPtr<ImageAsset> m##name##Asset[max];\
|
|
||||||
GFXTextureProfile * m##name##Profile[max];\
|
|
||||||
public: \
|
|
||||||
const StringTableEntry get##name##File(const U32& index) const { return m##name##Name[index]; }\
|
|
||||||
void set##name##File(const FileName &_in, const U32& index) { m##name##Name[index] = StringTable->insert(_in.c_str());}\
|
|
||||||
const AssetPtr<ImageAsset> & get##name##Asset(const U32& index) const { return m##name##Asset[index]; }\
|
|
||||||
void set##name##Asset(const AssetPtr<ImageAsset> &_in, const U32& index) { m##name##Asset[index] = _in;}\
|
|
||||||
\
|
|
||||||
bool _set##name(StringTableEntry _in, const U32& index)\
|
|
||||||
{\
|
|
||||||
if(m##name##AssetId[index] != _in || m##name##Name[index] != _in)\
|
|
||||||
{\
|
|
||||||
if(index >= sm##name##Count || index < 0)\
|
|
||||||
return false;\
|
|
||||||
if (_in == NULL || _in == StringTable->EmptyString())\
|
|
||||||
{\
|
|
||||||
m##name##Name[index] = StringTable->EmptyString();\
|
|
||||||
m##name##AssetId[index] = StringTable->EmptyString();\
|
|
||||||
m##name##Asset[index] = NULL;\
|
|
||||||
m##name[index].free();\
|
|
||||||
m##name[index] = NULL;\
|
|
||||||
return true;\
|
|
||||||
}\
|
|
||||||
else if(_in[0] == '$' || _in[0] == '#')\
|
|
||||||
{\
|
|
||||||
m##name##Name[index] = _in;\
|
|
||||||
m##name##AssetId[index] = StringTable->EmptyString();\
|
|
||||||
m##name##Asset[index] = NULL;\
|
|
||||||
m##name[index].free();\
|
|
||||||
m##name[index] = NULL;\
|
|
||||||
return true;\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
if (AssetDatabase.isDeclaredAsset(_in))\
|
|
||||||
{\
|
|
||||||
m##name##AssetId[index] = _in;\
|
|
||||||
\
|
|
||||||
U32 assetState = ImageAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]);\
|
|
||||||
\
|
|
||||||
if (ImageAsset::Ok == assetState)\
|
|
||||||
{\
|
|
||||||
m##name##Name[index] = StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
else\
|
|
||||||
{\
|
|
||||||
StringTableEntry assetId = ImageAsset::getAssetIdByFilename(_in);\
|
|
||||||
if (assetId != StringTable->EmptyString())\
|
|
||||||
{\
|
|
||||||
m##name##AssetId[index] = assetId;\
|
|
||||||
if (ImageAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]) == ImageAsset::Ok)\
|
|
||||||
{\
|
|
||||||
m##name##Name[index] = StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
else\
|
|
||||||
{\
|
|
||||||
m##name##Name[index] = _in;\
|
|
||||||
m##name##AssetId[index] = StringTable->EmptyString();\
|
|
||||||
m##name##Asset[index] = NULL;\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
if (get##name(index) != StringTable->EmptyString() && m##name##Name[index] != StringTable->insert("texhandle"))\
|
|
||||||
{\
|
|
||||||
m##name##Asset[index]->getChangedSignal().notify(this, &className::changeFunc);\
|
|
||||||
if (get##name(index)[0] != '$' && get##name(index)[0] != '#')\
|
|
||||||
m##name[index].set(get##name(index), m##name##Profile[index], avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));\
|
|
||||||
}\
|
|
||||||
else\
|
|
||||||
{\
|
|
||||||
m##name[index].free();\
|
|
||||||
m##name[index] = NULL;\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
if(get##name(index) == StringTable->EmptyString())\
|
|
||||||
return true;\
|
|
||||||
\
|
|
||||||
if (m##name##Asset[index].notNull() && m##name##Asset[index]->getStatus() != ImageAsset::Ok)\
|
|
||||||
{\
|
|
||||||
Con::errorf("%s(%s)::_set%s(%i) - image asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name), index, _in, ImageAsset::getAssetErrstrn(m##name##Asset[index]->getStatus()).c_str());\
|
|
||||||
return false; \
|
|
||||||
}\
|
|
||||||
else if (!m##name[index])\
|
|
||||||
{\
|
|
||||||
if (GFX->getAdapterType() != NullDevice)\
|
|
||||||
Con::errorf("%s(%s)::_set%s(%i) - Couldn't load image \"%s\"", macroText(className), getName(), macroText(name), index, _in);\
|
|
||||||
return false; \
|
|
||||||
}\
|
|
||||||
return true;\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
const StringTableEntry get##name(const U32& index) const\
|
|
||||||
{\
|
|
||||||
if (m##name##Asset[index] && (m##name##Asset[index]->getImageFileName() != StringTable->EmptyString()))\
|
|
||||||
if (m##name##Asset[index]->getImageFileName()[0] == '#' || m##name##Asset[index]->getImageFileName()[0] == '$')\
|
|
||||||
return m##name##Asset[index]->getImageFileName();\
|
|
||||||
else\
|
|
||||||
return Platform::makeRelativePathName(m##name##Asset[index]->getImagePath(), Platform::getMainDotCsDir());\
|
|
||||||
else if (m##name##AssetId[index] != StringTable->EmptyString())\
|
|
||||||
return m##name##AssetId[index];\
|
|
||||||
else if (m##name##Name[index] != StringTable->EmptyString())\
|
|
||||||
{\
|
|
||||||
if (String(m##name##Name[index]).startsWith("#") || String(m##name##Name[index]).startsWith("$"))\
|
|
||||||
return StringTable->insert(m##name##Name[index]);\
|
|
||||||
else\
|
|
||||||
return StringTable->insert(Platform::makeRelativePathName(m##name##Name[index], Platform::getMainDotCsDir()));\
|
|
||||||
}\
|
|
||||||
else\
|
|
||||||
return StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
GFXTexHandle get##name##Resource(const U32& index) \
|
|
||||||
{\
|
|
||||||
if(index >= sm##name##Count || index < 0)\
|
|
||||||
return nullptr;\
|
|
||||||
if (m##name##Asset[index] && (m##name##Asset[index]->getImageFileName() != StringTable->EmptyString()))\
|
|
||||||
return m##name##Asset[index]->getTexture(m##name##Profile[index]);\
|
|
||||||
return m##name[index];\
|
|
||||||
}\
|
|
||||||
bool name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); }
|
|
||||||
|
|
||||||
#define DECLARE_IMAGEASSET_ARRAY_SETGET(className, name)\
|
|
||||||
static bool _set##name##Data(void* obj, const char* index, const char* data)\
|
|
||||||
{\
|
|
||||||
if (!index) return false;\
|
|
||||||
U32 idx = dAtoi(index);\
|
|
||||||
if (idx >= sm##name##Count)\
|
|
||||||
return false;\
|
|
||||||
bool ret = false;\
|
|
||||||
className* object = static_cast<className*>(obj);\
|
|
||||||
ret = object->_set##name(StringTable->insert(data),idx);\
|
|
||||||
return ret;\
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DECLARE_IMAGEASSET_ARRAY_NET_SETGET(className, name, bitmask)\
|
#define DECLARE_IMAGEASSET_ARRAY(className, name, profile, max) \
|
||||||
static bool _set##name##Data(void* obj, const char* index, const char* data)\
|
private: \
|
||||||
{\
|
AssetPtr<ImageAsset> m##name##Asset[max]; \
|
||||||
if (!index) return false;\
|
public: \
|
||||||
U32 idx = dAtoi(index);\
|
void _set##name(StringTableEntry _in, const U32& index){ \
|
||||||
if (idx >= sm##name##Count)\
|
if(m##name##Asset[index].getAssetId() == _in) \
|
||||||
return false;\
|
return; \
|
||||||
bool ret = false;\
|
if(!AssetDatabase.isDeclaredAsset(_in)) \
|
||||||
className* object = static_cast<className*>(obj);\
|
{ \
|
||||||
ret = object->_set##name(StringTable->insert(data),idx);\
|
StringTableEntry imageAssetId = StringTable->EmptyString(); \
|
||||||
if(ret)\
|
AssetQuery query; \
|
||||||
object->setMaskBits(bitmask);\
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
||||||
return ret;\
|
if (foundAssetcount != 0) \
|
||||||
}
|
{ \
|
||||||
|
imageAssetId = query.mAssetList[0]; \
|
||||||
|
} \
|
||||||
|
else if(Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
||||||
|
{ \
|
||||||
|
imageAssetId = ImageAsset::getAssetIdByFilename(_in); \
|
||||||
|
if (imageAssetId == ImageAsset::smNoImageAssetFallback) \
|
||||||
|
{ \
|
||||||
|
ImageAsset* privateImage = new ImageAsset(); \
|
||||||
|
privateImage->setImageFile(_in); \
|
||||||
|
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||||
|
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||||
|
} \
|
||||||
|
m##name##Asset[index] = imageAssetId; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
m##name##Asset[index] = _in; \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
inline StringTableEntry _get##name(const U32& index) const { return m##name##Asset[index].getAssetId(); } \
|
||||||
|
GFXTexHandle get##name(const U32& index) { return get##name(&profile, index); } \
|
||||||
|
GFXTexHandle get##name(GFXTextureProfile* requestedProfile, const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getTexture(requestedProfile) : NULL; }\
|
||||||
|
AssetPtr<ImageAsset> get##name##Asset(const U32& index) { return m##name##Asset[index]; } \
|
||||||
|
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}
|
||||||
|
|
||||||
#define INIT_IMAGEASSET_ARRAY(name, profile, index) \
|
|
||||||
{\
|
|
||||||
m##name##Name[index] = StringTable->EmptyString(); \
|
|
||||||
m##name##AssetId[index] = StringTable->EmptyString(); \
|
|
||||||
m##name##Asset[index] = NULL;\
|
|
||||||
m##name[index] = NULL;\
|
|
||||||
m##name##Profile[index] = &profile;\
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEF_IMAGEASSET_ARRAY_BINDS(className,name)\
|
#define DECLARE_IMAGEASSET_ARRAY_NET(className, name, profile, max, mask) \
|
||||||
|
private: \
|
||||||
|
AssetPtr<ImageAsset> m##name##Asset[max]; \
|
||||||
|
public: \
|
||||||
|
void _set##name(StringTableEntry _in, const U32& index){ \
|
||||||
|
if(m##name##Asset[index].getAssetId() == _in) \
|
||||||
|
return; \
|
||||||
|
if(!AssetDatabase.isDeclaredAsset(_in)) \
|
||||||
|
{ \
|
||||||
|
StringTableEntry imageAssetId = StringTable->EmptyString(); \
|
||||||
|
AssetQuery query; \
|
||||||
|
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
||||||
|
if (foundAssetcount != 0) \
|
||||||
|
{ \
|
||||||
|
imageAssetId = query.mAssetList[0]; \
|
||||||
|
} \
|
||||||
|
else if(Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
||||||
|
{ \
|
||||||
|
imageAssetId = ImageAsset::getAssetIdByFilename(_in); \
|
||||||
|
if (imageAssetId == ImageAsset::smNoImageAssetFallback) \
|
||||||
|
{ \
|
||||||
|
ImageAsset* privateImage = new ImageAsset(); \
|
||||||
|
privateImage->setImageFile(_in); \
|
||||||
|
imageAssetId = AssetDatabase.addPrivateAsset(privateImage); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
||||||
|
imageAssetId = ImageAsset::smNoImageAssetFallback; \
|
||||||
|
} \
|
||||||
|
m##name##Asset[index] = imageAssetId; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
m##name##Asset[index] = _in; \
|
||||||
|
} \
|
||||||
|
setMaskBits(mask); \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
inline StringTableEntry _get##name(const U32& index) const { return m##name##Asset[index].getAssetId(); } \
|
||||||
|
GFXTexHandle get##name(const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getTexture(&profile) : NULL; } \
|
||||||
|
GFXTexHandle get##name(GFXTextureProfile* requestedProfile, const U32& index) { return m##name##Asset[index].notNull() ? m##name##Asset[index]->getTexture(requestedProfile) : NULL; }\
|
||||||
|
AssetPtr<ImageAsset> get##name##Asset(const U32& index) { return m##name##Asset[index]; } \
|
||||||
|
static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}
|
||||||
|
|
||||||
|
|
||||||
|
#define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, docs) \
|
||||||
|
addProtectedField(assetText(name, Asset), TypeImageAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));
|
||||||
|
|
||||||
|
#define DEF_IMAGEASSET_ARRAY_BINDS(className,name, max)\
|
||||||
DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\
|
DefineEngineMethod(className, get##name, const char*, (S32 index), , "get name")\
|
||||||
{\
|
{\
|
||||||
return object->get##name(index); \
|
return object->get##name##Asset(index).notNull() ? object->get##name##Asset(index)->getImageFile() : ""; \
|
||||||
}\
|
}\
|
||||||
DefineEngineMethod(className, get##name##Asset, const char*, (S32 index), , assetText(name, asset reference))\
|
DefineEngineMethod(className, get##name##Asset, const char*, (S32 index), , assetText(name, asset reference))\
|
||||||
{\
|
{\
|
||||||
if(index >= className::sm##name##Count || index < 0)\
|
if(index >= max || index < 0)\
|
||||||
return "";\
|
return "";\
|
||||||
return object->m##name##AssetId[index]; \
|
return object->_get##name(index); \
|
||||||
}\
|
}\
|
||||||
DefineEngineMethod(className, set##name, bool, (const char* map, S32 index), , assetText(name,assignment. first tries asset then flat file.))\
|
DefineEngineMethod(className, set##name, void, (const char* map, S32 index), , assetText(name,assignment. first tries asset then flat file.))\
|
||||||
{\
|
{\
|
||||||
return object->_set##name(StringTable->insert(map), index);\
|
object->_set##name(StringTable->insert(map), index);\
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
|
|
||||||
|
|
||||||
#define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, docs) \
|
|
||||||
addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs)); \
|
|
||||||
addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define INITPERSISTFIELD_IMAGEASSET_ARRAY(name, arraySize, consoleClass, docs) \
|
|
||||||
addProtectedField(#name, TypeImageFilename, Offset(m##name##Name, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
|
|
||||||
addProtectedField(assetText(name, Asset), TypeImageAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOAD_IMAGEASSET_ARRAY(name, index)\
|
|
||||||
if (m##name##AssetId[index] != StringTable->EmptyString())\
|
|
||||||
{\
|
|
||||||
S32 assetState = ImageAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]);\
|
|
||||||
if (assetState == ImageAsset::Ok )\
|
|
||||||
{\
|
|
||||||
m##name##Name[index] = StringTable->EmptyString();\
|
|
||||||
}\
|
|
||||||
else Con::warnf("Warning: %s::LOAD_IMAGEASSET(%s)-%s", mClassName, m##name##AssetId[index], ImageAsset::getAssetErrstrn(assetState).c_str());\
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ StringTableEntry LevelAsset::getPreviewImagePath(void) const
|
||||||
{
|
{
|
||||||
if (mPreviewImageAsset.notNull() && mPreviewImageAsset->isAssetValid())
|
if (mPreviewImageAsset.notNull() && mPreviewImageAsset->isAssetValid())
|
||||||
{
|
{
|
||||||
return mPreviewImageAsset->getImagePath();
|
return mPreviewImageAsset->getImageFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
|
|
|
||||||
|
|
@ -211,39 +211,21 @@ void MaterialAsset::initializeAsset()
|
||||||
|
|
||||||
void MaterialAsset::onAssetRefresh()
|
void MaterialAsset::onAssetRefresh()
|
||||||
{
|
{
|
||||||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
// Ignore if not yet added to the sim.
|
||||||
|
if (!isProperlyAdded())
|
||||||
if (mMatDefinitionName == StringTable->EmptyString())
|
|
||||||
{
|
|
||||||
mLoadedState = Failed;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (Con::isScriptFile(mScriptPath))
|
// Call parent.
|
||||||
|
Parent::onAssetRefresh();
|
||||||
|
|
||||||
|
if (mMaterialDefinition)
|
||||||
{
|
{
|
||||||
//Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
|
mMaterialDefinition->flush();
|
||||||
//But that definition, whatever it is, is the 'correct' one, so we enable the Replace Existing behavior
|
mMaterialDefinition->reload();
|
||||||
//when the engine encounters a named object conflict.
|
|
||||||
String redefineBehaviorPrev = Con::getVariable("$Con::redefineBehavior");
|
|
||||||
Con::setVariable("$Con::redefineBehavior", "replaceExisting");
|
|
||||||
|
|
||||||
if (Con::executeFile(mScriptPath, false, false))
|
|
||||||
mLoadedState = ScriptLoaded;
|
|
||||||
else
|
|
||||||
mLoadedState = Failed;
|
|
||||||
|
|
||||||
//And now that we've executed, switch back to the prior behavior
|
|
||||||
Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
load();
|
|
||||||
AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
|
|
||||||
// Iterate all dependencies.
|
|
||||||
while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId)
|
|
||||||
{
|
{
|
||||||
StringTableEntry assetId = assetDependenciesItr->value;
|
load();
|
||||||
AssetBase* dependent = AssetDatabase.acquireAsset<AssetBase>(assetId);
|
|
||||||
dependent->refreshAsset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -644,7 +626,7 @@ void GuiInspectorTypeMaterialAssetPtr::updatePreviewImage()
|
||||||
MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(previewImage);
|
MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(previewImage);
|
||||||
if (matAsset && matAsset->getMaterialDefinition())
|
if (matAsset && matAsset->getMaterialDefinition())
|
||||||
{
|
{
|
||||||
mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->mDiffuseMapAssetId[0]);
|
mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->_getDiffuseMap(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -676,7 +658,7 @@ void GuiInspectorTypeMaterialAssetPtr::setPreviewImage(StringTableEntry assetId)
|
||||||
MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(assetId);
|
MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(assetId);
|
||||||
if (matAsset && matAsset->getMaterialDefinition())
|
if (matAsset && matAsset->getMaterialDefinition())
|
||||||
{
|
{
|
||||||
mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->mDiffuseMapAssetId[0]);
|
mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->_getDiffuseMap(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1884,7 +1884,7 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
|
||||||
{
|
{
|
||||||
//got a match!
|
//got a match!
|
||||||
ImageAsset* foundImageAsset = AssetDatabase.acquireAsset<ImageAsset>(testAssetId.c_str());
|
ImageAsset* foundImageAsset = AssetDatabase.acquireAsset<ImageAsset>(testAssetId.c_str());
|
||||||
imagePath = foundImageAsset->getImagePath();
|
imagePath = foundImageAsset->getImageFile();
|
||||||
|
|
||||||
AssetImportObject* newImageAssetObj = addImportingAsset("ImageAsset", imagePath, assetItem, "");
|
AssetImportObject* newImageAssetObj = addImportingAsset("ImageAsset", imagePath, assetItem, "");
|
||||||
|
|
||||||
|
|
@ -1928,7 +1928,7 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
|
||||||
{
|
{
|
||||||
//got a match!
|
//got a match!
|
||||||
ImageAsset* foundImageAsset = AssetDatabase.acquireAsset<ImageAsset>(testAssetId.c_str());
|
ImageAsset* foundImageAsset = AssetDatabase.acquireAsset<ImageAsset>(testAssetId.c_str());
|
||||||
imagePath = foundImageAsset->getImagePath();
|
imagePath = foundImageAsset->getImageFile();
|
||||||
|
|
||||||
AssetImportObject* newImageAssetObj = addImportingAsset("ImageAsset", imagePath, assetItem, "");
|
AssetImportObject* newImageAssetObj = addImportingAsset("ImageAsset", imagePath, assetItem, "");
|
||||||
|
|
||||||
|
|
@ -2824,7 +2824,7 @@ Torque::Path AssetImporter::importImageAsset(AssetImportObject* assetItem)
|
||||||
|
|
||||||
StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str());
|
StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str());
|
||||||
|
|
||||||
String imageFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension();
|
String imageFileName = assetItem->filePath.getFullPath();
|
||||||
String assetPath = targetPath + "/" + imageFileName;
|
String assetPath = targetPath + "/" + imageFileName;
|
||||||
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
|
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
|
||||||
String originalPath = assetItem->filePath.getFullPath().c_str();
|
String originalPath = assetItem->filePath.getFullPath().c_str();
|
||||||
|
|
@ -2841,7 +2841,7 @@ Torque::Path AssetImporter::importImageAsset(AssetImportObject* assetItem)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
newAsset->setAssetName(assetName);
|
newAsset->setAssetName(assetName);
|
||||||
newAsset->setImageFileName(imageFileName.c_str());
|
newAsset->setImageFile(imageFileName.c_str());
|
||||||
|
|
||||||
//If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original
|
//If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original
|
||||||
//file path for reimporting support later
|
//file path for reimporting support later
|
||||||
|
|
@ -2995,27 +2995,27 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
|
||||||
|
|
||||||
if (imageType == ImageAsset::ImageTypes::Albedo || childItem->imageSuffixType.isEmpty())
|
if (imageType == ImageAsset::ImageTypes::Albedo || childItem->imageSuffixType.isEmpty())
|
||||||
{
|
{
|
||||||
newMat->mDiffuseMapAssetId[0] = assetMapFillInStr;
|
newMat->_setDiffuseMap(assetMapFillInStr,0);
|
||||||
}
|
}
|
||||||
else if (imageType == ImageAsset::ImageTypes::Normal)
|
else if (imageType == ImageAsset::ImageTypes::Normal)
|
||||||
{
|
{
|
||||||
newMat->mNormalMapAssetId[0] = assetMapFillInStr;
|
newMat->_setNormalMap(assetMapFillInStr, 0);
|
||||||
}
|
}
|
||||||
else if (imageType == ImageAsset::ImageTypes::ORMConfig)
|
else if (imageType == ImageAsset::ImageTypes::ORMConfig)
|
||||||
{
|
{
|
||||||
newMat->mORMConfigMapAssetId[0] = assetMapFillInStr;
|
newMat->_setORMConfigMap(assetMapFillInStr, 0);
|
||||||
}
|
}
|
||||||
else if (imageType == ImageAsset::ImageTypes::Metalness)
|
else if (imageType == ImageAsset::ImageTypes::Metalness)
|
||||||
{
|
{
|
||||||
newMat->mMetalMapAssetId[0] = assetMapFillInStr;
|
newMat->_setMetalMap(assetMapFillInStr, 0);
|
||||||
}
|
}
|
||||||
else if (imageType == ImageAsset::ImageTypes::AO)
|
else if (imageType == ImageAsset::ImageTypes::AO)
|
||||||
{
|
{
|
||||||
newMat->mAOMapAssetId[0] = assetMapFillInStr;
|
newMat->_setAOMap(assetMapFillInStr, 0);
|
||||||
}
|
}
|
||||||
else if (imageType == ImageAsset::ImageTypes::Roughness)
|
else if (imageType == ImageAsset::ImageTypes::Roughness)
|
||||||
{
|
{
|
||||||
newMat->mRoughMapAssetId[0] = assetMapFillInStr;
|
newMat->_setRoughMap(assetMapFillInStr, 0);
|
||||||
hasRoughness = true;
|
hasRoughness = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,93 @@ if (m##name##AssetId != StringTable->EmptyString())\
|
||||||
m##name##Asset = other.m##name##Asset;\
|
m##name##Asset = other.m##name##Asset;\
|
||||||
m##name = other.m##name
|
m##name = other.m##name
|
||||||
|
|
||||||
|
// copy constructor refactor
|
||||||
|
#define CLONE_ASSET_REFACTOR(name) \
|
||||||
|
m##name##Asset = other.m##name##Asset;\
|
||||||
|
|
||||||
|
//network send - datablock refactor
|
||||||
|
#define PACKDATA_ASSET_REFACTOR(name)\
|
||||||
|
if (stream->writeFlag(m##name##Asset.notNull()))\
|
||||||
|
{\
|
||||||
|
stream->writeString(m##name##Asset.getAssetId());\
|
||||||
|
}
|
||||||
|
|
||||||
|
//network recieve - datablock
|
||||||
|
#define UNPACKDATA_ASSET_REFACTOR(name)\
|
||||||
|
if (stream->readFlag())\
|
||||||
|
{\
|
||||||
|
_set##name(stream->readSTString());\
|
||||||
|
}
|
||||||
|
|
||||||
|
//network send - object-instance
|
||||||
|
#define PACK_ASSET_REFACTOR(netconn, name)\
|
||||||
|
if (stream->writeFlag(m##name##Asset.notNull()))\
|
||||||
|
{\
|
||||||
|
NetStringHandle assetIdStr = m##name##Asset.getAssetId();\
|
||||||
|
netconn->packNetStringHandleU(stream, assetIdStr);\
|
||||||
|
}
|
||||||
|
|
||||||
|
//network recieve - object-instance
|
||||||
|
#define UNPACK_ASSET_REFACTOR(netconn, name)\
|
||||||
|
if (stream->readFlag())\
|
||||||
|
{\
|
||||||
|
_set##name(netconn->unpackNetStringHandleU(stream).getString());\
|
||||||
|
}
|
||||||
|
|
||||||
|
//network send - datablock
|
||||||
|
#define PACKDATA_ASSET_ARRAY_REFACTOR(name, max)\
|
||||||
|
for (U32 i = 0; i < max; i++)\
|
||||||
|
{\
|
||||||
|
if (stream->writeFlag(m##name##Asset[i].notNull()))\
|
||||||
|
{\
|
||||||
|
stream->writeString(m##name##Asset[i].getAssetId()); \
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
//network recieve - datablock
|
||||||
|
#define UNPACKDATA_ASSET_ARRAY_REFACTOR(name, max)\
|
||||||
|
for (U32 i = 0; i < max; i++)\
|
||||||
|
{\
|
||||||
|
if (stream->readFlag())\
|
||||||
|
{\
|
||||||
|
m##name##Asset[i] = stream->readSTString();\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
//network send - object-instance
|
||||||
|
#define PACK_ASSET_ARRAY_REFACTOR(netconn, name, max)\
|
||||||
|
for (U32 i = 0; i < max; i++)\
|
||||||
|
{\
|
||||||
|
if (stream->writeFlag(m##name##Asset[i].notNull()))\
|
||||||
|
{\
|
||||||
|
NetStringHandle assetIdStr = m##name##Asset[i].getAssetId();\
|
||||||
|
netconn->packNetStringHandleU(stream, assetIdStr);\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
//network recieve - object-instance
|
||||||
|
#define UNPACK_ASSET_ARRAY_REFACTOR(netconn, name, max)\
|
||||||
|
for (U32 i = 0; i < max; i++)\
|
||||||
|
{\
|
||||||
|
if (stream->readFlag())\
|
||||||
|
{\
|
||||||
|
m##name##Asset[i] = StringTable->insert(netconn->unpackNetStringHandleU(stream).getString());\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEF_ASSET_BINDS_REFACTOR(className,name)\
|
||||||
|
DefineEngineMethod(className, get##name, StringTableEntry, (), , "get name")\
|
||||||
|
{\
|
||||||
|
return object->get##name##Asset()->getImageFile(); \
|
||||||
|
}\
|
||||||
|
DefineEngineMethod(className, get##name##Asset, StringTableEntry, (), , assetText(name, asset reference))\
|
||||||
|
{\
|
||||||
|
return object->_get##name(); \
|
||||||
|
}\
|
||||||
|
DefineEngineMethod(className, set##name, void, (const char* assetName), , assetText(name,assignment. first tries asset then flat file.))\
|
||||||
|
{\
|
||||||
|
object->_set##name(StringTable->insert(assetName));\
|
||||||
|
}
|
||||||
// addProtectedField acessors
|
// addProtectedField acessors
|
||||||
#define DECLARE_ASSET_SETGET(className, name)\
|
#define DECLARE_ASSET_SETGET(className, name)\
|
||||||
static bool _set##name##Data(void* obj, const char* index, const char* data)\
|
static bool _set##name##Data(void* obj, const char* index, const char* data)\
|
||||||
|
|
|
||||||
|
|
@ -972,10 +972,10 @@ void GroundCover::_initialize( U32 cellCount, U32 cellPlacementCount )
|
||||||
if(mat)
|
if(mat)
|
||||||
{
|
{
|
||||||
GFXTexHandle tex;
|
GFXTexHandle tex;
|
||||||
if (mat->getDiffuseMapResource(0))
|
if (mat->getDiffuseMap(0))
|
||||||
tex = mat->getDiffuseMapResource(0);
|
tex = mat->getDiffuseMap(0);
|
||||||
else if (mat->getDiffuseMap(0) != StringTable->EmptyString())
|
else if (mat->getDiffuseMapAsset(0).notNull())
|
||||||
tex = GFXTexHandle(mat->getDiffuseMap(0), &GFXStaticTextureSRGBProfile, "GroundCover texture aspect ratio check");
|
tex = mat->getDiffuseMap(0);
|
||||||
|
|
||||||
if(tex.isValid())
|
if(tex.isValid())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,6 @@ ParticleData::ParticleData()
|
||||||
animTexFramesString = NULL; // string of animation frame indices
|
animTexFramesString = NULL; // string of animation frame indices
|
||||||
animTexUVs = NULL; // array of tile vertex UVs
|
animTexUVs = NULL; // array of tile vertex UVs
|
||||||
|
|
||||||
INIT_ASSET(Texture);
|
|
||||||
INIT_ASSET(TextureExt);
|
|
||||||
|
|
||||||
constrain_pos = false;
|
constrain_pos = false;
|
||||||
start_angle = 0.0f;
|
start_angle = 0.0f;
|
||||||
angle_variance = 0.0f;
|
angle_variance = 0.0f;
|
||||||
|
|
@ -151,11 +148,6 @@ void ParticleData::initPersistFields()
|
||||||
{
|
{
|
||||||
docsURL;
|
docsURL;
|
||||||
addGroup("Basic");
|
addGroup("Basic");
|
||||||
addProtectedField("textureName", TYPEID< StringTableEntry >(), Offset(mTextureName, ParticleData), _setTextureData, defaultProtectedGetFn,
|
|
||||||
"Texture file to use for this particle.", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
addField("animTexName", TYPEID< StringTableEntry >(), Offset(mTextureName, ParticleData),
|
|
||||||
"@brief Texture file to use for this particle if animateTexture is true.\n\n"
|
|
||||||
"Deprecated. Use textureName instead.", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
INITPERSISTFIELD_IMAGEASSET(Texture, ParticleData, "Texture to use for this particle.");
|
INITPERSISTFIELD_IMAGEASSET(Texture, ParticleData, "Texture to use for this particle.");
|
||||||
addField("useInvAlpha", TYPEID< bool >(), Offset(useInvAlpha, ParticleData),
|
addField("useInvAlpha", TYPEID< bool >(), Offset(useInvAlpha, ParticleData),
|
||||||
"@brief Controls how particles blend with the scene.\n\n"
|
"@brief Controls how particles blend with the scene.\n\n"
|
||||||
|
|
@ -241,7 +233,6 @@ void ParticleData::initPersistFields()
|
||||||
endGroup("Over Time");
|
endGroup("Over Time");
|
||||||
|
|
||||||
addGroup("AFX");
|
addGroup("AFX");
|
||||||
addProtectedField("textureExtName", TypeFilename, Offset(mTextureExtName, ParticleData), _setTextureExtData, &defaultProtectedGetFn, "", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
INITPERSISTFIELD_IMAGEASSET(TextureExt, ParticleData, "");
|
INITPERSISTFIELD_IMAGEASSET(TextureExt, ParticleData, "");
|
||||||
addField("constrainPos", TypeBool, Offset(constrain_pos, ParticleData));
|
addField("constrainPos", TypeBool, Offset(constrain_pos, ParticleData));
|
||||||
addFieldV("angle", TypeRangedF32, Offset(start_angle, ParticleData), &CommonValidators::DegreeRange);
|
addFieldV("angle", TypeRangedF32, Offset(start_angle, ParticleData), &CommonValidators::DegreeRange);
|
||||||
|
|
@ -307,7 +298,7 @@ void ParticleData::packData(BitStream* stream)
|
||||||
stream->writeFloat( times[i], 8);
|
stream->writeFloat( times[i], 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
PACKDATA_ASSET(Texture);
|
PACKDATA_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
mathWrite(*stream, texCoords[i]);
|
mathWrite(*stream, texCoords[i]);
|
||||||
|
|
@ -321,7 +312,7 @@ void ParticleData::packData(BitStream* stream)
|
||||||
stream->writeInt(framesPerSec, 8);
|
stream->writeInt(framesPerSec, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
PACKDATA_ASSET(TextureExt);
|
PACKDATA_ASSET_REFACTOR(TextureExt);
|
||||||
|
|
||||||
stream->writeFlag(constrain_pos);
|
stream->writeFlag(constrain_pos);
|
||||||
stream->writeFloat(start_angle/360.0f, 11);
|
stream->writeFloat(start_angle/360.0f, 11);
|
||||||
|
|
@ -392,7 +383,7 @@ void ParticleData::unpackData(BitStream* stream)
|
||||||
times[i] = stream->readFloat(8);
|
times[i] = stream->readFloat(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNPACKDATA_ASSET(Texture);
|
UNPACKDATA_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
mathRead(*stream, &texCoords[i]);
|
mathRead(*stream, &texCoords[i]);
|
||||||
|
|
@ -405,7 +396,7 @@ void ParticleData::unpackData(BitStream* stream)
|
||||||
framesPerSec = stream->readInt(8);
|
framesPerSec = stream->readInt(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNPACKDATA_ASSET(TextureExt);
|
UNPACKDATA_ASSET_REFACTOR(TextureExt);
|
||||||
|
|
||||||
constrain_pos = stream->readFlag();
|
constrain_pos = stream->readFlag();
|
||||||
start_angle = 360.0f*stream->readFloat(11);
|
start_angle = 360.0f*stream->readFloat(11);
|
||||||
|
|
@ -711,13 +702,6 @@ bool ParticleData::reload(char errorBuffer[256])
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
StringTableEntry particleTex = getTexture();
|
|
||||||
|
|
||||||
if (!_setTexture(particleTex))
|
|
||||||
{
|
|
||||||
dSprintf(errorBuffer, 256, "Missing particle texture: %s", particleTex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
numFrames = 0;
|
numFrames = 0;
|
||||||
for( S32 i=0; i<PDC_MAX_TEX; i++ )
|
for( S32 i=0; i<PDC_MAX_TEX; i++ )
|
||||||
|
|
@ -788,12 +772,12 @@ ParticleData::ParticleData(const ParticleData& other, bool temp_clone) : SimData
|
||||||
animTexFramesString = other.animTexFramesString;
|
animTexFramesString = other.animTexFramesString;
|
||||||
animTexFrames = other.animTexFrames; // -- parsed from animTexFramesString
|
animTexFrames = other.animTexFrames; // -- parsed from animTexFramesString
|
||||||
|
|
||||||
CLONE_ASSET(Texture);
|
CLONE_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
spinBias = other.spinBias;
|
spinBias = other.spinBias;
|
||||||
randomizeSpinDir = other.randomizeSpinDir;
|
randomizeSpinDir = other.randomizeSpinDir;
|
||||||
|
|
||||||
CLONE_ASSET(TextureExt);
|
CLONE_ASSET_REFACTOR(TextureExt);
|
||||||
|
|
||||||
constrain_pos = other.constrain_pos;
|
constrain_pos = other.constrain_pos;
|
||||||
start_angle = other.start_angle;
|
start_angle = other.start_angle;
|
||||||
|
|
@ -829,4 +813,4 @@ void ParticleData::onPerformSubstitutions()
|
||||||
reload(errorBuffer);
|
reload(errorBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_ASSET_BINDS(ParticleData, Texture);
|
DEF_ASSET_BINDS_REFACTOR(ParticleData, Texture);
|
||||||
|
|
|
||||||
|
|
@ -86,17 +86,11 @@ class ParticleData : public SimDataBlock
|
||||||
StringTableEntry animTexFramesString;
|
StringTableEntry animTexFramesString;
|
||||||
Vector<U8> animTexFrames;
|
Vector<U8> animTexFrames;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(ParticleData, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(ParticleData, Texture, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(ParticleData, Texture);
|
|
||||||
|
|
||||||
static bool protectedSetSizes(void* object, const char* index, const char* data);
|
static bool protectedSetSizes(void* object, const char* index, const char* data);
|
||||||
static bool protectedSetTimes(void* object, const char* index, const char* data);
|
static bool protectedSetTimes(void* object, const char* index, const char* data);
|
||||||
|
|
||||||
void onImageChanged()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ParticleData();
|
ParticleData();
|
||||||
~ParticleData();
|
~ParticleData();
|
||||||
|
|
@ -120,8 +114,7 @@ public:
|
||||||
F32 spinBias;
|
F32 spinBias;
|
||||||
bool randomizeSpinDir;
|
bool randomizeSpinDir;
|
||||||
public:
|
public:
|
||||||
DECLARE_IMAGEASSET(ParticleData, TextureExt, onImageChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(ParticleData, TextureExt,GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(ParticleData, TextureExt);
|
|
||||||
|
|
||||||
bool constrain_pos;
|
bool constrain_pos;
|
||||||
F32 start_angle;
|
F32 start_angle;
|
||||||
|
|
|
||||||
|
|
@ -740,16 +740,19 @@ bool ParticleEmitterData::preload(bool server, String &errorStr)
|
||||||
// otherwise, check that all particles refer to the same texture
|
// otherwise, check that all particles refer to the same texture
|
||||||
else if (particleDataBlocks.size() > 1)
|
else if (particleDataBlocks.size() > 1)
|
||||||
{
|
{
|
||||||
StringTableEntry txr_name = particleDataBlocks[0]->getTexture();
|
if (particleDataBlocks[0]->getTextureAsset().notNull())
|
||||||
for (S32 i = 1; i < particleDataBlocks.size(); i++)
|
{
|
||||||
{
|
StringTableEntry txr_name = particleDataBlocks[0]->getTextureAsset()->getImageFile();
|
||||||
// warn if particle textures are inconsistent
|
for (S32 i = 1; i < particleDataBlocks.size(); i++)
|
||||||
if (particleDataBlocks[i]->getTexture() != txr_name)
|
{
|
||||||
{
|
// warn if particle textures are inconsistent
|
||||||
Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles reference different textures.", getName());
|
if (particleDataBlocks[i]->getTextureAsset()->getImageFile() != txr_name)
|
||||||
break;
|
{
|
||||||
}
|
Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles reference different textures.", getName());
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1225,7 +1228,7 @@ void ParticleEmitter::prepRenderImage(SceneRenderState* state)
|
||||||
if (mDataBlock->textureHandle)
|
if (mDataBlock->textureHandle)
|
||||||
ri->diffuseTex = &*(mDataBlock->textureHandle);
|
ri->diffuseTex = &*(mDataBlock->textureHandle);
|
||||||
else
|
else
|
||||||
ri->diffuseTex = &*(part_list_head.next->dataBlock->getTextureResource());
|
ri->diffuseTex = &*(part_list_head.next->dataBlock->getTexture());
|
||||||
|
|
||||||
ri->softnessDistance = mDataBlock->softnessDistance;
|
ri->softnessDistance = mDataBlock->softnessDistance;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,12 +129,8 @@ PrecipitationData::PrecipitationData()
|
||||||
{
|
{
|
||||||
INIT_ASSET(Sound);
|
INIT_ASSET(Sound);
|
||||||
|
|
||||||
INIT_ASSET(Drop);
|
|
||||||
|
|
||||||
mDropShaderName = StringTable->EmptyString();
|
mDropShaderName = StringTable->EmptyString();
|
||||||
|
|
||||||
INIT_ASSET(Splash);
|
|
||||||
|
|
||||||
mSplashShaderName = StringTable->EmptyString();
|
mSplashShaderName = StringTable->EmptyString();
|
||||||
|
|
||||||
mDropsPerSide = 4;
|
mDropsPerSide = 4;
|
||||||
|
|
@ -146,12 +142,6 @@ void PrecipitationData::initPersistFields()
|
||||||
docsURL;
|
docsURL;
|
||||||
INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
|
INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
|
||||||
|
|
||||||
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn,
|
|
||||||
"@brief Texture filename for drop particles.\n\n"
|
|
||||||
"The drop texture can contain several different drop sub-textures "
|
|
||||||
"arranged in a grid. There must be the same number of rows as columns. A "
|
|
||||||
"random frame will be chosen for each drop.", AbstractClassRep::FIELD_HideInInspectors );
|
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET(Drop, PrecipitationData, "@brief Texture for drop particles.\n\n"
|
INITPERSISTFIELD_IMAGEASSET(Drop, PrecipitationData, "@brief Texture for drop particles.\n\n"
|
||||||
"The drop texture can contain several different drop sub-textures "
|
"The drop texture can contain several different drop sub-textures "
|
||||||
"arranged in a grid. There must be the same number of rows as columns. A "
|
"arranged in a grid. There must be the same number of rows as columns. A "
|
||||||
|
|
@ -160,12 +150,6 @@ void PrecipitationData::initPersistFields()
|
||||||
addField( "dropShader", TypeString, Offset(mDropShaderName, PrecipitationData),
|
addField( "dropShader", TypeString, Offset(mDropShaderName, PrecipitationData),
|
||||||
"The name of the shader used for raindrops." );
|
"The name of the shader used for raindrops." );
|
||||||
|
|
||||||
addProtectedField("splashTexture", TypeFilename, Offset(mSplashName, PrecipitationData), &_setSplashData, &defaultProtectedGetFn,
|
|
||||||
"@brief Texture filename for splash particles.\n\n"
|
|
||||||
"The splash texture can contain several different splash sub-textures "
|
|
||||||
"arranged in a grid. There must be the same number of rows as columns. A "
|
|
||||||
"random frame will be chosen for each splash.", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET(Splash, PrecipitationData, "@brief Texture for splash particles.\n\n"
|
INITPERSISTFIELD_IMAGEASSET(Splash, PrecipitationData, "@brief Texture for splash particles.\n\n"
|
||||||
"The splash texture can contain several different splash sub-textures "
|
"The splash texture can contain several different splash sub-textures "
|
||||||
"arranged in a grid. There must be the same number of rows as columns. A "
|
"arranged in a grid. There must be the same number of rows as columns. A "
|
||||||
|
|
@ -206,11 +190,11 @@ void PrecipitationData::packData(BitStream* stream)
|
||||||
|
|
||||||
PACKDATA_ASSET(Sound);
|
PACKDATA_ASSET(Sound);
|
||||||
|
|
||||||
PACKDATA_ASSET(Drop);
|
PACKDATA_ASSET_REFACTOR(Drop);
|
||||||
|
|
||||||
stream->writeString(mDropShaderName);
|
stream->writeString(mDropShaderName);
|
||||||
|
|
||||||
PACKDATA_ASSET(Splash);
|
PACKDATA_ASSET_REFACTOR(Splash);
|
||||||
|
|
||||||
stream->writeString(mSplashShaderName);
|
stream->writeString(mSplashShaderName);
|
||||||
stream->write(mDropsPerSide);
|
stream->write(mDropsPerSide);
|
||||||
|
|
@ -223,11 +207,11 @@ void PrecipitationData::unpackData(BitStream* stream)
|
||||||
|
|
||||||
UNPACKDATA_ASSET(Sound);
|
UNPACKDATA_ASSET(Sound);
|
||||||
|
|
||||||
UNPACKDATA_ASSET(Drop);
|
UNPACKDATA_ASSET_REFACTOR(Drop);
|
||||||
|
|
||||||
mDropShaderName = stream->readSTString();
|
mDropShaderName = stream->readSTString();
|
||||||
|
|
||||||
UNPACKDATA_ASSET(Splash);
|
UNPACKDATA_ASSET_REFACTOR(Splash);
|
||||||
|
|
||||||
mSplashShaderName = stream->readSTString();
|
mSplashShaderName = stream->readSTString();
|
||||||
stream->read(&mDropsPerSide);
|
stream->read(&mDropsPerSide);
|
||||||
|
|
@ -632,10 +616,10 @@ void Precipitation::initMaterials()
|
||||||
mDropShader = NULL;
|
mDropShader = NULL;
|
||||||
mSplashShader = NULL;
|
mSplashShader = NULL;
|
||||||
|
|
||||||
if(pd->mDrop.isNull())
|
if(pd->getDropAsset().isNull())
|
||||||
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getDrop());
|
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getDropAsset().getAssetId());
|
||||||
else
|
else
|
||||||
mDropHandle = pd->mDrop;
|
mDropHandle = pd->getDrop();
|
||||||
|
|
||||||
if ( dStrlen(pd->mDropShaderName) > 0 )
|
if ( dStrlen(pd->mDropShaderName) > 0 )
|
||||||
{
|
{
|
||||||
|
|
@ -655,10 +639,10 @@ void Precipitation::initMaterials()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pd->mSplash.isNull())
|
if (pd->getSplashAsset().isNull())
|
||||||
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getSplash());
|
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getSplashAsset().getAssetId());
|
||||||
else
|
else
|
||||||
mSplashHandle = pd->mSplash;
|
mSplashHandle = pd->getSplash();
|
||||||
|
|
||||||
if ( dStrlen(pd->mSplashShaderName) > 0 )
|
if ( dStrlen(pd->mSplashShaderName) > 0 )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,11 @@ class PrecipitationData : public GameBaseData
|
||||||
DECLARE_SOUNDASSET(PrecipitationData, Sound);
|
DECLARE_SOUNDASSET(PrecipitationData, Sound);
|
||||||
DECLARE_ASSET_SETGET(PrecipitationData, Sound);
|
DECLARE_ASSET_SETGET(PrecipitationData, Sound);
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
|
DECLARE_IMAGEASSET(PrecipitationData, Drop, GFXStaticTextureSRGBProfile) ///< Texture for drop particles
|
||||||
DECLARE_ASSET_SETGET(PrecipitationData, Drop);
|
|
||||||
|
|
||||||
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
|
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
|
DECLARE_IMAGEASSET(PrecipitationData, Splash, GFXStaticTextureSRGBProfile) ///< Texture for splash particles
|
||||||
DECLARE_ASSET_SETGET(PrecipitationData, Splash);
|
|
||||||
|
|
||||||
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
|
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
|
||||||
|
|
||||||
|
|
@ -68,15 +66,6 @@ class PrecipitationData : public GameBaseData
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
void packData(BitStream* stream) override;
|
void packData(BitStream* stream) override;
|
||||||
void unpackData(BitStream* stream) override;
|
void unpackData(BitStream* stream) override;
|
||||||
|
|
||||||
void onDropChanged()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
void onSplashChanged()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Raindrop
|
struct Raindrop
|
||||||
|
|
|
||||||
|
|
@ -96,11 +96,6 @@ SplashData::SplashData()
|
||||||
explosionId = 0;
|
explosionId = 0;
|
||||||
|
|
||||||
U32 i;
|
U32 i;
|
||||||
for (i = 0; i < NUM_TEX; i++)
|
|
||||||
{
|
|
||||||
INIT_IMAGEASSET_ARRAY(Texture, GFXStaticTextureSRGBProfile, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
for( i=0; i<NUM_TIME_KEYS; i++ )
|
for( i=0; i<NUM_TIME_KEYS; i++ )
|
||||||
times[i] = 1.0;
|
times[i] = 1.0;
|
||||||
|
|
||||||
|
|
@ -188,6 +183,8 @@ void SplashData::packData(BitStream* stream)
|
||||||
stream->writeRangedU32(explosion->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
stream->writeRangedU32(explosion->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PACKDATA_ASSET_ARRAY_REFACTOR(Texture, NUM_TEX);
|
||||||
|
|
||||||
S32 i;
|
S32 i;
|
||||||
for( i=0; i<NUM_EMITTERS; i++ )
|
for( i=0; i<NUM_EMITTERS; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -206,11 +203,6 @@ void SplashData::packData(BitStream* stream)
|
||||||
{
|
{
|
||||||
stream->write( times[i] );
|
stream->write( times[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<NUM_TEX; i++ )
|
|
||||||
{
|
|
||||||
PACKDATA_ASSET_ARRAY(Texture, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
@ -244,6 +236,8 @@ void SplashData::unpackData(BitStream* stream)
|
||||||
explosionId = stream->readRangedU32( DataBlockObjectIdFirst, DataBlockObjectIdLast );
|
explosionId = stream->readRangedU32( DataBlockObjectIdFirst, DataBlockObjectIdLast );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UNPACKDATA_ASSET_ARRAY_REFACTOR(Texture, NUM_TEX);
|
||||||
|
|
||||||
U32 i;
|
U32 i;
|
||||||
for( i=0; i<NUM_EMITTERS; i++ )
|
for( i=0; i<NUM_EMITTERS; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -262,11 +256,6 @@ void SplashData::unpackData(BitStream* stream)
|
||||||
{
|
{
|
||||||
stream->read( ×[i] );
|
stream->read( ×[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<NUM_TEX; i++ )
|
|
||||||
{
|
|
||||||
UNPACKDATA_ASSET_ARRAY(Texture, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
@ -299,9 +288,9 @@ bool SplashData::preload(bool server, String &errorStr)
|
||||||
|
|
||||||
for( i=0; i<NUM_TEX; i++ )
|
for( i=0; i<NUM_TEX; i++ )
|
||||||
{
|
{
|
||||||
if (mTexture[i].isNull())
|
if (mTextureAsset[i].isNull())
|
||||||
{
|
{
|
||||||
_setTexture(getTexture(i), i);
|
_setTexture(_getTexture(i), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,12 +122,7 @@ public:
|
||||||
F32 times[ NUM_TIME_KEYS ];
|
F32 times[ NUM_TIME_KEYS ];
|
||||||
LinearColorF colors[ NUM_TIME_KEYS ];
|
LinearColorF colors[ NUM_TIME_KEYS ];
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, NUM_TEX, onTextureChanged);
|
DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, GFXStaticTextureSRGBProfile, NUM_TEX)
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(SplashData, Texture)
|
|
||||||
void onTextureChanged()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExplosionData* explosion;
|
ExplosionData* explosion;
|
||||||
S32 explosionId;
|
S32 explosionId;
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,6 @@ GameMode::GameMode() :
|
||||||
mIsActive(false),
|
mIsActive(false),
|
||||||
mIsAlwaysActive(false)
|
mIsAlwaysActive(false)
|
||||||
{
|
{
|
||||||
INIT_ASSET(PreviewImage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::initPersistFields()
|
void GameMode::initPersistFields()
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ private:
|
||||||
StringTableEntry mGameModeName;
|
StringTableEntry mGameModeName;
|
||||||
StringTableEntry mGameModeDesc;
|
StringTableEntry mGameModeDesc;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GameMode, PreviewImage, previewChange, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(GameMode, PreviewImage, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(GameMode, PreviewImage);
|
|
||||||
|
|
||||||
bool mIsActive;
|
bool mIsActive;
|
||||||
bool mIsAlwaysActive;
|
bool mIsAlwaysActive;
|
||||||
|
|
@ -45,8 +44,6 @@ public:
|
||||||
|
|
||||||
static void findGameModes(const char* gameModeList, Vector<GameMode*>* outGameModes);
|
static void findGameModes(const char* gameModeList, Vector<GameMode*>* outGameModes);
|
||||||
|
|
||||||
void previewChange() {}
|
|
||||||
|
|
||||||
DECLARE_CALLBACK(void, onActivated, ());
|
DECLARE_CALLBACK(void, onActivated, ());
|
||||||
DECLARE_CALLBACK(void, onDeactivated, ());
|
DECLARE_CALLBACK(void, onDeactivated, ());
|
||||||
DECLARE_CALLBACK(void, onSceneLoaded, ());
|
DECLARE_CALLBACK(void, onSceneLoaded, ());
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,6 @@ LevelInfo::LevelInfo()
|
||||||
|
|
||||||
mAdvancedLightmapSupport = true;
|
mAdvancedLightmapSupport = true;
|
||||||
|
|
||||||
INIT_ASSET(AccuTexture);
|
|
||||||
|
|
||||||
// Register with the light manager activation signal, and we need to do it first
|
// Register with the light manager activation signal, and we need to do it first
|
||||||
// so the advanced light bin manager can be instructed about MRT lightmaps
|
// so the advanced light bin manager can be instructed about MRT lightmaps
|
||||||
LightManager::smActivateSignal.notify(this, &LevelInfo::_onLMActivate, 0.01f);
|
LightManager::smActivateSignal.notify(this, &LevelInfo::_onLMActivate, 0.01f);
|
||||||
|
|
@ -114,9 +112,8 @@ LevelInfo::LevelInfo()
|
||||||
LevelInfo::~LevelInfo()
|
LevelInfo::~LevelInfo()
|
||||||
{
|
{
|
||||||
LightManager::smActivateSignal.remove(this, &LevelInfo::_onLMActivate);
|
LightManager::smActivateSignal.remove(this, &LevelInfo::_onLMActivate);
|
||||||
if (!mAccuTexture.isNull())
|
if (!mAccuTextureAsset.isNull())
|
||||||
{
|
{
|
||||||
mAccuTexture.free();
|
|
||||||
gLevelAccuMap.free();
|
gLevelAccuMap.free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -222,7 +219,7 @@ U32 LevelInfo::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
|
||||||
sfxWrite( stream, mSoundAmbience );
|
sfxWrite( stream, mSoundAmbience );
|
||||||
stream->writeInt( mSoundDistanceModel, 1 );
|
stream->writeInt( mSoundDistanceModel, 1 );
|
||||||
|
|
||||||
PACK_ASSET(conn, AccuTexture);
|
PACK_ASSET_REFACTOR(conn, AccuTexture);
|
||||||
|
|
||||||
return retMask;
|
return retMask;
|
||||||
}
|
}
|
||||||
|
|
@ -271,8 +268,8 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream)
|
||||||
SFX->setDistanceModel( mSoundDistanceModel );
|
SFX->setDistanceModel( mSoundDistanceModel );
|
||||||
}
|
}
|
||||||
|
|
||||||
UNPACK_ASSET(conn, AccuTexture);
|
UNPACK_ASSET_REFACTOR(conn, AccuTexture);
|
||||||
setLevelAccuTexture(getAccuTexture());
|
setLevelAccuTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -368,24 +365,12 @@ void LevelInfo::_onLMActivate(const char *lm, bool enable)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LevelInfo::_setLevelAccuTexture(void *object, const char *index, const char *data)
|
void LevelInfo::setLevelAccuTexture()
|
||||||
{
|
{
|
||||||
LevelInfo* volume = reinterpret_cast< LevelInfo* >(object);
|
if (isClientObject() && mAccuTextureAsset.notNull())
|
||||||
volume->setLevelAccuTexture(StringTable->insert(data));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LevelInfo::setLevelAccuTexture(StringTableEntry name)
|
|
||||||
{
|
|
||||||
_setAccuTexture(name);
|
|
||||||
|
|
||||||
if (isClientObject() && getAccuTexture() != StringTable->EmptyString())
|
|
||||||
{
|
{
|
||||||
if (mAccuTexture.isNull())
|
gLevelAccuMap = getAccuTexture();
|
||||||
Con::warnf("AccumulationVolume::setTexture - Unable to load texture: %s", getAccuTexture());
|
|
||||||
else
|
|
||||||
gLevelAccuMap = mAccuTexture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AccumulationVolume::refreshVolumes();
|
AccumulationVolume::refreshVolumes();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,10 +106,7 @@ class LevelInfo : public NetObject
|
||||||
void _onLMActivate(const char *lm, bool enable);
|
void _onLMActivate(const char *lm, bool enable);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(LevelInfo, AccuTexture, onAccuTextureChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(LevelInfo, AccuTexture, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(LevelInfo, AccuTexture);
|
|
||||||
|
|
||||||
void onAccuTextureChanged() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -146,8 +143,7 @@ class LevelInfo : public NetObject
|
||||||
|
|
||||||
U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) override;
|
U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream ) override;
|
||||||
void unpackUpdate( NetConnection *conn, BitStream *stream ) override;
|
void unpackUpdate( NetConnection *conn, BitStream *stream ) override;
|
||||||
static bool _setLevelAccuTexture(void *object, const char *index, const char *data);
|
void setLevelAccuTexture();
|
||||||
void setLevelAccuTexture(StringTableEntry name);
|
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,6 @@ LightFlareData::LightFlareData()
|
||||||
|
|
||||||
for ( U32 i = 0; i < MAX_ELEMENTS; i++ )
|
for ( U32 i = 0; i < MAX_ELEMENTS; i++ )
|
||||||
mElementDist[i] = -1.0f;
|
mElementDist[i] = -1.0f;
|
||||||
|
|
||||||
INIT_ASSET(FlareTexture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LightFlareData::~LightFlareData()
|
LightFlareData::~LightFlareData()
|
||||||
|
|
@ -220,7 +218,7 @@ void LightFlareData::packData( BitStream *stream )
|
||||||
|
|
||||||
stream->writeFlag( mFlareEnabled );
|
stream->writeFlag( mFlareEnabled );
|
||||||
|
|
||||||
PACKDATA_ASSET(FlareTexture);
|
PACKDATA_ASSET_REFACTOR(FlareTexture);
|
||||||
|
|
||||||
stream->write( mScale );
|
stream->write( mScale );
|
||||||
stream->write( mOcclusionRadius );
|
stream->write( mOcclusionRadius );
|
||||||
|
|
@ -245,7 +243,7 @@ void LightFlareData::unpackData( BitStream *stream )
|
||||||
|
|
||||||
mFlareEnabled = stream->readFlag();
|
mFlareEnabled = stream->readFlag();
|
||||||
|
|
||||||
UNPACKDATA_ASSET(FlareTexture);
|
UNPACKDATA_ASSET_REFACTOR(FlareTexture);
|
||||||
|
|
||||||
stream->read( &mScale );
|
stream->read( &mScale );
|
||||||
stream->read( &mOcclusionRadius );
|
stream->read( &mOcclusionRadius );
|
||||||
|
|
@ -540,7 +538,7 @@ void LightFlareData::prepRender(SceneRenderState *state, LightFlareState *flareS
|
||||||
|
|
||||||
GFXVertexPCT *vert = flareState->vertBuffer.lock();
|
GFXVertexPCT *vert = flareState->vertBuffer.lock();
|
||||||
|
|
||||||
const Point2F oneOverTexSize( 1.0f / (F32)mFlareTexture.getWidth(), 1.0f / (F32)mFlareTexture.getHeight() );
|
const Point2F oneOverTexSize( 1.0f / (F32)getFlareTexture().getWidth(), 1.0f / (F32)getFlareTexture().getHeight());
|
||||||
|
|
||||||
for ( U32 i = 0; i < mElementCount; i++ )
|
for ( U32 i = 0; i < mElementCount; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -614,7 +612,7 @@ void LightFlareData::prepRender(SceneRenderState *state, LightFlareState *flareS
|
||||||
ri->bbModelViewProj = &MatrixF::Identity;
|
ri->bbModelViewProj = &MatrixF::Identity;
|
||||||
ri->count = elementCount;
|
ri->count = elementCount;
|
||||||
ri->blendStyle = ParticleRenderInst::BlendGreyscale;
|
ri->blendStyle = ParticleRenderInst::BlendGreyscale;
|
||||||
ri->diffuseTex = mFlareTexture;
|
ri->diffuseTex = getFlareTexture();
|
||||||
ri->softnessDistance = 1.0f;
|
ri->softnessDistance = 1.0f;
|
||||||
ri->defaultKey = ri->diffuseTex ? (uintptr_t)ri->diffuseTex : (uintptr_t)ri->vertBuff; // Sort by texture too.
|
ri->defaultKey = ri->diffuseTex ? (uintptr_t)ri->diffuseTex : (uintptr_t)ri->vertBuff; // Sort by texture too.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,11 +106,6 @@ protected:
|
||||||
void _makePrimBuffer( GFXPrimitiveBufferHandle *pb, U32 count );
|
void _makePrimBuffer( GFXPrimitiveBufferHandle *pb, U32 count );
|
||||||
void _renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
|
void _renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
|
||||||
|
|
||||||
void onImageChanged()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static const U32 LosMask;
|
static const U32 LosMask;
|
||||||
|
|
@ -123,8 +118,7 @@ protected:
|
||||||
F32 mScale;
|
F32 mScale;
|
||||||
bool mFlareEnabled;
|
bool mFlareEnabled;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(LightFlareData, FlareTexture, onImageChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(LightFlareData, FlareTexture, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(LightFlareData, FlareTexture);
|
|
||||||
|
|
||||||
F32 mOcclusionRadius;
|
F32 mOcclusionRadius;
|
||||||
bool mRenderReflectPass;
|
bool mRenderReflectPass;
|
||||||
|
|
|
||||||
|
|
@ -605,7 +605,7 @@ void ReflectionProbe::processBakedCubemap()
|
||||||
|
|
||||||
if (mIrridianceMap == nullptr || mIrridianceMap->mCubemap.isNull())
|
if (mIrridianceMap == nullptr || mIrridianceMap->mCubemap.isNull())
|
||||||
{
|
{
|
||||||
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked irradiance map at %s", getIrradianceMapPath().c_str());
|
Con::errorf("ReflectionProbe::processBakedCubemap() - Unable to load baked irradiance map at %s", getIrradianceMapPath().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -618,7 +618,7 @@ void ReflectionProbe::processBakedCubemap()
|
||||||
|
|
||||||
if (mPrefilterMap == nullptr || mPrefilterMap->mCubemap.isNull())
|
if (mPrefilterMap == nullptr || mPrefilterMap->mCubemap.isNull())
|
||||||
{
|
{
|
||||||
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked prefilter map at %s", getPrefilterMapPath().c_str());
|
Con::errorf("ReflectionProbe::processBakedCubemap() - Unable to load baked prefilter map at %s", getPrefilterMapPath().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ void afxZodiacGroundPlaneRenderer::render(SceneRenderState* state)
|
||||||
GFX->setShaderConstBuffer(shader_consts);
|
GFX->setShaderConstBuffer(shader_consts);
|
||||||
|
|
||||||
// set the texture
|
// set the texture
|
||||||
GFX->setTexture(0, *zode->txr);
|
GFX->setTexture(0, zode->txr);
|
||||||
LinearColorF zode_color = (LinearColorF)zode->color;
|
LinearColorF zode_color = (LinearColorF)zode->color;
|
||||||
zode_color.alpha *= fadebias;
|
zode_color.alpha *= fadebias;
|
||||||
shader_consts->set(color_sc, zode_color);
|
shader_consts->set(color_sc, zode_color);
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ void afxZodiacMeshRoadRenderer::render(SceneRenderState* state)
|
||||||
GFX->setShaderConstBuffer(shader_consts);
|
GFX->setShaderConstBuffer(shader_consts);
|
||||||
|
|
||||||
// set the texture
|
// set the texture
|
||||||
GFX->setTexture(0, *zode->txr);
|
GFX->setTexture(0, zode->txr);
|
||||||
LinearColorF zode_color = (LinearColorF)zode->color;
|
LinearColorF zode_color = (LinearColorF)zode->color;
|
||||||
zode_color.alpha *= fadebias;
|
zode_color.alpha *= fadebias;
|
||||||
shader_consts->set(color_sc, zode_color);
|
shader_consts->set(color_sc, zode_color);
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ void afxZodiacPolysoupRenderer::render(SceneRenderState* state)
|
||||||
GFX->setShaderConstBuffer(shader_consts);
|
GFX->setShaderConstBuffer(shader_consts);
|
||||||
|
|
||||||
// set the texture
|
// set the texture
|
||||||
GFX->setTexture(0, *zode->txr);
|
GFX->setTexture(0, zode->txr);
|
||||||
LinearColorF zode_color = (LinearColorF)zode->color;
|
LinearColorF zode_color = (LinearColorF)zode->color;
|
||||||
zode_color.alpha *= fadebias;
|
zode_color.alpha *= fadebias;
|
||||||
shader_consts->set(color_sc, zode_color);
|
shader_consts->set(color_sc, zode_color);
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ void afxZodiacTerrainRenderer::render(SceneRenderState* state)
|
||||||
GFX->setShaderConstBuffer(shader_consts);
|
GFX->setShaderConstBuffer(shader_consts);
|
||||||
|
|
||||||
// set the texture
|
// set the texture
|
||||||
GFX->setTexture(0, *zode->txr);
|
GFX->setTexture(0, zode->txr);
|
||||||
LinearColorF zode_color = (LinearColorF)zode->color;
|
LinearColorF zode_color = (LinearColorF)zode->color;
|
||||||
zode_color.alpha *= fadebias;
|
zode_color.alpha *= fadebias;
|
||||||
shader_consts->set(color_sc, zode_color);
|
shader_consts->set(color_sc, zode_color);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ ConsoleDocClass( afxBillboardData,
|
||||||
afxBillboardData::afxBillboardData()
|
afxBillboardData::afxBillboardData()
|
||||||
{
|
{
|
||||||
color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
INIT_ASSET(Texture);
|
|
||||||
dimensions.set(1.0f, 1.0f);
|
dimensions.set(1.0f, 1.0f);
|
||||||
texCoords[0].set(0.0f, 0.0f);
|
texCoords[0].set(0.0f, 0.0f);
|
||||||
texCoords[1].set(0.0f, 1.0f);
|
texCoords[1].set(0.0f, 1.0f);
|
||||||
|
|
@ -66,7 +65,7 @@ afxBillboardData::afxBillboardData(const afxBillboardData& other, bool temp_clon
|
||||||
: GameBaseData(other, temp_clone)
|
: GameBaseData(other, temp_clone)
|
||||||
{
|
{
|
||||||
color = other.color;
|
color = other.color;
|
||||||
CLONE_ASSET(Texture);
|
CLONE_ASSET_REFACTOR(Texture);
|
||||||
dimensions = other.dimensions;
|
dimensions = other.dimensions;
|
||||||
texCoords[0] = other.texCoords[0];
|
texCoords[0] = other.texCoords[0];
|
||||||
texCoords[1] = other.texCoords[1];
|
texCoords[1] = other.texCoords[1];
|
||||||
|
|
@ -124,7 +123,7 @@ void afxBillboardData::packData(BitStream* stream)
|
||||||
Parent::packData(stream);
|
Parent::packData(stream);
|
||||||
|
|
||||||
stream->write(color);
|
stream->write(color);
|
||||||
PACKDATA_ASSET(Texture);
|
PACKDATA_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
mathWrite(*stream, dimensions);
|
mathWrite(*stream, dimensions);
|
||||||
mathWrite(*stream, texCoords[0]);
|
mathWrite(*stream, texCoords[0]);
|
||||||
|
|
@ -141,7 +140,7 @@ void afxBillboardData::unpackData(BitStream* stream)
|
||||||
Parent::unpackData(stream);
|
Parent::unpackData(stream);
|
||||||
|
|
||||||
stream->read(&color);
|
stream->read(&color);
|
||||||
UNPACKDATA_ASSET(Texture);
|
UNPACKDATA_ASSET_REFACTOR(Texture);
|
||||||
mathRead(*stream, &dimensions);
|
mathRead(*stream, &dimensions);
|
||||||
mathRead(*stream, &texCoords[0]);
|
mathRead(*stream, &texCoords[0]);
|
||||||
mathRead(*stream, &texCoords[1]);
|
mathRead(*stream, &texCoords[1]);
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_IMAGEASSET(afxBillboardData, Texture, onChangeTexture, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(afxBillboardData, Texture, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(afxBillboardData, Texture);
|
|
||||||
|
|
||||||
|
|
||||||
LinearColorF color;
|
LinearColorF color;
|
||||||
|
|
@ -71,11 +70,6 @@ public:
|
||||||
|
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
|
|
||||||
void onChangeTexture()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
DECLARE_CONOBJECT(afxBillboardData);
|
DECLARE_CONOBJECT(afxBillboardData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ void afxBillboard::_renderBillboard(ObjectRenderInst *ri, SceneRenderState* stat
|
||||||
GFXTransformSaver saver;
|
GFXTransformSaver saver;
|
||||||
GFX->multWorld(getRenderTransform());
|
GFX->multWorld(getRenderTransform());
|
||||||
|
|
||||||
GFX->setTexture(0, mDataBlock->mTexture);
|
GFX->setTexture(0, mDataBlock->getTexture());
|
||||||
|
|
||||||
MatrixF worldmod = GFX->getWorldMatrix();
|
MatrixF worldmod = GFX->getWorldMatrix();
|
||||||
MatrixF viewmod = GFX->getViewMatrix();
|
MatrixF viewmod = GFX->getViewMatrix();
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,6 @@ bool afxZodiacData::sPreferDestinationGradients = false;
|
||||||
|
|
||||||
afxZodiacData::afxZodiacData()
|
afxZodiacData::afxZodiacData()
|
||||||
{
|
{
|
||||||
INIT_ASSET(Texture);
|
|
||||||
|
|
||||||
radius_xy = 1;
|
radius_xy = 1;
|
||||||
vert_range.set(0.0f, 0.0f);
|
vert_range.set(0.0f, 0.0f);
|
||||||
start_ang = 0;
|
start_ang = 0;
|
||||||
|
|
@ -120,7 +118,7 @@ afxZodiacData::afxZodiacData()
|
||||||
|
|
||||||
afxZodiacData::afxZodiacData(const afxZodiacData& other, bool temp_clone) : GameBaseData(other, temp_clone)
|
afxZodiacData::afxZodiacData(const afxZodiacData& other, bool temp_clone) : GameBaseData(other, temp_clone)
|
||||||
{
|
{
|
||||||
CLONE_ASSET(Texture);
|
CLONE_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
radius_xy = other.radius_xy;
|
radius_xy = other.radius_xy;
|
||||||
vert_range = other.vert_range;
|
vert_range = other.vert_range;
|
||||||
|
|
@ -158,7 +156,7 @@ void afxZodiacData::initPersistFields()
|
||||||
{
|
{
|
||||||
docsURL;
|
docsURL;
|
||||||
INITPERSISTFIELD_IMAGEASSET(Texture, afxZodiacData, "An image to use as the zodiac's texture.");
|
INITPERSISTFIELD_IMAGEASSET(Texture, afxZodiacData, "An image to use as the zodiac's texture.");
|
||||||
addFieldV("radius", TypeRangedF32, Offset(radius_xy, afxZodiacData), &CommonValidators::PositiveFloat,
|
addField("radius", TypeF32, Offset(radius_xy, afxZodiacData),
|
||||||
"The zodiac's radius in scene units.");
|
"The zodiac's radius in scene units.");
|
||||||
addField("verticalRange", TypePoint2F, Offset(vert_range, afxZodiacData),
|
addField("verticalRange", TypePoint2F, Offset(vert_range, afxZodiacData),
|
||||||
"For interior zodiacs only, verticalRange specifies distances above and below the "
|
"For interior zodiacs only, verticalRange specifies distances above and below the "
|
||||||
|
|
@ -270,7 +268,7 @@ void afxZodiacData::packData(BitStream* stream)
|
||||||
|
|
||||||
merge_zflags();
|
merge_zflags();
|
||||||
|
|
||||||
PACKDATA_ASSET(Texture);
|
PACKDATA_ASSET_REFACTOR(Texture);
|
||||||
stream->write(radius_xy);
|
stream->write(radius_xy);
|
||||||
stream->write(vert_range.x);
|
stream->write(vert_range.x);
|
||||||
stream->write(vert_range.y);
|
stream->write(vert_range.y);
|
||||||
|
|
@ -295,7 +293,7 @@ void afxZodiacData::unpackData(BitStream* stream)
|
||||||
{
|
{
|
||||||
Parent::unpackData(stream);
|
Parent::unpackData(stream);
|
||||||
|
|
||||||
UNPACKDATA_ASSET(Texture);
|
UNPACKDATA_ASSET_REFACTOR(Texture);
|
||||||
stream->read(&radius_xy);
|
stream->read(&radius_xy);
|
||||||
stream->read(&vert_range.x);
|
stream->read(&vert_range.x);
|
||||||
stream->read(&vert_range.y);
|
stream->read(&vert_range.y);
|
||||||
|
|
@ -326,22 +324,11 @@ bool afxZodiacData::preload(bool server, String &errorStr)
|
||||||
if (vert_range.x == 0.0f && vert_range.y == 0.0f)
|
if (vert_range.x == 0.0f && vert_range.y == 0.0f)
|
||||||
vert_range.x = vert_range.y = radius_xy;
|
vert_range.x = vert_range.y = radius_xy;
|
||||||
|
|
||||||
if (mTextureAssetId != StringTable->EmptyString())
|
if (mTextureAsset.notNull())
|
||||||
{
|
{
|
||||||
mTextureAsset = mTextureAssetId;
|
getTexture();
|
||||||
if (mTextureAsset.notNull())
|
|
||||||
{
|
|
||||||
if (getTexture() != StringTable->EmptyString() && mTextureName != StringTable->insert("texhandle"))
|
|
||||||
{
|
|
||||||
if (mTextureAsset.notNull())
|
|
||||||
{
|
|
||||||
mTextureAsset->getChangedSignal().notify(this, &afxZodiacData::onImageChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
mTexture.set(getTexture(), mTextureProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -358,21 +345,9 @@ void afxZodiacData::onStaticModified(const char* slot, const char* newValue)
|
||||||
|
|
||||||
void afxZodiacData::onPerformSubstitutions()
|
void afxZodiacData::onPerformSubstitutions()
|
||||||
{
|
{
|
||||||
if (mTextureAssetId != StringTable->EmptyString())
|
if (mTextureAsset.notNull())
|
||||||
{
|
{
|
||||||
mTextureAsset = mTextureAssetId;
|
getTexture();
|
||||||
if (mTextureAsset.notNull())
|
|
||||||
{
|
|
||||||
if (getTexture() != StringTable->EmptyString() && mTextureName != StringTable->insert("texhandle"))
|
|
||||||
{
|
|
||||||
if (mTextureAsset.notNull())
|
|
||||||
{
|
|
||||||
mTextureAsset->getChangedSignal().notify(this, &afxZodiacData::onImageChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
mTexture.set(getTexture(), mTextureProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,8 @@ public:
|
||||||
|
|
||||||
static void convertGradientRangeFromDegrees(Point2F& gradrange, const Point2F& gradrange_deg);
|
static void convertGradientRangeFromDegrees(Point2F& gradrange, const Point2F& gradrange_deg);
|
||||||
|
|
||||||
void onImageChanged()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_IMAGEASSET(afxZodiacData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile);
|
DECLARE_IMAGEASSET(afxZodiacData, Texture, AFX_GFXZodiacTextureProfile)
|
||||||
DECLARE_ASSET_SETGET(afxZodiacData, Texture);
|
|
||||||
|
|
||||||
F32 radius_xy;
|
F32 radius_xy;
|
||||||
Point2F vert_range;
|
Point2F vert_range;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ void afxZodiacMgr::addTerrainZodiac(Point3F& pos, F32 radius, LinearColorF& colo
|
||||||
z.color = color.toColorI();
|
z.color = color.toColorI();
|
||||||
z.angle = mDegToRad(angle);
|
z.angle = mDegToRad(angle);
|
||||||
z.zflags = zode->zflags;
|
z.zflags = zode->zflags;
|
||||||
z.txr = &zode->mTexture;
|
z.txr = zode->getTexture();
|
||||||
|
|
||||||
z.distance_max = zode->distance_max*zode->distance_max;
|
z.distance_max = zode->distance_max*zode->distance_max;
|
||||||
z.distance_falloff = zode->distance_falloff*zode->distance_falloff;
|
z.distance_falloff = zode->distance_falloff*zode->distance_falloff;
|
||||||
|
|
@ -84,7 +84,7 @@ void afxZodiacMgr::addInteriorZodiac(Point3F& pos, F32 radius, Point2F& vert_ran
|
||||||
z.color = color.toColorI();
|
z.color = color.toColorI();
|
||||||
z.angle = mDegToRad(angle);
|
z.angle = mDegToRad(angle);
|
||||||
z.zflags = zode->zflags;
|
z.zflags = zode->zflags;
|
||||||
z.txr = &zode->mTexture;
|
z.txr = zode->getTexture();
|
||||||
|
|
||||||
z.distance_max = zode->distance_max*zode->distance_max;
|
z.distance_max = zode->distance_max*zode->distance_max;
|
||||||
z.distance_falloff = zode->distance_falloff*zode->distance_falloff;
|
z.distance_falloff = zode->distance_falloff*zode->distance_falloff;
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ private:
|
||||||
ColorI color; // 4// color of zodiac
|
ColorI color; // 4// color of zodiac
|
||||||
F32 angle; // 4// angle in radians
|
F32 angle; // 4// angle in radians
|
||||||
U32 zflags; // 4// 0=normal,1=additive,2=subtractive
|
U32 zflags; // 4// 0=normal,1=additive,2=subtractive
|
||||||
GFXTexHandle* txr; // 4// zodiac texture
|
GFXTexHandle txr; // 4// zodiac texture
|
||||||
|
|
||||||
F32 distance_max;
|
F32 distance_max;
|
||||||
F32 distance_falloff;
|
F32 distance_falloff;
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,6 @@ ConsoleDocClass( afxZodiacPlaneData,
|
||||||
|
|
||||||
afxZodiacPlaneData::afxZodiacPlaneData()
|
afxZodiacPlaneData::afxZodiacPlaneData()
|
||||||
{
|
{
|
||||||
INIT_ASSET(Texture);
|
|
||||||
|
|
||||||
radius_xy = 1;
|
radius_xy = 1;
|
||||||
start_ang = 0;
|
start_ang = 0;
|
||||||
ang_per_sec = 0;
|
ang_per_sec = 0;
|
||||||
|
|
@ -71,7 +69,7 @@ afxZodiacPlaneData::afxZodiacPlaneData()
|
||||||
afxZodiacPlaneData::afxZodiacPlaneData(const afxZodiacPlaneData& other, bool temp_clone)
|
afxZodiacPlaneData::afxZodiacPlaneData(const afxZodiacPlaneData& other, bool temp_clone)
|
||||||
: GameBaseData(other, temp_clone)
|
: GameBaseData(other, temp_clone)
|
||||||
{
|
{
|
||||||
CLONE_ASSET(Texture);
|
CLONE_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
radius_xy = other.radius_xy;
|
radius_xy = other.radius_xy;
|
||||||
start_ang = other.start_ang;
|
start_ang = other.start_ang;
|
||||||
|
|
@ -166,7 +164,7 @@ void afxZodiacPlaneData::packData(BitStream* stream)
|
||||||
|
|
||||||
merge_zflags();
|
merge_zflags();
|
||||||
|
|
||||||
PACKDATA_ASSET(Texture);
|
PACKDATA_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
stream->write(radius_xy);
|
stream->write(radius_xy);
|
||||||
stream->write(start_ang);
|
stream->write(start_ang);
|
||||||
|
|
@ -185,7 +183,7 @@ void afxZodiacPlaneData::unpackData(BitStream* stream)
|
||||||
{
|
{
|
||||||
Parent::unpackData(stream);
|
Parent::unpackData(stream);
|
||||||
|
|
||||||
UNPACKDATA_ASSET(Texture);
|
UNPACKDATA_ASSET_REFACTOR(Texture);
|
||||||
|
|
||||||
stream->read(&radius_xy);
|
stream->read(&radius_xy);
|
||||||
stream->read(&start_ang);
|
stream->read(&start_ang);
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,8 @@ public:
|
||||||
FACES_BITS = 3
|
FACES_BITS = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
void onImageChanged()
|
|
||||||
{
|
|
||||||
reloadOnLocalClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_IMAGEASSET(afxZodiacPlaneData, Texture, onImageChanged, AFX_GFXZodiacTextureProfile);
|
DECLARE_IMAGEASSET(afxZodiacPlaneData, Texture, AFX_GFXZodiacTextureProfile)
|
||||||
DECLARE_ASSET_SETGET(afxZodiacPlaneData, Texture);
|
|
||||||
|
|
||||||
F32 radius_xy;
|
F32 radius_xy;
|
||||||
F32 start_ang;
|
F32 start_ang;
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ void afxZodiacPlane::_renderZodiacPlane(ObjectRenderInst *ri, SceneRenderState*
|
||||||
GFXTransformSaver saver;
|
GFXTransformSaver saver;
|
||||||
GFX->multWorld(getRenderTransform());
|
GFX->multWorld(getRenderTransform());
|
||||||
|
|
||||||
GFX->setTexture(0, mDataBlock->mTexture);
|
GFX->setTexture(0, mDataBlock->getTexture());
|
||||||
|
|
||||||
PrimBuild::begin(GFXTriangleStrip, 4);
|
PrimBuild::begin(GFXTriangleStrip, 4);
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ void afxParticlePool::pool_renderObject_Normal(RenderPassManager *renderManager,
|
||||||
if (main_emitter_data->textureHandle)
|
if (main_emitter_data->textureHandle)
|
||||||
ri->diffuseTex = &*(main_emitter_data->textureHandle);
|
ri->diffuseTex = &*(main_emitter_data->textureHandle);
|
||||||
else
|
else
|
||||||
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureResource());
|
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTexture());
|
||||||
|
|
||||||
ri->softnessDistance = main_emitter_data->softnessDistance;
|
ri->softnessDistance = main_emitter_data->softnessDistance;
|
||||||
|
|
||||||
|
|
@ -277,7 +277,7 @@ void afxParticlePool::pool_renderObject_TwoPass(RenderPassManager *renderManager
|
||||||
//if (main_emitter_data->textureHandle)
|
//if (main_emitter_data->textureHandle)
|
||||||
// ri->diffuseTex = &*(main_emitter_data->textureHandle);
|
// ri->diffuseTex = &*(main_emitter_data->textureHandle);
|
||||||
//else
|
//else
|
||||||
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureExtResource());
|
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureExt());
|
||||||
|
|
||||||
F32 save_sort_dist = ri->sortDistSq;
|
F32 save_sort_dist = ri->sortDistSq;
|
||||||
|
|
||||||
|
|
@ -481,7 +481,7 @@ void afxParticlePool::pool_renderObject_TwoPass(RenderPassManager *renderManager
|
||||||
if (main_emitter_data->textureHandle)
|
if (main_emitter_data->textureHandle)
|
||||||
ri->diffuseTex = &*(main_emitter_data->textureHandle);
|
ri->diffuseTex = &*(main_emitter_data->textureHandle);
|
||||||
else
|
else
|
||||||
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTextureResource());
|
ri->diffuseTex = &*(main_emitter_data->particleDataBlocks[0]->getTexture());
|
||||||
|
|
||||||
ri->softnessDistance = main_emitter_data->softnessDistance;
|
ri->softnessDistance = main_emitter_data->softnessDistance;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1660,8 +1660,8 @@ void AssetManager::dumpDeclaredAssets( void ) const
|
||||||
pAssetDefinition->mAssetInternal,
|
pAssetDefinition->mAssetInternal,
|
||||||
pAssetDefinition->mAssetPrivate,
|
pAssetDefinition->mAssetPrivate,
|
||||||
pAssetDefinition->mAssetType,
|
pAssetDefinition->mAssetType,
|
||||||
pAssetDefinition->mpModuleDefinition->getModuleId(),
|
pAssetDefinition->mAssetPrivate ? "Private" : pAssetDefinition->mpModuleDefinition->getModuleId(),
|
||||||
pAssetDefinition->mpModuleDefinition->getVersionId(),
|
pAssetDefinition->mAssetPrivate ? 0 : pAssetDefinition->mpModuleDefinition->getVersionId(),
|
||||||
pAssetDefinition->mAssetBaseFilePath );
|
pAssetDefinition->mAssetBaseFilePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,6 @@ VolumetricFog::VolumetricFog()
|
||||||
mFrontBufferTarget = NULL;
|
mFrontBufferTarget = NULL;
|
||||||
|
|
||||||
z_buf = NULL;
|
z_buf = NULL;
|
||||||
mTexture = NULL;
|
|
||||||
|
|
||||||
mIsVBDirty = false;
|
mIsVBDirty = false;
|
||||||
mIsPBDirty = false;
|
mIsPBDirty = false;
|
||||||
|
|
@ -138,7 +137,6 @@ VolumetricFog::VolumetricFog()
|
||||||
mSpeed2.set(0.1f, 0.1f);
|
mSpeed2.set(0.1f, 0.1f);
|
||||||
|
|
||||||
INIT_ASSET(Shape);
|
INIT_ASSET(Shape);
|
||||||
INIT_ASSET(Texture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumetricFog::~VolumetricFog()
|
VolumetricFog::~VolumetricFog()
|
||||||
|
|
@ -159,8 +157,6 @@ VolumetricFog::~VolumetricFog()
|
||||||
|
|
||||||
z_buf = NULL;
|
z_buf = NULL;
|
||||||
|
|
||||||
if (!mTexture.isNull())
|
|
||||||
mTexture.free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumetricFog::initPersistFields()
|
void VolumetricFog::initPersistFields()
|
||||||
|
|
@ -330,8 +326,10 @@ void VolumetricFog::handleResize(VolumetricFogRTManager *RTM, bool resize)
|
||||||
F32 width = (F32)mPlatformWindow->getClientExtent().x;
|
F32 width = (F32)mPlatformWindow->getClientExtent().x;
|
||||||
F32 height = (F32)mPlatformWindow->getClientExtent().y;
|
F32 height = (F32)mPlatformWindow->getClientExtent().y;
|
||||||
|
|
||||||
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width);
|
// load texture.
|
||||||
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height);
|
getTexture();
|
||||||
|
mTexScale.x = 2.0f - ((F32)mTextureAsset->getTextureWidth() / width);
|
||||||
|
mTexScale.y = 2.0f - ((F32)mTextureAsset->getTextureHeight() / height);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateBuffers(0,true);
|
UpdateBuffers(0,true);
|
||||||
|
|
@ -545,7 +543,7 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||||
stream->write(mFogDensity);
|
stream->write(mFogDensity);
|
||||||
if (stream->writeFlag(mask & FogModulationMask))
|
if (stream->writeFlag(mask & FogModulationMask))
|
||||||
{
|
{
|
||||||
PACK_ASSET(con, Texture);
|
PACK_ASSET_REFACTOR(con, Texture);
|
||||||
mTexTiles = mFabs(mTexTiles);
|
mTexTiles = mFabs(mTexTiles);
|
||||||
stream->write(mTexTiles);
|
stream->write(mTexTiles);
|
||||||
stream->write(mStrength);
|
stream->write(mStrength);
|
||||||
|
|
@ -597,7 +595,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
MatrixF mat;
|
MatrixF mat;
|
||||||
VectorF scale;
|
VectorF scale;
|
||||||
VectorF mOldScale = getScale();
|
VectorF mOldScale = getScale();
|
||||||
StringTableEntry oldTextureName = mTextureAssetId;
|
StringTableEntry oldTextureName = mTextureAsset.getAssetId();
|
||||||
StringTableEntry oldShapeAsset = mShapeAssetId;
|
StringTableEntry oldShapeAsset = mShapeAssetId;
|
||||||
StringTableEntry oldShape = mShapeName;
|
StringTableEntry oldShape = mShapeName;
|
||||||
|
|
||||||
|
|
@ -615,7 +613,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
}
|
}
|
||||||
if (stream->readFlag())// Fog Modulation
|
if (stream->readFlag())// Fog Modulation
|
||||||
{
|
{
|
||||||
UNPACK_ASSET(con, Texture);
|
UNPACK_ASSET_REFACTOR(con, Texture);
|
||||||
stream->read(&mTexTiles);
|
stream->read(&mTexTiles);
|
||||||
mTexTiles = mFabs(mTexTiles);
|
mTexTiles = mFabs(mTexTiles);
|
||||||
stream->read(&mStrength);
|
stream->read(&mStrength);
|
||||||
|
|
@ -625,12 +623,11 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
|
|
||||||
if (isProperlyAdded())
|
if (isProperlyAdded())
|
||||||
{
|
{
|
||||||
if (oldTextureName != mTextureAssetId)
|
if (oldTextureName != mTextureAsset.getAssetId())
|
||||||
InitTexture();
|
InitTexture();
|
||||||
if (oldTextureName != StringTable->EmptyString() && mTextureAssetId == StringTable->EmptyString())
|
if (oldTextureName != StringTable->EmptyString() && mTextureAsset.isNull())
|
||||||
{
|
{
|
||||||
mIsTextured = false;
|
mIsTextured = false;
|
||||||
mTexture.free();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1149,7 +1146,7 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
||||||
|
|
||||||
if (mIsTextured && mStrength > 0.0f)
|
if (mIsTextured && mStrength > 0.0f)
|
||||||
{
|
{
|
||||||
GFX->setTexture(3, mTexture);
|
GFX->setTexture(3, getTexture());
|
||||||
mShaderConsts->setSafe(mIsTexturedSC, 1.0f);
|
mShaderConsts->setSafe(mIsTexturedSC, 1.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1222,15 +1219,16 @@ void VolumetricFog::InitTexture()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mTexture.isNull())
|
if (!mTextureAsset.isNull())
|
||||||
{
|
{
|
||||||
mIsTextured = true;
|
mIsTextured = true;
|
||||||
|
// load asset.
|
||||||
|
getTexture();
|
||||||
F32 width = (F32)mPlatformWindow->getClientExtent().x;
|
F32 width = (F32)mPlatformWindow->getClientExtent().x;
|
||||||
F32 height = (F32)mPlatformWindow->getClientExtent().y;
|
F32 height = (F32)mPlatformWindow->getClientExtent().y;
|
||||||
|
|
||||||
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width);
|
mTexScale.x = 2.0f - ((F32)mTextureAsset->getTextureWidth() / width);
|
||||||
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height);
|
mTexScale.y = 2.0f - ((F32)mTextureAsset->getTextureHeight() / height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,7 @@ class VolumetricFog : public SceneObject
|
||||||
F32 mInvScale;
|
F32 mInvScale;
|
||||||
|
|
||||||
// Fog Modulation data
|
// Fog Modulation data
|
||||||
DECLARE_IMAGEASSET(VolumetricFog, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET_NET(VolumetricFog, Texture, GFXStaticTextureSRGBProfile, FogModulationMask)
|
||||||
DECLARE_ASSET_NET_SETGET(VolumetricFog, Texture, FogModulationMask);
|
|
||||||
|
|
||||||
bool mIsTextured;
|
bool mIsTextured;
|
||||||
F32 mTexTiles;
|
F32 mTexTiles;
|
||||||
|
|
@ -221,8 +220,6 @@ class VolumetricFog : public SceneObject
|
||||||
|
|
||||||
static bool _setShapeAsset(void* obj, const char* index, const char* data);
|
static bool _setShapeAsset(void* obj, const char* index, const char* data);
|
||||||
|
|
||||||
void onImageChanged() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Public methods
|
// Public methods
|
||||||
VolumetricFog();
|
VolumetricFog();
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,6 @@ BasicClouds::BasicClouds()
|
||||||
mTexOffset[0].set( 0.5f, 0.5f );
|
mTexOffset[0].set( 0.5f, 0.5f );
|
||||||
mTexOffset[1].set( 0.5f, 0.5f );
|
mTexOffset[1].set( 0.5f, 0.5f );
|
||||||
mTexOffset[2].set( 0.5f, 0.5f );
|
mTexOffset[2].set( 0.5f, 0.5f );
|
||||||
|
|
||||||
for (U32 i=0; i< TEX_COUNT;i++)
|
|
||||||
INIT_IMAGEASSET_ARRAY(Texture, GFXStaticTextureSRGBProfile, i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_CO_NETOBJECT_V1( BasicClouds );
|
IMPLEMENT_CO_NETOBJECT_V1( BasicClouds );
|
||||||
|
|
@ -215,12 +212,11 @@ U32 BasicClouds::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
|
||||||
{
|
{
|
||||||
U32 retMask = Parent::packUpdate( conn, mask, stream );
|
U32 retMask = Parent::packUpdate( conn, mask, stream );
|
||||||
|
|
||||||
|
PACK_ASSET_ARRAY_REFACTOR(conn, Texture, TEX_COUNT)
|
||||||
|
|
||||||
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
stream->writeFlag( mLayerEnabled[i] );
|
stream->writeFlag( mLayerEnabled[i] );
|
||||||
|
|
||||||
PACK_ASSET_ARRAY(conn, Texture, i);
|
|
||||||
|
|
||||||
stream->write( mTexScale[i] );
|
stream->write( mTexScale[i] );
|
||||||
mathWrite( *stream, mTexDirection[i] );
|
mathWrite( *stream, mTexDirection[i] );
|
||||||
stream->write( mTexSpeed[i] );
|
stream->write( mTexSpeed[i] );
|
||||||
|
|
@ -236,12 +232,11 @@ void BasicClouds::unpackUpdate( NetConnection *conn, BitStream *stream )
|
||||||
{
|
{
|
||||||
Parent::unpackUpdate( conn, stream );
|
Parent::unpackUpdate( conn, stream );
|
||||||
|
|
||||||
|
UNPACK_ASSET_ARRAY_REFACTOR(conn, Texture, TEX_COUNT)
|
||||||
|
|
||||||
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
mLayerEnabled[i] = stream->readFlag();
|
mLayerEnabled[i] = stream->readFlag();
|
||||||
|
|
||||||
UNPACK_ASSET_ARRAY(conn, Texture, i);
|
|
||||||
|
|
||||||
stream->read( &mTexScale[i] );
|
stream->read( &mTexScale[i] );
|
||||||
mathRead( *stream, &mTexDirection[i] );
|
mathRead( *stream, &mTexDirection[i] );
|
||||||
stream->read( &mTexSpeed[i] );
|
stream->read( &mTexSpeed[i] );
|
||||||
|
|
@ -315,14 +310,14 @@ void BasicClouds::renderObject( ObjectRenderInst *ri, SceneRenderState *state, B
|
||||||
|
|
||||||
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
if ( !mLayerEnabled[i] )
|
if ( !mLayerEnabled[i] || mTextureAsset[i].isNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mShaderConsts->setSafe( mTexScaleSC, mTexScale[i] );
|
mShaderConsts->setSafe( mTexScaleSC, mTexScale[i] );
|
||||||
mShaderConsts->setSafe( mTexDirectionSC, mTexDirection[i] * mTexSpeed[i] );
|
mShaderConsts->setSafe( mTexDirectionSC, mTexDirection[i] * mTexSpeed[i] );
|
||||||
mShaderConsts->setSafe( mTexOffsetSC, mTexOffset[i] );
|
mShaderConsts->setSafe( mTexOffsetSC, mTexOffset[i] );
|
||||||
|
|
||||||
GFX->setTexture( mDiffuseMapSC->getSamplerRegister(), mTexture[i] );
|
GFX->setTexture( mDiffuseMapSC->getSamplerRegister(), getTexture(i) );
|
||||||
GFX->setVertexBuffer( mVB[i] );
|
GFX->setVertexBuffer( mVB[i] );
|
||||||
|
|
||||||
GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, smVertCount, 0, smTriangleCount );
|
GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, smVertCount, 0, smTriangleCount );
|
||||||
|
|
@ -337,13 +332,11 @@ void BasicClouds::_initTexture()
|
||||||
{
|
{
|
||||||
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
if ( !mLayerEnabled[i] )
|
if ( mLayerEnabled[i] && mTextureAsset[i].notNull())
|
||||||
{
|
{
|
||||||
mTexture[i] = NULL;
|
// load the resource.
|
||||||
continue;
|
getTexture(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setTexture(getTexture(i), i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,8 @@ protected:
|
||||||
static U32 smVertCount;
|
static U32 smVertCount;
|
||||||
static U32 smTriangleCount;
|
static U32 smTriangleCount;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(BasicClouds, Texture, TEX_COUNT, onTextureChanged);
|
DECLARE_IMAGEASSET_ARRAY_NET(BasicClouds, Texture, GFXStaticTextureSRGBProfile, TEX_COUNT, -1)
|
||||||
DECLARE_IMAGEASSET_ARRAY_NET_SETGET(BasicClouds, Texture, -1);
|
|
||||||
void onTextureChanged() {}
|
|
||||||
GFXStateBlockRef mStateblock;
|
GFXStateBlockRef mStateblock;
|
||||||
|
|
||||||
GFXShaderRef mShader;
|
GFXShaderRef mShader;
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,6 @@ CloudLayer::CloudLayer()
|
||||||
mTexOffset[0] = mTexOffset[1] = mTexOffset[2] = Point2F::Zero;
|
mTexOffset[0] = mTexOffset[1] = mTexOffset[2] = Point2F::Zero;
|
||||||
|
|
||||||
mHeight = 4.0f;
|
mHeight = 4.0f;
|
||||||
|
|
||||||
INIT_ASSET(Texture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_CO_NETOBJECT_V1( CloudLayer );
|
IMPLEMENT_CO_NETOBJECT_V1( CloudLayer );
|
||||||
|
|
@ -131,8 +129,6 @@ bool CloudLayer::onAdd()
|
||||||
|
|
||||||
addToScene();
|
addToScene();
|
||||||
|
|
||||||
LOAD_IMAGEASSET(Texture);
|
|
||||||
|
|
||||||
if ( isClientObject() )
|
if ( isClientObject() )
|
||||||
{
|
{
|
||||||
_initBuffers();
|
_initBuffers();
|
||||||
|
|
@ -194,7 +190,7 @@ void CloudLayer::initPersistFields()
|
||||||
docsURL;
|
docsURL;
|
||||||
addGroup( "CloudLayer" );
|
addGroup( "CloudLayer" );
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).");
|
INITPERSISTFIELD_IMAGEASSET(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).")
|
||||||
|
|
||||||
addArray( "Textures", TEX_COUNT );
|
addArray( "Textures", TEX_COUNT );
|
||||||
|
|
||||||
|
|
@ -243,7 +239,9 @@ U32 CloudLayer::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
|
||||||
{
|
{
|
||||||
U32 retMask = Parent::packUpdate( conn, mask, stream );
|
U32 retMask = Parent::packUpdate( conn, mask, stream );
|
||||||
|
|
||||||
PACK_ASSET(conn, Texture);
|
if (stream->writeFlag(mTextureAsset.notNull())) {
|
||||||
|
NetStringHandle assetIdStr = mTextureAsset.getAssetId(); conn->packNetStringHandleU(stream, assetIdStr);
|
||||||
|
}
|
||||||
|
|
||||||
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -265,10 +263,9 @@ void CloudLayer::unpackUpdate( NetConnection *conn, BitStream *stream )
|
||||||
{
|
{
|
||||||
Parent::unpackUpdate( conn, stream );
|
Parent::unpackUpdate( conn, stream );
|
||||||
|
|
||||||
UNPACK_ASSET(conn, Texture);
|
if (stream->readFlag()) {
|
||||||
|
mTextureAsset.setAssetId(_getStringTable()->insert(conn->unpackNetStringHandleU(stream).getString()));
|
||||||
if(mTextureAssetId != StringTable->EmptyString())
|
}
|
||||||
mTextureAsset = mTextureAssetId;
|
|
||||||
|
|
||||||
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -334,7 +331,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
|
||||||
{
|
{
|
||||||
GFXTransformSaver saver;
|
GFXTransformSaver saver;
|
||||||
|
|
||||||
if (!mTextureAsset || !mTextureAsset->isAssetValid())
|
if (!mTextureAsset)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Point3F &camPos = state->getCameraPosition();
|
const Point3F &camPos = state->getCameraPosition();
|
||||||
|
|
@ -385,7 +382,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
|
||||||
|
|
||||||
mShaderConsts->setSafe( mExposureSC, mExposure );
|
mShaderConsts->setSafe( mExposureSC, mExposure );
|
||||||
|
|
||||||
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), getTextureResource());
|
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTextureAsset->getTexture(&GFXStaticTextureSRGBProfile));
|
||||||
GFX->setVertexBuffer( mVB );
|
GFX->setVertexBuffer( mVB );
|
||||||
GFX->setPrimitiveBuffer( mPB );
|
GFX->setPrimitiveBuffer( mPB );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ class CloudLayer : public SceneObject
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TEX_COUNT 3
|
#define TEX_COUNT 3
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CloudLayer();
|
CloudLayer();
|
||||||
|
|
@ -97,8 +96,9 @@ protected:
|
||||||
static U32 smVertCount;
|
static U32 smVertCount;
|
||||||
static U32 smTriangleCount;
|
static U32 smTriangleCount;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(CloudLayer, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
|
public:
|
||||||
DECLARE_ASSET_NET_SETGET(CloudLayer, Texture, CloudLayerMask);
|
|
||||||
|
DECLARE_IMAGEASSET_NET(CloudLayer,Texture, GFXStaticTextureSRGBProfile, CloudLayerMask)
|
||||||
|
|
||||||
GFXShaderRef mShader;
|
GFXShaderRef mShader;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,10 +260,6 @@ WaterObject::WaterObject()
|
||||||
mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16));
|
mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16));
|
||||||
constructInPlace(mMatrixSet);
|
constructInPlace(mMatrixSet);
|
||||||
|
|
||||||
INIT_ASSET(RippleTex);
|
|
||||||
INIT_ASSET(FoamTex);
|
|
||||||
INIT_ASSET(DepthGradientTex);
|
|
||||||
|
|
||||||
mCubemapName = StringTable->EmptyString();
|
mCubemapName = StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -547,9 +543,9 @@ U32 WaterObject::packUpdate( NetConnection * conn, U32 mask, BitStream *stream )
|
||||||
|
|
||||||
if ( stream->writeFlag( mask & TextureMask ) )
|
if ( stream->writeFlag( mask & TextureMask ) )
|
||||||
{
|
{
|
||||||
PACK_ASSET(conn, RippleTex);
|
PACK_ASSET_REFACTOR(conn, RippleTex);
|
||||||
PACK_ASSET(conn, DepthGradientTex);
|
PACK_ASSET_REFACTOR(conn, DepthGradientTex);
|
||||||
PACK_ASSET(conn, FoamTex);
|
PACK_ASSET_REFACTOR(conn, FoamTex);
|
||||||
|
|
||||||
stream->writeString( mCubemapName );
|
stream->writeString( mCubemapName );
|
||||||
}
|
}
|
||||||
|
|
@ -669,9 +665,9 @@ void WaterObject::unpackUpdate( NetConnection * conn, BitStream *stream )
|
||||||
// TextureMask
|
// TextureMask
|
||||||
if ( stream->readFlag() )
|
if ( stream->readFlag() )
|
||||||
{
|
{
|
||||||
UNPACK_ASSET(conn, RippleTex);
|
UNPACK_ASSET_REFACTOR(conn, RippleTex);
|
||||||
UNPACK_ASSET(conn, DepthGradientTex);
|
UNPACK_ASSET_REFACTOR(conn, DepthGradientTex);
|
||||||
UNPACK_ASSET(conn, FoamTex);
|
UNPACK_ASSET_REFACTOR(conn, FoamTex);
|
||||||
|
|
||||||
mCubemapName = stream->readSTString();
|
mCubemapName = stream->readSTString();
|
||||||
|
|
||||||
|
|
@ -767,13 +763,13 @@ void WaterObject::renderObject( ObjectRenderInst *ri, SceneRenderState *state, B
|
||||||
void WaterObject::setCustomTextures( S32 matIdx, U32 pass, const WaterMatParams ¶mHandles )
|
void WaterObject::setCustomTextures( S32 matIdx, U32 pass, const WaterMatParams ¶mHandles )
|
||||||
{
|
{
|
||||||
// Always use the ripple texture.
|
// Always use the ripple texture.
|
||||||
GFX->setTexture( paramHandles.mRippleSamplerSC->getSamplerRegister(pass), mRippleTex );
|
GFX->setTexture( paramHandles.mRippleSamplerSC->getSamplerRegister(pass), getRippleTex() );
|
||||||
|
|
||||||
// Only above-water in advanced-lighting uses the foam texture.
|
// Only above-water in advanced-lighting uses the foam texture.
|
||||||
if ( matIdx == WaterMat )
|
if ( matIdx == WaterMat )
|
||||||
{
|
{
|
||||||
GFX->setTexture( paramHandles.mFoamSamplerSC->getSamplerRegister(pass), mFoamTex );
|
GFX->setTexture( paramHandles.mFoamSamplerSC->getSamplerRegister(pass), getFoamTex() );
|
||||||
GFX->setTexture( paramHandles.mDepthGradSamplerSC->getSamplerRegister(pass), mDepthGradientTex );
|
GFX->setTexture( paramHandles.mDepthGradSamplerSC->getSamplerRegister(pass), getDepthGradientTex() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( matIdx == WaterMat || matIdx == BasicWaterMat ) && mCubemap )
|
if ( ( matIdx == WaterMat || matIdx == BasicWaterMat ) && mCubemap )
|
||||||
|
|
@ -1118,7 +1114,7 @@ void WaterObject::updateUnderwaterEffect( SceneRenderState *state )
|
||||||
// be fetched by the effect when it renders.
|
// be fetched by the effect when it renders.
|
||||||
if ( !mNamedDepthGradTex.isRegistered() )
|
if ( !mNamedDepthGradTex.isRegistered() )
|
||||||
mNamedDepthGradTex.registerWithName( "waterDepthGradMap" );
|
mNamedDepthGradTex.registerWithName( "waterDepthGradMap" );
|
||||||
mNamedDepthGradTex.setTexture( mDepthGradientTex );
|
mNamedDepthGradTex.setTexture( getDepthGradientTex() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
effect->disable();
|
effect->disable();
|
||||||
|
|
@ -1172,7 +1168,7 @@ bool WaterObject::initMaterial( S32 idx )
|
||||||
void WaterObject::initTextures()
|
void WaterObject::initTextures()
|
||||||
{
|
{
|
||||||
if ( mNamedDepthGradTex.isRegistered() )
|
if ( mNamedDepthGradTex.isRegistered() )
|
||||||
mNamedDepthGradTex.setTexture( mDepthGradientTex );
|
mNamedDepthGradTex.setTexture( getDepthGradientTex() );
|
||||||
|
|
||||||
if ( mCubemapName != StringTable->EmptyString() )
|
if ( mCubemapName != StringTable->EmptyString() )
|
||||||
Sim::findObject( mCubemapName, mCubemap );
|
Sim::findObject( mCubemapName, mCubemap );
|
||||||
|
|
|
||||||
|
|
@ -203,10 +203,6 @@ protected:
|
||||||
/// Callback used internally when smEnableTrueReflections changes.
|
/// Callback used internally when smEnableTrueReflections changes.
|
||||||
void _onEnableTrueReflections();
|
void _onEnableTrueReflections();
|
||||||
|
|
||||||
void onRippleTexChanged() {}
|
|
||||||
void onFoamTexChanged() {}
|
|
||||||
void onDepthGradientTexChanged() {}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static bool _setFullReflect( void *object, const char *index, const char *data );
|
static bool _setFullReflect( void *object, const char *index, const char *data );
|
||||||
|
|
@ -273,12 +269,9 @@ protected:
|
||||||
F32 mDepthGradientMax;
|
F32 mDepthGradientMax;
|
||||||
|
|
||||||
// Other textures
|
// Other textures
|
||||||
DECLARE_IMAGEASSET(WaterObject, RippleTex, onRippleTexChanged, GFXStaticTextureProfile);
|
DECLARE_IMAGEASSET_NET(WaterObject, RippleTex, GFXStaticTextureProfile, TextureMask)
|
||||||
DECLARE_ASSET_NET_SETGET(WaterObject, RippleTex, TextureMask);
|
DECLARE_IMAGEASSET_NET(WaterObject, FoamTex, GFXStaticTextureSRGBProfile, TextureMask)
|
||||||
DECLARE_IMAGEASSET(WaterObject, FoamTex, onFoamTexChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET_NET(WaterObject, DepthGradientTex, GFXStaticTextureSRGBProfile, TextureMask)
|
||||||
DECLARE_ASSET_NET_SETGET(WaterObject, FoamTex, TextureMask);
|
|
||||||
DECLARE_IMAGEASSET(WaterObject, DepthGradientTex, onDepthGradientTexChanged, GFXStaticTextureSRGBProfile);
|
|
||||||
DECLARE_ASSET_NET_SETGET(WaterObject, DepthGradientTex, TextureMask);
|
|
||||||
|
|
||||||
StringTableEntry mCubemapName;
|
StringTableEntry mCubemapName;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@
|
||||||
#pragma warning( push )
|
#pragma warning( push )
|
||||||
#pragma warning( disable : 4505 ) // unreferenced function removed.
|
#pragma warning( disable : 4505 ) // unreferenced function removed.
|
||||||
|
|
||||||
|
#ifndef STB_IMAGE_IMPLEMENTATION
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#define STB_IMAGE_STATIC
|
#define STB_IMAGE_STATIC
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
#define STB_IMAGE_WRITE_STATIC
|
#define STB_IMAGE_WRITE_STATIC
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,6 @@ IMPLEMENT_CONOBJECT( CubemapData );
|
||||||
CubemapData::CubemapData()
|
CubemapData::CubemapData()
|
||||||
{
|
{
|
||||||
mCubemap = NULL;
|
mCubemap = NULL;
|
||||||
|
|
||||||
for (U32 i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
INIT_IMAGEASSET_ARRAY(CubeMapFace, GFXStaticTextureSRGBProfile, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_ASSET(CubeMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CubemapData::~CubemapData()
|
CubemapData::~CubemapData()
|
||||||
|
|
@ -77,16 +70,6 @@ ConsoleDocClass( CubemapData,
|
||||||
void CubemapData::initPersistFields()
|
void CubemapData::initPersistFields()
|
||||||
{
|
{
|
||||||
docsURL;
|
docsURL;
|
||||||
addProtectedField( "cubeFace", TypeStringFilename, Offset(mCubeMapFaceName, CubemapData), _setCubeMapFaceData, defaultProtectedGetFn, 6,
|
|
||||||
"@brief The 6 cubemap face textures for a static cubemap.\n\n"
|
|
||||||
"They are in the following order:\n"
|
|
||||||
" - cubeFace[0] is -X\n"
|
|
||||||
" - cubeFace[1] is +X\n"
|
|
||||||
" - cubeFace[2] is -Z\n"
|
|
||||||
" - cubeFace[3] is +Z\n"
|
|
||||||
" - cubeFace[4] is -Y\n"
|
|
||||||
" - cubeFace[5] is +Y\n", AbstractClassRep::FIELD_HideInInspectors );
|
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(CubeMapFace, 6, CubemapData, "@brief The 6 cubemap face textures for a static cubemap.\n\n"
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(CubeMapFace, 6, CubemapData, "@brief The 6 cubemap face textures for a static cubemap.\n\n"
|
||||||
"They are in the following order:\n"
|
"They are in the following order:\n"
|
||||||
" - cubeFace[0] is -X\n"
|
" - cubeFace[0] is -X\n"
|
||||||
|
|
@ -116,19 +99,26 @@ void CubemapData::createMap()
|
||||||
{
|
{
|
||||||
bool initSuccess = true;
|
bool initSuccess = true;
|
||||||
//check mCubeMapFile first
|
//check mCubeMapFile first
|
||||||
if (getCubeMap() != StringTable->EmptyString())
|
if (mCubeMapAsset.notNull())
|
||||||
{
|
{
|
||||||
mCubemap = TEXMGR->createCubemap(getCubeMap());
|
mCubemap = TEXMGR->createCubemap(mCubeMapAsset->getImageFile());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (U32 i = 0; i < 6; i++)
|
for (U32 i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
if (!_setCubeMapFace(getCubeMapFace(i), i))
|
if (mCubeMapFaceAsset[i].notNull())
|
||||||
{
|
{
|
||||||
Con::errorf("CubemapData::createMap - Failed to load texture '%s'", getCubeMapFace(i));
|
if (!getCubeMapFace(i))
|
||||||
initSuccess = false;
|
{
|
||||||
|
Con::errorf("CubemapData::createMap - Failed to load texture '%s'", mCubeMapFaceAsset[i]->getImageFile());
|
||||||
|
initSuccess = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mCubeMapFaceTex[i] = getCubeMapFace(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,9 +126,10 @@ void CubemapData::createMap()
|
||||||
if( initSuccess )
|
if( initSuccess )
|
||||||
{
|
{
|
||||||
mCubemap = GFX->createCubemap();
|
mCubemap = GFX->createCubemap();
|
||||||
if (!mCubeMapFace || mCubeMapFace->isNull())
|
if (mCubeMapFaceAsset->isNull())
|
||||||
return;
|
return;
|
||||||
mCubemap->initStatic(mCubeMapFace);
|
|
||||||
|
mCubemap->initStatic(mCubeMapFaceTex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,20 +138,27 @@ void CubemapData::updateFaces()
|
||||||
{
|
{
|
||||||
bool initSuccess = true;
|
bool initSuccess = true;
|
||||||
|
|
||||||
for( U32 i=0; i<6; i++ )
|
//check mCubeMapFile first
|
||||||
|
if (mCubeMapAsset.notNull())
|
||||||
{
|
{
|
||||||
//check mCubeMapFile first
|
mCubemap = TEXMGR->createCubemap(mCubeMapAsset->getImageFile());
|
||||||
if (getCubeMap() != StringTable->EmptyString())
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (U32 i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
mCubemap = TEXMGR->createCubemap(getCubeMap());
|
if (mCubeMapFaceAsset[i].notNull())
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!_setCubeMapFace(getCubeMapFace(i), i))
|
|
||||||
{
|
{
|
||||||
Con::errorf("CubemapData::createMap - Failed to load texture '%s'", getCubeMapFace(i));
|
if (!getCubeMapFace(i))
|
||||||
initSuccess = false;
|
{
|
||||||
|
Con::errorf("CubemapData::createMap - Failed to load texture '%s'", mCubeMapFaceAsset[i]->getImageFile());
|
||||||
|
initSuccess = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mCubeMapFaceTex[i] = getCubeMapFace(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,14 +167,16 @@ void CubemapData::updateFaces()
|
||||||
{
|
{
|
||||||
mCubemap = NULL;
|
mCubemap = NULL;
|
||||||
mCubemap = GFX->createCubemap();
|
mCubemap = GFX->createCubemap();
|
||||||
|
if (mCubeMapFaceAsset->isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
mCubemap->initStatic( mCubeMapFace );
|
mCubemap->initStatic(mCubeMapFaceTex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CubemapData::setCubemapFile(FileName newCubemapFile)
|
void CubemapData::setCubemapFile(FileName newCubemapFile)
|
||||||
{
|
{
|
||||||
mCubeMapName = newCubemapFile;
|
_setCubeMap(newCubemapFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CubemapData::setCubeFaceFile(U32 index, FileName newFaceFile)
|
void CubemapData::setCubeFaceFile(U32 index, FileName newFaceFile)
|
||||||
|
|
@ -184,7 +184,7 @@ void CubemapData::setCubeFaceFile(U32 index, FileName newFaceFile)
|
||||||
if (index >= 6)
|
if (index >= 6)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCubeMapFaceName[index] = newFaceFile;
|
_setCubeMapFace(newFaceFile, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CubemapData::setCubeFaceTexture(U32 index, GFXTexHandle newFaceTexture)
|
void CubemapData::setCubeFaceTexture(U32 index, GFXTexHandle newFaceTexture)
|
||||||
|
|
@ -192,7 +192,7 @@ void CubemapData::setCubeFaceTexture(U32 index, GFXTexHandle newFaceTexture)
|
||||||
if (index >= 6)
|
if (index >= 6)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCubeMapFace[index] = newFaceTexture;
|
mCubeMapFaceTex[index] = newFaceTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod( CubemapData, updateFaces, void, (),,
|
DefineEngineMethod( CubemapData, updateFaces, void, (),,
|
||||||
|
|
|
||||||
|
|
@ -70,20 +70,16 @@ public:
|
||||||
|
|
||||||
void setCubeFaceTexture(U32 index, GFXTexHandle newFaceTexture);
|
void setCubeFaceTexture(U32 index, GFXTexHandle newFaceTexture);
|
||||||
|
|
||||||
GFXTexHandle* getCubeFaceTexture(U32 faceIdx) { return &mCubeMapFace[faceIdx]; }
|
GFXTexHandle* getCubeFaceTexture(U32 faceIdx) { return &mCubeMapFaceTex[faceIdx]; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_IMAGEASSET(CubemapData, CubeMap, onCubemapChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(CubemapData, CubeMap, GFXStaticTextureSRGBProfile);
|
||||||
DECLARE_ASSET_SETGET(CubemapData, CubeMap);
|
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(CubemapData, CubeMapFace, 6, onCubeMapFaceChanged);
|
DECLARE_IMAGEASSET_ARRAY(CubemapData, CubeMapFace, GFXStaticTextureSRGBProfile, 6);
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(CubemapData, CubeMapFace);
|
|
||||||
|
|
||||||
void onCubeMapFaceChanged() {}
|
GFXTexHandle mCubeMapFaceTex[6];
|
||||||
GFXTexHandle mDepthBuff;
|
GFXTexHandle mDepthBuff;
|
||||||
GFXTextureTargetRef mRenderTarget;
|
GFXTextureTargetRef mRenderTarget;
|
||||||
|
|
||||||
void onCubemapChanged() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CUBEMAPDATA
|
#endif // CUBEMAPDATA
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,9 @@ GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
|
||||||
setExtent( 140, 30 );
|
setExtent( 140, 30 );
|
||||||
mMasked = false;
|
mMasked = false;
|
||||||
mColor = ColorI::WHITE;
|
mColor = ColorI::WHITE;
|
||||||
INIT_ASSET(Bitmap);
|
mBitmapName = StringTable->EmptyString();
|
||||||
|
mBitmap = NULL;
|
||||||
|
mBitmapAsset.registerRefreshNotify(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -139,14 +141,10 @@ void GuiBitmapButtonCtrl::initPersistFields()
|
||||||
docsURL;
|
docsURL;
|
||||||
addGroup( "Bitmap" );
|
addGroup( "Bitmap" );
|
||||||
|
|
||||||
addProtectedField("Bitmap", TypeImageFilename, Offset(mBitmapName, GuiBitmapButtonCtrl), _setBitmapFieldData, &defaultProtectedGetFn, "Texture file to display on this button.\n"
|
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapButtonCtrl,"Texture file to display on this button.\n"
|
||||||
"If useStates is false, this will be the file that renders on the control. Otherwise, this will "
|
"If useStates is false, this will be the file that renders on the control. Otherwise, this will "
|
||||||
"specify the default texture name to which the various state and modifier suffixes are appended "
|
"specify the default texture name to which the various state and modifier suffixes are appended "
|
||||||
"to find the per-state and per-modifier (if enabled) textures.", AbstractClassRep::FIELD_HideInInspectors); \
|
"to find the per-state and per-modifier (if enabled) textures.")
|
||||||
addProtectedField("BitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiBitmapButtonCtrl), _setBitmapFieldData, &defaultProtectedGetFn, "Texture file to display on this button.\n"
|
|
||||||
"If useStates is false, this will be the file that renders on the control. Otherwise, this will "
|
|
||||||
"specify the default texture name to which the various state and modifier suffixes are appended "
|
|
||||||
"to find the per-state and per-modifier (if enabled) textures.");
|
|
||||||
|
|
||||||
addField("color", TypeColorI, Offset(mColor, GuiBitmapButtonCtrl), "color mul");
|
addField("color", TypeColorI, Offset(mColor, GuiBitmapButtonCtrl), "color mul");
|
||||||
|
|
||||||
|
|
@ -184,7 +182,7 @@ bool GuiBitmapButtonCtrl::onWake()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setActive( true );
|
setActive( true );
|
||||||
setBitmap( getBitmap() );
|
setBitmap( mBitmapName );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +240,7 @@ void GuiBitmapButtonCtrl::inspectPostApply()
|
||||||
{
|
{
|
||||||
Parent::inspectPostApply();
|
Parent::inspectPostApply();
|
||||||
|
|
||||||
setBitmap(getBitmap());
|
setBitmap(mBitmapName);
|
||||||
|
|
||||||
// if the extent is set to (0,0) in the gui editor and appy hit, this control will
|
// if the extent is set to (0,0) in the gui editor and appy hit, this control will
|
||||||
// set it's extent to be exactly the size of the normal bitmap (if present)
|
// set it's extent to be exactly the size of the normal bitmap (if present)
|
||||||
|
|
@ -274,7 +272,7 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
|
|
||||||
if( mBitmapAsset.notNull())
|
if( mBitmapAsset.notNull())
|
||||||
{
|
{
|
||||||
if( dStricmp( getBitmap(), "texhandle" ) != 0 )
|
if( dStricmp( mBitmapName, "texhandle" ) != 0 )
|
||||||
{
|
{
|
||||||
const U32 count = mUseModifiers ? NumModifiers : 1;
|
const U32 count = mUseModifiers ? NumModifiers : 1;
|
||||||
for( U32 i = 0; i < count; ++ i )
|
for( U32 i = 0; i < count; ++ i )
|
||||||
|
|
@ -292,7 +290,7 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
static String s_h[2] = { "_h", "_h_image" };
|
static String s_h[2] = { "_h", "_h_image" };
|
||||||
static String s_i[2] = { "_i", "_i_image" };
|
static String s_i[2] = { "_i", "_i_image" };
|
||||||
|
|
||||||
String baseName = mBitmapAssetId;
|
String baseName = mBitmapAsset.getAssetId();
|
||||||
|
|
||||||
//strip any pre-assigned suffix, just in case
|
//strip any pre-assigned suffix, just in case
|
||||||
baseName = baseName.replace("_n_image", "");
|
baseName = baseName.replace("_n_image", "");
|
||||||
|
|
@ -301,7 +299,7 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
if( mUseModifiers )
|
if( mUseModifiers )
|
||||||
baseName += modifiers[ i ];
|
baseName += modifiers[ i ];
|
||||||
|
|
||||||
mTextures[ i ].mTextureNormal = GFXTexHandle( mBitmapAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
|
mTextures[i].mTextureNormal = getBitmap();
|
||||||
|
|
||||||
if( mUseStates )
|
if( mUseStates )
|
||||||
{
|
{
|
||||||
|
|
@ -323,7 +321,7 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
mTextures[i].mTextureNormalAsset->load();
|
mTextures[i].mTextureNormalAsset->load();
|
||||||
if (mTextures[i].mTextureNormalAsset->getStatus() == AssetBase::Ok)
|
if (mTextures[i].mTextureNormalAsset->getStatus() == AssetBase::Ok)
|
||||||
{
|
{
|
||||||
mTextures[i].mTextureNormal = GFXTexHandle(mTextures[i].mTextureNormalAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
|
mTextures[i].mTextureNormal = mTextures[i].mTextureNormalAsset->getTexture(&GFXDefaultGUIProfile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -345,7 +343,7 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
mTextures[i].mTextureHilightAsset->load();
|
mTextures[i].mTextureHilightAsset->load();
|
||||||
if (mTextures[i].mTextureHilightAsset->getStatus() == AssetBase::Ok)
|
if (mTextures[i].mTextureHilightAsset->getStatus() == AssetBase::Ok)
|
||||||
{
|
{
|
||||||
mTextures[i].mTextureHilight = GFXTexHandle(mTextures[i].mTextureHilightAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
|
mTextures[i].mTextureHilight = mTextures[i].mTextureHilightAsset->getTexture(&GFXDefaultGUIProfile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -369,7 +367,7 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
mTextures[i].mTextureDepressedAsset->load();
|
mTextures[i].mTextureDepressedAsset->load();
|
||||||
if (mTextures[i].mTextureDepressedAsset->getStatus() == AssetBase::Ok)
|
if (mTextures[i].mTextureDepressedAsset->getStatus() == AssetBase::Ok)
|
||||||
{
|
{
|
||||||
mTextures[i].mTextureDepressed = GFXTexHandle(mTextures[i].mTextureDepressedAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
|
mTextures[i].mTextureDepressed = mTextures[i].mTextureDepressedAsset->getTexture(&GFXDefaultGUIProfile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -393,7 +391,7 @@ void GuiBitmapButtonCtrl::setBitmap( StringTableEntry name )
|
||||||
mTextures[i].mTextureInactiveAsset->load();
|
mTextures[i].mTextureInactiveAsset->load();
|
||||||
if (mTextures[i].mTextureInactiveAsset->getStatus() == AssetBase::Ok)
|
if (mTextures[i].mTextureInactiveAsset->getStatus() == AssetBase::Ok)
|
||||||
{
|
{
|
||||||
mTextures[i].mTextureInactive = GFXTexHandle(mTextures[i].mTextureInactiveAsset->getImagePath(), &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
|
mTextures[i].mTextureInactive = mTextures[i].mTextureInactiveAsset->getTexture(&GFXDefaultGUIProfile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -670,4 +668,4 @@ bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
|
||||||
return Parent::pointInControl(parentCoordPoint);
|
return Parent::pointInControl(parentCoordPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_ASSET_BINDS(GuiBitmapButtonCtrl, Bitmap);
|
DEF_ASSET_BINDS_REFACTOR(GuiBitmapButtonCtrl, Bitmap)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
/// To implement different handlers for the modifier states, use the "onDefaultClick",
|
/// To implement different handlers for the modifier states, use the "onDefaultClick",
|
||||||
/// "onCtrlClick", "onAltClick", and "onShiftClick" methods.
|
/// "onCtrlClick", "onAltClick", and "onShiftClick" methods.
|
||||||
///
|
///
|
||||||
class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
class GuiBitmapButtonCtrl : public GuiButtonCtrl, protected AssetPtrCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -118,9 +118,35 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
||||||
///
|
///
|
||||||
BitmapMode mBitmapMode;
|
BitmapMode mBitmapMode;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiBitmapButtonCtrl, Bitmap, onBitmapChange, GFXDefaultGUIProfile);
|
private: AssetPtr<ImageAsset> mBitmapAsset; public: void _setBitmap(StringTableEntry _in) {
|
||||||
DECLARE_ASSET_SETGET(GuiBitmapButtonCtrl, Bitmap);
|
if (mBitmapAsset.getAssetId() == _in) return; if (!AssetDatabase.isDeclaredAsset(_in)) {
|
||||||
|
StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback; AssetQuery query; S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); if (foundAssetcount != 0) {
|
||||||
|
imageAssetId = query.mAssetList[0];
|
||||||
|
} mBitmapAsset = imageAssetId;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mBitmapAsset = _in;
|
||||||
|
mBitmapName = _in;
|
||||||
|
mBitmap = getBitmap();
|
||||||
|
}
|
||||||
|
}; inline StringTableEntry _getBitmap(void) const {
|
||||||
|
return mBitmapAsset.getAssetId();
|
||||||
|
} GFXTexHandle getBitmap() {
|
||||||
|
return mBitmapAsset.notNull() ? mBitmapAsset->getTexture(&GFXDefaultGUIProfile) : 0;
|
||||||
|
} AssetPtr<ImageAsset> getBitmapAsset(void) {
|
||||||
|
return mBitmapAsset;
|
||||||
|
} static bool _setBitmapData(void* obj, const char* index, const char* data) {
|
||||||
|
static_cast<GuiBitmapButtonCtrl*>(obj)->_setBitmap(_getStringTable()->insert(data)); return false;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override
|
||||||
|
{
|
||||||
|
setBitmap(mBitmapName);
|
||||||
|
}
|
||||||
|
|
||||||
|
GFXTexHandle mBitmap;
|
||||||
|
StringTableEntry mBitmapName;
|
||||||
/// alpha masking
|
/// alpha masking
|
||||||
bool mMasked;
|
bool mMasked;
|
||||||
|
|
||||||
|
|
@ -158,11 +184,6 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
void onBitmapChange()
|
|
||||||
{
|
|
||||||
setBitmap(getBitmap());
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GuiBitmapButtonCtrl();
|
GuiBitmapButtonCtrl();
|
||||||
|
|
@ -185,14 +206,6 @@ class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
||||||
DECLARE_CONOBJECT(GuiBitmapButtonCtrl);
|
DECLARE_CONOBJECT(GuiBitmapButtonCtrl);
|
||||||
DECLARE_DESCRIPTION( "A button control rendered entirely from bitmaps.\n"
|
DECLARE_DESCRIPTION( "A button control rendered entirely from bitmaps.\n"
|
||||||
"The individual button states are represented with separate bitmaps." );
|
"The individual button states are represented with separate bitmaps." );
|
||||||
|
|
||||||
//Basically a wrapper function to do our special state handling setup when the fields change
|
|
||||||
static bool _setBitmapFieldData(void* obj, const char* index, const char* data)
|
|
||||||
{
|
|
||||||
GuiBitmapButtonCtrl* object = static_cast<GuiBitmapButtonCtrl*>(obj);
|
|
||||||
object->setBitmap(StringTable->insert(data));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef GuiBitmapButtonCtrl::BitmapMode GuiBitmapMode;
|
typedef GuiBitmapButtonCtrl::BitmapMode GuiBitmapMode;
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ void GuiCheckBoxCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
}
|
}
|
||||||
xOffset = mProfile->mBitmapArrayRects[0].extent.x + 2 + mIndent;
|
xOffset = mProfile->mBitmapArrayRects[0].extent.x + 2 + mIndent;
|
||||||
S32 y = (getHeight() - mProfile->mBitmapArrayRects[0].extent.y) / 2;
|
S32 y = (getHeight() - mProfile->mBitmapArrayRects[0].extent.y) / 2;
|
||||||
GFX->getDrawUtil()->drawBitmapSR(mProfile->getBitmapResource(), offset + Point2I(mIndent, y), mProfile->mBitmapArrayRects[index]);
|
GFX->getDrawUtil()->drawBitmapSR(mProfile->getBitmap(), offset + Point2I(mIndent, y), mProfile->mBitmapArrayRects[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mButtonText[0] != '\0')
|
if(mButtonText[0] != '\0')
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ ConsoleDocClass( GuiIconButtonCtrl,
|
||||||
|
|
||||||
GuiIconButtonCtrl::GuiIconButtonCtrl()
|
GuiIconButtonCtrl::GuiIconButtonCtrl()
|
||||||
{
|
{
|
||||||
INIT_ASSET(Bitmap);
|
|
||||||
mTextLocation = TextLocLeft;
|
mTextLocation = TextLocLeft;
|
||||||
mIconLocation = IconLocLeft;
|
mIconLocation = IconLocLeft;
|
||||||
mTextMargin = 4;
|
mTextMargin = 4;
|
||||||
|
|
@ -127,7 +126,7 @@ void GuiIconButtonCtrl::initPersistFields()
|
||||||
docsURL;
|
docsURL;
|
||||||
addField( "buttonMargin", TypePoint2I, Offset( mButtonMargin, GuiIconButtonCtrl ),"Margin area around the button.\n");
|
addField( "buttonMargin", TypePoint2I, Offset( mButtonMargin, GuiIconButtonCtrl ),"Margin area around the button.\n");
|
||||||
|
|
||||||
addProtectedField( "iconBitmap", TypeImageFilename, Offset( mBitmapName, GuiIconButtonCtrl ), &_setBitmapData, &defaultProtectedGetFn, "Bitmap file for the icon to display on the button.\n", AbstractClassRep::FIELD_HideInInspectors);
|
addProtectedField( "iconBitmap", TypeImageFilename, Offset( mBitmapAsset, GuiIconButtonCtrl ), &_setBitmapData, &defaultProtectedGetFn, "Bitmap file for the icon to display on the button.\n", AbstractClassRep::FIELD_HideInInspectors);
|
||||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiIconButtonCtrl, "Bitmap file for the icon to display on the button.\n");
|
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiIconButtonCtrl, "Bitmap file for the icon to display on the button.\n");
|
||||||
|
|
||||||
addField( "iconLocation", TYPEID< IconLocation >(), Offset( mIconLocation, GuiIconButtonCtrl ),"Where to place the icon on the control. Options are 0 (None), 1 (Left), 2 (Right), 3 (Center).\n");
|
addField( "iconLocation", TYPEID< IconLocation >(), Offset( mIconLocation, GuiIconButtonCtrl ),"Where to place the icon on the control. Options are 0 (None), 1 (Left), 2 (Right), 3 (Center).\n");
|
||||||
|
|
@ -148,8 +147,6 @@ bool GuiIconButtonCtrl::onWake()
|
||||||
return false;
|
return false;
|
||||||
setActive(true);
|
setActive(true);
|
||||||
|
|
||||||
setBitmap(mBitmapName);
|
|
||||||
|
|
||||||
if( mProfile )
|
if( mProfile )
|
||||||
mProfile->constructBitmapArray();
|
mProfile->constructBitmapArray();
|
||||||
|
|
||||||
|
|
@ -181,8 +178,8 @@ bool GuiIconButtonCtrl::resize(const Point2I &newPosition, const Point2I &newExt
|
||||||
|
|
||||||
if ( mIconLocation != IconLocNone )
|
if ( mIconLocation != IconLocNone )
|
||||||
{
|
{
|
||||||
autoExtent.y = mBitmap.getHeight() + mButtonMargin.y * 2;
|
autoExtent.y = getBitmap().getHeight() + mButtonMargin.y * 2;
|
||||||
autoExtent.x = mBitmap.getWidth() + mButtonMargin.x * 2;
|
autoExtent.x = getBitmap().getWidth() + mButtonMargin.x * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mTextLocation != TextLocNone && mButtonText && mButtonText[0] )
|
if ( mTextLocation != TextLocNone && mButtonText && mButtonText[0] )
|
||||||
|
|
@ -209,7 +206,7 @@ void GuiIconButtonCtrl::setBitmap(const char *name)
|
||||||
if(!isAwake())
|
if(!isAwake())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_setBitmap(getBitmap());
|
_setBitmap(name);
|
||||||
|
|
||||||
// So that extent is recalculated if autoSize is set.
|
// So that extent is recalculated if autoSize is set.
|
||||||
resize( getPosition(), getExtent() );
|
resize( getPosition(), getExtent() );
|
||||||
|
|
@ -299,13 +296,13 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
||||||
RectI iconRect( 0, 0, 0, 0 );
|
RectI iconRect( 0, 0, 0, 0 );
|
||||||
|
|
||||||
// Render the icon
|
// Render the icon
|
||||||
if ( mBitmap && mIconLocation != GuiIconButtonCtrl::IconLocNone )
|
if ( mBitmapAsset.notNull() && mIconLocation != GuiIconButtonCtrl::IconLocNone)
|
||||||
{
|
{
|
||||||
// Render the normal bitmap
|
// Render the normal bitmap
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
|
|
||||||
// Size of the bitmap
|
// Size of the bitmap
|
||||||
Point2I textureSize(mBitmap->getWidth(), mBitmap->getHeight());
|
Point2I textureSize(getBitmap()->getWidth(), getBitmap()->getHeight());
|
||||||
|
|
||||||
// Reduce the size with the margin (if set)
|
// Reduce the size with the margin (if set)
|
||||||
textureSize.x = textureSize.x - (mBitmapMargin * 2);
|
textureSize.x = textureSize.x - (mBitmapMargin * 2);
|
||||||
|
|
@ -332,7 +329,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
||||||
iconRect.point.y = offset.y + ( getHeight() - textureSize.y ) / 2;
|
iconRect.point.y = offset.y + ( getHeight() - textureSize.y ) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawer->drawBitmapStretch(mBitmap, iconRect );
|
drawer->drawBitmapStretch(getBitmap(), iconRect );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -366,7 +363,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
||||||
iconRect.point.y = offset.y + (getHeight() / 2) - (iconRect.extent.y / 2) + mButtonMargin.y;
|
iconRect.point.y = offset.y + (getHeight() / 2) - (iconRect.extent.y / 2) + mButtonMargin.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawer->drawBitmapStretch( mBitmap, iconRect );
|
drawer->drawBitmapStretch(getBitmap(), iconRect );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -383,7 +380,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
||||||
if ( mTextLocation == TextLocRight )
|
if ( mTextLocation == TextLocRight )
|
||||||
{
|
{
|
||||||
Point2I start( mTextMargin, ( getHeight() - mProfile->mFont->getHeight() ) / 2 );
|
Point2I start( mTextMargin, ( getHeight() - mProfile->mFont->getHeight() ) / 2 );
|
||||||
if (mBitmap && mIconLocation != IconLocNone )
|
if (mBitmapAsset.notNull() && mIconLocation != IconLocNone)
|
||||||
{
|
{
|
||||||
start.x = iconRect.extent.x + mButtonMargin.x + mTextMargin;
|
start.x = iconRect.extent.x + mButtonMargin.x + mTextMargin;
|
||||||
}
|
}
|
||||||
|
|
@ -403,7 +400,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
||||||
if ( mTextLocation == TextLocCenter )
|
if ( mTextLocation == TextLocCenter )
|
||||||
{
|
{
|
||||||
Point2I start;
|
Point2I start;
|
||||||
if (mBitmap && mIconLocation == IconLocLeft )
|
if (mBitmapAsset.notNull() && mIconLocation == IconLocLeft )
|
||||||
{
|
{
|
||||||
start.set( ( getWidth() - textWidth - iconRect.extent.x ) / 2 + iconRect.extent.x,
|
start.set( ( getWidth() - textWidth - iconRect.extent.x ) / 2 + iconRect.extent.x,
|
||||||
( getHeight() - mProfile->mFont->getHeight() ) / 2 );
|
( getHeight() - mProfile->mFont->getHeight() ) / 2 );
|
||||||
|
|
@ -468,4 +465,4 @@ void GuiIconButtonCtrl::renderBitmapArray(RectI &bounds, S32 state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_ASSET_BINDS(GuiIconButtonCtrl, Bitmap);
|
DEF_ASSET_BINDS_REFACTOR(GuiIconButtonCtrl, Bitmap)
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiIconButtonCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiIconButtonCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiIconButtonCtrl, Bitmap);
|
|
||||||
|
|
||||||
S32 mIconLocation;
|
S32 mIconLocation;
|
||||||
S32 mTextLocation;
|
S32 mTextLocation;
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,6 @@ ConsoleDocClass( GuiToolboxButtonCtrl,
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
GuiToolboxButtonCtrl::GuiToolboxButtonCtrl()
|
GuiToolboxButtonCtrl::GuiToolboxButtonCtrl()
|
||||||
{
|
{
|
||||||
INIT_ASSET(NormalBitmap);
|
|
||||||
INIT_ASSET(LoweredBitmap);
|
|
||||||
INIT_ASSET(HoverBitmap);
|
|
||||||
|
|
||||||
setMinExtent(Point2I(16,16));
|
setMinExtent(Point2I(16,16));
|
||||||
setExtent(48, 48);
|
setExtent(48, 48);
|
||||||
mButtonType = ButtonTypeRadio;
|
mButtonType = ButtonTypeRadio;
|
||||||
|
|
@ -75,10 +71,6 @@ bool GuiToolboxButtonCtrl::onWake()
|
||||||
|
|
||||||
setActive( true );
|
setActive( true );
|
||||||
|
|
||||||
setNormalBitmap( getNormalBitmap() );
|
|
||||||
setLoweredBitmap( getLoweredBitmap() );
|
|
||||||
setHoverBitmap( getHoverBitmap() );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,9 +88,9 @@ void GuiToolboxButtonCtrl::inspectPostApply()
|
||||||
// set it's extent to be exactly the size of the normal bitmap (if present)
|
// set it's extent to be exactly the size of the normal bitmap (if present)
|
||||||
Parent::inspectPostApply();
|
Parent::inspectPostApply();
|
||||||
|
|
||||||
if ((getWidth() == 0) && (getHeight() == 0) && mNormalBitmap)
|
if ((getWidth() == 0) && (getHeight() == 0) && mNormalBitmapAsset.notNull())
|
||||||
{
|
{
|
||||||
setExtent(mNormalBitmap->getWidth(), mNormalBitmap->getHeight());
|
setExtent(getNormalBitmap()->getWidth(), getNormalBitmap()->getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,15 +136,15 @@ void GuiToolboxButtonCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
{
|
{
|
||||||
RectI r(offset, getExtent());
|
RectI r(offset, getExtent());
|
||||||
if ( mDepressed || mStateOn )
|
if ( mDepressed || mStateOn )
|
||||||
renderStateRect( mLoweredBitmap , r );
|
renderStateRect( getLoweredBitmap(), r);
|
||||||
else if ( mHighlighted )
|
else if ( mHighlighted )
|
||||||
renderStateRect( mHoverBitmap , r );
|
renderStateRect( getHoverBitmap(), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now render the image
|
// Now render the image
|
||||||
if( mNormalBitmap )
|
if( mNormalBitmapAsset.notNull() )
|
||||||
{
|
{
|
||||||
renderButton(mNormalBitmap, offset, updateRect );
|
renderButton(getNormalBitmap(), offset, updateRect );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,7 +160,7 @@ void GuiToolboxButtonCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiToolboxButtonCtrl::renderStateRect( GFXTexHandle &texture, const RectI& rect )
|
void GuiToolboxButtonCtrl::renderStateRect( GFXTexHandle texture, const RectI& rect )
|
||||||
{
|
{
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
|
|
@ -179,7 +171,7 @@ void GuiToolboxButtonCtrl::renderStateRect( GFXTexHandle &texture, const RectI&
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void GuiToolboxButtonCtrl::renderButton(GFXTexHandle &texture, Point2I &offset, const RectI& updateRect)
|
void GuiToolboxButtonCtrl::renderButton(GFXTexHandle texture, Point2I &offset, const RectI& updateRect)
|
||||||
{
|
{
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
|
|
@ -194,6 +186,6 @@ void GuiToolboxButtonCtrl::renderButton(GFXTexHandle &texture, Point2I &offset,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_ASSET_BINDS(GuiToolboxButtonCtrl, NormalBitmap);
|
DEF_ASSET_BINDS_REFACTOR(GuiToolboxButtonCtrl, NormalBitmap)
|
||||||
DEF_ASSET_BINDS(GuiToolboxButtonCtrl, LoweredBitmap);
|
DEF_ASSET_BINDS_REFACTOR(GuiToolboxButtonCtrl, LoweredBitmap)
|
||||||
DEF_ASSET_BINDS(GuiToolboxButtonCtrl, HoverBitmap);
|
DEF_ASSET_BINDS_REFACTOR(GuiToolboxButtonCtrl, HoverBitmap)
|
||||||
|
|
|
||||||
|
|
@ -39,19 +39,12 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, NormalBitmap, onNormalImageChanged, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, NormalBitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiToolboxButtonCtrl, NormalBitmap);
|
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, LoweredBitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, LoweredBitmap, onLoweredImageChanged, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, HoverBitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiToolboxButtonCtrl, LoweredBitmap);
|
|
||||||
DECLARE_IMAGEASSET(GuiToolboxButtonCtrl, HoverBitmap, onHoverImageChanged, GFXDefaultGUIProfile);
|
|
||||||
DECLARE_ASSET_SETGET(GuiToolboxButtonCtrl, HoverBitmap);
|
|
||||||
|
|
||||||
void renderButton(GFXTexHandle &texture, Point2I &offset, const RectI& updateRect);
|
void renderButton(GFXTexHandle texture, Point2I &offset, const RectI& updateRect);
|
||||||
void renderStateRect( GFXTexHandle &texture, const RectI& rect );
|
void renderStateRect( GFXTexHandle texture, const RectI& rect );
|
||||||
|
|
||||||
void onNormalImageChanged() {}
|
|
||||||
void onLoweredImageChanged() {}
|
|
||||||
void onHoverImageChanged() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_CONOBJECT(GuiToolboxButtonCtrl);
|
DECLARE_CONOBJECT(GuiToolboxButtonCtrl);
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
Point2I barOffset(barStart, barTop);
|
Point2I barOffset(barStart, barTop);
|
||||||
|
|
||||||
// Draw the start of the bar...
|
// Draw the start of the bar...
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->getBitmapResource(),RectI(barOffset, mProfile->mBitmapArrayRects[2].extent), mProfile->mBitmapArrayRects[2] );
|
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->getBitmap(),RectI(barOffset, mProfile->mBitmapArrayRects[2].extent), mProfile->mBitmapArrayRects[2] );
|
||||||
|
|
||||||
// Now draw the middle...
|
// Now draw the middle...
|
||||||
barOffset.x += mProfile->mBitmapArrayRects[2].extent.x;
|
barOffset.x += mProfile->mBitmapArrayRects[2].extent.x;
|
||||||
|
|
@ -291,7 +291,7 @@ void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
foo.inset(1,0);
|
foo.inset(1,0);
|
||||||
|
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||||
mProfile->getBitmapResource(),
|
mProfile->getBitmap(),
|
||||||
RectI(barOffset, Point2I(barMiddleSize, mProfile->mBitmapArrayRects[3].extent.y)),
|
RectI(barOffset, Point2I(barMiddleSize, mProfile->mBitmapArrayRects[3].extent.y)),
|
||||||
foo
|
foo
|
||||||
);
|
);
|
||||||
|
|
@ -300,7 +300,7 @@ void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
// And the end
|
// And the end
|
||||||
barOffset.x += barMiddleSize;
|
barOffset.x += barMiddleSize;
|
||||||
|
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->getBitmapResource(), RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
|
GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->getBitmap(), RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
|
||||||
mProfile->mBitmapArrayRects[4]);
|
mProfile->mBitmapArrayRects[4]);
|
||||||
|
|
||||||
GFX->getDrawUtil()->setBitmapModulation((mMouseOver ? mProfile->mFontColorHL : mProfile->mFontColor));
|
GFX->getDrawUtil()->setBitmapModulation((mMouseOver ? mProfile->mFontColorHL : mProfile->mFontColor));
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
|
|
||||||
GFX->getDrawUtil()->clearBitmapModulation();
|
GFX->getDrawUtil()->clearBitmapModulation();
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||||
mProfile->getBitmapResource(),
|
mProfile->getBitmap(),
|
||||||
RectI(offset, mProfile->mBitmapArrayRects[idx].extent),
|
RectI(offset, mProfile->mBitmapArrayRects[idx].extent),
|
||||||
mProfile->mBitmapArrayRects[idx]
|
mProfile->mBitmapArrayRects[idx]
|
||||||
);
|
);
|
||||||
|
|
@ -226,7 +226,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
|
|
||||||
// Draw the start of the bar...
|
// Draw the start of the bar...
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||||
mProfile->getBitmapResource(),
|
mProfile->getBitmap(),
|
||||||
RectI(barOffset, mProfile->mBitmapArrayRects[2].extent),
|
RectI(barOffset, mProfile->mBitmapArrayRects[2].extent),
|
||||||
mProfile->mBitmapArrayRects[2]
|
mProfile->mBitmapArrayRects[2]
|
||||||
);
|
);
|
||||||
|
|
@ -243,7 +243,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
foo.inset(1,0);
|
foo.inset(1,0);
|
||||||
|
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||||
mProfile->getBitmapResource(),
|
mProfile->getBitmap(),
|
||||||
RectI(barOffset, Point2I(barMiddleSize, mProfile->mBitmapArrayRects[3].extent.y)),
|
RectI(barOffset, Point2I(barMiddleSize, mProfile->mBitmapArrayRects[3].extent.y)),
|
||||||
foo
|
foo
|
||||||
);
|
);
|
||||||
|
|
@ -253,7 +253,7 @@ void GuiPaneControl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
barOffset.x += barMiddleSize;
|
barOffset.x += barMiddleSize;
|
||||||
|
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(
|
GFX->getDrawUtil()->drawBitmapStretchSR(
|
||||||
mProfile->getBitmapResource(),
|
mProfile->getBitmap(),
|
||||||
RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
|
RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
|
||||||
mProfile->mBitmapArrayRects[4]
|
mProfile->mBitmapArrayRects[4]
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ bool GuiScrollCtrl::onWake()
|
||||||
if (! Parent::onWake())
|
if (! Parent::onWake())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mTextureObject = mProfile->getBitmapResource();
|
mTextureObject = mProfile->getBitmap();
|
||||||
if (mTextureObject && (mProfile->constructBitmapArray() >= (U32)BmpStates * (U32)BmpCount))
|
if (mTextureObject && (mProfile->constructBitmapArray() >= (U32)BmpStates * (U32)BmpCount))
|
||||||
{
|
{
|
||||||
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
||||||
|
|
|
||||||
|
|
@ -696,7 +696,7 @@ bool GuiWindowCtrl::onWake()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mTextureObject = mProfile->getBitmapResource();
|
mTextureObject = mProfile->getBitmap();
|
||||||
|
|
||||||
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
||||||
S32 buttonHeight = mBitmapBounds[(U32)BmpStates * (U32)BmpClose].extent.y;
|
S32 buttonHeight = mBitmapBounds[(U32)BmpStates * (U32)BmpClose].extent.y;
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ bool GuiBitmapBorderCtrl::onWake()
|
||||||
|
|
||||||
//get the texture for the close, minimize, and maximize buttons
|
//get the texture for the close, minimize, and maximize buttons
|
||||||
mBitmapBounds = NULL;
|
mBitmapBounds = NULL;
|
||||||
mTextureObject = mProfile->getBitmapResource();
|
mTextureObject = mProfile->getBitmap();
|
||||||
if( mProfile->constructBitmapArray() >= NumBitmaps )
|
if( mProfile->constructBitmapArray() >= NumBitmaps )
|
||||||
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
mBitmapBounds = mProfile->mBitmapArrayRects.address();
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(GuiBitmapCtrl);
|
IMPLEMENT_CONOBJECT(GuiBitmapCtrl);
|
||||||
|
|
||||||
ConsoleDocClass( GuiBitmapCtrl,
|
ConsoleDocClass(GuiBitmapCtrl,
|
||||||
"@brief A gui control that is used to display an image.\n\n"
|
"@brief A gui control that is used to display an image.\n\n"
|
||||||
|
|
||||||
"The image is stretched to the constraints of the control by default. However, the control can also\n"
|
"The image is stretched to the constraints of the control by default. However, the control can also\n"
|
||||||
|
|
@ -56,40 +56,25 @@ ConsoleDocClass( GuiBitmapCtrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
GuiBitmapCtrl::GuiBitmapCtrl(void)
|
GuiBitmapCtrl::GuiBitmapCtrl(void)
|
||||||
: mStartPoint( 0, 0 ),
|
: mStartPoint(0, 0),
|
||||||
mColor(ColorI::WHITE),
|
mColor(ColorI::WHITE),
|
||||||
mAngle(0),
|
mAngle(0),
|
||||||
mWrap( false )
|
mWrap(false),
|
||||||
|
mBitmap(NULL),
|
||||||
|
mBitmapName(StringTable->EmptyString())
|
||||||
{
|
{
|
||||||
INIT_ASSET(Bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GuiBitmapCtrl::setBitmapName( void *object, const char *index, const char *data )
|
|
||||||
{
|
|
||||||
// Prior to this, you couldn't do bitmap.bitmap = "foo.jpg" and have it work.
|
|
||||||
// With protected console types you can now call the setBitmap function and
|
|
||||||
// make it load the image.
|
|
||||||
static_cast<GuiBitmapCtrl *>( object )->setBitmap( data );
|
|
||||||
|
|
||||||
// Return false because the setBitmap method will assign 'mBitmapName' to the
|
|
||||||
// argument we are specifying in the call.
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiBitmapCtrl::initPersistFields()
|
void GuiBitmapCtrl::initPersistFields()
|
||||||
{
|
{
|
||||||
docsURL;
|
docsURL;
|
||||||
addGroup( "Bitmap" );
|
addGroup("Bitmap");
|
||||||
|
|
||||||
addField("Bitmap", TypeImageFilename, Offset(mBitmapName, GuiBitmapCtrl), assetDoc(Bitmap, docs), AbstractClassRep::FIELD_HideInInspectors);
|
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiBitmapCtrl, "The bitmap to render in this BitmapCtrl.")
|
||||||
addField("BitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiBitmapCtrl), assetDoc(Bitmap, asset docs.));
|
|
||||||
|
|
||||||
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl),"color mul");
|
|
||||||
addField( "wrap", TypeBool, Offset( mWrap, GuiBitmapCtrl ),
|
|
||||||
"If true, the bitmap is tiled inside the control rather than stretched to fit." );
|
|
||||||
|
|
||||||
addFieldV("angle", TypeRangedF32, Offset(mAngle, GuiBitmapCtrl), &CommonValidators::DegreeRange, "rotation");
|
|
||||||
|
|
||||||
|
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl), "color mul");
|
||||||
|
addField("wrap", TypeBool, Offset(mWrap, GuiBitmapCtrl), "If true, the bitmap is tiled inside the control rather than stretched to fit.");
|
||||||
|
addFieldV("angle", TypeRangedF32, Offset(mAngle, GuiBitmapCtrl), &CommonValidators::DegreeRange, "rotation");
|
||||||
endGroup( "Bitmap" );
|
endGroup( "Bitmap" );
|
||||||
|
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
|
|
@ -97,55 +82,53 @@ void GuiBitmapCtrl::initPersistFields()
|
||||||
|
|
||||||
bool GuiBitmapCtrl::onWake()
|
bool GuiBitmapCtrl::onWake()
|
||||||
{
|
{
|
||||||
if (! Parent::onWake())
|
if (!Parent::onWake())
|
||||||
return false;
|
return false;
|
||||||
setActive(true);
|
setActive(true);
|
||||||
|
|
||||||
if (mBitmapName != StringTable->insert("texhandle"))
|
|
||||||
setBitmap(getBitmap());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiBitmapCtrl::onSleep()
|
void GuiBitmapCtrl::onSleep()
|
||||||
{
|
{
|
||||||
if ( mBitmapName != StringTable->insert("texhandle") )
|
|
||||||
mBitmap = NULL;
|
|
||||||
|
|
||||||
Parent::onSleep();
|
Parent::onSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
void GuiBitmapCtrl::inspectPostApply()
|
void GuiBitmapCtrl::inspectPostApply()
|
||||||
{
|
{
|
||||||
//This is a little bit of a 'special case' handling for this class
|
|
||||||
//Because we don't do the normal protectedField setup for the bitmapName/bitmapAsset fields
|
|
||||||
//which would automatically update the internal values and bound content, we'll do it here manually
|
|
||||||
//to ensure it's updated before we force a refresh, which would thrash the new values
|
|
||||||
if (mBitmapName != StringTable->insert("texhandle"))
|
|
||||||
{
|
|
||||||
_setBitmap(mBitmapAssetId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setBitmap(getBitmap());
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the extent is set to (0,0) in the gui editor and appy hit, this control will
|
// if the extent is set to (0,0) in the gui editor and appy hit, this control will
|
||||||
// set it's extent to be exactly the size of the bitmap (if present)
|
// set it's extent to be exactly the size of the bitmap (if present)
|
||||||
Parent::inspectPostApply();
|
Parent::inspectPostApply();
|
||||||
|
|
||||||
if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mBitmap)
|
if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mBitmapAsset.notNull())
|
||||||
{
|
{
|
||||||
setExtent( mBitmap->getWidth(), mBitmap->getHeight());
|
setExtent(mBitmap->getWidth(), mBitmap->getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiBitmapCtrl::setBitmap( const char *name, bool resize )
|
void GuiBitmapCtrl::setBitmap(const char* name, bool resize)
|
||||||
{
|
{
|
||||||
_setBitmap(StringTable->insert(name));
|
// coming in here we are probably getting a filename.
|
||||||
|
if (AssetDatabase.isDeclaredAsset(name))
|
||||||
if (mBitmap && resize)
|
|
||||||
{
|
{
|
||||||
|
_setBitmap(StringTable->insert(name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringTableEntry assetId = ImageAsset::getAssetIdByFilename(StringTable->insert(name));
|
||||||
|
|
||||||
|
if (assetId != StringTable->EmptyString())
|
||||||
|
_setBitmap(assetId);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mBitmap = mBitmapAsset->getTexture(&GFXDefaultGUIProfile);
|
||||||
|
|
||||||
|
if (mBitmapAsset.notNull() && resize)
|
||||||
|
{
|
||||||
|
|
||||||
setExtent(mBitmap->getWidth(), mBitmap->getHeight());
|
setExtent(mBitmap->getWidth(), mBitmap->getHeight());
|
||||||
updateSizing();
|
updateSizing();
|
||||||
}
|
}
|
||||||
|
|
@ -153,15 +136,6 @@ void GuiBitmapCtrl::setBitmap( const char *name, bool resize )
|
||||||
setUpdate();
|
setUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiBitmapCtrl::updateSizing()
|
|
||||||
{
|
|
||||||
if(!getParent())
|
|
||||||
return;
|
|
||||||
// updates our bounds according to our horizSizing and verSizing rules
|
|
||||||
RectI fakeBounds( getPosition(), getParent()->getExtent());
|
|
||||||
parentResized( fakeBounds, fakeBounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
|
void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
|
||||||
{
|
{
|
||||||
mBitmap = handle;
|
mBitmap = handle;
|
||||||
|
|
@ -176,39 +150,51 @@ void GuiBitmapCtrl::setBitmapHandle(GFXTexHandle handle, bool resize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
void GuiBitmapCtrl::updateSizing()
|
||||||
{
|
{
|
||||||
|
if (!getParent())
|
||||||
|
return;
|
||||||
|
// updates our bounds according to our horizSizing and verSizing rules
|
||||||
|
RectI fakeBounds(getPosition(), getParent()->getExtent());
|
||||||
|
parentResized(fakeBounds, fakeBounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiBitmapCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
|
{
|
||||||
|
if (mBitmap.isNull() && mBitmapAsset.notNull())
|
||||||
|
mBitmap = getBitmap();
|
||||||
|
|
||||||
if (mBitmap)
|
if (mBitmap)
|
||||||
{
|
{
|
||||||
GFX->getDrawUtil()->clearBitmapModulation();
|
GFX->getDrawUtil()->clearBitmapModulation();
|
||||||
GFX->getDrawUtil()->setBitmapModulation(mColor);
|
GFX->getDrawUtil()->setBitmapModulation(mColor);
|
||||||
if(mWrap)
|
if (mWrap)
|
||||||
{
|
{
|
||||||
// We manually draw each repeat because non power of two textures will
|
// We manually draw each repeat because non power of two textures will
|
||||||
// not tile correctly when rendered with GFX->drawBitmapTile(). The non POT
|
// not tile correctly when rendered with GFX->drawBitmapTile(). The non POT
|
||||||
// bitmap will be padded by the hardware, and we'll see lots of slack
|
// bitmap will be padded by the hardware, and we'll see lots of slack
|
||||||
// in the texture. So... lets do what we must: draw each repeat by itself:
|
// in the texture. So... lets do what we must: draw each repeat by itself:
|
||||||
GFXTextureObject* texture = mBitmap;
|
GFXTextureObject* texture = mBitmap;
|
||||||
RectI srcRegion;
|
RectI srcRegion;
|
||||||
RectI dstRegion;
|
RectI dstRegion;
|
||||||
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
|
F32 xdone = ((F32)getExtent().x / (F32)texture->mBitmapSize.x) + 1;
|
||||||
F32 ydone = ((F32)getExtent().y/(F32)texture->mBitmapSize.y)+1;
|
F32 ydone = ((F32)getExtent().y / (F32)texture->mBitmapSize.y) + 1;
|
||||||
|
|
||||||
S32 xshift = mStartPoint.x%texture->mBitmapSize.x;
|
S32 xshift = mStartPoint.x % texture->mBitmapSize.x;
|
||||||
S32 yshift = mStartPoint.y%texture->mBitmapSize.y;
|
S32 yshift = mStartPoint.y % texture->mBitmapSize.y;
|
||||||
for(S32 y = 0; y < ydone; ++y)
|
for (S32 y = 0; y < ydone; ++y)
|
||||||
for(S32 x = 0; x < xdone; ++x)
|
for (S32 x = 0; x < xdone; ++x)
|
||||||
{
|
{
|
||||||
srcRegion.set(0,0,texture->mBitmapSize.x,texture->mBitmapSize.y);
|
srcRegion.set(0, 0, texture->mBitmapSize.x, texture->mBitmapSize.y);
|
||||||
dstRegion.set( ((texture->mBitmapSize.x*x)+offset.x)-xshift,
|
dstRegion.set(((texture->mBitmapSize.x * x) + offset.x) - xshift,
|
||||||
((texture->mBitmapSize.y*y)+offset.y)-yshift,
|
((texture->mBitmapSize.y * y) + offset.y) - yshift,
|
||||||
texture->mBitmapSize.x,
|
texture->mBitmapSize.x,
|
||||||
texture->mBitmapSize.y);
|
texture->mBitmapSize.y);
|
||||||
GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, mAngle);
|
GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, mAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RectI rect(offset, getExtent());
|
RectI rect(offset, getExtent());
|
||||||
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false, mAngle);
|
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false, mAngle);
|
||||||
|
|
@ -226,21 +212,21 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
|
|
||||||
void GuiBitmapCtrl::setValue(S32 x, S32 y)
|
void GuiBitmapCtrl::setValue(S32 x, S32 y)
|
||||||
{
|
{
|
||||||
if (mBitmap)
|
if (mBitmapAsset.notNull())
|
||||||
{
|
{
|
||||||
x += mBitmap->getWidth() / 2;
|
x += mBitmapAsset->getTextureBitmapWidth() / 2;
|
||||||
y += mBitmap->getHeight() / 2;
|
y += mBitmapAsset->getTextureBitmapHeight() / 2;
|
||||||
}
|
}
|
||||||
while (x < 0)
|
while (x < 0)
|
||||||
x += 256;
|
x += 256;
|
||||||
mStartPoint.x = x % 256;
|
mStartPoint.x = x % 256;
|
||||||
|
|
||||||
while (y < 0)
|
while (y < 0)
|
||||||
y += 256;
|
y += 256;
|
||||||
mStartPoint.y = y % 256;
|
mStartPoint.y = y % 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod( GuiBitmapCtrl, setValue, void, ( S32 x, S32 y ),,
|
DefineEngineMethod(GuiBitmapCtrl, setValue, void, (S32 x, S32 y), ,
|
||||||
"Set the offset of the bitmap within the control.\n"
|
"Set the offset of the bitmap within the control.\n"
|
||||||
"@param x The x-axis offset of the image.\n"
|
"@param x The x-axis offset of the image.\n"
|
||||||
"@param y The y-axis offset of the image.\n")
|
"@param y The y-axis offset of the image.\n")
|
||||||
|
|
@ -257,7 +243,7 @@ static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap1(
|
||||||
"@param filename The filename of the image.\n"
|
"@param filename The filename of the image.\n"
|
||||||
"@param resize Optional parameter. If true, the GUI will resize to fit the image.",
|
"@param resize Optional parameter. If true, the GUI will resize to fit the image.",
|
||||||
"GuiBitmapCtrl", // The class to place the method in; use NULL for functions.
|
"GuiBitmapCtrl", // The class to place the method in; use NULL for functions.
|
||||||
"void setBitmap( String filename, bool resize );" ); // The definition string.
|
"void setBitmap( String filename, bool resize );"); // The definition string.
|
||||||
|
|
||||||
static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2(
|
static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2(
|
||||||
"@brief Assign an image to the control.\n\n"
|
"@brief Assign an image to the control.\n\n"
|
||||||
|
|
@ -265,42 +251,42 @@ static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2(
|
||||||
"@param filename The filename of the image.\n"
|
"@param filename The filename of the image.\n"
|
||||||
"@param resize A boolean value that decides whether the ctrl refreshes or not.",
|
"@param resize A boolean value that decides whether the ctrl refreshes or not.",
|
||||||
"GuiBitmapCtrl", // The class to place the method in; use NULL for functions.
|
"GuiBitmapCtrl", // The class to place the method in; use NULL for functions.
|
||||||
"void setBitmap( String filename );" ); // The definition string.
|
"void setBitmap( String filename );"); // The definition string.
|
||||||
|
|
||||||
|
|
||||||
//"Set the bitmap displayed in the control. Note that it is limited in size, to 256x256."
|
//"Set the bitmap displayed in the control. Note that it is limited in size, to 256x256."
|
||||||
DefineEngineMethod( GuiBitmapCtrl, setBitmap, void, ( const char * fileRoot, bool resize), ( false),
|
DefineEngineMethod(GuiBitmapCtrl, setBitmap, void, (const char* fileRoot, bool resize), (false),
|
||||||
"( String filename | String filename, bool resize ) Assign an image to the control.\n\n"
|
"( String filename | String filename, bool resize ) Assign an image to the control.\n\n"
|
||||||
"@hide" )
|
"@hide")
|
||||||
{
|
{
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
Con::expandScriptFilename(filename, sizeof(filename), fileRoot);
|
Con::expandScriptFilename(filename, sizeof(filename), fileRoot);
|
||||||
object->setBitmap(filename, resize );
|
object->setBitmap(filename, resize);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod(GuiBitmapCtrl, getBitmap, const char*, (),,
|
DefineEngineMethod(GuiBitmapCtrl, getBitmap, const char*, (), ,
|
||||||
"Gets the current bitmap set for this control.\n\n"
|
"Gets the current bitmap set for this control.\n\n"
|
||||||
"@hide")
|
"@hide")
|
||||||
{
|
{
|
||||||
return object->getBitmap();
|
return object->_getBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod( GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture),,
|
DefineEngineMethod(GuiBitmapCtrl, setNamedTexture, bool, (String namedtexture), ,
|
||||||
"@brief Set a texture as the image.\n\n"
|
"@brief Set a texture as the image.\n\n"
|
||||||
"@param namedtexture The name of the texture (NamedTexTarget).\n"
|
"@param namedtexture The name of the texture (NamedTexTarget).\n"
|
||||||
"@return true if the texture exists." )
|
"@return true if the texture exists.")
|
||||||
{
|
{
|
||||||
GFXTexHandle theTex;
|
GFXTexHandle theTex;
|
||||||
NamedTexTarget *namedTarget = NULL;
|
NamedTexTarget* namedTarget = NULL;
|
||||||
namedTarget = NamedTexTarget::find(namedtexture.c_str());
|
namedTarget = NamedTexTarget::find(namedtexture.c_str());
|
||||||
if ( namedTarget )
|
if (namedTarget)
|
||||||
{
|
{
|
||||||
theTex = namedTarget->getTexture( 0 );
|
theTex = namedTarget->getTexture(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( theTex.isValid() )
|
if (theTex.isValid())
|
||||||
{
|
{
|
||||||
object->setBitmapHandle( theTex , false );
|
object->setBitmapHandle(theTex, false);
|
||||||
return true; //a new texture was set correctly
|
return true; //a new texture was set correctly
|
||||||
}
|
}
|
||||||
return false; //we couldn't change the texture
|
return false; //we couldn't change the texture
|
||||||
|
|
|
||||||
|
|
@ -31,51 +31,47 @@
|
||||||
/// Renders a bitmap.
|
/// Renders a bitmap.
|
||||||
class GuiBitmapCtrl : public GuiControl
|
class GuiBitmapCtrl : public GuiControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef GuiControl Parent;
|
typedef GuiControl Parent;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded
|
/// Name of the bitmap file. If this is 'texhandle' the bitmap is not loaded
|
||||||
/// from a file but rather set explicitly on the control.
|
/// from a file but rather set explicitly on the control.
|
||||||
DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiBitmapCtrl, Bitmap);
|
|
||||||
|
|
||||||
Point2I mStartPoint;
|
Point2I mStartPoint;
|
||||||
ColorI mColor;
|
ColorI mColor;
|
||||||
F32 mAngle;
|
F32 mAngle;
|
||||||
|
|
||||||
/// If true, bitmap tiles inside control. Otherwise stretches.
|
/// If true, bitmap tiles inside control. Otherwise stretches.
|
||||||
bool mWrap;
|
bool mWrap;
|
||||||
|
|
||||||
static bool setBitmapName( void *object, const char *index, const char *data );
|
public:
|
||||||
static const char *getBitmapName( void *obj, const char *data );
|
GFXTexHandle mBitmap;
|
||||||
|
StringTableEntry mBitmapName;
|
||||||
|
|
||||||
void onImageChanged() {}
|
GuiBitmapCtrl();
|
||||||
|
static void initPersistFields();
|
||||||
|
|
||||||
public:
|
// GuiControl.
|
||||||
|
bool onWake() override;
|
||||||
|
void onSleep() override;
|
||||||
|
void inspectPostApply() override;
|
||||||
|
|
||||||
GuiBitmapCtrl();
|
void setBitmap(const char* name, bool resize = true);
|
||||||
static void initPersistFields();
|
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
|
||||||
|
|
||||||
void setBitmap(const char *name,bool resize = false);
|
void updateSizing();
|
||||||
void setBitmapHandle(GFXTexHandle handle, bool resize = false);
|
|
||||||
|
|
||||||
// GuiControl.
|
void onRender(Point2I offset, const RectI& updateRect) override;
|
||||||
bool onWake() override;
|
void setValue(S32 x, S32 y);
|
||||||
void onSleep() override;
|
|
||||||
void inspectPostApply() override;
|
|
||||||
|
|
||||||
void updateSizing();
|
DECLARE_CONOBJECT(GuiBitmapCtrl);
|
||||||
|
DECLARE_CATEGORY("Gui Images");
|
||||||
void onRender(Point2I offset, const RectI &updateRect) override;
|
DECLARE_DESCRIPTION("A control that displays a single, static image from a file.n"
|
||||||
void setValue(S32 x, S32 y);
|
"The bitmap can either be tiled or stretched inside the control.");
|
||||||
|
|
||||||
DECLARE_CONOBJECT( GuiBitmapCtrl );
|
|
||||||
DECLARE_CATEGORY( "Gui Images" );
|
|
||||||
DECLARE_DESCRIPTION( "A control that displays a single, static image from a file.n"
|
|
||||||
"The bitmap can either be tiled or stretched inside the control." );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ void GuiGameListMenuCtrl::onRenderListOption(Row* row, Point2I currentOffset)
|
||||||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||||
|
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
drawer->drawBitmapStretchSR(profile->getBitmap(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||||
|
|
||||||
// render the right arrow
|
// render the right arrow
|
||||||
bool arrowOnR = (isRowSelected || isRowHighlighted) && (row->mWrapOptions || (row->mSelectedOption < row->mOptions.size() - 1));
|
bool arrowOnR = (isRowSelected || isRowHighlighted) && (row->mWrapOptions || (row->mSelectedOption < row->mOptions.size() - 1));
|
||||||
|
|
@ -215,7 +215,7 @@ void GuiGameListMenuCtrl::onRenderListOption(Row* row, Point2I currentOffset)
|
||||||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||||
|
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
drawer->drawBitmapStretchSR(profile->getBitmap(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the appropriate font color
|
// get the appropriate font color
|
||||||
|
|
@ -1759,7 +1759,7 @@ bool GuiGameListMenuProfile::onAdd()
|
||||||
|
|
||||||
// We can't call enforceConstraints() here because incRefCount initializes
|
// We can't call enforceConstraints() here because incRefCount initializes
|
||||||
// some of the things to enforce. Do a basic sanity check here instead.
|
// some of the things to enforce. Do a basic sanity check here instead.
|
||||||
U32 assetStatus = ImageAsset::getAssetErrCode(mBitmapAsset);
|
U32 assetStatus = ImageAsset::getAssetErrCode(getBitmapAsset());
|
||||||
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
if (assetStatus != AssetBase::Ok && assetStatus != AssetBase::UsingFallback)
|
||||||
{
|
{
|
||||||
Con::errorf( "GuiGameListMenuProfile: %s can't be created without a bitmap. Please add a 'Bitmap' property to the object definition.", getName() );
|
Con::errorf( "GuiGameListMenuProfile: %s can't be created without a bitmap. Please add a 'Bitmap' property to the object definition.", getName() );
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ void GuiGameListOptionsCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||||
|
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
drawer->drawBitmapStretchSR(profile->getBitmap(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||||
|
|
||||||
// render the right arrow
|
// render the right arrow
|
||||||
bool arrowOnR = (isRowSelected || isRowHighlighted) && (myRow->mWrapOptions || (myRow->mSelectedOption < myRow->mOptions.size() - 1));
|
bool arrowOnR = (isRowSelected || isRowHighlighted) && (myRow->mWrapOptions || (myRow->mSelectedOption < myRow->mOptions.size() - 1));
|
||||||
|
|
@ -120,7 +120,7 @@ void GuiGameListOptionsCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||||
|
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
drawer->drawBitmapStretchSR(profile->getBitmap(), RectI(arrowOffset, arrowExtent), profile->getBitmapArrayRect((U32)iconIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the appropriate font color
|
// get the appropriate font color
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,6 @@ GuiGameSettingsCtrl::GuiGameSettingsCtrl() :
|
||||||
mCallbackOnB = mCallbackOnA;
|
mCallbackOnB = mCallbackOnA;
|
||||||
mCallbackOnX = mCallbackOnA;
|
mCallbackOnX = mCallbackOnA;
|
||||||
mCallbackOnY = mCallbackOnA;
|
mCallbackOnY = mCallbackOnA;
|
||||||
|
|
||||||
INIT_ASSET(KeybindBitmap);
|
|
||||||
INIT_ASSET(PreviousBitmap);
|
|
||||||
INIT_ASSET(NextBitmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiGameSettingsCtrl::~GuiGameSettingsCtrl()
|
GuiGameSettingsCtrl::~GuiGameSettingsCtrl()
|
||||||
|
|
@ -194,7 +190,7 @@ void GuiGameSettingsCtrl::onRenderListOption(Point2I currentOffset)
|
||||||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||||
|
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
drawer->drawBitmapStretch(mPreviousBitmap, RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
drawer->drawBitmapStretch(getPreviousBitmap(), RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -215,7 +211,7 @@ void GuiGameSettingsCtrl::onRenderListOption(Point2I currentOffset)
|
||||||
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
arrowOffset.y = currentOffset.y + arrowOffsetY;
|
||||||
|
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
drawer->drawBitmapStretch(mNextBitmap, RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
drawer->drawBitmapStretch(getNextBitmap(), RectI(arrowOffset, Point2I(mArrowSize, mArrowSize)), GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -377,7 +373,7 @@ void GuiGameSettingsCtrl::onRenderKeybindOption(Point2I currentOffset)
|
||||||
{
|
{
|
||||||
RectI rect(button, buttonSize);
|
RectI rect(button, buttonSize);
|
||||||
drawer->clearBitmapModulation();
|
drawer->clearBitmapModulation();
|
||||||
drawer->drawBitmapStretch(mKeybindBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
drawer->drawBitmapStretch(getKeybindBitmap(), rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//drawer->drawRectFill(button, ColorI::BLUE);
|
//drawer->drawRectFill(button, ColorI::BLUE);
|
||||||
|
|
@ -455,22 +451,11 @@ bool GuiGameSettingsCtrl::onWake()
|
||||||
if( !Parent::onWake() )
|
if( !Parent::onWake() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_setNextBitmap(getNextBitmap());
|
|
||||||
_setPreviousBitmap(getPreviousBitmap());
|
|
||||||
_setKeybindBitmap(getKeybindBitmap());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiGameSettingsCtrl::onSleep()
|
void GuiGameSettingsCtrl::onSleep()
|
||||||
{
|
{
|
||||||
if (mNextBitmapAsset.notNull())
|
|
||||||
mNextBitmap = NULL;
|
|
||||||
if (mPreviousBitmapAsset.notNull())
|
|
||||||
mPreviousBitmap = NULL;
|
|
||||||
if (mKeybindBitmapAsset.notNull())
|
|
||||||
mKeybindBitmap = NULL;
|
|
||||||
|
|
||||||
Parent::onSleep();
|
Parent::onSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,14 +72,9 @@ protected:
|
||||||
Point2F mRange; ///< When working as a slider, this sets our min/max range
|
Point2F mRange; ///< When working as a slider, this sets our min/max range
|
||||||
|
|
||||||
//Keybind option
|
//Keybind option
|
||||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, KeybindBitmap, changeBitmap, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, KeybindBitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, KeybindBitmap);
|
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, PreviousBitmap, GFXDefaultGUIProfile)
|
||||||
|
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, NextBitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, PreviousBitmap, changeBitmap, GFXDefaultGUIProfile);
|
|
||||||
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, PreviousBitmap);
|
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, NextBitmap, changeBitmap, GFXDefaultGUIProfile);
|
|
||||||
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, NextBitmap);
|
|
||||||
|
|
||||||
S32 mArrowSize;
|
S32 mArrowSize;
|
||||||
S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'.
|
S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'.
|
||||||
|
|
@ -89,8 +84,6 @@ protected:
|
||||||
bool mSelected;
|
bool mSelected;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void changeBitmap() {}
|
|
||||||
|
|
||||||
/// Sets the control as selected . Only controls that are enabled can be selected.
|
/// Sets the control as selected . Only controls that are enabled can be selected.
|
||||||
virtual void setSelected();
|
virtual void setSelected();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,9 +278,6 @@ GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void)
|
||||||
mBackgroundCancel = false; // Added
|
mBackgroundCancel = false; // Added
|
||||||
mReverseTextList = false; // Added - Don't reverse text list if displaying up
|
mReverseTextList = false; // Added - Don't reverse text list if displaying up
|
||||||
|
|
||||||
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, 0);
|
|
||||||
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, 1);
|
|
||||||
|
|
||||||
mBitmapBounds.set(16, 16); // Added
|
mBitmapBounds.set(16, 16); // Added
|
||||||
mIdMax = -1;
|
mIdMax = -1;
|
||||||
mBackground = NULL;
|
mBackground = NULL;
|
||||||
|
|
@ -302,8 +299,7 @@ void GuiPopUpMenuCtrl::initPersistFields(void)
|
||||||
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrl));
|
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrl));
|
||||||
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrl));
|
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrl));
|
||||||
|
|
||||||
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiPopUpMenuCtrl), _setBitmaps, defaultProtectedGetFn, "");
|
addProtectedField("BitmapAsset", TypeImageAssetPtr, Offset(mBitmapAsset, GuiPopUpMenuCtrl), _setBitmaps, &defaultProtectedGetFn, "@brief ""Bitmap"" ""asset \"\".");
|
||||||
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiPopUpMenuCtrl), _setBitmaps, defaultProtectedGetFn, "");
|
|
||||||
|
|
||||||
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrl));
|
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrl));
|
||||||
|
|
||||||
|
|
@ -473,9 +469,6 @@ bool GuiPopUpMenuCtrl::onWake()
|
||||||
if ( !Parent::onWake() )
|
if ( !Parent::onWake() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Set the bitmap for the popup.
|
|
||||||
setBitmap(getBitmap(Normal));
|
|
||||||
|
|
||||||
// Now update the Form Control's bitmap array, and possibly the child's too
|
// Now update the Form Control's bitmap array, and possibly the child's too
|
||||||
mProfile->constructBitmapArray();
|
mProfile->constructBitmapArray();
|
||||||
|
|
||||||
|
|
@ -592,8 +585,8 @@ void GuiPopUpMenuCtrl::setBitmap( const char *name )
|
||||||
dStrcpy(p, "_d", pLen);
|
dStrcpy(p, "_d", pLen);
|
||||||
_setBitmap((StringTableEntry)buffer, Depressed);
|
_setBitmap((StringTableEntry)buffer, Depressed);
|
||||||
|
|
||||||
if ( !mBitmap[Depressed] )
|
if ( mBitmapAsset[Depressed].isNull() )
|
||||||
mBitmap[Depressed] = mBitmap[Normal];
|
mBitmapAsset[Depressed] = mBitmapAsset[Normal];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -898,17 +891,17 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a bitmap over the background?
|
// Draw a bitmap over the background?
|
||||||
if ( mBitmap[Depressed] )
|
if ( mBitmapAsset[Depressed].notNull() )
|
||||||
{
|
{
|
||||||
RectI rect(offset, mBitmapBounds);
|
RectI rect(offset, mBitmapBounds);
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch( mBitmap[Depressed], rect );
|
drawUtil->drawBitmapStretch( getBitmap(Depressed), rect );
|
||||||
}
|
}
|
||||||
else if ( mBitmap[Normal] )
|
else if ( mBitmapAsset[Normal].notNull() )
|
||||||
{
|
{
|
||||||
RectI rect(offset, mBitmapBounds);
|
RectI rect(offset, mBitmapBounds);
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch( mBitmap[Normal], rect );
|
drawUtil->drawBitmapStretch(getBitmap(Normal), rect );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we render a bitmap border or lines?
|
// Do we render a bitmap border or lines?
|
||||||
|
|
@ -948,11 +941,11 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a bitmap over the background?
|
// Draw a bitmap over the background?
|
||||||
if ( mBitmap[Normal] )
|
if ( mBitmapAsset[Normal].notNull() )
|
||||||
{
|
{
|
||||||
RectI rect( offset, mBitmapBounds );
|
RectI rect( offset, mBitmapBounds );
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch( mBitmap[Normal], rect );
|
drawUtil->drawBitmapStretch(getBitmap(Normal) , rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we render a bitmap border or lines?
|
// Do we render a bitmap border or lines?
|
||||||
|
|
@ -984,11 +977,11 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a bitmap over the background?
|
// Draw a bitmap over the background?
|
||||||
if ( mBitmap[Normal] )
|
if (mBitmapAsset[Normal].notNull())
|
||||||
{
|
{
|
||||||
RectI rect(offset, mBitmapBounds);
|
RectI rect(offset, mBitmapBounds);
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch( mBitmap[Normal], rect );
|
drawUtil->drawBitmapStretch( getBitmap(Normal), rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we render a bitmap border or lines?
|
// Do we render a bitmap border or lines?
|
||||||
|
|
|
||||||
|
|
@ -126,9 +126,8 @@ protected:
|
||||||
NumBitmapModes = 2
|
NumBitmapModes = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, NumBitmapModes, onBitmapChanged);
|
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrl, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrl, Bitmap);
|
|
||||||
void onBitmapChanged() {}
|
|
||||||
Point2I mBitmapBounds; // Added
|
Point2I mBitmapBounds; // Added
|
||||||
S32 mIdMax;
|
S32 mIdMax;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -330,9 +330,6 @@ GuiPopUpMenuCtrlEx::GuiPopUpMenuCtrlEx(void)
|
||||||
mBackgroundCancel = false; // Added
|
mBackgroundCancel = false; // Added
|
||||||
mReverseTextList = false; // Added - Don't reverse text list if displaying up
|
mReverseTextList = false; // Added - Don't reverse text list if displaying up
|
||||||
|
|
||||||
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, Normal);
|
|
||||||
INIT_IMAGEASSET_ARRAY(Bitmap, GFXDefaultGUIProfile, Depressed);
|
|
||||||
|
|
||||||
mBitmapBounds.set(16, 16); // Added
|
mBitmapBounds.set(16, 16); // Added
|
||||||
mHotTrackItems = false;
|
mHotTrackItems = false;
|
||||||
mIdMax = -1;
|
mIdMax = -1;
|
||||||
|
|
@ -357,8 +354,7 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
|
||||||
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrlEx), "Deprecated" "@internal");
|
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrlEx), "Deprecated" "@internal");
|
||||||
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrlEx), "Reverses text list if popup extends up, instead of down");
|
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrlEx), "Reverses text list if popup extends up, instead of down");
|
||||||
|
|
||||||
addProtectedField("bitmap", TypeImageFilename, Offset(mBitmapName, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "File name of bitmap to use");
|
addProtectedField("BitmapAsset", TypeImageAssetPtr, Offset(mBitmapAsset, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "@brief ""Bitmap"" ""asset \"Name of bitmap asset to use\".");
|
||||||
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiPopUpMenuCtrlEx), _setBitmaps, &defaultProtectedGetFn, "Name of bitmap asset to use");
|
|
||||||
|
|
||||||
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrlEx), "Boundaries of bitmap displayed");
|
addField("bitmapBounds", TypePoint2I, Offset(mBitmapBounds, GuiPopUpMenuCtrlEx), "Boundaries of bitmap displayed");
|
||||||
addField("hotTrackCallback", TypeBool, Offset(mHotTrackItems, GuiPopUpMenuCtrlEx),
|
addField("hotTrackCallback", TypeBool, Offset(mHotTrackItems, GuiPopUpMenuCtrlEx),
|
||||||
|
|
@ -369,14 +365,6 @@ void GuiPopUpMenuCtrlEx::initPersistFields(void)
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiPopUpMenuCtrlEx::_setBitmaps(void* obj, const char* index, const char* data)
|
|
||||||
{
|
|
||||||
GuiPopUpMenuCtrlEx* object = static_cast<GuiPopUpMenuCtrlEx*>(obj);
|
|
||||||
|
|
||||||
object->setBitmap(data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
ConsoleDocFragment _GuiPopUpMenuCtrlExAdd(
|
ConsoleDocFragment _GuiPopUpMenuCtrlExAdd(
|
||||||
"@brief Adds an entry to the list\n\n"
|
"@brief Adds an entry to the list\n\n"
|
||||||
|
|
@ -691,9 +679,6 @@ bool GuiPopUpMenuCtrlEx::onWake()
|
||||||
if ( !Parent::onWake() )
|
if ( !Parent::onWake() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Set the bitmap for the popup.
|
|
||||||
setBitmap(getBitmap(Normal));
|
|
||||||
|
|
||||||
// Now update the Form Control's bitmap array, and possibly the child's too
|
// Now update the Form Control's bitmap array, and possibly the child's too
|
||||||
mProfile->constructBitmapArray();
|
mProfile->constructBitmapArray();
|
||||||
|
|
||||||
|
|
@ -798,6 +783,14 @@ static S32 QSORT_CALLBACK idCompare(const void *a,const void *b)
|
||||||
return ( (ea->id < eb->id) ? -1 : ((ea->id > eb->id) ? 1 : 0) );
|
return ( (ea->id < eb->id) ? -1 : ((ea->id > eb->id) ? 1 : 0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GuiPopUpMenuCtrlEx::_setBitmaps(void* obj, const char* index, const char* data)
|
||||||
|
{
|
||||||
|
GuiPopUpMenuCtrlEx* object = static_cast<GuiPopUpMenuCtrlEx*>(obj);
|
||||||
|
|
||||||
|
object->setBitmap(data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Added
|
// Added
|
||||||
void GuiPopUpMenuCtrlEx::setBitmap(const char *name)
|
void GuiPopUpMenuCtrlEx::setBitmap(const char *name)
|
||||||
|
|
@ -819,8 +812,8 @@ void GuiPopUpMenuCtrlEx::setBitmap(const char *name)
|
||||||
dStrcpy(p, "_d", pLen);
|
dStrcpy(p, "_d", pLen);
|
||||||
_setBitmap((StringTableEntry)buffer, Depressed);
|
_setBitmap((StringTableEntry)buffer, Depressed);
|
||||||
|
|
||||||
if (!mBitmap[Depressed])
|
if (mBitmapAsset[Depressed].isNull())
|
||||||
mBitmap[Depressed] = mBitmap[Normal];
|
mBitmapAsset[Depressed] = mBitmapAsset[Normal];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1097,17 +1090,17 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a bitmap over the background?
|
// Draw a bitmap over the background?
|
||||||
if ( mBitmap[Depressed] )
|
if ( mBitmapAsset[Depressed].notNull() )
|
||||||
{
|
{
|
||||||
RectI rect(offset, mBitmapBounds);
|
RectI rect(offset, mBitmapBounds);
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch(mBitmap[Depressed], rect );
|
drawUtil->drawBitmapStretch(getBitmap(Depressed), rect );
|
||||||
}
|
}
|
||||||
else if (mBitmap[Normal])
|
else if (mBitmapAsset[Normal].notNull())
|
||||||
{
|
{
|
||||||
RectI rect(offset, mBitmapBounds);
|
RectI rect(offset, mBitmapBounds);
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
|
drawUtil->drawBitmapStretch(getBitmap(Normal), rect );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we render a bitmap border or lines?
|
// Do we render a bitmap border or lines?
|
||||||
|
|
@ -1141,11 +1134,11 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a bitmap over the background?
|
// Draw a bitmap over the background?
|
||||||
if (mBitmap[Normal])
|
if (mBitmapAsset[Normal].notNull())
|
||||||
{
|
{
|
||||||
RectI rect( offset, mBitmapBounds );
|
RectI rect( offset, mBitmapBounds );
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
|
drawUtil->drawBitmapStretch(getBitmap(Normal), rect );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we render a bitmap border or lines?
|
// Do we render a bitmap border or lines?
|
||||||
|
|
@ -1171,11 +1164,11 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a bitmap over the background?
|
// Draw a bitmap over the background?
|
||||||
if (mBitmap[Normal])
|
if (mBitmapAsset[Normal].notNull())
|
||||||
{
|
{
|
||||||
RectI rect(offset, mBitmapBounds);
|
RectI rect(offset, mBitmapBounds);
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapStretch(mBitmap[Normal], rect );
|
drawUtil->drawBitmapStretch(getBitmap(Normal), rect );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we render a bitmap border or lines?
|
// Do we render a bitmap border or lines?
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,8 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
|
||||||
NumBitmapModes = 2
|
NumBitmapModes = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrlEx, Bitmap, NumBitmapModes, onBitmapChanged);
|
DECLARE_IMAGEASSET_ARRAY(GuiPopUpMenuCtrlEx, Bitmap, GFXDefaultGUIProfile, NumBitmapModes)
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(GuiPopUpMenuCtrlEx, Bitmap);
|
|
||||||
void onBitmapChanged() {}
|
|
||||||
Point2I mBitmapBounds; // Added
|
Point2I mBitmapBounds; // Added
|
||||||
|
|
||||||
S32 mIdMax;
|
S32 mIdMax;
|
||||||
|
|
|
||||||
|
|
@ -432,9 +432,9 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
|
|
||||||
//left border
|
//left border
|
||||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(), Point2I(offset.x,offset.y), mBitmapBounds[SliderLineLeft]);
|
drawUtil->drawBitmapSR(mProfile->getBitmap(), Point2I(offset.x,offset.y), mBitmapBounds[SliderLineLeft]);
|
||||||
//right border
|
//right border
|
||||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(), Point2I(offset.x + getWidth() - mBitmapBounds[SliderLineRight].extent.x, offset.y), mBitmapBounds[SliderLineRight]);
|
drawUtil->drawBitmapSR(mProfile->getBitmap(), Point2I(offset.x + getWidth() - mBitmapBounds[SliderLineRight].extent.x, offset.y), mBitmapBounds[SliderLineRight]);
|
||||||
|
|
||||||
|
|
||||||
//draw our center piece to our slider control's border and stretch it
|
//draw our center piece to our slider control's border and stretch it
|
||||||
|
|
@ -448,11 +448,11 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
stretchRect = mBitmapBounds[SliderLineCenter];
|
stretchRect = mBitmapBounds[SliderLineCenter];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
|
|
||||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), destRect, stretchRect);
|
drawUtil->drawBitmapStretchSR(mProfile->getBitmap(), destRect, stretchRect);
|
||||||
|
|
||||||
//draw our control slider button
|
//draw our control slider button
|
||||||
thumb.point += pos;
|
thumb.point += pos;
|
||||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(),Point2I(thumb.point.x,offset.y ),mBitmapBounds[index]);
|
drawUtil->drawBitmapSR(mProfile->getBitmap(),Point2I(thumb.point.x,offset.y ),mBitmapBounds[index]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (getWidth() >= getHeight())
|
else if (getWidth() >= getHeight())
|
||||||
|
|
|
||||||
|
|
@ -3781,7 +3781,7 @@ void GuiTreeViewCtrl::onRenderCell(Point2I offset, Point2I cell, bool, bool )
|
||||||
if( ( bitmap >= 0 ) && ( bitmap < mProfile->mBitmapArrayRects.size() ) )
|
if( ( bitmap >= 0 ) && ( bitmap < mProfile->mBitmapArrayRects.size() ) )
|
||||||
{
|
{
|
||||||
if( drawBitmap )
|
if( drawBitmap )
|
||||||
drawer->drawBitmapSR( mProfile->getBitmapResource(), drawRect.point, mProfile->mBitmapArrayRects[bitmap] );
|
drawer->drawBitmapSR( mProfile->getBitmap(), drawRect.point, mProfile->mBitmapArrayRects[bitmap] );
|
||||||
newOffset = mProfile->mBitmapArrayRects[bitmap].extent.x;
|
newOffset = mProfile->mBitmapArrayRects[bitmap].extent.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,14 +173,14 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
||||||
// Draw all corners first.
|
// Draw all corners first.
|
||||||
|
|
||||||
//top left border
|
//top left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
|
||||||
//top right border
|
//top right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
|
||||||
|
|
||||||
//bottom left border
|
//bottom left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
|
||||||
//bottom right border
|
//bottom right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(
|
||||||
bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x,
|
bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x,
|
||||||
bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y),
|
bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y),
|
||||||
mBitmapBounds[BorderBottomRight]);
|
mBitmapBounds[BorderBottomRight]);
|
||||||
|
|
@ -198,7 +198,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
||||||
stretchRect = mBitmapBounds[BorderTop];
|
stretchRect = mBitmapBounds[BorderTop];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//bottom line stretch
|
//bottom line stretch
|
||||||
destRect.point.x = bounds.point.x + mBitmapBounds[BorderBottomLeft].extent.x;
|
destRect.point.x = bounds.point.x + mBitmapBounds[BorderBottomLeft].extent.x;
|
||||||
destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x - mBitmapBounds[BorderBottomLeft].extent.x;
|
destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x - mBitmapBounds[BorderBottomLeft].extent.x;
|
||||||
|
|
@ -208,7 +208,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
||||||
stretchRect = mBitmapBounds[BorderBottom];
|
stretchRect = mBitmapBounds[BorderBottom];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//left line stretch
|
//left line stretch
|
||||||
destRect.point.x = bounds.point.x;
|
destRect.point.x = bounds.point.x;
|
||||||
destRect.extent.x = mBitmapBounds[BorderLeft].extent.x;
|
destRect.extent.x = mBitmapBounds[BorderLeft].extent.x;
|
||||||
|
|
@ -218,7 +218,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
||||||
stretchRect = mBitmapBounds[BorderLeft];
|
stretchRect = mBitmapBounds[BorderLeft];
|
||||||
stretchRect.inset(0,1);
|
stretchRect.inset(0,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//right line stretch
|
//right line stretch
|
||||||
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x;
|
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x;
|
||||||
destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
|
destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
|
||||||
|
|
@ -228,7 +228,7 @@ void renderBorder( const RectI &bounds, GuiControlProfile *profile )
|
||||||
stretchRect = mBitmapBounds[BorderRight];
|
stretchRect = mBitmapBounds[BorderRight];
|
||||||
stretchRect.inset(0,1);
|
stretchRect.inset(0,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
|
|
||||||
// End drawing sides and top stretched borders
|
// End drawing sides and top stretched borders
|
||||||
break;
|
break;
|
||||||
|
|
@ -288,14 +288,14 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
||||||
// Draw all corners first.
|
// Draw all corners first.
|
||||||
|
|
||||||
//top left border
|
//top left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||||
//top right border
|
//top right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||||
|
|
||||||
//bottom left border
|
//bottom left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||||
//bottom right border
|
//bottom right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(
|
||||||
bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x,
|
bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x,
|
||||||
bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y),
|
bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y),
|
||||||
mBitmapBounds[borderBottomRight]);
|
mBitmapBounds[borderBottomRight]);
|
||||||
|
|
@ -313,7 +313,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
||||||
stretchRect = mBitmapBounds[borderTop];
|
stretchRect = mBitmapBounds[borderTop];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//bottom line stretch
|
//bottom line stretch
|
||||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x;
|
destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x;
|
||||||
destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x;
|
destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x;
|
||||||
|
|
@ -323,7 +323,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
||||||
stretchRect = mBitmapBounds[borderBottom];
|
stretchRect = mBitmapBounds[borderBottom];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//left line stretch
|
//left line stretch
|
||||||
destRect.point.x = bounds.point.x;
|
destRect.point.x = bounds.point.x;
|
||||||
destRect.extent.x = mBitmapBounds[borderLeft].extent.x;
|
destRect.extent.x = mBitmapBounds[borderLeft].extent.x;
|
||||||
|
|
@ -333,7 +333,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
||||||
stretchRect = mBitmapBounds[borderLeft];
|
stretchRect = mBitmapBounds[borderLeft];
|
||||||
stretchRect.inset(0,1);
|
stretchRect.inset(0,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//right line stretch
|
//right line stretch
|
||||||
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x;
|
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x;
|
||||||
destRect.extent.x = mBitmapBounds[borderRight].extent.x;
|
destRect.extent.x = mBitmapBounds[borderRight].extent.x;
|
||||||
|
|
@ -343,7 +343,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
||||||
stretchRect = mBitmapBounds[borderRight];
|
stretchRect = mBitmapBounds[borderRight];
|
||||||
stretchRect.inset(0,1);
|
stretchRect.inset(0,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//fill stretch
|
//fill stretch
|
||||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x;
|
destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x;
|
||||||
destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x;
|
destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x;
|
||||||
|
|
@ -353,7 +353,7 @@ void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier,
|
||||||
stretchRect = mBitmapBounds[fill];
|
stretchRect = mBitmapBounds[fill];
|
||||||
stretchRect.inset(1,1);
|
stretchRect.inset(1,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
|
|
||||||
// End drawing sides and top stretched borders
|
// End drawing sides and top stretched borders
|
||||||
}
|
}
|
||||||
|
|
@ -388,14 +388,14 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
||||||
// Draw all corners first.
|
// Draw all corners first.
|
||||||
|
|
||||||
//top left border
|
//top left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]);
|
||||||
//top right border
|
//top right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]);
|
||||||
|
|
||||||
//bottom left border
|
//bottom left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]);
|
||||||
//bottom right border
|
//bottom right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(
|
||||||
bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x,
|
bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x,
|
||||||
bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y),
|
bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y),
|
||||||
mBitmapBounds[borderBottomRight]);
|
mBitmapBounds[borderBottomRight]);
|
||||||
|
|
@ -413,7 +413,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
||||||
stretchRect = mBitmapBounds[borderTop];
|
stretchRect = mBitmapBounds[borderTop];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//bottom line stretch
|
//bottom line stretch
|
||||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x;
|
destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x;
|
||||||
destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x;
|
destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x;
|
||||||
|
|
@ -423,7 +423,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
||||||
stretchRect = mBitmapBounds[borderBottom];
|
stretchRect = mBitmapBounds[borderBottom];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//left line stretch
|
//left line stretch
|
||||||
destRect.point.x = bounds.point.x;
|
destRect.point.x = bounds.point.x;
|
||||||
destRect.extent.x = mBitmapBounds[borderLeft].extent.x;
|
destRect.extent.x = mBitmapBounds[borderLeft].extent.x;
|
||||||
|
|
@ -433,7 +433,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
||||||
stretchRect = mBitmapBounds[borderLeft];
|
stretchRect = mBitmapBounds[borderLeft];
|
||||||
stretchRect.inset(0,1);
|
stretchRect.inset(0,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//left line stretch
|
//left line stretch
|
||||||
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x;
|
destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x;
|
||||||
destRect.extent.x = mBitmapBounds[borderRight].extent.x;
|
destRect.extent.x = mBitmapBounds[borderRight].extent.x;
|
||||||
|
|
@ -443,7 +443,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
||||||
stretchRect = mBitmapBounds[borderRight];
|
stretchRect = mBitmapBounds[borderRight];
|
||||||
stretchRect.inset(0,1);
|
stretchRect.inset(0,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
//fill stretch
|
//fill stretch
|
||||||
destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x;
|
destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x;
|
||||||
destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x;
|
destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x;
|
||||||
|
|
@ -453,7 +453,7 @@ void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex,
|
||||||
stretchRect = mBitmapBounds[fill];
|
stretchRect = mBitmapBounds[fill];
|
||||||
stretchRect.inset(1,1);
|
stretchRect.inset(1,1);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
|
|
||||||
// End drawing sides and top stretched borders
|
// End drawing sides and top stretched borders
|
||||||
}
|
}
|
||||||
|
|
@ -484,9 +484,9 @@ void renderFixedBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier, Gu
|
||||||
// Draw all corners first.
|
// Draw all corners first.
|
||||||
|
|
||||||
//left border
|
//left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||||
//right border
|
//right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||||
|
|
||||||
// End drawing corners
|
// End drawing corners
|
||||||
|
|
||||||
|
|
@ -501,7 +501,7 @@ void renderFixedBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier, Gu
|
||||||
stretchRect = mBitmapBounds[fill];
|
stretchRect = mBitmapBounds[fill];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
|
|
||||||
// End drawing fill
|
// End drawing fill
|
||||||
}
|
}
|
||||||
|
|
@ -529,9 +529,9 @@ void renderFixedBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex, G
|
||||||
// Draw all corners first.
|
// Draw all corners first.
|
||||||
|
|
||||||
//left border
|
//left border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]);
|
||||||
//right border
|
//right border
|
||||||
drawer->drawBitmapSR(profile->getBitmapResource(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
drawer->drawBitmapSR(profile->getBitmap(),Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]);
|
||||||
|
|
||||||
// End drawing corners
|
// End drawing corners
|
||||||
|
|
||||||
|
|
@ -546,7 +546,7 @@ void renderFixedBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex, G
|
||||||
stretchRect = mBitmapBounds[fill];
|
stretchRect = mBitmapBounds[fill];
|
||||||
stretchRect.inset(1,0);
|
stretchRect.inset(1,0);
|
||||||
//draw it
|
//draw it
|
||||||
drawer->drawBitmapStretchSR(profile->getBitmapResource(),destRect,stretchRect);
|
drawer->drawBitmapStretchSR(profile->getBitmap(),destRect,stretchRect);
|
||||||
|
|
||||||
// End drawing fill
|
// End drawing fill
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,6 @@ GuiCursor::GuiCursor()
|
||||||
mHotSpot.set(0,0);
|
mHotSpot.set(0,0);
|
||||||
mRenderOffset.set(0.0f,0.0f);
|
mRenderOffset.set(0.0f,0.0f);
|
||||||
mExtent.set(1,1);
|
mExtent.set(1,1);
|
||||||
|
|
||||||
INIT_ASSET(Bitmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiCursor::~GuiCursor()
|
GuiCursor::~GuiCursor()
|
||||||
|
|
@ -93,7 +91,6 @@ void GuiCursor::initPersistFields()
|
||||||
addField("hotSpot", TypePoint2I, Offset(mHotSpot, GuiCursor), "The location of the cursor's hot spot (which pixel carries the click).");
|
addField("hotSpot", TypePoint2I, Offset(mHotSpot, GuiCursor), "The location of the cursor's hot spot (which pixel carries the click).");
|
||||||
addField("renderOffset",TypePoint2F, Offset(mRenderOffset, GuiCursor), "Offset of the bitmap, where 0 signifies left edge of the bitmap, 1, the right. Similarly for the Y-component.");
|
addField("renderOffset",TypePoint2F, Offset(mRenderOffset, GuiCursor), "Offset of the bitmap, where 0 signifies left edge of the bitmap, 1, the right. Similarly for the Y-component.");
|
||||||
|
|
||||||
addProtectedField("bitmapName", TypeImageFilename, Offset(mBitmapName, GuiCursor), _setBitmapData, &defaultProtectedGetFn, "File name of the bitmap for the cursor.");
|
|
||||||
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
|
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiCursor, "name of the bitmap for the cursor.");
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
}
|
}
|
||||||
|
|
@ -115,21 +112,21 @@ void GuiCursor::onRemove()
|
||||||
|
|
||||||
void GuiCursor::render(const Point2I &pos)
|
void GuiCursor::render(const Point2I &pos)
|
||||||
{
|
{
|
||||||
if (mBitmap)
|
if (mBitmapAsset.notNull())
|
||||||
{
|
{
|
||||||
mExtent.set(mBitmap->getWidth(), mBitmap->getHeight());
|
mExtent.set(getBitmap()->getWidth(), getBitmap()->getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the cursor centered according to dimensions of texture
|
// Render the cursor centered according to dimensions of texture
|
||||||
S32 texWidth = mBitmap.getWidth();
|
S32 texWidth = getBitmap()->getWidth();
|
||||||
S32 texHeight = mBitmap.getHeight();
|
S32 texHeight = getBitmap()->getHeight();
|
||||||
|
|
||||||
Point2I renderPos = pos;
|
Point2I renderPos = pos;
|
||||||
renderPos.x -= (S32)( texWidth * mRenderOffset.x );
|
renderPos.x -= (S32)( texWidth * mRenderOffset.x );
|
||||||
renderPos.y -= (S32)( texHeight * mRenderOffset.y );
|
renderPos.y -= (S32)( texHeight * mRenderOffset.y );
|
||||||
|
|
||||||
GFX->getDrawUtil()->clearBitmapModulation();
|
GFX->getDrawUtil()->clearBitmapModulation();
|
||||||
GFX->getDrawUtil()->drawBitmap(mBitmap, renderPos);
|
GFX->getDrawUtil()->drawBitmap(getBitmap(), renderPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -183,7 +180,7 @@ void GuiControlProfile::setBitmapHandle(GFXTexHandle handle)
|
||||||
{
|
{
|
||||||
mBitmap = handle;
|
mBitmap = handle;
|
||||||
|
|
||||||
_setBitmap(StringTable->insert("texhandle"));
|
mBitmapName = "texhandle";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, const char *data )
|
bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, const char *data )
|
||||||
|
|
@ -200,16 +197,17 @@ bool GuiControlProfile::protectedSetBitmap( void *object, const char *index, con
|
||||||
profile->mBitmapArrayRects.clear();
|
profile->mBitmapArrayRects.clear();
|
||||||
profile->mBitmap = nullptr;
|
profile->mBitmap = nullptr;
|
||||||
|
|
||||||
if (profile->getBitmap() != StringTable->EmptyString())
|
if (profile->mBitmapName != StringTable->EmptyString())
|
||||||
{
|
{
|
||||||
if (profile->mBitmapAsset.notNull() && profile->getBitmap() != StringTable->insert("texHandle"))
|
if (profile->mBitmapAsset.notNull() && profile->mBitmapName != StringTable->insert("texHandle"))
|
||||||
{
|
{
|
||||||
profile->mBitmap.set(profile->mBitmapAsset->getImagePath(), profile->mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
profile->mBitmap = profile->getBitmap();
|
||||||
|
profile->mBitmapName = profile->mBitmapAsset->getImageFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
//verify the bitmap
|
//verify the bitmap
|
||||||
if (!profile->mBitmap)
|
if (!profile->mBitmap)
|
||||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", profile->getName(), profile->getBitmap());
|
Con::errorf("(%s) - Failed to load profile bitmap (%s)", profile->getName(), profile->getBitmapAsset().getAssetId());
|
||||||
|
|
||||||
// If we've got a special border, make sure it's usable.
|
// If we've got a special border, make sure it's usable.
|
||||||
//if( profile->mBorder == -1 || profile->mBorder == -2 )
|
//if( profile->mBorder == -1 || profile->mBorder == -2 )
|
||||||
|
|
@ -275,7 +273,9 @@ GuiControlProfile::GuiControlProfile(void) :
|
||||||
mMouseOverSelected = false;
|
mMouseOverSelected = false;
|
||||||
|
|
||||||
// bitmap members
|
// bitmap members
|
||||||
INIT_ASSET(Bitmap);
|
mBitmap = NULL;
|
||||||
|
mBitmapName = StringTable->EmptyString();
|
||||||
|
|
||||||
mUseBitmapArray = false;
|
mUseBitmapArray = false;
|
||||||
|
|
||||||
mChildrenProfileName = NULL;
|
mChildrenProfileName = NULL;
|
||||||
|
|
@ -442,7 +442,7 @@ void GuiControlProfile::initPersistFields()
|
||||||
"Texture to use for rendering control.", AbstractClassRep::FIELD_HideInInspectors);
|
"Texture to use for rendering control.", AbstractClassRep::FIELD_HideInInspectors);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
addProtectedField("bitmapAsset", TypeImageAssetId, Offset(mBitmapAssetId, GuiControlProfile),
|
addProtectedField("bitmapAsset", TypeImageAssetPtr, Offset(mBitmapAsset, GuiControlProfile),
|
||||||
&GuiControlProfile::protectedSetBitmap, &defaultProtectedGetFn,
|
&GuiControlProfile::protectedSetBitmap, &defaultProtectedGetFn,
|
||||||
"Texture to use for rendering control.");
|
"Texture to use for rendering control.");
|
||||||
|
|
||||||
|
|
@ -550,15 +550,12 @@ S32 GuiControlProfile::constructBitmapArray()
|
||||||
|
|
||||||
if( mBitmap.isNull() )
|
if( mBitmap.isNull() )
|
||||||
{
|
{
|
||||||
if (!_setBitmap(getBitmap()))
|
if (mBitmapAsset.notNull() && mBitmapName != StringTable->insert("texhandle"))
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (getBitmap() != StringTable->EmptyString() && mBitmapName != StringTable->insert("texhandle"))
|
|
||||||
{
|
{
|
||||||
mBitmap.set(getBitmap(), mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
mBitmap = getBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBitmap() == StringTable->EmptyString() || mBitmap.isNull())
|
if (mBitmapAsset.isNull() || mBitmap.isNull())
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -568,8 +565,8 @@ S32 GuiControlProfile::constructBitmapArray()
|
||||||
ColorI sepColor;
|
ColorI sepColor;
|
||||||
if ( !bmp || !bmp->getColor( 0, 0, sepColor ) )
|
if ( !bmp || !bmp->getColor( 0, 0, sepColor ) )
|
||||||
{
|
{
|
||||||
Con::errorf("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmap(), getName());
|
Con::errorf("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmapAsset().getAssetId(), getName());
|
||||||
AssertFatal( false, avar("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmap(), getName()));
|
AssertFatal( false, avar("Failed to create bitmap array from %s for profile %s - couldn't ascertain seperator color!", getBitmapAsset().getAssetId(), getName()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -644,17 +641,13 @@ void GuiControlProfile::incLoadCount()
|
||||||
if( mFont == NULL )
|
if( mFont == NULL )
|
||||||
loadFont();
|
loadFont();
|
||||||
|
|
||||||
//
|
if (mBitmapAsset.notNull() && mBitmapName != StringTable->insert("texHandle"))
|
||||||
if (getBitmap() != StringTable->EmptyString())
|
|
||||||
{
|
{
|
||||||
if (mBitmapAsset.notNull() && getBitmap() != StringTable->insert("texHandle"))
|
mBitmap = getBitmap();
|
||||||
{
|
|
||||||
mBitmap.set(mBitmapAsset->getImagePath(), mBitmapProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
|
||||||
}
|
|
||||||
|
|
||||||
//verify the bitmap
|
//verify the bitmap
|
||||||
if (!mBitmap)
|
if (!mBitmap)
|
||||||
Con::errorf("(%s) - Failed to load profile bitmap (%s)", getName(), getBitmap());
|
Con::errorf("(%s) - Failed to load profile bitmap (%s)", getName(), getBitmapAsset().getAssetId());
|
||||||
|
|
||||||
constructBitmapArray();
|
constructBitmapArray();
|
||||||
}
|
}
|
||||||
|
|
@ -680,7 +673,7 @@ void GuiControlProfile::decLoadCount()
|
||||||
getId(), getClassName(), getName(), getInternalName() );
|
getId(), getClassName(), getName(), getInternalName() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
StringTableEntry bitmapName = getBitmap();
|
StringTableEntry bitmapName = getBitmapAsset().getAssetId();
|
||||||
if(bitmapName == StringTable->EmptyString() || bitmapName == StringTable->insert("texhandle"))
|
if(bitmapName == StringTable->EmptyString() || bitmapName == StringTable->insert("texhandle"))
|
||||||
mBitmap = NULL;
|
mBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -708,15 +701,15 @@ DefineEngineMethod( GuiControlProfile, getStringWidth, S32, (const char* string)
|
||||||
|
|
||||||
DefineEngineMethod(GuiControlProfile, getBitmap, const char*, (), , "get name")
|
DefineEngineMethod(GuiControlProfile, getBitmap, const char*, (), , "get name")
|
||||||
{
|
{
|
||||||
return object->getBitmap();
|
return object->getBitmapAsset()->getImageFile();
|
||||||
}
|
}
|
||||||
DefineEngineMethod(GuiControlProfile, getBitmapAsset, const char*, (), , "")
|
DefineEngineMethod(GuiControlProfile, getBitmapAsset, const char*, (), , "")
|
||||||
{
|
{
|
||||||
return object->mBitmapAssetId;
|
return object->getBitmapAsset().getAssetId();
|
||||||
}
|
}
|
||||||
DefineEngineMethod(GuiControlProfile, setBitmap, bool, (const char* map), , "")
|
DefineEngineMethod(GuiControlProfile, setBitmap, void, (const char* map), , "")
|
||||||
{
|
{
|
||||||
return object->_setBitmap(StringTable->insert(map));
|
object->_setBitmap(StringTable->insert(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -348,8 +348,7 @@ class GuiCursor : public SimObject
|
||||||
private:
|
private:
|
||||||
typedef SimObject Parent;
|
typedef SimObject Parent;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiCursor, Bitmap, onImageChanged, GFXGuiCursorProfile);
|
DECLARE_IMAGEASSET(GuiCursor, Bitmap, GFXGuiCursorProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiCursor, Bitmap);
|
|
||||||
|
|
||||||
Point2I mHotSpot;
|
Point2I mHotSpot;
|
||||||
Point2F mRenderOffset;
|
Point2F mRenderOffset;
|
||||||
|
|
@ -367,8 +366,6 @@ public:
|
||||||
bool onAdd(void) override;
|
bool onAdd(void) override;
|
||||||
void onRemove() override;
|
void onRemove() override;
|
||||||
void render(const Point2I &pos);
|
void render(const Point2I &pos);
|
||||||
|
|
||||||
void onImageChanged() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A GuiControlProfile is used by every GuiObject and is akin to a
|
/// A GuiControlProfile is used by every GuiObject and is akin to a
|
||||||
|
|
@ -460,113 +457,11 @@ public:
|
||||||
///< Bitmap for the bitmap of the control
|
///< Bitmap for the bitmap of the control
|
||||||
///
|
///
|
||||||
public:
|
public:
|
||||||
GFXTexHandle mBitmap = NULL;
|
|
||||||
|
DECLARE_IMAGEASSET(GuiControlProfile, Bitmap, GFXDefaultGUIProfile)
|
||||||
|
|
||||||
|
GFXTexHandle mBitmap;
|
||||||
StringTableEntry mBitmapName;
|
StringTableEntry mBitmapName;
|
||||||
StringTableEntry mBitmapAssetId;
|
|
||||||
AssetPtr<ImageAsset> mBitmapAsset;
|
|
||||||
GFXTextureProfile* mBitmapProfile = &GFXDefaultGUIProfile;
|
|
||||||
public:
|
|
||||||
const StringTableEntry getBitmapFile() const { return mBitmapName; }
|
|
||||||
void setBitmapFile(const FileName& _in) { mBitmapName = StringTable->insert(_in.c_str()); }
|
|
||||||
const AssetPtr<ImageAsset>& getBitmapAsset() const { return mBitmapAsset; }
|
|
||||||
void setBitmapAsset(const AssetPtr<ImageAsset>& _in) { mBitmapAsset = _in; }
|
|
||||||
|
|
||||||
bool _setBitmap(StringTableEntry _in)
|
|
||||||
{
|
|
||||||
if (mBitmapAssetId != _in || mBitmapName != _in)
|
|
||||||
{
|
|
||||||
if (mBitmapAsset.notNull())
|
|
||||||
{
|
|
||||||
mBitmapAsset->getChangedSignal().remove(this, &GuiControlProfile::onBitmapChanged);
|
|
||||||
}
|
|
||||||
if (_in == StringTable->EmptyString())
|
|
||||||
{
|
|
||||||
mBitmapName = StringTable->EmptyString();
|
|
||||||
mBitmapAssetId = StringTable->EmptyString();
|
|
||||||
mBitmapAsset = NULL;
|
|
||||||
mBitmap.free();
|
|
||||||
mBitmap = NULL;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (_in[0] == '$' || _in[0] == '#')
|
|
||||||
{
|
|
||||||
mBitmapName = _in;
|
|
||||||
mBitmapAssetId = StringTable->EmptyString();
|
|
||||||
mBitmapAsset = NULL;
|
|
||||||
mBitmap.free();
|
|
||||||
mBitmap = NULL;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AssetDatabase.isDeclaredAsset(_in))
|
|
||||||
{
|
|
||||||
mBitmapAssetId = _in;
|
|
||||||
|
|
||||||
U32 assetState = ImageAsset::getAssetById(mBitmapAssetId, &mBitmapAsset);
|
|
||||||
|
|
||||||
if (ImageAsset::Ok == assetState)
|
|
||||||
{
|
|
||||||
mBitmapName = StringTable->EmptyString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StringTableEntry assetId = ImageAsset::getAssetIdByFilename(_in);
|
|
||||||
if (assetId != StringTable->EmptyString())
|
|
||||||
{
|
|
||||||
mBitmapAssetId = assetId;
|
|
||||||
if (ImageAsset::getAssetById(mBitmapAssetId, &mBitmapAsset) == ImageAsset::Ok)
|
|
||||||
{
|
|
||||||
mBitmapName = StringTable->EmptyString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mBitmapName = _in;
|
|
||||||
mBitmapAssetId = StringTable->EmptyString();
|
|
||||||
mBitmapAsset = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getBitmap() != StringTable->EmptyString() && mBitmapName != StringTable->insert("texhandle"))
|
|
||||||
{
|
|
||||||
if (mBitmapAsset.notNull())
|
|
||||||
{
|
|
||||||
mBitmapAsset->getChangedSignal().notify(this, &GuiControlProfile::onBitmapChanged);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mBitmap.free();
|
|
||||||
mBitmap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getBitmap() != StringTable->EmptyString() && mBitmapAsset.notNull() && mBitmapAsset->getStatus() != ImageAsset::Ok)
|
|
||||||
{
|
|
||||||
Con::errorf("%s(%s)::_set%s() - image asset failure \"%s\" due to [%s]", macroText(className), getName(), macroText(name), _in, ImageAsset::getAssetErrstrn(mBitmapAsset->getStatus()).c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const StringTableEntry getBitmap() const
|
|
||||||
{
|
|
||||||
if (mBitmapAsset && (mBitmapAsset->getImageFileName() != StringTable->EmptyString()))
|
|
||||||
return Platform::makeRelativePathName(mBitmapAsset->getImagePath(), Platform::getMainDotCsDir());
|
|
||||||
else if (mBitmapAssetId != StringTable->EmptyString())
|
|
||||||
return mBitmapAssetId;
|
|
||||||
else if (mBitmapName != StringTable->EmptyString())
|
|
||||||
return StringTable->insert(Platform::makeRelativePathName(mBitmapName, Platform::getMainDotCsDir()));
|
|
||||||
else
|
|
||||||
return StringTable->EmptyString();
|
|
||||||
}
|
|
||||||
GFXTexHandle getBitmapResource()
|
|
||||||
{
|
|
||||||
return mBitmap;
|
|
||||||
}
|
|
||||||
DECLARE_ASSET_SETGET(GuiControlProfile, Bitmap);
|
|
||||||
|
|
||||||
void onBitmapChanged() {}
|
|
||||||
|
|
||||||
bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering
|
bool mUseBitmapArray; ///< Flag to use the bitmap array or to fallback to non-array rendering
|
||||||
Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes
|
Vector<RectI> mBitmapArrayRects; ///< Used for controls which use an array of bitmaps such as checkboxes
|
||||||
|
|
|
||||||
|
|
@ -410,7 +410,7 @@ void GuiMenuBar::onRender(Point2I offset, const RectI &updateRect)
|
||||||
bitmapstart.y = mMenuList[i].bounds.point.y + (mMenuList[i].bounds.extent.y - rect.extent.y) / 2;
|
bitmapstart.y = mMenuList[i].bounds.point.y + (mMenuList[i].bounds.extent.y - rect.extent.y) / 2;
|
||||||
|
|
||||||
drawUtil->clearBitmapModulation();
|
drawUtil->clearBitmapModulation();
|
||||||
drawUtil->drawBitmapSR(mProfile->getBitmapResource(), offset + bitmapstart, rect);
|
drawUtil->drawBitmapSR(mProfile->getBitmap(), offset + bitmapstart, rect);
|
||||||
|
|
||||||
// Should we also draw the text?
|
// Should we also draw the text?
|
||||||
if (!mMenuList[i].drawBitmapOnly)
|
if (!mMenuList[i].drawBitmapOnly)
|
||||||
|
|
@ -526,10 +526,22 @@ void GuiMenuBar::processTick()
|
||||||
|
|
||||||
void GuiMenuBar::insert(SimObject* pObject, S32 pos)
|
void GuiMenuBar::insert(SimObject* pObject, S32 pos)
|
||||||
{
|
{
|
||||||
PopupMenu* menu = dynamic_cast<PopupMenu*>(pObject);
|
PopupMenu* menu = nullptr;
|
||||||
|
if (pObject != nullptr)
|
||||||
|
{
|
||||||
|
menu = dynamic_cast<PopupMenu*>(pObject);
|
||||||
|
}
|
||||||
|
|
||||||
if (menu == nullptr)
|
if (menu == nullptr)
|
||||||
{
|
{
|
||||||
Con::errorf("GuiMenuBar::insert() - attempted to insert non-popupMenu object: %d", pObject->getId());
|
if (pObject != nullptr)
|
||||||
|
{
|
||||||
|
Con::errorf("GuiMenuBar::insert() - attempted to insert non-popupMenu object: %d", pObject->getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con::errorf("GuiMenuBar::insert() - attempted to insert a nullptr object.");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -552,10 +564,22 @@ void GuiMenuBar::insert(SimObject* pObject, S32 pos)
|
||||||
|
|
||||||
void GuiMenuBar::remove(SimObject* pObject)
|
void GuiMenuBar::remove(SimObject* pObject)
|
||||||
{
|
{
|
||||||
PopupMenu* menu = dynamic_cast<PopupMenu*>(pObject);
|
PopupMenu* menu = nullptr;
|
||||||
|
if (pObject != nullptr)
|
||||||
|
{
|
||||||
|
menu = dynamic_cast<PopupMenu*>(pObject);
|
||||||
|
}
|
||||||
|
|
||||||
if (menu == nullptr)
|
if (menu == nullptr)
|
||||||
{
|
{
|
||||||
Con::errorf("GuiMenuBar::remove() - attempted to remove non-popupMenu object: %d", pObject->getId());
|
if (pObject != nullptr)
|
||||||
|
{
|
||||||
|
Con::errorf("GuiMenuBar::insert() - attempted to insert non-popupMenu object: %d", pObject->getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con::errorf("GuiMenuBar::insert() - attempted to insert a nullptr object.");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool s
|
||||||
Point2I bitPos = Point2I(offset.x + mCellSize.y / 2, offset.y + mCellSize.y / 2);
|
Point2I bitPos = Point2I(offset.x + mCellSize.y / 2, offset.y + mCellSize.y / 2);
|
||||||
|
|
||||||
GFX->getDrawUtil()->clearBitmapModulation();
|
GFX->getDrawUtil()->clearBitmapModulation();
|
||||||
GFX->getDrawUtil()->drawBitmapSR(mProfile->getBitmapResource(), bitPos + off, rect);
|
GFX->getDrawUtil()->drawBitmapSR(mProfile->getBitmap(), bitPos + off, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ bool GuiInspectorDynamicField::onAdd()
|
||||||
mParent->getId() );
|
mParent->getId() );
|
||||||
|
|
||||||
// FIXME Hardcoded image
|
// FIXME Hardcoded image
|
||||||
mDeleteButton->setField( "Bitmap", "ToolsModule:iconDelete_image" );
|
mDeleteButton->_setBitmap("ToolsModule:iconDelete_image");
|
||||||
mDeleteButton->setField( "Text", "X" );
|
mDeleteButton->setField( "Text", "X" );
|
||||||
mDeleteButton->setField( "Command", szBuffer );
|
mDeleteButton->setField( "Command", szBuffer );
|
||||||
mDeleteButton->setSizing( horizResizeLeft, vertResizeCenter );
|
mDeleteButton->setSizing( horizResizeLeft, vertResizeCenter );
|
||||||
|
|
|
||||||
|
|
@ -663,7 +663,7 @@ void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntr
|
||||||
else if (typeName == StringTable->insert("material"))
|
else if (typeName == StringTable->insert("material"))
|
||||||
fieldType = TypeMaterialAssetId;
|
fieldType = TypeMaterialAssetId;
|
||||||
else if (typeName == StringTable->insert("image"))
|
else if (typeName == StringTable->insert("image"))
|
||||||
fieldType = TypeImageAssetId;
|
fieldType = TypeImageAssetPtr;
|
||||||
else if (typeName == StringTable->insert("shape"))
|
else if (typeName == StringTable->insert("shape"))
|
||||||
fieldType = TypeShapeAssetId;
|
fieldType = TypeShapeAssetId;
|
||||||
else if (typeName == StringTable->insert("sound"))
|
else if (typeName == StringTable->insert("sound"))
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ void GuiVariableInspector::addField(const char* name, const char* label, const c
|
||||||
else if (newField->mFieldTypeName == StringTable->insert("material"))
|
else if (newField->mFieldTypeName == StringTable->insert("material"))
|
||||||
fieldTypeMask = TypeMaterialAssetId;
|
fieldTypeMask = TypeMaterialAssetId;
|
||||||
else if (newField->mFieldTypeName == StringTable->insert("image"))
|
else if (newField->mFieldTypeName == StringTable->insert("image"))
|
||||||
fieldTypeMask = TypeImageAssetId;
|
fieldTypeMask = TypeImageAssetPtr;
|
||||||
else if (newField->mFieldTypeName == StringTable->insert("shape"))
|
else if (newField->mFieldTypeName == StringTable->insert("shape"))
|
||||||
fieldTypeMask = TypeShapeAssetId;
|
fieldTypeMask = TypeShapeAssetId;
|
||||||
else if (newField->mFieldTypeName == StringTable->insert("bool"))
|
else if (newField->mFieldTypeName == StringTable->insert("bool"))
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,6 @@ DefineEngineMethod( GuiChunkedBitmapCtrl, setBitmap, void, (const char* filename
|
||||||
|
|
||||||
GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
|
GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
|
||||||
{
|
{
|
||||||
INIT_ASSET(Bitmap);
|
|
||||||
|
|
||||||
mUseVariable = false;
|
mUseVariable = false;
|
||||||
mTile = false;
|
mTile = false;
|
||||||
}
|
}
|
||||||
|
|
@ -112,16 +110,6 @@ bool GuiChunkedBitmapCtrl::onWake()
|
||||||
if(!Parent::onWake())
|
if(!Parent::onWake())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( !mBitmap
|
|
||||||
&& ( ( mBitmapName && mBitmapName[ 0 ] )
|
|
||||||
|| ( mUseVariable && mConsoleVariable && mConsoleVariable[ 0 ] ) ) )
|
|
||||||
{
|
|
||||||
if ( mUseVariable )
|
|
||||||
mBitmap.set( Con::getVariable( mConsoleVariable ), &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
|
|
||||||
else
|
|
||||||
mBitmap.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,10 +155,10 @@ void GuiChunkedBitmapCtrl::renderRegion(const Point2I &offset, const Point2I &ex
|
||||||
void GuiChunkedBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
void GuiChunkedBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( mBitmap )
|
if( mBitmapAsset.notNull() )
|
||||||
{
|
{
|
||||||
RectI boundsRect( offset, getExtent());
|
RectI boundsRect( offset, getExtent());
|
||||||
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear );
|
GFX->getDrawUtil()->drawBitmapStretch(getBitmap(), boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChildControls(offset, updateRect);
|
renderChildControls(offset, updateRect);
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiChunkedBitmapCtrl, Bitmap);
|
|
||||||
|
|
||||||
bool mUseVariable;
|
bool mUseVariable;
|
||||||
bool mTile;
|
bool mTile;
|
||||||
|
|
@ -38,6 +37,4 @@ public:
|
||||||
void setBitmap(const char *name);
|
void setBitmap(const char *name);
|
||||||
|
|
||||||
void onRender(Point2I offset, const RectI &updateRect) override;
|
void onRender(Point2I offset, const RectI &updateRect) override;
|
||||||
|
|
||||||
void onImageChanged() {}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,6 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
|
||||||
mNumberOfBitmaps(0),
|
mNumberOfBitmaps(0),
|
||||||
mDim(0)
|
mDim(0)
|
||||||
{
|
{
|
||||||
INIT_ASSET(Bitmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -221,14 +220,14 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
//drawing stretch bitmap
|
//drawing stretch bitmap
|
||||||
RectI progressRect = ctrlRect;
|
RectI progressRect = ctrlRect;
|
||||||
progressRect.extent.x = width;
|
progressRect.extent.x = width;
|
||||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[0]);
|
drawUtil->drawBitmapStretchSR(mProfile->getBitmap(), progressRect, mProfile->mBitmapArrayRects[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(mNumberOfBitmaps >= 3)
|
else if(mNumberOfBitmaps >= 3)
|
||||||
{
|
{
|
||||||
//drawing left-end bitmap
|
//drawing left-end bitmap
|
||||||
RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
|
RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
|
||||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectLeft, mProfile->mBitmapArrayRects[0]);
|
drawUtil->drawBitmapStretchSR(mProfile->getBitmap(), progressRectLeft, mProfile->mBitmapArrayRects[0]);
|
||||||
|
|
||||||
//draw the progress with image
|
//draw the progress with image
|
||||||
S32 width = (S32)((F32)(getWidth()) * mProgress);
|
S32 width = (S32)((F32)(getWidth()) * mProgress);
|
||||||
|
|
@ -240,11 +239,11 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
progressRect.extent.x = (width - mDim - mDim);
|
progressRect.extent.x = (width - mDim - mDim);
|
||||||
if (progressRect.extent.x < 0)
|
if (progressRect.extent.x < 0)
|
||||||
progressRect.extent.x = 0;
|
progressRect.extent.x = 0;
|
||||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[1]);
|
drawUtil->drawBitmapStretchSR(mProfile->getBitmap(), progressRect, mProfile->mBitmapArrayRects[1]);
|
||||||
|
|
||||||
//drawing right-end bitmap
|
//drawing right-end bitmap
|
||||||
RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
|
RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
|
||||||
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectRight, mProfile->mBitmapArrayRects[2]);
|
drawUtil->drawBitmapStretchSR(mProfile->getBitmap(), progressRectRight, mProfile->mBitmapArrayRects[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -47,22 +47,13 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
|
||||||
|
|
||||||
F32 mProgress;
|
F32 mProgress;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiProgressBitmapCtrl, Bitmap);
|
|
||||||
|
|
||||||
bool mUseVariable;
|
bool mUseVariable;
|
||||||
bool mTile;
|
bool mTile;
|
||||||
S32 mNumberOfBitmaps;
|
S32 mNumberOfBitmaps;
|
||||||
S32 mDim;
|
S32 mDim;
|
||||||
|
|
||||||
static bool _setBitmap( void* object, const char* index, const char* data )
|
|
||||||
{
|
|
||||||
static_cast< GuiProgressBitmapCtrl* >( object )->setBitmap( data );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onImageChanged() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GuiProgressBitmapCtrl();
|
GuiProgressBitmapCtrl();
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,6 @@ ConsoleDocClass( GuiMissionAreaCtrl,
|
||||||
|
|
||||||
GuiMissionAreaCtrl::GuiMissionAreaCtrl()
|
GuiMissionAreaCtrl::GuiMissionAreaCtrl()
|
||||||
{
|
{
|
||||||
INIT_ASSET(HandleBitmap);
|
|
||||||
|
|
||||||
mHandleTextureSize = Point2I::Zero;
|
mHandleTextureSize = Point2I::Zero;
|
||||||
mHandleTextureHalfSize = Point2F::Zero;
|
mHandleTextureHalfSize = Point2F::Zero;
|
||||||
|
|
||||||
|
|
@ -114,9 +112,9 @@ bool GuiMissionAreaCtrl::onAdd()
|
||||||
desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
|
desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
|
||||||
mBlendStateBlock = GFX->createStateBlock( desc );
|
mBlendStateBlock = GFX->createStateBlock( desc );
|
||||||
|
|
||||||
if (!mHandleBitmap.isNull())
|
if (!mHandleBitmapAsset.isNull())
|
||||||
{
|
{
|
||||||
mHandleTextureSize = Point2I(mHandleBitmap->getWidth(), mHandleBitmap->getHeight() );
|
mHandleTextureSize = Point2I(getHandleBitmap()->getWidth(), getHandleBitmap()->getHeight());
|
||||||
mHandleTextureHalfSize = Point2F(mHandleTextureSize.x, mHandleTextureSize.y) * 0.5f;
|
mHandleTextureHalfSize = Point2F(mHandleTextureSize.x, mHandleTextureSize.y) * 0.5f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -418,7 +416,7 @@ void GuiMissionAreaCtrl::setArea(const RectI & area)
|
||||||
void GuiMissionAreaCtrl::drawHandle(const Point2F & pos)
|
void GuiMissionAreaCtrl::drawHandle(const Point2F & pos)
|
||||||
{
|
{
|
||||||
Point2F pnt(pos.x-mHandleTextureHalfSize.x, pos.y-mHandleTextureHalfSize.y);
|
Point2F pnt(pos.x-mHandleTextureHalfSize.x, pos.y-mHandleTextureHalfSize.y);
|
||||||
GFX->getDrawUtil()->drawBitmap(mHandleBitmap, pnt);
|
GFX->getDrawUtil()->drawBitmap(getHandleBitmap(), pnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiMissionAreaCtrl::drawHandles(RectI & box)
|
void GuiMissionAreaCtrl::drawHandles(RectI & box)
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,7 @@ protected:
|
||||||
GFXStateBlockRef mBlendStateBlock;
|
GFXStateBlockRef mBlendStateBlock;
|
||||||
GFXStateBlockRef mSolidStateBlock;
|
GFXStateBlockRef mSolidStateBlock;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(GuiMissionAreaCtrl, HandleBitmap, onHandleBitmapChanged, GFXDefaultGUIProfile);
|
DECLARE_IMAGEASSET(GuiMissionAreaCtrl, HandleBitmap, GFXDefaultGUIProfile)
|
||||||
DECLARE_ASSET_SETGET(GuiMissionAreaCtrl, HandleBitmap);
|
|
||||||
|
|
||||||
Point2I mHandleTextureSize;
|
Point2I mHandleTextureSize;
|
||||||
Point2F mHandleTextureHalfSize;
|
Point2F mHandleTextureHalfSize;
|
||||||
|
|
@ -110,8 +109,6 @@ protected:
|
||||||
bool testWithinHandle(const Point2I & testPoint, S32 handleX, S32 handleY);
|
bool testWithinHandle(const Point2I & testPoint, S32 handleX, S32 handleY);
|
||||||
S32 getHitHandles(const Point2I & mousePnt, const RectI & box);
|
S32 getHitHandles(const Point2I & mousePnt, const RectI & box);
|
||||||
|
|
||||||
void onHandleBitmapChanged() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiMissionAreaCtrl();
|
GuiMissionAreaCtrl();
|
||||||
virtual ~GuiMissionAreaCtrl();
|
virtual ~GuiMissionAreaCtrl();
|
||||||
|
|
|
||||||
|
|
@ -1817,9 +1817,9 @@ WorldEditor::WorldEditor()
|
||||||
mPopupBackgroundColor.set(100,100,100);
|
mPopupBackgroundColor.set(100,100,100);
|
||||||
mPopupTextColor.set(255,255,0);
|
mPopupTextColor.set(255,255,0);
|
||||||
|
|
||||||
mSelectHandleAssetId = StringTable->insert("ToolsModule:SelectHandle");
|
mSelectHandleAsset = StringTable->insert("ToolsModule:SelectHandle_image");
|
||||||
mDefaultHandleAssetId = StringTable->insert("ToolsModule:DefaultHandle");
|
mDefaultHandleAsset = StringTable->insert("ToolsModule:DefaultHandle_image");
|
||||||
mLockedHandleAssetId = StringTable->insert("ToolsModule:LockedHandle");
|
mLockedHandleAsset = StringTable->insert("ToolsModule:LockedHandle_image");
|
||||||
|
|
||||||
mObjectTextColor.set(255,255,255);
|
mObjectTextColor.set(255,255,255);
|
||||||
mObjectsUseBoxCenter = true;
|
mObjectsUseBoxCenter = true;
|
||||||
|
|
@ -1905,9 +1905,9 @@ bool WorldEditor::onAdd()
|
||||||
// create the default class entry
|
// create the default class entry
|
||||||
mDefaultClassEntry.mName = 0;
|
mDefaultClassEntry.mName = 0;
|
||||||
mDefaultClassEntry.mIgnoreCollision = false;
|
mDefaultClassEntry.mIgnoreCollision = false;
|
||||||
mDefaultClassEntry.mDefaultHandle = mDefaultHandle;
|
mDefaultClassEntry.mDefaultHandle = getDefaultHandle();
|
||||||
mDefaultClassEntry.mSelectHandle = mSelectHandle;
|
mDefaultClassEntry.mSelectHandle = getSelectHandle();
|
||||||
mDefaultClassEntry.mLockedHandle = mLockedHandle;
|
mDefaultClassEntry.mLockedHandle = getLockedHandle();
|
||||||
|
|
||||||
if(!(mDefaultClassEntry.mDefaultHandle && mDefaultClassEntry.mSelectHandle && mDefaultClassEntry.mLockedHandle))
|
if(!(mDefaultClassEntry.mDefaultHandle && mDefaultClassEntry.mSelectHandle && mDefaultClassEntry.mLockedHandle))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -328,12 +328,9 @@ class WorldEditor : public EditTSCtrl
|
||||||
ColorI mPopupBackgroundColor;
|
ColorI mPopupBackgroundColor;
|
||||||
ColorI mPopupTextColor;
|
ColorI mPopupTextColor;
|
||||||
|
|
||||||
DECLARE_IMAGEASSET(WorldEditor, SelectHandle, onSelectHandleChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(WorldEditor, SelectHandle, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(WorldEditor, SelectHandle);
|
DECLARE_IMAGEASSET(WorldEditor, DefaultHandle, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_IMAGEASSET(WorldEditor, DefaultHandle, onDefaultHandleChanged, GFXStaticTextureSRGBProfile);
|
DECLARE_IMAGEASSET(WorldEditor, LockedHandle, GFXStaticTextureSRGBProfile)
|
||||||
DECLARE_ASSET_SETGET(WorldEditor, DefaultHandle);
|
|
||||||
DECLARE_IMAGEASSET(WorldEditor, LockedHandle, onLockedHandleChanged, GFXStaticTextureSRGBProfile);
|
|
||||||
DECLARE_ASSET_SETGET(WorldEditor, LockedHandle);
|
|
||||||
|
|
||||||
ColorI mObjectTextColor;
|
ColorI mObjectTextColor;
|
||||||
bool mObjectsUseBoxCenter;
|
bool mObjectsUseBoxCenter;
|
||||||
|
|
@ -425,10 +422,6 @@ class WorldEditor : public EditTSCtrl
|
||||||
|
|
||||||
void setEditorTool(EditorTool*);
|
void setEditorTool(EditorTool*);
|
||||||
EditorTool* getActiveEditorTool() { return mActiveEditorTool; }
|
EditorTool* getActiveEditorTool() { return mActiveEditorTool; }
|
||||||
|
|
||||||
void onSelectHandleChanged() {}
|
|
||||||
void onDefaultHandleChanged() {}
|
|
||||||
void onLockedHandleChanged() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef WorldEditor::DropType WorldEditorDropType;
|
typedef WorldEditor::DropType WorldEditorDropType;
|
||||||
|
|
|
||||||
|
|
@ -139,19 +139,6 @@ Material::Material()
|
||||||
mAccuCoverage[i] = 0.9f;
|
mAccuCoverage[i] = 0.9f;
|
||||||
mAccuSpecular[i] = 16.0f;
|
mAccuSpecular[i] = 16.0f;
|
||||||
|
|
||||||
INIT_IMAGEASSET_ARRAY(DiffuseMap, GFXStaticTextureSRGBProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(OverlayMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(LightMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(ToneMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(DetailMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(NormalMap, GFXNormalMapProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(ORMConfigMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(RoughMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(AOMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(MetalMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(GlowMap, GFXStaticTextureProfile, i);
|
|
||||||
INIT_IMAGEASSET_ARRAY(DetailNormalMap, GFXNormalMapProfile, i);
|
|
||||||
|
|
||||||
mParallaxScale[i] = 0.0f;
|
mParallaxScale[i] = 0.0f;
|
||||||
|
|
||||||
mVertLit[i] = false;
|
mVertLit[i] = false;
|
||||||
|
|
@ -245,11 +232,6 @@ FRangeValidator glowMulRange(0.0f, 20.0f);
|
||||||
FRangeValidator parallaxScaleRange(0.0f, 4.0f);
|
FRangeValidator parallaxScaleRange(0.0f, 4.0f);
|
||||||
FRangeValidator scrollSpeedRange(0.0f, 10.0f);
|
FRangeValidator scrollSpeedRange(0.0f, 10.0f);
|
||||||
FRangeValidator waveFreqRange(0.0f, 10.0f);
|
FRangeValidator waveFreqRange(0.0f, 10.0f);
|
||||||
void Material::onImageAssetChanged()
|
|
||||||
{
|
|
||||||
flush();
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Material::initPersistFields()
|
void Material::initPersistFields()
|
||||||
{
|
{
|
||||||
|
|
@ -279,21 +261,20 @@ void Material::initPersistFields()
|
||||||
"Treat Roughness as Roughness");
|
"Treat Roughness as Roughness");
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(AOMap, MAX_STAGES, Material, "AOMap");
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(AOMap, MAX_STAGES, Material, "AOMap");
|
||||||
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(RoughMap, MAX_STAGES, Material, "RoughMap (also needs MetalMap)");
|
||||||
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(MetalMap, MAX_STAGES, Material, "MetalMap (also needs RoughMap)");
|
||||||
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(GlowMap, MAX_STAGES, Material, "GlowMap (needs Albedo)");
|
||||||
|
|
||||||
addFieldV("AOChan", TypeRangedS32, Offset(mAOChan, Material), &bmpChanRange, MAX_STAGES,
|
addFieldV("AOChan", TypeRangedS32, Offset(mAOChan, Material), &bmpChanRange, MAX_STAGES,
|
||||||
"The input channel AO maps use.");
|
"The input channel AO maps use.");
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(RoughMap, MAX_STAGES, Material, "RoughMap (also needs MetalMap)");
|
|
||||||
addFieldV("roughness", TypeRangedF32, Offset(mRoughness, Material), &CommonValidators::F32_8BitPercent,MAX_STAGES,
|
addFieldV("roughness", TypeRangedF32, Offset(mRoughness, Material), &CommonValidators::F32_8BitPercent,MAX_STAGES,
|
||||||
"The degree of roughness when not using a ORMConfigMap.");
|
"The degree of roughness when not using a ORMConfigMap.");
|
||||||
addFieldV("roughnessChan", TypeRangedS32, Offset(mRoughnessChan, Material), &bmpChanRange, MAX_STAGES,
|
addFieldV("roughnessChan", TypeRangedS32, Offset(mRoughnessChan, Material), &bmpChanRange, MAX_STAGES,
|
||||||
"The input channel roughness maps use.");
|
"The input channel roughness maps use.");
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(MetalMap, MAX_STAGES, Material, "MetalMap (also needs RoughMap)");
|
|
||||||
addFieldV("metalness", TypeRangedF32, Offset(mMetalness, Material), &CommonValidators::F32_8BitPercent, MAX_STAGES,
|
addFieldV("metalness", TypeRangedF32, Offset(mMetalness, Material), &CommonValidators::F32_8BitPercent, MAX_STAGES,
|
||||||
"The degree of Metalness when not using a ORMConfigMap.");
|
"The degree of Metalness when not using a ORMConfigMap.");
|
||||||
addFieldV("metalChan", TypeRangedS32, Offset(mMetalChan, Material), &bmpChanRange, MAX_STAGES,
|
addFieldV("metalChan", TypeRangedS32, Offset(mMetalChan, Material), &bmpChanRange, MAX_STAGES,
|
||||||
"The input channel metalness maps use.");
|
"The input channel metalness maps use.");
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(GlowMap, MAX_STAGES, Material, "GlowMap (needs Albedo)");
|
|
||||||
|
|
||||||
addFieldV("glowMul", TypeRangedF32, Offset(mGlowMul, Material),&glowMulRange, MAX_STAGES,
|
addFieldV("glowMul", TypeRangedF32, Offset(mGlowMul, Material),&glowMulRange, MAX_STAGES,
|
||||||
"glow mask multiplier");
|
"glow mask multiplier");
|
||||||
|
|
@ -306,6 +287,7 @@ void Material::initPersistFields()
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(DetailNormalMap, MAX_STAGES, Material, "DetailNormalMap");
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(DetailNormalMap, MAX_STAGES, Material, "DetailNormalMap");
|
||||||
addFieldV("detailNormalMapStrength", TypeRangedF32, Offset(mDetailNormalMapStrength, Material), &CommonValidators::PositiveFloat, MAX_STAGES,
|
addFieldV("detailNormalMapStrength", TypeRangedF32, Offset(mDetailNormalMapStrength, Material), &CommonValidators::PositiveFloat, MAX_STAGES,
|
||||||
|
|
||||||
"Used to scale the strength of the detail normal map when blended with the base normal map.");
|
"Used to scale the strength of the detail normal map when blended with the base normal map.");
|
||||||
|
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(OverlayMap, MAX_STAGES, Material, "Overlay");
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(OverlayMap, MAX_STAGES, Material, "Overlay");
|
||||||
|
|
@ -508,18 +490,6 @@ void Material::initPersistFields()
|
||||||
// They point at the new 'map' fields, but reads always return
|
// They point at the new 'map' fields, but reads always return
|
||||||
// an empty string and writes only apply if the value is not empty.
|
// an empty string and writes only apply if the value is not empty.
|
||||||
//
|
//
|
||||||
addProtectedField("baseTex", TypeImageFilename, Offset(mDiffuseMapName, Material),
|
|
||||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
|
||||||
"For backwards compatibility.\n@see diffuseMap\n", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
addProtectedField("detailTex", TypeImageFilename, Offset(mDetailMapName, Material),
|
|
||||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
|
||||||
"For backwards compatibility.\n@see detailMap\n", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
addProtectedField("overlayTex", TypeImageFilename, Offset(mOverlayMapName, Material),
|
|
||||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
|
||||||
"For backwards compatibility.\n@see overlayMap\n", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
addProtectedField("bumpTex", TypeImageFilename, Offset(mNormalMapName, Material),
|
|
||||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
|
||||||
"For backwards compatibility.\n@see normalMap\n", AbstractClassRep::FIELD_HideInInspectors);
|
|
||||||
addProtectedField("colorMultiply", TypeColorF, Offset(mDiffuse, Material),
|
addProtectedField("colorMultiply", TypeColorF, Offset(mDiffuse, Material),
|
||||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
||||||
"For backwards compatibility.\n@see diffuseColor\n", AbstractClassRep::FIELD_HideInInspectors);
|
"For backwards compatibility.\n@see diffuseColor\n", AbstractClassRep::FIELD_HideInInspectors);
|
||||||
|
|
@ -625,7 +595,7 @@ bool Material::isLightmapped() const
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (U32 i = 0; i < MAX_STAGES; i++)
|
for (U32 i = 0; i < MAX_STAGES; i++)
|
||||||
ret |= mLightMapName[i] != StringTable->EmptyString() || mToneMapName[i] != StringTable->EmptyString() || mVertLit[i];
|
ret |= mLightMapAsset[i].notNull() || mToneMapAsset[i].notNull() || mVertLit[i];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -658,26 +628,11 @@ void Material::_mapMaterial()
|
||||||
// If mapTo not defined in script, try to use the base texture name instead
|
// If mapTo not defined in script, try to use the base texture name instead
|
||||||
if (mMapTo.isEmpty())
|
if (mMapTo.isEmpty())
|
||||||
{
|
{
|
||||||
if (mDiffuseMapName[0] == StringTable->EmptyString() && mDiffuseMapAsset->isNull())
|
if (mDiffuseMapAsset->isNull())
|
||||||
return;
|
return;
|
||||||
|
else if (mDiffuseMapAsset->notNull())
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// extract filename from base texture
|
mMapTo = mDiffuseMapAsset[0]->getImageFile();
|
||||||
if (mDiffuseMapName[0] != StringTable->EmptyString())
|
|
||||||
{
|
|
||||||
U32 slashPos = String(mDiffuseMapName[0]).find('/', 0, String::Right);
|
|
||||||
if (slashPos == String::NPos)
|
|
||||||
// no '/' character, must be no path, just the filename
|
|
||||||
mMapTo = mDiffuseMapName[0];
|
|
||||||
else
|
|
||||||
// use everything after the last slash
|
|
||||||
mMapTo = String(mDiffuseMapName[0]).substr(slashPos + 1, (U32)strlen(mDiffuseMapName[0]) - slashPos - 1);
|
|
||||||
}
|
|
||||||
else if (!mDiffuseMapAsset->isNull())
|
|
||||||
{
|
|
||||||
mMapTo = mDiffuseMapAsset[0]->getImageFileName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -852,16 +807,15 @@ bool Material::_setAccuEnabled(void* object, const char* index, const char* data
|
||||||
//material.getDiffuseMap(%layer); //returns the raw file referenced
|
//material.getDiffuseMap(%layer); //returns the raw file referenced
|
||||||
//material.getDiffuseMapAsset(%layer); //returns the asset id
|
//material.getDiffuseMapAsset(%layer); //returns the asset id
|
||||||
//material.setDiffuseMap(%texture, %layer); //tries to set the asset and failing that attempts a flat file reference
|
//material.setDiffuseMap(%texture, %layer); //tries to set the asset and failing that attempts a flat file reference
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, DiffuseMap)
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, DiffuseMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, OverlayMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, NormalMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, LightMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, DetailNormalMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, ToneMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, OverlayMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, DetailMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, LightMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, NormalMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, ToneMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, ORMConfigMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, DetailMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, RoughMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, ORMConfigMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, AOMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, RoughMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, MetalMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, AOMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, GlowMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, MetalMap, Material::Constants::MAX_STAGES)
|
||||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, DetailNormalMap);
|
DEF_IMAGEASSET_ARRAY_BINDS(Material, GlowMap, Material::Constants::MAX_STAGES)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,56 +208,29 @@ public:
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Data
|
// Data
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
void onImageAssetChanged();
|
DECLARE_IMAGEASSET_ARRAY(Material, DiffuseMap, GFXStaticTextureSRGBProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, NormalMap, GFXNormalMapProfile, MAX_STAGES)
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, DiffuseMap, MAX_STAGES, onImageAssetChanged);
|
DECLARE_IMAGEASSET_ARRAY(Material, DetailNormalMap, GFXNormalMapProfile, MAX_STAGES)
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DiffuseMap);
|
DECLARE_IMAGEASSET_ARRAY(Material, OverlayMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, LightMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, ToneMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, DetailMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, ORMConfigMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, AOMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, RoughMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, MetalMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
DECLARE_IMAGEASSET_ARRAY(Material, GlowMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||||
|
|
||||||
bool mDiffuseMapSRGB[MAX_STAGES]; // SRGB diffuse
|
bool mDiffuseMapSRGB[MAX_STAGES]; // SRGB diffuse
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, OverlayMap, MAX_STAGES, onImageAssetChanged);
|
bool mIsSRGb[MAX_STAGES]; // SRGB ORM
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, OverlayMap);
|
F32 mAOChan[MAX_STAGES];
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, LightMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, LightMap);
|
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, ToneMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ToneMap);
|
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, DetailMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DetailMap);
|
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, NormalMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, NormalMap);
|
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, ORMConfigMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, ORMConfigMap);
|
|
||||||
|
|
||||||
bool mIsSRGb[MAX_STAGES];
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, AOMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, AOMap);
|
|
||||||
S32 mAOChan[MAX_STAGES];
|
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, RoughMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, RoughMap);
|
|
||||||
bool mInvertRoughness[MAX_STAGES];
|
bool mInvertRoughness[MAX_STAGES];
|
||||||
S32 mRoughnessChan[MAX_STAGES];
|
F32 mRoughnessChan[MAX_STAGES];
|
||||||
|
F32 mMetalChan[MAX_STAGES];
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, MetalMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, MetalMap);
|
|
||||||
|
|
||||||
S32 mMetalChan[MAX_STAGES];
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, GlowMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, GlowMap);
|
|
||||||
|
|
||||||
F32 mGlowMul[MAX_STAGES];
|
F32 mGlowMul[MAX_STAGES];
|
||||||
/// A second normal map which repeats at the detail map
|
|
||||||
/// scale and blended with the base normal map.
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(Material, DetailNormalMap, MAX_STAGES, onImageAssetChanged);
|
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(Material, DetailNormalMap);
|
|
||||||
|
|
||||||
/// The strength scalar for the detail normal map.
|
/// The strength scalar for the detail normal map.
|
||||||
F32 mDetailNormalMapStrength[MAX_STAGES];
|
F32 mDetailNormalMapStrength[MAX_STAGES];
|
||||||
|
|
||||||
bool mAccuEnabled[MAX_STAGES];
|
bool mAccuEnabled[MAX_STAGES];
|
||||||
F32 mAccuScale[MAX_STAGES];
|
F32 mAccuScale[MAX_STAGES];
|
||||||
F32 mAccuDirection[MAX_STAGES];
|
F32 mAccuDirection[MAX_STAGES];
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,6 @@ MaterialManager::MaterialManager()
|
||||||
mLastTime = 0;
|
mLastTime = 0;
|
||||||
mDampness = 0.0f;
|
mDampness = 0.0f;
|
||||||
mWarningInst = NULL;
|
mWarningInst = NULL;
|
||||||
mMatDefToFlush = NULL;
|
|
||||||
mMatDefToReload = NULL;
|
|
||||||
|
|
||||||
GFXDevice::getDeviceEventSignal().notify( this, &MaterialManager::_handleGFXEvent );
|
GFXDevice::getDeviceEventSignal().notify( this, &MaterialManager::_handleGFXEvent );
|
||||||
|
|
||||||
|
|
@ -75,8 +73,6 @@ MaterialManager::MaterialManager()
|
||||||
mUsingDeferred = false;
|
mUsingDeferred = false;
|
||||||
|
|
||||||
mFlushAndReInit = false;
|
mFlushAndReInit = false;
|
||||||
mMatDefShouldFlush = false;
|
|
||||||
mMatDefShouldReload = false;
|
|
||||||
|
|
||||||
mDefaultAnisotropy = 1;
|
mDefaultAnisotropy = 1;
|
||||||
Con::addVariable( "$pref::Video::defaultAnisotropy", TypeS32, &mDefaultAnisotropy,
|
Con::addVariable( "$pref::Video::defaultAnisotropy", TypeS32, &mDefaultAnisotropy,
|
||||||
|
|
@ -328,12 +324,6 @@ String MaterialManager::getMapEntry(const String & textureName) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialManager::flushAndReInitInstances()
|
void MaterialManager::flushAndReInitInstances()
|
||||||
{
|
|
||||||
// delay flushes and reinits until the start of the next frame.
|
|
||||||
mFlushAndReInit = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaterialManager::_flushAndReInitInstances()
|
|
||||||
{
|
{
|
||||||
// Clear the flag if its set.
|
// Clear the flag if its set.
|
||||||
mFlushAndReInit = false;
|
mFlushAndReInit = false;
|
||||||
|
|
@ -368,16 +358,8 @@ void MaterialManager::_flushAndReInitInstances()
|
||||||
(*iter)->reInit();
|
(*iter)->reInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used in the materialEditor. This flushes the material preview object so it can be reloaded easily.
|
void MaterialManager::flushInstance( BaseMaterialDefinition *target )
|
||||||
void MaterialManager::flushInstance(BaseMaterialDefinition* target)
|
|
||||||
{
|
{
|
||||||
mMatDefToFlush = target;
|
|
||||||
mMatDefShouldFlush = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaterialManager::_flushInstance( BaseMaterialDefinition *target )
|
|
||||||
{
|
|
||||||
mMatDefShouldFlush = false;
|
|
||||||
Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin();
|
Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin();
|
||||||
while ( iter != mMatInstanceList.end() )
|
while ( iter != mMatInstanceList.end() )
|
||||||
{
|
{
|
||||||
|
|
@ -388,26 +370,16 @@ void MaterialManager::_flushInstance( BaseMaterialDefinition *target )
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
mMatDefToFlush = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialManager::reInitInstance(BaseMaterialDefinition* target)
|
void MaterialManager::reInitInstance( BaseMaterialDefinition *target )
|
||||||
{
|
{
|
||||||
mMatDefToReload = target;
|
|
||||||
mMatDefShouldReload = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaterialManager::_reInitInstance( BaseMaterialDefinition *target )
|
|
||||||
{
|
|
||||||
mMatDefShouldReload = false;
|
|
||||||
Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin();
|
Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin();
|
||||||
for ( ; iter != mMatInstanceList.end(); iter++ )
|
for ( ; iter != mMatInstanceList.end(); iter++ )
|
||||||
{
|
{
|
||||||
if ( (*iter)->getMaterial() == target )
|
if ( (*iter)->getMaterial() == target )
|
||||||
(*iter)->reInit();
|
(*iter)->reInit();
|
||||||
}
|
}
|
||||||
mMatDefToReload = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialManager::updateTime()
|
void MaterialManager::updateTime()
|
||||||
|
|
@ -526,15 +498,7 @@ bool MaterialManager::_handleGFXEvent( GFXDevice::GFXDeviceEventType event_ )
|
||||||
|
|
||||||
case GFXDevice::deStartOfFrame:
|
case GFXDevice::deStartOfFrame:
|
||||||
if ( mFlushAndReInit )
|
if ( mFlushAndReInit )
|
||||||
_flushAndReInitInstances();
|
flushAndReInitInstances();
|
||||||
if (mMatDefShouldFlush)
|
|
||||||
{
|
|
||||||
_flushInstance(mMatDefToFlush);
|
|
||||||
}
|
|
||||||
if (mMatDefShouldReload)
|
|
||||||
{
|
|
||||||
_reInitInstance(mMatDefToReload);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -116,12 +116,16 @@ public:
|
||||||
/// Returns the signal used to notify systems that the
|
/// Returns the signal used to notify systems that the
|
||||||
/// procedural shaders have been flushed.
|
/// procedural shaders have been flushed.
|
||||||
FlushSignal& getFlushSignal() { return mFlushSignal; }
|
FlushSignal& getFlushSignal() { return mFlushSignal; }
|
||||||
|
|
||||||
|
/// Flushes all the procedural shaders and re-initializes all
|
||||||
|
/// the active materials instances immediately.
|
||||||
void flushAndReInitInstances();
|
void flushAndReInitInstances();
|
||||||
|
|
||||||
// Flush the instance
|
// Flush the instance
|
||||||
void flushInstance( BaseMaterialDefinition *target );
|
void flushInstance(BaseMaterialDefinition* target);
|
||||||
|
|
||||||
/// Re-initializes the material instances for a specific target material.
|
/// Re-initializes the material instances for a specific target material.
|
||||||
void reInitInstance( BaseMaterialDefinition *target );
|
void reInitInstance(BaseMaterialDefinition* target);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
@ -129,14 +133,7 @@ protected:
|
||||||
friend class MatInstance;
|
friend class MatInstance;
|
||||||
void _track(MatInstance*);
|
void _track(MatInstance*);
|
||||||
void _untrack(MatInstance*);
|
void _untrack(MatInstance*);
|
||||||
/// Flushes all the procedural shaders and re-initializes all
|
|
||||||
/// the active materials instances immediately.
|
|
||||||
void _flushAndReInitInstances();
|
|
||||||
// Flush the instance
|
|
||||||
void _flushInstance(BaseMaterialDefinition* target);
|
|
||||||
|
|
||||||
/// Re-initializes the material instances for a specific target material.
|
|
||||||
void _reInitInstance(BaseMaterialDefinition* target);
|
|
||||||
/// @see LightManager::smActivateSignal
|
/// @see LightManager::smActivateSignal
|
||||||
void _onLMActivate( const char *lm, bool activate );
|
void _onLMActivate( const char *lm, bool activate );
|
||||||
|
|
||||||
|
|
@ -158,8 +155,6 @@ protected:
|
||||||
/// If set we flush and reinitialize all materials at the
|
/// If set we flush and reinitialize all materials at the
|
||||||
/// start of the next rendered frame.
|
/// start of the next rendered frame.
|
||||||
bool mFlushAndReInit;
|
bool mFlushAndReInit;
|
||||||
bool mMatDefShouldReload;
|
|
||||||
bool mMatDefShouldFlush;
|
|
||||||
|
|
||||||
// material map
|
// material map
|
||||||
typedef Map<String, String> MaterialMap;
|
typedef Map<String, String> MaterialMap;
|
||||||
|
|
@ -174,8 +169,6 @@ protected:
|
||||||
F32 mDampness;
|
F32 mDampness;
|
||||||
|
|
||||||
BaseMatInstance* mWarningInst;
|
BaseMatInstance* mWarningInst;
|
||||||
BaseMaterialDefinition* mMatDefToFlush;
|
|
||||||
BaseMaterialDefinition* mMatDefToReload;
|
|
||||||
|
|
||||||
/// The default max anisotropy used in texture filtering.
|
/// The default max anisotropy used in texture filtering.
|
||||||
S32 mDefaultAnisotropy;
|
S32 mDefaultAnisotropy;
|
||||||
|
|
|
||||||
|
|
@ -392,69 +392,54 @@ void ProcessedMaterial::_setStageData()
|
||||||
for (i = 0; i < Material::MAX_STAGES; i++)
|
for (i = 0; i < Material::MAX_STAGES; i++)
|
||||||
{
|
{
|
||||||
// DiffuseMap
|
// DiffuseMap
|
||||||
if (mMaterial->mDiffuseMapAsset[i] && !mMaterial->mDiffuseMapAsset[i].isNull())
|
if (mMaterial->getDiffuseMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_DiffuseMap, mMaterial->getDiffuseMapResource(i));
|
mStages[i].setTex(MFT_DiffuseMap, mMaterial->getDiffuseMap(i));
|
||||||
if (!mStages[i].getTex(MFT_DiffuseMap))
|
if (!mStages[i].getTex(MFT_DiffuseMap))
|
||||||
{
|
{
|
||||||
// If we start with a #, we're probably actually attempting to hit a named target and it may not get a hit on the first pass.
|
// If we start with a #, we're probably actually attempting to hit a named target and it may not get a hit on the first pass.
|
||||||
if (!String(mMaterial->mDiffuseMapAsset[i]->getImageFileName()).startsWith("#") && !String(mMaterial->mDiffuseMapAsset[i]->getImageFileName()).startsWith("$"))
|
if (!mMaterial->getDiffuseMapAsset(i)->isNamedTarget())
|
||||||
mMaterial->logError("Failed to load diffuse map %s for stage %i", mMaterial->mDiffuseMapAsset[i]->getImageFileName(), i);
|
mMaterial->logError("Failed to load diffuse map %s for stage %i", mMaterial->getDiffuseMapAsset(i)->getImageFile(), i);
|
||||||
|
|
||||||
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
|
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mMaterial->mDiffuseMapName[i] != StringTable->EmptyString())
|
|
||||||
{
|
|
||||||
mStages[i].setTex(MFT_DiffuseMap, _createTexture(mMaterial->mDiffuseMapName[i], &GFXStaticTextureSRGBProfile));
|
|
||||||
if (!mStages[i].getTex(MFT_DiffuseMap))
|
|
||||||
{
|
|
||||||
//If we start with a #, we're probably actually attempting to hit a named target and it may not get a hit on the first pass.
|
|
||||||
if (!String(mMaterial->mDiffuseMapName[i]).startsWith("#") && !String(mMaterial->mDiffuseMapName[i]).startsWith("$"))
|
|
||||||
mMaterial->logError("Failed to load diffuse map %s for stage %i", mMaterial->mDiffuseMapName[i], i);
|
|
||||||
|
|
||||||
// Load a debug texture to make it clear to the user
|
|
||||||
// that the texture for this stage was missing.
|
|
||||||
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// OverlayMap
|
// OverlayMap
|
||||||
if (mMaterial->getOverlayMap(i) != StringTable->EmptyString())
|
if (mMaterial->getOverlayMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_OverlayMap, mMaterial->getOverlayMapResource(i));
|
mStages[i].setTex(MFT_OverlayMap, mMaterial->getOverlayMap(i));
|
||||||
if (!mStages[i].getTex(MFT_OverlayMap))
|
if (!mStages[i].getTex(MFT_OverlayMap))
|
||||||
mMaterial->logError("Failed to load overlay map %s for stage %i", mMaterial->getOverlayMap(i), i);
|
mMaterial->logError("Failed to load overlay map %s for stage %i", mMaterial->_getOverlayMap(i), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LightMap
|
// LightMap
|
||||||
if (mMaterial->getLightMap(i) != StringTable->EmptyString())
|
if (mMaterial->getLightMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_LightMap, mMaterial->getLightMapResource(i));
|
mStages[i].setTex(MFT_LightMap, mMaterial->getLightMap(i));
|
||||||
if (!mStages[i].getTex(MFT_LightMap))
|
if (!mStages[i].getTex(MFT_LightMap))
|
||||||
mMaterial->logError("Failed to load light map %s for stage %i", mMaterial->getLightMap(i), i);
|
mMaterial->logError("Failed to load light map %s for stage %i", mMaterial->_getLightMap(i), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToneMap
|
// ToneMap
|
||||||
if (mMaterial->getToneMap(i) != StringTable->EmptyString())
|
if (mMaterial->getToneMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_ToneMap, mMaterial->getToneMapResource(i));
|
mStages[i].setTex(MFT_ToneMap, mMaterial->getToneMap(i));
|
||||||
if (!mStages[i].getTex(MFT_ToneMap))
|
if (!mStages[i].getTex(MFT_ToneMap))
|
||||||
mMaterial->logError("Failed to load tone map %s for stage %i", mMaterial->getToneMap(i), i);
|
mMaterial->logError("Failed to load tone map %s for stage %i", mMaterial->_getToneMap(i), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DetailMap
|
// DetailMap
|
||||||
if (mMaterial->getDetailMap(i) != StringTable->EmptyString())
|
if (mMaterial->getDetailMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_DetailMap, mMaterial->getDetailMapResource(i));
|
mStages[i].setTex(MFT_DetailMap, mMaterial->getDetailMap(i));
|
||||||
if (!mStages[i].getTex(MFT_DetailMap))
|
if (!mStages[i].getTex(MFT_DetailMap))
|
||||||
mMaterial->logError("Failed to load detail map %s for stage %i", mMaterial->getDetailMap(i), i);
|
mMaterial->logError("Failed to load detail map %s for stage %i", mMaterial->_getDetailMap(i), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NormalMap
|
// NormalMap
|
||||||
if (mMaterial->mNormalMapAsset[i] && !mMaterial->mNormalMapAsset[i].isNull())
|
if (mMaterial->getNormalMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_NormalMap, mMaterial->getNormalMapResource(i));
|
mStages[i].setTex(MFT_NormalMap, mMaterial->getNormalMap(i));
|
||||||
//mStages[i].setTex(MFT_DiffuseMap, _createTexture(mMaterial->getDiffuseMap(i), &GFXStaticTextureSRGBProfile));
|
|
||||||
if (!mStages[i].getTex(MFT_NormalMap))
|
if (!mStages[i].getTex(MFT_NormalMap))
|
||||||
{
|
{
|
||||||
// Load a debug texture to make it clear to the user
|
// Load a debug texture to make it clear to the user
|
||||||
|
|
@ -462,24 +447,13 @@ void ProcessedMaterial::_setStageData()
|
||||||
mStages[i].setTex(MFT_NormalMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXNormalMapProfile));
|
mStages[i].setTex(MFT_NormalMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXNormalMapProfile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mMaterial->mNormalMapName[i] != StringTable->EmptyString())
|
|
||||||
{
|
|
||||||
mStages[i].setTex(MFT_NormalMap, _createTexture(mMaterial->mNormalMapName[i], &GFXNormalMapProfile));
|
|
||||||
if (!mStages[i].getTex(MFT_NormalMap))
|
|
||||||
{
|
|
||||||
//If we start with a #, we're probably actually attempting to hit a named target and it may not get a hit on the first pass. So we'll
|
|
||||||
//pass on the error rather than spamming the console
|
|
||||||
if (!String(mMaterial->mNormalMapName[i]).startsWith("#"))
|
|
||||||
mMaterial->logError("Failed to load normal map %s for stage %i", mMaterial->mNormalMapName[i], i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detail Normal Map
|
// Detail Normal Map
|
||||||
if (mMaterial->getDetailNormalMap(i) != StringTable->EmptyString())
|
if (mMaterial->getDetailNormalMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_DetailNormalMap, mMaterial->getDetailNormalMapResource(i));
|
mStages[i].setTex(MFT_DetailNormalMap, mMaterial->getDetailNormalMap(i));
|
||||||
if (!mStages[i].getTex(MFT_DetailNormalMap))
|
if (!mStages[i].getTex(MFT_DetailNormalMap))
|
||||||
mMaterial->logError("Failed to load normal map %s for stage %i", mMaterial->getDetailNormalMap(i), i);
|
mMaterial->logError("Failed to load normal map %s for stage %i", mMaterial->_getDetailNormalMap(i), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//depending on creation method this may or may not have been shoved into srgb space eroneously
|
//depending on creation method this may or may not have been shoved into srgb space eroneously
|
||||||
|
|
@ -488,33 +462,33 @@ void ProcessedMaterial::_setStageData()
|
||||||
profile = &GFXStaticTextureSRGBProfile;
|
profile = &GFXStaticTextureSRGBProfile;
|
||||||
|
|
||||||
// ORMConfig
|
// ORMConfig
|
||||||
if (mMaterial->getORMConfigMap(i) != StringTable->EmptyString())
|
if (mMaterial->getORMConfigMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_OrmMap, _createTexture(mMaterial->getORMConfigMap(i), profile));
|
mStages[i].setTex(MFT_OrmMap, mMaterial->getORMConfigMap(profile, i));
|
||||||
if (!mStages[i].getTex(MFT_OrmMap))
|
if (!mStages[i].getTex(MFT_OrmMap))
|
||||||
mMaterial->logError("Failed to load PBR Config map %s for stage %i", mMaterial->getORMConfigMap(i), i);
|
mMaterial->logError("Failed to load PBR Config map %s for stage %i", mMaterial->_getORMConfigMap(i), i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((mMaterial->getAOMap(i) != StringTable->EmptyString()) || (mMaterial->getRoughMap(i) != StringTable->EmptyString()) || (mMaterial->getMetalMap(i) != StringTable->EmptyString()))
|
if ((mMaterial->getAOMapAsset(i).notNull()) || (mMaterial->getRoughMapAsset(i).notNull()) || (mMaterial->getMetalMapAsset(i).notNull()))
|
||||||
{
|
{
|
||||||
U32 inputKey[4];
|
U32 inputKey[4];
|
||||||
inputKey[0] = mMaterial->mAOChan[i];
|
inputKey[0] = mMaterial->mAOChan[i];
|
||||||
inputKey[1] = mMaterial->mRoughnessChan[i];
|
inputKey[1] = mMaterial->mRoughnessChan[i];
|
||||||
inputKey[2] = mMaterial->mMetalChan[i];
|
inputKey[2] = mMaterial->mMetalChan[i];
|
||||||
inputKey[3] = 0;
|
inputKey[3] = 0;
|
||||||
mStages[i].setTex(MFT_OrmMap, _createCompositeTexture( mMaterial->getAOMap(i), mMaterial->getRoughMap(i),
|
mStages[i].setTex(MFT_OrmMap, _createCompositeTexture( mMaterial->getAOMapAsset(i)->getImageFile(), mMaterial->getRoughMapAsset(i)->getImageFile(),
|
||||||
mMaterial->getMetalMap(i), "",
|
mMaterial->getMetalMapAsset(i)->getImageFile(), "",
|
||||||
inputKey, profile));
|
inputKey, profile));
|
||||||
if (!mStages[i].getTex(MFT_OrmMap))
|
if (!mStages[i].getTex(MFT_OrmMap))
|
||||||
mMaterial->logError("Failed to dynamically create ORM Config map for stage %i", i);
|
mMaterial->logError("Failed to dynamically create ORM Config map for stage %i", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mMaterial->getGlowMap(i) != StringTable->EmptyString())
|
if (mMaterial->getGlowMapAsset(i).notNull())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_GlowMap, mMaterial->getGlowMapResource(i));
|
mStages[i].setTex(MFT_GlowMap, mMaterial->getGlowMap(i));
|
||||||
if (!mStages[i].getTex(MFT_GlowMap))
|
if (!mStages[i].getTex(MFT_GlowMap))
|
||||||
mMaterial->logError("Failed to load glow map %s for stage %i", mMaterial->getGlowMap(i), i);
|
mMaterial->logError("Failed to load glow map %s for stage %i", mMaterial->_getGlowMap(i), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -229,10 +229,9 @@ bool ProcessedShaderMaterial::init( const FeatureSet &features,
|
||||||
mInstancingState = new InstancingState();
|
mInstancingState = new InstancingState();
|
||||||
mInstancingState->setFormat( _getRPD( 0 )->shader->getInstancingFormat(), mVertexFormat );
|
mInstancingState->setFormat( _getRPD( 0 )->shader->getInstancingFormat(), mVertexFormat );
|
||||||
}
|
}
|
||||||
if (mMaterial && mMaterial->mDiffuseMapName[0] != StringTable->EmptyString() && String(mMaterial->mDiffuseMapName[0]).startsWith("#"))
|
if (mMaterial && mMaterial->getDiffuseMapAsset(0).notNull() && mMaterial->getDiffuseMapAsset(0)->isNamedTarget())
|
||||||
{
|
{
|
||||||
String texTargetBufferName = String(mMaterial->mDiffuseMapName[0]).substr(1, (U32)strlen(mMaterial->mDiffuseMapName[0]) - 1);
|
NamedTexTarget *texTarget = mMaterial->getDiffuseMapAsset(0)->getNamedTarget();
|
||||||
NamedTexTarget *texTarget = NamedTexTarget::find(texTargetBufferName);
|
|
||||||
RenderPassData* rpd = getPass(0);
|
RenderPassData* rpd = getPass(0);
|
||||||
|
|
||||||
if (rpd)
|
if (rpd)
|
||||||
|
|
@ -876,13 +875,27 @@ void ProcessedShaderMaterial::setTextureStages( SceneRenderState *state, const S
|
||||||
case Material::TexTarget:
|
case Material::TexTarget:
|
||||||
{
|
{
|
||||||
texTarget = rpd->mTexSlot[i].texTarget;
|
texTarget = rpd->mTexSlot[i].texTarget;
|
||||||
if ( !texTarget )
|
if (!mMaterial->getDiffuseMapAsset(0).notNull())
|
||||||
{
|
{
|
||||||
GFX->setTexture( i, NULL );
|
GFX->setTexture(i, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
texObject = texTarget->getTexture();
|
texObject = mMaterial->getDiffuseMapAsset(0)->getTexture(&GFXStaticTextureSRGBProfile);
|
||||||
|
if ( !texTarget )
|
||||||
|
{
|
||||||
|
// try again.
|
||||||
|
texTarget = mMaterial->getDiffuseMapAsset(0)->getNamedTarget();
|
||||||
|
if (!texTarget)
|
||||||
|
{
|
||||||
|
GFX->setTexture(i, texObject);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rpd->mTexSlot[i].texTarget = texTarget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If no texture is available then map the default 2x2
|
// If no texture is available then map the default 2x2
|
||||||
// black texture to it. This at least will ensure that
|
// black texture to it. This at least will ensure that
|
||||||
|
|
@ -1271,35 +1284,35 @@ void ProcessedShaderMaterial::setNodeTransforms(const MatrixF *transforms, const
|
||||||
|
|
||||||
void ProcessedShaderMaterial::setCustomShaderData(Vector<CustomShaderBindingData> &shaderData, const U32 pass)
|
void ProcessedShaderMaterial::setCustomShaderData(Vector<CustomShaderBindingData> &shaderData, const U32 pass)
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE(ProcessedShaderMaterial_setCustomShaderData);
|
PROFILE_SCOPE(ProcessedShaderMaterial_setCustomShaderData);
|
||||||
|
|
||||||
GFXShaderConstBuffer* shaderConsts = _getShaderConstBuffer(pass);
|
GFXShaderConstBuffer* shaderConsts = _getShaderConstBuffer(pass);
|
||||||
ShaderConstHandles* handles = _getShaderConstHandles(pass);
|
ShaderConstHandles* handles = _getShaderConstHandles(pass);
|
||||||
|
|
||||||
for (U32 i = 0; i < shaderData.size(); i++)
|
for (U32 i = 0; i < shaderData.size(); i++)
|
||||||
{
|
{
|
||||||
//roll through and try setting our data!
|
//roll through and try setting our data!
|
||||||
for (U32 h = 0; h < handles->mCustomHandles.size(); ++h)
|
for (U32 h = 0; h < handles->mCustomHandles.size(); ++h)
|
||||||
{
|
{
|
||||||
if (handles->mCustomHandles[h].handleName == shaderData[i].getHandleName())
|
if (handles->mCustomHandles[h].handleName == shaderData[i].getHandleName())
|
||||||
{
|
{
|
||||||
if (handles->mCustomHandles[h].handle->isValid())
|
if (handles->mCustomHandles[h].handle->isValid())
|
||||||
{
|
{
|
||||||
CustomShaderBindingData::UniformType type = shaderData[i].getType();
|
CustomShaderBindingData::UniformType type = shaderData[i].getType();
|
||||||
|
|
||||||
if (type == CustomShaderBindingData::Float)
|
if (type == CustomShaderBindingData::Float)
|
||||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat());
|
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat());
|
||||||
else if (type == CustomShaderBindingData::Float2)
|
else if (type == CustomShaderBindingData::Float2)
|
||||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat2());
|
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat2());
|
||||||
else if (type == CustomShaderBindingData::Float3)
|
else if (type == CustomShaderBindingData::Float3)
|
||||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat3());
|
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat3());
|
||||||
else if (type == CustomShaderBindingData::Float4)
|
else if (type == CustomShaderBindingData::Float4)
|
||||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat4());
|
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat4());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessedShaderMaterial::setSceneInfo(SceneRenderState * state, const SceneData& sgData, U32 pass)
|
void ProcessedShaderMaterial::setSceneInfo(SceneRenderState * state, const SceneData& sgData, U32 pass)
|
||||||
|
|
|
||||||
|
|
@ -531,5 +531,7 @@ inline F64 mSquared( F64 n )
|
||||||
return n * n;
|
return n * n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
inline void mSwap(T& a, T& b) { T temp = b; b = a; a = temp; }
|
||||||
|
|
||||||
#endif //_MMATHFN_H_
|
#endif //_MMATHFN_H_
|
||||||
|
|
|
||||||
|
|
@ -508,10 +508,6 @@ PostEffect::PostEffect()
|
||||||
dMemset( mTexSizeSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
dMemset( mTexSizeSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
||||||
dMemset( mRenderTargetParamsSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
dMemset( mRenderTargetParamsSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
||||||
|
|
||||||
for (U32 i = 0; i < NumTextures; i++)
|
|
||||||
{
|
|
||||||
INIT_IMAGEASSET_ARRAY(Texture, PostFxTextureProfile, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PostEffect::~PostEffect()
|
PostEffect::~PostEffect()
|
||||||
|
|
@ -556,6 +552,7 @@ void PostEffect::initPersistFields()
|
||||||
addField( "targetViewport", TYPEID< PFXTargetViewport >(), Offset( mTargetViewport, PostEffect ),
|
addField( "targetViewport", TYPEID< PFXTargetViewport >(), Offset( mTargetViewport, PostEffect ),
|
||||||
"Specifies how the viewport should be set up for a target texture." );
|
"Specifies how the viewport should be set up for a target texture." );
|
||||||
|
|
||||||
|
addProtectedField("Texture", TypeImageFilename, Offset(mTextureAsset, PostEffect), _setTextureData, &defaultProtectedGetFn, NumTextures, "Input textures to this effect(samplers).\n", AbstractClassRep::FIELD_HideInInspectors);
|
||||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(Texture, NumTextures, PostEffect, "Input textures to this effect ( samplers ).\n"
|
INITPERSISTFIELD_IMAGEASSET_ARRAY(Texture, NumTextures, PostEffect, "Input textures to this effect ( samplers ).\n"
|
||||||
"@see PFXTextureIdentifiers");
|
"@see PFXTextureIdentifiers");
|
||||||
|
|
||||||
|
|
@ -608,22 +605,24 @@ bool PostEffect::onAdd()
|
||||||
for (S32 i = 0; i < NumTextures; i++)
|
for (S32 i = 0; i < NumTextures; i++)
|
||||||
{
|
{
|
||||||
mTextureType[i] = NormalTextureType;
|
mTextureType[i] = NormalTextureType;
|
||||||
String texFilename = getTexture(i);
|
if (mTextureAsset[i].notNull()) {
|
||||||
|
String texFilename = mTextureAsset[i]->getImageFile();
|
||||||
|
|
||||||
// Skip empty stages or ones with variable or target names.
|
// Skip empty stages or ones with variable or target names.
|
||||||
if (texFilename.isEmpty() ||
|
if (texFilename.isEmpty() ||
|
||||||
texFilename[0] == '$' ||
|
texFilename[0] == '$' ||
|
||||||
texFilename[0] == '#')
|
texFilename[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
||||||
_setTexture(texFilename, i);
|
_setTexture(texFilename, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the target a named target?
|
// Is the target a named target?
|
||||||
if ( mTargetName.isNotEmpty() && mTargetName[0] == '#' )
|
if ( mTargetName.isNotEmpty() && mTargetName[0] == '#' )
|
||||||
{
|
{
|
||||||
mNamedTarget.registerWithName( mTargetName.substr( 1 ) );
|
mNamedTarget.registerWithName(mTargetName.substr(1));
|
||||||
mNamedTarget.getTextureDelegate().bind( this, &PostEffect::_getTargetTexture );
|
mNamedTarget.getTextureDelegate().bind( this, &PostEffect::_getTargetTexture );
|
||||||
}
|
}
|
||||||
if ( mTargetDepthStencilName.isNotEmpty() && mTargetDepthStencilName[0] == '#' )
|
if ( mTargetDepthStencilName.isNotEmpty() && mTargetDepthStencilName[0] == '#' )
|
||||||
|
|
@ -1136,7 +1135,7 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
||||||
|
|
||||||
void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *inTexViewport )
|
void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *inTexViewport )
|
||||||
{
|
{
|
||||||
const String &texFilename = getTexture( stage );
|
const String &texFilename = mTextureAsset[stage].notNull() ? mTextureAsset[stage]->getImageFile() : "";
|
||||||
|
|
||||||
GFXTexHandle theTex;
|
GFXTexHandle theTex;
|
||||||
NamedTexTarget *namedTarget = NULL;
|
NamedTexTarget *namedTarget = NULL;
|
||||||
|
|
@ -1173,7 +1172,11 @@ void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
theTex = mTexture[ stage ];
|
theTex = mTexture[stage];
|
||||||
|
|
||||||
|
if (!theTex && mTextureAsset[stage].notNull())
|
||||||
|
theTex = mTextureAsset[stage]->getTexture(mTextureProfile[stage]);
|
||||||
|
|
||||||
if ( theTex )
|
if ( theTex )
|
||||||
viewport.set( 0, 0, theTex->getWidth(), theTex->getHeight() );
|
viewport.set( 0, 0, theTex->getWidth(), theTex->getHeight() );
|
||||||
}
|
}
|
||||||
|
|
@ -1640,7 +1643,6 @@ void PostEffect::reload()
|
||||||
void PostEffect::setTexture( U32 index, const String &texFilePath )
|
void PostEffect::setTexture( U32 index, const String &texFilePath )
|
||||||
{
|
{
|
||||||
// Set the new texture name.
|
// Set the new texture name.
|
||||||
mTextureName[index] = texFilePath;
|
|
||||||
mTexture[index].free();
|
mTexture[index].free();
|
||||||
|
|
||||||
// Skip empty stages or ones with variable or target names.
|
// Skip empty stages or ones with variable or target names.
|
||||||
|
|
@ -1651,14 +1653,13 @@ void PostEffect::setTexture( U32 index, const String &texFilePath )
|
||||||
|
|
||||||
mTextureProfile[index] = (mTexSRGB[index])? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
mTextureProfile[index] = (mTexSRGB[index])? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
||||||
_setTexture(texFilePath, index);
|
_setTexture(texFilePath, index);
|
||||||
|
mTexture[index] = mTextureAsset[index]->getTexture(mTextureProfile[index]);
|
||||||
mTextureType[index] = NormalTextureType;
|
mTextureType[index] = NormalTextureType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostEffect::setTexture(U32 index, const GFXTexHandle& texHandle)
|
void PostEffect::setTexture(U32 index, const GFXTexHandle& texHandle)
|
||||||
{
|
{
|
||||||
// Set the new texture name.
|
// Set the new texture name.
|
||||||
mTextureName[index] = StringTable->EmptyString();
|
|
||||||
mTexture[index].free();
|
mTexture[index].free();
|
||||||
|
|
||||||
// Skip empty stages or ones with variable or target names.
|
// Skip empty stages or ones with variable or target names.
|
||||||
|
|
@ -1847,18 +1848,21 @@ void PostEffect::_checkRequirements()
|
||||||
{
|
{
|
||||||
if (mTextureType[i] == NormalTextureType)
|
if (mTextureType[i] == NormalTextureType)
|
||||||
{
|
{
|
||||||
const String &texFilename = mTextureName[i];
|
if (mTextureAsset[i].notNull())
|
||||||
|
|
||||||
if (texFilename.isNotEmpty() && texFilename[0] == '#')
|
|
||||||
{
|
{
|
||||||
NamedTexTarget *namedTarget = NamedTexTarget::find(texFilename.c_str() + 1);
|
const String& texFilename = mTextureAsset[i]->getImageFile();
|
||||||
if (!namedTarget)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab the macros for shader initialization.
|
if (texFilename.isNotEmpty() && texFilename[0] == '#')
|
||||||
namedTarget->getShaderMacros(¯os);
|
{
|
||||||
|
NamedTexTarget* namedTarget = NamedTexTarget::find(texFilename.c_str() + 1);
|
||||||
|
if (!namedTarget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grab the macros for shader initialization.
|
||||||
|
namedTarget->getShaderMacros(¯os);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DECLARE_IMAGEASSET_ARRAY(PostEffect, Texture, NumTextures, onTextureChanged);
|
DECLARE_IMAGEASSET_ARRAY(PostEffect, Texture, GFXStaticTextureSRGBProfile, NumTextures);
|
||||||
DECLARE_IMAGEASSET_ARRAY_SETGET(PostEffect, Texture);
|
GFXTextureProfile* mTextureProfile[NumTextures];
|
||||||
void onTextureChanged() {}
|
GFXTexHandle mTexture[NumTextures];
|
||||||
|
|
||||||
bool mTexSRGB[NumTextures];
|
bool mTexSRGB[NumTextures];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ void PostEffectVis::open( PostEffect *pfx )
|
||||||
// Only allocate window/bitmaps for input textures that are actually used.
|
// Only allocate window/bitmaps for input textures that are actually used.
|
||||||
if ( i > Target )
|
if ( i > Target )
|
||||||
{
|
{
|
||||||
if ( pfx->mTextureName[i-1] == StringTable->EmptyString())
|
if ( pfx->mTextureAsset[i-1].notNull() && pfx->mTextureAsset[i - 1]->getImageFile() == StringTable->EmptyString())
|
||||||
{
|
{
|
||||||
window.window[i] = NULL;
|
window.window[i] = NULL;
|
||||||
window.bmp[i] = NULL;
|
window.bmp[i] = NULL;
|
||||||
|
|
@ -275,9 +275,9 @@ void PostEffectVis::onPFXProcessed( PostEffect *pfx )
|
||||||
|
|
||||||
|
|
||||||
if ( tex )
|
if ( tex )
|
||||||
dSprintf( caption, 256, "%s[%i] input%i - %s [ %ix%i ]", name, pfx->getId(), i-1, pfx->mTextureName[i-1], tex->getWidth(), tex->getHeight() );
|
dSprintf( caption, 256, "%s[%i] input%i - %s [ %ix%i ]", name, pfx->getId(), i-1, pfx->mTextureAsset[i - 1].notNull() ? pfx->mTextureAsset[i - 1]->getImageFile() : "", tex->getWidth(), tex->getHeight());
|
||||||
else
|
else
|
||||||
dSprintf( caption, 256, "%s[%i] input%i - %s", name, pfx->getId(), i-1, pfx->mTextureName[i-1] );
|
dSprintf( caption, 256, "%s[%i] input%i - %s", name, pfx->getId(), i-1, pfx->mTextureAsset[i - 1].notNull() ? pfx->mTextureAsset[i - 1]->getImageFile() : "");
|
||||||
|
|
||||||
pWinCtrl->setDataField( StringTable->insert("text"), NULL, caption );
|
pWinCtrl->setDataField( StringTable->insert("text"), NULL, caption );
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +364,7 @@ void PostEffectVis::_setDefaultCaption( VisWindow &vis, U32 texIndex )
|
||||||
else
|
else
|
||||||
dSprintf( name, 256, "%s", pfx->getName() );
|
dSprintf( name, 256, "%s", pfx->getName() );
|
||||||
|
|
||||||
dSprintf( caption, 256, "%s[%i] input%i - %s [NOT ENABLED]", name, pfx->getId(), texIndex-1, pfx->mTextureName[texIndex-1] );
|
dSprintf( caption, 256, "%s[%i] input%i - %s [NOT ENABLED]", name, pfx->getId(), texIndex-1, pfx->mTextureAsset[texIndex - 1].notNull() ? pfx->mTextureAsset[texIndex - 1]->getImageFile() : "");
|
||||||
|
|
||||||
winCtrl->setDataField( StringTable->insert("text"), NULL, caption );
|
winCtrl->setDataField( StringTable->insert("text"), NULL, caption );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue