mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
cloud layer example
This commit is contained in:
parent
eca0820134
commit
24b374f545
|
|
@ -181,6 +181,17 @@ const String ImageAsset::mErrCodeStrings[] =
|
|||
"UnKnown"
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ImageAsset::ImageAsset() :
|
||||
mImageFile(StringTable->EmptyString()),
|
||||
mUseMips(true),
|
||||
mIsHDRImage(false),
|
||||
mImageType(Albedo),
|
||||
mTextureHandle(NULL)
|
||||
{
|
||||
mLoadedState = AssetErrCode::NotLoaded;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ImageAsset::~ImageAsset()
|
||||
|
|
@ -618,7 +629,7 @@ void GuiInspectorTypeImageAssetPtr::consoleInit()
|
|||
{
|
||||
Parent::consoleInit();
|
||||
|
||||
ConsoleBaseType::getType(TypeImageAssetPtr)->setInspectorFieldType("GuiInspectorTypeImageAssetPtr");
|
||||
ConsoleBaseType::getType(TypeImageAssetPtrRefactor)->setInspectorFieldType("GuiInspectorTypeImageAssetPtr");
|
||||
}
|
||||
|
||||
GuiControl* GuiInspectorTypeImageAssetPtr::constructEditControl()
|
||||
|
|
|
|||
|
|
@ -592,7 +592,26 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
|
|||
private: \
|
||||
AssetPtr<ImageAsset> m##name##Asset; \
|
||||
public: \
|
||||
void _set##name(StringTableEntry _in); \
|
||||
void _set##name(StringTableEntry _in){ \
|
||||
if(m##name##Asset.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]; \
|
||||
} \
|
||||
m##name##Asset = imageAssetId; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
m##name##Asset = _in; \
|
||||
} \
|
||||
}; \
|
||||
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; } \
|
||||
|
|
|
|||
|
|
@ -112,8 +112,6 @@ CloudLayer::CloudLayer()
|
|||
mTexOffset[0] = mTexOffset[1] = mTexOffset[2] = Point2F::Zero;
|
||||
|
||||
mHeight = 4.0f;
|
||||
|
||||
INIT_ASSET(Texture);
|
||||
}
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1( CloudLayer );
|
||||
|
|
@ -131,8 +129,6 @@ bool CloudLayer::onAdd()
|
|||
|
||||
addToScene();
|
||||
|
||||
LOAD_IMAGEASSET(Texture);
|
||||
|
||||
if ( isClientObject() )
|
||||
{
|
||||
_initBuffers();
|
||||
|
|
@ -194,8 +190,8 @@ void CloudLayer::initPersistFields()
|
|||
docsURL;
|
||||
addGroup( "CloudLayer" );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).")
|
||||
|
||||
addArray( "Textures", TEX_COUNT );
|
||||
|
||||
addField( "texScale", TypeF32, Offset( mTexScale, CloudLayer ), TEX_COUNT,
|
||||
|
|
@ -243,7 +239,9 @@ U32 CloudLayer::packUpdate( NetConnection *conn, U32 mask, BitStream *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++ )
|
||||
{
|
||||
|
|
@ -265,10 +263,9 @@ void CloudLayer::unpackUpdate( NetConnection *conn, BitStream *stream )
|
|||
{
|
||||
Parent::unpackUpdate( conn, stream );
|
||||
|
||||
UNPACK_ASSET(conn, Texture);
|
||||
|
||||
if(mTextureAssetId != StringTable->EmptyString())
|
||||
mTextureAsset = mTextureAssetId;
|
||||
if (stream->readFlag()) {
|
||||
mTextureAsset.setAssetId(_getStringTable()->insert(conn->unpackNetStringHandleU(stream).getString()));
|
||||
}
|
||||
|
||||
for ( U32 i = 0; i < TEX_COUNT; i++ )
|
||||
{
|
||||
|
|
@ -334,7 +331,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
|
|||
{
|
||||
GFXTransformSaver saver;
|
||||
|
||||
if (!mTextureAsset || !mTextureAsset->isAssetValid())
|
||||
if (!mTextureAsset)
|
||||
return;
|
||||
|
||||
const Point3F &camPos = state->getCameraPosition();
|
||||
|
|
@ -385,7 +382,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
|
|||
|
||||
mShaderConsts->setSafe( mExposureSC, mExposure );
|
||||
|
||||
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), getTextureResource());
|
||||
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTextureAsset->getTexture(&GFXStaticTextureSRGBProfile));
|
||||
GFX->setVertexBuffer( mVB );
|
||||
GFX->setPrimitiveBuffer( mPB );
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ class CloudLayer : public SceneObject
|
|||
};
|
||||
|
||||
#define TEX_COUNT 3
|
||||
|
||||
public:
|
||||
|
||||
CloudLayer();
|
||||
|
|
@ -97,8 +96,9 @@ protected:
|
|||
static U32 smVertCount;
|
||||
static U32 smTriangleCount;
|
||||
|
||||
DECLARE_IMAGEASSET(CloudLayer, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_ASSET_NET_SETGET(CloudLayer, Texture, CloudLayerMask);
|
||||
public:
|
||||
|
||||
DECLARE_IMAGEASSET_REFACTOR(CloudLayer,Texture, GFXStaticTextureSRGBProfile)
|
||||
|
||||
GFXShaderRef mShader;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue