mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-20 20:05:33 +00:00
fully working
This commit is contained in:
parent
85463c85ac
commit
f6dc694bd4
10 changed files with 88 additions and 75 deletions
|
|
@ -111,7 +111,7 @@ ConsoleSetType(TypeImageAssetId)
|
|||
ImplementEnumType(ImageAssetType,
|
||||
"Type of mesh data available in a shape.\n"
|
||||
"@ingroup gameObjects")
|
||||
{ ImageAsset::Albedo, "Albedo", "" },
|
||||
{ ImageAsset::Albedo, "Albedo", "" },
|
||||
{ ImageAsset::Normal, "Normal", "" },
|
||||
{ ImageAsset::ORMConfig, "ORMConfig", "" },
|
||||
{ ImageAsset::GUI, "GUI", "" },
|
||||
|
|
@ -121,8 +121,7 @@ ImplementEnumType(ImageAssetType,
|
|||
{ ImageAsset::Glow, "Glow", "" },
|
||||
{ ImageAsset::Particle, "Particle", "" },
|
||||
{ ImageAsset::Decal, "Decal", "" },
|
||||
{ ImageAsset::Cubemap, "Cubemap", "" },
|
||||
{ ImageAsset::Target, "Target", "" },
|
||||
{ ImageAsset::Cubemap, "Cubemap", "" },
|
||||
|
||||
EndImplementEnumType;
|
||||
|
||||
|
|
@ -278,7 +277,7 @@ U32 ImageAsset::load()
|
|||
// this is a target.
|
||||
if (mImageFileName[0] == '$' || mImageFileName[0] == '#')
|
||||
{
|
||||
NamedTexTarget* namedTarget = NamedTexTarget::find(mImageFileName + 1);
|
||||
NamedTexTargetRef namedTarget = NamedTexTarget::find(mImageFileName + 1);
|
||||
if (namedTarget) {
|
||||
mLoadedState = Ok;
|
||||
mIsValidImage = true;
|
||||
|
|
@ -289,7 +288,6 @@ U32 ImageAsset::load()
|
|||
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);
|
||||
|
|
@ -364,6 +362,7 @@ void ImageAsset::setImageFileName(const char* pScriptFile)
|
|||
|
||||
GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
|
||||
{
|
||||
load();
|
||||
if (mResourceMap.contains(requestedProfile))
|
||||
{
|
||||
mLoadedState = Ok;
|
||||
|
|
@ -371,21 +370,41 @@ GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
|
|||
}
|
||||
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 = TEXMGR->createTexture(mImagePath, requestedProfile);
|
||||
if (newTex)
|
||||
// this is a target.
|
||||
if (mImageFileName[0] == '$' || mImageFileName[0] == '#')
|
||||
{
|
||||
mResourceMap.insert(requestedProfile, newTex);
|
||||
mLoadedState = Ok;
|
||||
return newTex;
|
||||
NamedTexTargetRef namedTarget = NamedTexTarget::find(mImageFileName + 1);
|
||||
if (namedTarget.isValid() && namedTarget->getTexture())
|
||||
{
|
||||
if (mNamedTarget == NULL) {
|
||||
mNamedTarget = namedTarget;
|
||||
mResourceMap.insert(requestedProfile, mNamedTarget->getTexture());
|
||||
mIsValidImage = true;
|
||||
mChangeSignal.trigger();
|
||||
}
|
||||
}
|
||||
if (mNamedTarget == NULL)
|
||||
return nullptr;
|
||||
else
|
||||
return mNamedTarget->getTexture();
|
||||
|
||||
}
|
||||
else
|
||||
mLoadedState = BadFileReference;
|
||||
{
|
||||
//If we don't have an existing map case to the requested format, we'll just create it and insert it in
|
||||
GFXTexHandle newTex = TEXMGR->createTexture(mImagePath, requestedProfile);
|
||||
if (newTex)
|
||||
{
|
||||
mResourceMap.insert(requestedProfile, newTex);
|
||||
mLoadedState = Ok;
|
||||
return newTex;
|
||||
}
|
||||
else
|
||||
mLoadedState = BadFileReference;
|
||||
}
|
||||
}
|
||||
|
||||
//if (mTexture.isValid())
|
||||
// return mTexture;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -428,7 +447,6 @@ const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type)
|
|||
"Particle",
|
||||
"Decal",
|
||||
"Cubemap"
|
||||
"Target"
|
||||
};
|
||||
|
||||
if (type < 0 || type >= ImageTypeCount)
|
||||
|
|
|
|||
|
|
@ -39,11 +39,7 @@
|
|||
#endif
|
||||
#ifndef _ASSET_PTR_H_
|
||||
#include "assets/assetPtr.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MATTEXTURETARGET_H_
|
||||
#include "materials/matTextureTarget.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "gfx/bitmap/gBitmap.h"
|
||||
#include "gfx/gfxTextureHandle.h"
|
||||
|
|
@ -54,6 +50,11 @@
|
|||
#include "assetMacroHelpers.h"
|
||||
|
||||
#include "gfx/gfxDevice.h"
|
||||
|
||||
#ifndef _MATTEXTURETARGET_H_
|
||||
#include "materials/matTextureTarget.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class ImageAsset : public AssetBase
|
||||
{
|
||||
|
|
@ -75,8 +76,7 @@ public:
|
|||
Particle = 8,
|
||||
Decal = 9,
|
||||
Cubemap = 10,
|
||||
Target = 11,
|
||||
ImageTypeCount = 12
|
||||
ImageTypeCount = 11
|
||||
};
|
||||
|
||||
static StringTableEntry smNoImageAssetFallback;
|
||||
|
|
@ -100,6 +100,7 @@ public:
|
|||
protected:
|
||||
StringTableEntry mImageFileName;
|
||||
StringTableEntry mImagePath;
|
||||
NamedTexTargetRef mNamedTarget;
|
||||
|
||||
bool mIsValidImage;
|
||||
bool mUseMips;
|
||||
|
|
@ -256,12 +257,10 @@ public: \
|
|||
}\
|
||||
\
|
||||
if (get##name()[0] == '$' || get##name()[0] == '#') {\
|
||||
NamedTexTarget* namedTarget = NamedTexTarget::find(get##name() + 1);\
|
||||
if (namedTarget)\
|
||||
NamedTexTargetRef namedTarget = NamedTexTarget::find(get##name() + 1);\
|
||||
if (namedTarget.isValid())\
|
||||
{\
|
||||
m##name = namedTarget->getTexture(0);\
|
||||
m##name##Name = get##name();\
|
||||
m##name##AssetId = StringTable->EmptyString();\
|
||||
}\
|
||||
}\
|
||||
else\
|
||||
|
|
@ -306,6 +305,8 @@ public: \
|
|||
}\
|
||||
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); }
|
||||
|
|
@ -341,7 +342,7 @@ if (m##name##AssetId != StringTable->EmptyString())\
|
|||
#pragma region Arrayed Asset Macros
|
||||
|
||||
//Arrayed Assets
|
||||
#define DECLARE_IMAGEASSET_ARRAY(className, name, max) public: \
|
||||
#define DECLARE_IMAGEASSET_ARRAY(className, name, max, changeFunc) public: \
|
||||
static const U32 sm##name##Count = max;\
|
||||
GFXTexHandle m##name[max];\
|
||||
StringTableEntry m##name##Name[max]; \
|
||||
|
|
@ -412,13 +413,7 @@ public: \
|
|||
if (get##name(index) != StringTable->EmptyString() && m##name##Name[index] != StringTable->insert("texhandle"))\
|
||||
{\
|
||||
if (get##name(index)[0] == '$' || get##name(index)[0] == '#') {\
|
||||
NamedTexTarget* namedTarget = NamedTexTarget::find(get##name(index) + 1);\
|
||||
if (namedTarget)\
|
||||
{\
|
||||
m##name[index] = namedTarget->getTexture(0);\
|
||||
m##name##Name[index] = get##name(index);\
|
||||
m##name##AssetId[index] = StringTable->EmptyString();\
|
||||
}\
|
||||
m##name##Asset[index]->getChangedSignal().notify(this, &className::changeFunc);\
|
||||
}\
|
||||
else\
|
||||
m##name[index].set(get##name(index), m##name##Profile[index], avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));\
|
||||
|
|
@ -469,6 +464,8 @@ public: \
|
|||
{\
|
||||
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); }
|
||||
|
|
|
|||
|
|
@ -122,8 +122,9 @@ public:
|
|||
F32 times[ NUM_TIME_KEYS ];
|
||||
LinearColorF colors[ NUM_TIME_KEYS ];
|
||||
|
||||
DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, NUM_TEX);
|
||||
DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, NUM_TEX, onTextureChanged);
|
||||
DECLARE_IMAGEASSET_ARRAY_SETGET(SplashData, Texture)
|
||||
void onTextureChanged() {}
|
||||
|
||||
ExplosionData* explosion;
|
||||
S32 explosionId;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue