Merge remote-tracking branch 'devhead/Preview4_0' into tsneo

# Conflicts:
#	Templates/BaseGame/game/data/ui/guis/loadingGui.gui
#	Templates/BaseGame/game/data/ui/guis/mainMenu.gui
#	Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui
#	Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui
#	Templates/BaseGame/game/tools/forestEditor/brushes.tscript
This commit is contained in:
Jeff Hutchinson 2021-08-13 20:14:39 -04:00
commit 717c7acca9
2266 changed files with 48780 additions and 26034 deletions

View file

@ -124,7 +124,6 @@ VolumetricFog::VolumetricFog()
mLightRayMod = 1.0f;
mOldLightRayStrength = 0.1f;
mShapeName = "";
mShapeLoaded = false;
mMinDisplaySize = 10.0f;
mFadeSize = 0.0f;
@ -132,15 +131,14 @@ VolumetricFog::VolumetricFog()
mNumDetailLevels = 0;
det_size.clear();
mTextureName = "";
mIsTextured = false;
mStrength = 0.5f;
mTexTiles = 1.0f;
mSpeed1.set(0.5f, 0.0f);
mSpeed2.set(0.1f, 0.1f);
mShapeAsset = StringTable->EmptyString();
mShapeAssetId = StringTable->EmptyString();
INIT_SHAPEASSET(Shape);
INIT_IMAGEASSET(Texture);
}
VolumetricFog::~VolumetricFog()
@ -168,11 +166,8 @@ VolumetricFog::~VolumetricFog()
void VolumetricFog::initPersistFields()
{
addGroup("VolumetricFogData");
addProtectedField("shapeAsset", TypeShapeAssetPtr, Offset(mShapeAsset, VolumetricFog),
&VolumetricFog::_setShapeAsset, &defaultProtectedGetFn, "The source shape asset.");
addField("shapeName", TypeShapeFilename, Offset(mShapeName, VolumetricFog),
"Path and filename of the model file (.DTS, .DAE) to use for this Volume.", AbstractClassRep::FieldFlags::FIELD_HideInInspectors );
INITPERSISTFIELD_SHAPEASSET(Shape, VolumetricFog, "The source shape asset.");
addField("FogColor", TypeColorI, Offset(mFogColor, VolumetricFog),
"Fog color RGBA (Alpha is ignored)");
@ -187,8 +182,8 @@ void VolumetricFog::initPersistFields()
endGroup("VolumetricFogData");
addGroup("VolumetricFogModulation");
addField("texture", TypeImageFilename, Offset(mTextureName, VolumetricFog),
"A texture which contains Fogdensity modulator in the red channel and color with 1-green channel. No texture disables modulation.");
INITPERSISTFIELD_IMAGEASSET(Texture, VolumetricFog, "A texture which contains Fogdensity modulator in the red channel and color with 1-green channel. No texture disables modulation.");
addField("tiles", TypeF32, Offset(mTexTiles, VolumetricFog),
"How many times the texture is mapped to the object.");
addField("modStrength", TypeF32, Offset(mStrength, VolumetricFog),
@ -356,40 +351,15 @@ bool VolumetricFog::LoadShape()
{
GFXPrimitiveType GFXdrawTypes[] = { GFXTriangleList, GFXTriangleStrip };
Resource<TSShape> mShape;
if (mShapeAssetId != StringTable->EmptyString())
if (mShapeAsset.isNull())
{
mShapeAsset = mShapeAssetId;
if (mShapeAsset.isNull())
{
Con::errorf("[TSStatic] Failed to load shape asset.");
return false;
}
mShape = mShapeAsset->getShapeResource();
if (!mShape)
{
Con::errorf("TSStatic::_createShape() - Shape Asset had no valid shape!");
return false;
}
}
else
{
if (!mShapeName || mShapeName[0] == '\0')
{
Con::errorf("VolumetricFog::LoadShape() - No shape name! Volumetric Fog will not be rendered!");
return false;
}
// Load shape, server side only reads bounds and radius
mShape = ResourceManager::get().load(mShapeName);
Con::errorf("[VolumetricFog] Failed to load shape asset.");
return false;
}
if (bool(mShape) == false)
if (!mShape)
{
Con::errorf("VolumetricFog::LoadShape() - Unable to load shape: %s", mShapeName);
Con::errorf("VolumetricFog::_createShape() - Shape Asset had no valid shape!");
return false;
}
@ -573,7 +543,7 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
stream->write(mFogDensity);
if (stream->writeFlag(mask & FogModulationMask))
{
stream->write(mTextureName);
PACK_IMAGEASSET(con, Texture);
mTexTiles = mFabs(mTexTiles);
stream->write(mTexTiles);
stream->write(mStrength);
@ -597,27 +567,20 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
}
if (stream->writeFlag(mask & FogShapeMask))
{
stream->writeString(mShapeAssetId);
stream->writeString(mShapeName);
PACK_SHAPEASSET(con, Shape);
mathWrite(*stream, getTransform());
mathWrite(*stream, getScale());
Resource<TSShape> mShape;
if (mShapeAssetId != StringTable->EmptyString())
if (mShapeAsset.notNull())
{
mShape = mShapeAsset->getShapeResource();
mObjBox = mShapeAsset->getShapeResource()->mBounds;
mRadius = mShapeAsset->getShapeResource()->mRadius;
}
else if (mShapeName && mShapeName[0] != '\0')
else
{
mShape = ResourceManager::get().load(mShapeName);
}
if (bool(mShape) == false)
return retMask;
}
mObjBox = mShape->mBounds;
mRadius = mShape->mRadius;
resetWorldBox();
mObjSize = mWorldBox.getGreatestDiagonalLength();
mObjScale = getScale();
@ -632,7 +595,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
MatrixF mat;
VectorF scale;
VectorF mOldScale = getScale();
String oldTextureName = mTextureName;
StringTableEntry oldTextureName = mTextureAssetId;
StringTableEntry oldShapeAsset = mShapeAssetId;
StringTableEntry oldShape = mShapeName;
@ -650,7 +613,7 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
}
if (stream->readFlag())// Fog Modulation
{
stream->read(&mTextureName);
UNPACK_IMAGEASSET(con, Texture);
stream->read(&mTexTiles);
mTexTiles = mFabs(mTexTiles);
stream->read(&mStrength);
@ -660,9 +623,9 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
if (isProperlyAdded())
{
if (oldTextureName != mTextureName)
if (oldTextureName != mTextureAssetId)
InitTexture();
if (oldTextureName.isNotEmpty() && mTextureName.isEmpty())
if (oldTextureName != StringTable->EmptyString() && mTextureAssetId == StringTable->EmptyString())
{
mIsTextured = false;
mTexture.free();
@ -704,11 +667,8 @@ void VolumetricFog::unpackUpdate(NetConnection *con, BitStream *stream)
}
if (stream->readFlag())//Fog shape
{
char buffer[256];
stream->readString(buffer);
mShapeAssetId = StringTable->insert(buffer);
UNPACK_SHAPEASSET(con, Shape);
mShapeName = stream->readSTString();
mathRead(*stream, &mat);
mathRead(*stream, &scale);
if (strcmp(oldShapeAsset, mShapeAssetId) != 0 || strcmp(oldShape, mShapeName) != 0)
@ -1255,8 +1215,8 @@ void VolumetricFog::InitTexture()
{
mIsTextured = false;
if (mTextureName.isNotEmpty())
mTexture.set(mTextureName, &GFXStaticTextureSRGBProfile, "VolumetricFogMod");
if (mTextureAsset.isNull())
return;
if (!mTexture.isNull())
{

View file

@ -83,6 +83,9 @@ class VolumetricFog : public SceneObject
Vector <GFXPrimitive> *piArray;
Vector <U32> *indices;
};
DECLARE_SHAPEASSET(VolumetricFog, Shape, onShapeChanged);
DECLARE_SHAPEASSET_NET_SETGET(VolumetricFog, Shape, FogShapeMask);
protected:
// Rendertargets;
@ -91,9 +94,6 @@ class VolumetricFog : public SceneObject
NamedTexTargetRef mDepthBufferTarget;
NamedTexTargetRef mFrontBufferTarget;
// Fog Modulation texture
GFXTexHandle mTexture;
// Shaders
GFXShaderRef mShader;
GFXShaderRef mDeferredShader;
@ -143,10 +143,7 @@ class VolumetricFog : public SceneObject
GFXPrimitiveBufferHandle mPB;
// Fog volume data;
AssetPtr<ShapeAsset> mShapeAsset;
StringTableEntry mShapeAssetId;
StringTableEntry mShapeName;
ColorI mFogColor;
F32 mFogDensity;
bool mIgnoreWater;
@ -165,7 +162,9 @@ class VolumetricFog : public SceneObject
F32 mInvScale;
// Fog Modulation data
String mTextureName;
DECLARE_IMAGEASSET(VolumetricFog, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
DECLARE_IMAGEASSET_NET_SETGET(VolumetricFog, Texture, FogModulationMask);
bool mIsTextured;
F32 mTexTiles;
F32 mStrength;
@ -221,6 +220,8 @@ class VolumetricFog : public SceneObject
void _leaveFog(ShapeBase *control);
static bool _setShapeAsset(void* obj, const char* index, const char* data);
void onImageChanged() {}
public:
// Public methods
@ -248,6 +249,8 @@ class VolumetricFog : public SceneObject
bool isInsideFog();
bool setShapeAsset(const StringTableEntry shapeAssetId);
void onShapeChanged() {}
DECLARE_CONOBJECT(VolumetricFog);

View file

@ -173,8 +173,7 @@ void BasicClouds::initPersistFields()
addField( "layerEnabled", TypeBool, Offset( mLayerEnabled, BasicClouds ), TEX_COUNT,
"Enable or disable rendering of this layer." );
addField( "texture", TypeImageFilename, Offset( mTexName, BasicClouds ), TEX_COUNT,
"Texture for this layer." );
INITPERSISTFIELD_IMAGEASSET_ARRAY(Texture, TEX_COUNT, BasicClouds, "Texture for this layer.");
addField( "texScale", TypeF32, Offset( mTexScale, BasicClouds ), TEX_COUNT,
"Texture repeat for this layer." );
@ -216,7 +215,7 @@ U32 BasicClouds::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
{
stream->writeFlag( mLayerEnabled[i] );
stream->write( mTexName[i] );
PACK_IMAGEASSET_ARRAY(conn, Texture, i);
stream->write( mTexScale[i] );
mathWrite( *stream, mTexDirection[i] );
@ -237,7 +236,7 @@ void BasicClouds::unpackUpdate( NetConnection *conn, BitStream *stream )
{
mLayerEnabled[i] = stream->readFlag();
stream->read( &mTexName[i] );
UNPACK_IMAGEASSET_ARRAY(conn, Texture, i);
stream->read( &mTexScale[i] );
mathRead( *stream, &mTexDirection[i] );
@ -340,11 +339,7 @@ void BasicClouds::_initTexture()
continue;
}
if ( mTexName[i].isNotEmpty() )
mTexture[i].set( mTexName[i], &GFXStaticTextureSRGBProfile, "BasicClouds" );
if ( mTexture[i].isNull() )
mTexture[i].set( GFXTextureManager::getWarningTexturePath(), &GFXStaticTextureSRGBProfile, "BasicClouds" );
_setTexture(getTexture(i), i);
}
}

View file

@ -42,6 +42,8 @@
#include "gfx/gfxShader.h"
#endif
#include "T3D/assets/ImageAsset.h"
class BaseMatInstance;
@ -91,7 +93,8 @@ protected:
static U32 smVertCount;
static U32 smTriangleCount;
GFXTexHandle mTexture[TEX_COUNT];
DECLARE_IMAGEASSET_ARRAY(BasicClouds, Texture, GFXStaticTextureSRGBProfile, TEX_COUNT);
DECLARE_IMAGEASSET_ARRAY_NET_SETGET(BasicClouds, Texture, -1);
GFXStateBlockRef mStateblock;
@ -111,7 +114,6 @@ protected:
// Fields...
bool mLayerEnabled[TEX_COUNT];
String mTexName[TEX_COUNT];
F32 mTexScale[TEX_COUNT];
Point2F mTexDirection[TEX_COUNT];
F32 mTexSpeed[TEX_COUNT];

View file

@ -38,6 +38,8 @@
#include "lighting/lightInfo.h"
#include "math/mathIO.h"
#include "sim/netConnection.h"
ConsoleDocClass( CloudLayer,
"@brief A layer of clouds which change shape over time and are affected by scene lighting.\n\n"
@ -110,6 +112,8 @@ CloudLayer::CloudLayer()
mTexOffset[0] = mTexOffset[1] = mTexOffset[2] = Point2F::Zero;
mHeight = 4.0f;
INIT_IMAGEASSET(Texture);
}
IMPLEMENT_CO_NETOBJECT_V1( CloudLayer );
@ -127,9 +131,10 @@ bool CloudLayer::onAdd()
addToScene();
LOAD_IMAGEASSET(Texture);
if ( isClientObject() )
{
_initTexture();
_initBuffers();
// Find ShaderData
@ -186,11 +191,10 @@ void CloudLayer::onRemove()
void CloudLayer::initPersistFields()
{
addGroup( "CloudLayer" );
addField( "texture", TypeImageFilename, Offset( mTextureName, CloudLayer ),
"An RGBA texture which should contain normals and opacity (density)." );
addGroup( "CloudLayer" );
INITPERSISTFIELD_IMAGEASSET(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).");
addArray( "Textures", TEX_COUNT );
addField( "texScale", TypeF32, Offset( mTexScale, CloudLayer ), TEX_COUNT,
@ -238,7 +242,7 @@ U32 CloudLayer::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
{
U32 retMask = Parent::packUpdate( conn, mask, stream );
stream->write( mTextureName );
PACK_IMAGEASSET(conn, Texture);
for ( U32 i = 0; i < TEX_COUNT; i++ )
{
@ -260,8 +264,10 @@ void CloudLayer::unpackUpdate( NetConnection *conn, BitStream *stream )
{
Parent::unpackUpdate( conn, stream );
String oldTextureName = mTextureName;
stream->read( &mTextureName );
UNPACK_IMAGEASSET(conn, Texture);
if(mTextureAssetId != StringTable->EmptyString())
mTextureAsset = mTextureAssetId;
for ( U32 i = 0; i < TEX_COUNT; i++ )
{
@ -283,8 +289,6 @@ void CloudLayer::unpackUpdate( NetConnection *conn, BitStream *stream )
if ( isProperlyAdded() )
{
if ( ( oldTextureName != mTextureName ) || ( ( oldCoverage == 0.0f ) != ( mCoverage == 0.0f ) ) )
_initTexture();
if ( oldHeight != mHeight )
_initBuffers();
}
@ -330,6 +334,9 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
{
GFXTransformSaver saver;
if (!mTextureAsset || !mTextureAsset->isAssetValid())
return;
const Point3F &camPos = state->getCameraPosition();
MatrixF xfm(true);
xfm.setPosition(camPos);
@ -378,7 +385,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
mShaderConsts->setSafe( mExposureSC, mExposure );
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTexture );
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), getTextureResource());
GFX->setVertexBuffer( mVB );
GFX->setPrimitiveBuffer( mPB );
@ -389,21 +396,6 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
// CloudLayer Internal Methods....
void CloudLayer::_initTexture()
{
if ( mCoverage <= 0.0f )
{
mTexture = NULL;
return;
}
if ( mTextureName.isNotEmpty() )
mTexture.set( mTextureName, &GFXNormalMapProfile, "CloudLayer" );
if ( mTexture.isNull() )
mTexture.set( GFXTextureManager::getWarningTexturePath(), &GFXNormalMapProfile, "CloudLayer" );
}
void CloudLayer::_initBuffers()
{
// Vertex Buffer...

View file

@ -39,6 +39,8 @@
#include "materials/matInstance.h"
#endif
#include "T3D/assets/ImageAsset.h"
GFXDeclareVertexFormat( GFXCloudVertex )
{
Point3F point;
@ -81,9 +83,10 @@ public:
void prepRenderImage( SceneRenderState *state );
void renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi );
void onImageChanged() {}
protected:
void _initTexture();
void _initBuffers();
protected:
@ -93,7 +96,8 @@ protected:
static U32 smVertCount;
static U32 smTriangleCount;
GFXTexHandle mTexture;
DECLARE_IMAGEASSET(CloudLayer, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
DECLARE_IMAGEASSET_NET_SETGET(CloudLayer, Texture, CloudLayerMask);
GFXShaderRef mShader;
@ -120,7 +124,6 @@ protected:
// Fields...
String mTextureName;
F32 mTexScale[TEX_COUNT];
Point2F mTexDirection[TEX_COUNT];
F32 mTexSpeed[TEX_COUNT];

View file

@ -277,8 +277,6 @@ DecalRoad::DecalRoad()
mTextureLength( 5.0f ),
mRenderPriority( 10 ),
mLoadRenderData( true ),
mMaterial( NULL ),
mMatInst( NULL ),
mTriangleCount(0),
mVertCount(0),
mUpdateEventId( -1 ),
@ -289,7 +287,9 @@ DecalRoad::DecalRoad()
mTypeMask |= StaticObjectType | StaticShapeObjectType;
mNetFlags.set(Ghostable);
initMaterialAsset(Material);
INIT_MATERIALASSET(Material);
mMaterialInst = nullptr;
}
DecalRoad::~DecalRoad()
@ -305,8 +305,7 @@ void DecalRoad::initPersistFields()
{
addGroup( "DecalRoad" );
addProtectedField("materialAsset", TypeMaterialAssetId, Offset(mMaterialAssetId, DecalRoad), &DecalRoad::_setMaterialAsset, &defaultProtectedGetFn, "Material Asset used for rendering.");
addProtectedField( "material", TypeMaterialName, Offset( mMaterialName, DecalRoad ), &DecalRoad::_setMaterialName, &defaultProtectedGetFn, "Material used for rendering." );
INITPERSISTFIELD_MATERIALASSET(Material, DecalRoad, "Material used for rendering.");
addProtectedField( "textureLength", TypeF32, Offset( mTextureLength, DecalRoad ), &DecalRoad::ptSetTextureLength, &defaultProtectedGetFn,
"The length in meters of textures mapped to the DecalRoad" );
@ -398,7 +397,7 @@ bool DecalRoad::onAdd()
void DecalRoad::onRemove()
{
SAFE_DELETE( mMatInst );
SAFE_DELETE( mMaterialInst );
TerrainBlock::smUpdateSignal.remove( this, &DecalRoad::_onTerrainChanged );
@ -492,7 +491,7 @@ U32 DecalRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
if ( stream->writeFlag( mask & DecalRoadMask ) )
{
// Write Texture Name.
packMaterialAsset(con, Material);
PACK_MATERIALASSET(con, Material);
stream->write( mBreakAngle );
@ -581,7 +580,7 @@ void DecalRoad::unpackUpdate( NetConnection *con, BitStream *stream )
// DecalRoadMask
if ( stream->readFlag() )
{
unpackMaterialAsset(con, Material);
UNPACK_MATERIALASSET(con, Material);
if (isProperlyAdded())
_initMaterial();
@ -685,13 +684,13 @@ void DecalRoad::prepRenderImage( SceneRenderState* state )
if ( mNodes.size() <= 1 ||
mBatches.size() == 0 ||
!mMatInst ||
!mMaterialInst ||
state->isShadowPass() )
return;
// If we don't have a material instance after the override then
// we can skip rendering all together.
BaseMatInstance *matInst = state->getOverrideMaterial( mMatInst );
BaseMatInstance *matInst = state->getOverrideMaterial(mMaterialInst);
if ( !matInst )
return;
@ -1045,12 +1044,14 @@ bool DecalRoad::addNodeFromField( void *object, const char *index, const char *d
void DecalRoad::_initMaterial()
{
_setMaterial(getMaterial());
if (mMaterialAsset.notNull())
{
if (mMatInst && String(mMaterialAsset->getMaterialDefinitionName()).equal(mMatInst->getMaterial()->getName(), String::NoCase))
if (mMaterialInst && String(mMaterialAsset->getMaterialDefinitionName()).equal(mMaterialInst->getMaterial()->getName(), String::NoCase))
return;
SAFE_DELETE(mMatInst);
SAFE_DELETE(mMaterialInst);
Material* tMat = nullptr;
@ -1060,22 +1061,22 @@ void DecalRoad::_initMaterial()
mMaterial = tMat;
if (mMaterial)
mMatInst = mMaterial->createMatInstance();
mMaterialInst = mMaterial->createMatInstance();
else
mMatInst = MATMGR->createMatInstance("WarningMaterial");
mMaterialInst = MATMGR->createMatInstance("WarningMaterial");
if (!mMatInst)
if (!mMaterialInst)
Con::errorf("DecalRoad::_initMaterial - no Material called '%s'", mMaterialAsset->getMaterialDefinitionName());
}
if (!mMatInst)
if (!mMaterialInst)
return;
GFXStateBlockDesc desc;
desc.setZReadWrite( true, false );
mMatInst->addStateBlockDesc( desc );
mMaterialInst->addStateBlockDesc( desc );
mMatInst->init( MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPNTBT>() );
mMaterialInst->init( MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPNTBT>() );
}
void DecalRoad::_debugRender( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance* )

View file

@ -240,7 +240,11 @@ protected:
U32 mSegmentsPerBatch;
F32 mTextureLength;
DECLARE_NET_MATERIALASSET(DecalRoad, Material, DecalRoadMask);
BaseMatInstance* mMaterialInst;
DECLARE_MATERIALASSET(DecalRoad, Material);
DECLARE_MATERIALASSET_NET_SETGET(DecalRoad, Material, DecalRoadMask);
U32 mRenderPriority;
// Static ConsoleVars for editor
@ -261,9 +265,6 @@ protected:
RoadBatchVector mBatches;
bool mLoadRenderData;
SimObjectPtr<Material> mMaterial;
BaseMatInstance *mMatInst;
GFXVertexBufferHandle<GFXVertexPNTBT> mVB;
GFXPrimitiveBufferHandle mPB;

View file

@ -97,6 +97,10 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl()
mHoverNodeColor( 255,255,255,255 ),
mHasCopied( false )
{
INIT_MATERIALASSET(TopMaterial);
INIT_MATERIALASSET(BottomMaterial);
INIT_MATERIALASSET(SideMaterial);
mTopMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultTopMaterialAsset");
mBottomMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultBottomMaterialAsset");
mSideMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultSideMaterialAsset");
@ -205,10 +209,6 @@ bool GuiMeshRoadEditorCtrl::onAdd()
desc.zEnable = true;
mZEnableSB = GFX->createStateBlock(desc);
bindMaterialAsset(TopMaterial);
bindMaterialAsset(BottomMaterial);
bindMaterialAsset(SideMaterial);
return true;
}
@ -222,9 +222,9 @@ void GuiMeshRoadEditorCtrl::initPersistFields()
addField( "HoverNodeColor", TypeColorI, Offset( mHoverNodeColor, GuiMeshRoadEditorCtrl ) );
addField( "isDirty", TypeBool, Offset( mIsDirty, GuiMeshRoadEditorCtrl ) );
addField("topMaterial", TypeMaterialAssetId, Offset(mTopMaterialAssetId, GuiMeshRoadEditorCtrl), "Default Material used by the Mesh Road Editor on upper surface road creation.");
addField("bottomMaterial", TypeMaterialAssetId, Offset(mBottomMaterialAssetId, GuiMeshRoadEditorCtrl), "Default Material used by the Mesh Road Editor on bottom surface road creation.");
addField("sideMaterial", TypeMaterialAssetId, Offset(mSideMaterialAssetId, GuiMeshRoadEditorCtrl), "Default Material used by the Mesh Road Editor on side surface road creation.");
INITPERSISTFIELD_MATERIALASSET(TopMaterial, GuiMeshRoadEditorCtrl, "Default Material used by the Mesh Road Editor on upper surface road creation.");
INITPERSISTFIELD_MATERIALASSET(BottomMaterial, GuiMeshRoadEditorCtrl, "Default Material used by the Mesh Road Editor on bottom surface road creation.");
INITPERSISTFIELD_MATERIALASSET(SideMaterial, GuiMeshRoadEditorCtrl, "Default Material used by the Mesh Road Editor on side surface road creation.");
//addField( "MoveNodeCursor", TYPEID< SimObject >(), Offset( mMoveNodeCursor, GuiMeshRoadEditorCtrl) );
//addField( "AddNodeCursor", TYPEID< SimObject >(), Offset( mAddNodeCursor, GuiMeshRoadEditorCtrl) );
@ -627,11 +627,11 @@ void GuiMeshRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
MeshRoad *newRoad = new MeshRoad;
if(mTopMaterialAsset.notNull())
newRoad->setTopMaterialAssetId(mTopMaterialAssetId);
newRoad->_setTopMaterial(mTopMaterialAssetId);
if (mBottomMaterialAsset.notNull())
newRoad->setBottomMaterialAssetId(mBottomMaterialAssetId);
newRoad->_setBottomMaterial(mBottomMaterialAssetId);
if (mSideMaterialAsset.notNull())
newRoad->setSideMaterialAssetId(mSideMaterialAssetId);
newRoad->_setSideMaterial(mSideMaterialAssetId);
newRoad->registerObject();

View file

@ -159,13 +159,14 @@ class GuiMeshRoadEditorCtrl : public EditTSCtrl
bool mHasCopied;
public:
StringTableEntry mTopMaterialAssetId;
StringTableEntry mBottomMaterialAssetId;
StringTableEntry mSideMaterialAssetId;
DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, TopMaterial);
DECLARE_MATERIALASSET_SETGET(GuiMeshRoadEditorCtrl, TopMaterial);
AssetPtr<MaterialAsset> mTopMaterialAsset;
AssetPtr<MaterialAsset> mBottomMaterialAsset;
AssetPtr<MaterialAsset> mSideMaterialAsset;
DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, BottomMaterial);
DECLARE_MATERIALASSET_SETGET(GuiMeshRoadEditorCtrl, BottomMaterial);
DECLARE_MATERIALASSET(GuiMeshRoadEditorCtrl, SideMaterial);
DECLARE_MATERIALASSET_SETGET(GuiMeshRoadEditorCtrl, SideMaterial);
};
class GuiMeshRoadEditorUndoAction : public UndoAction

View file

@ -108,7 +108,7 @@ void GuiRoadEditorUndoAction::undo()
nodes.merge( road->mNodes );
// Restore the Road properties saved in the UndoAction
road->setMaterialAssetId(materialAssetId);
road->_setMaterial(materialAssetId);
road->mBreakAngle = breakAngle;
road->mSegmentsPerBatch = segmentsPerBatch;
road->mTextureLength = textureLength;
@ -153,8 +153,6 @@ bool GuiRoadEditorCtrl::onAdd()
mZDisableSB = GFX->createStateBlock(desc);
bindMaterialAsset(Material);
return true;
}
@ -166,7 +164,7 @@ void GuiRoadEditorCtrl::initPersistFields()
addField( "HoverNodeColor", TypeColorI, Offset( mHoverNodeColor, GuiRoadEditorCtrl ) );
addField( "isDirty", TypeBool, Offset( mIsDirty, GuiRoadEditorCtrl ) );
addField("material", TypeMaterialAssetId, Offset(mMaterialAssetId, GuiRoadEditorCtrl), "Default Material used by the Road Editor on road creation.");
INITPERSISTFIELD_MATERIALASSET(Material, GuiRoadEditorCtrl, "Default Material used by the Road Editor on road creation.");
//addField( "MoveNodeCursor", TYPEID< SimObject >(), Offset( mMoveNodeCursor, GuiRoadEditorCtrl) );
//addField( "AddNodeCursor", TYPEID< SimObject >(), Offset( mAddNodeCursor, GuiRoadEditorCtrl) );
@ -409,7 +407,7 @@ void GuiRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
DecalRoad *newRoad = new DecalRoad;
if (mMaterialAsset.notNull())
newRoad->setMaterialAssetId(mMaterialAssetId);
newRoad->_setMaterial(mMaterialAssetId);
newRoad->registerObject();

View file

@ -103,8 +103,9 @@ class GuiRoadEditorCtrl : public EditTSCtrl
public:
StringTableEntry mMaterialAssetId;
AssetPtr<MaterialAsset> mMaterialAsset;
DECLARE_MATERIALASSET(GuiRoadEditorCtrl, Material);
DECLARE_MATERIALASSET_SETGET(GuiRoadEditorCtrl, Material);
protected:
void _drawRoadSpline( DecalRoad *road, const ColorI &color );

View file

@ -920,9 +920,9 @@ MeshRoad::MeshRoad()
mTriangleCount[i] = 0;
}
initMaterialAsset(TopMaterial);
initMaterialAsset(BottomMaterial);
initMaterialAsset(SideMaterial);
INIT_MATERIALASSET(TopMaterial);
INIT_MATERIALASSET(BottomMaterial);
INIT_MATERIALASSET(SideMaterial);
mSideProfile.mRoad = this;
}
@ -937,14 +937,9 @@ void MeshRoad::initPersistFields()
{
addGroup( "MeshRoad" );
addProtectedField("TopMaterial", TypeMaterialName, Offset(mTopMaterialName, MeshRoad), MeshRoad::_setTopMaterialName, & defaultProtectedGetFn, "Material for the upper surface of the road.", AbstractClassRep::FIELD_HideInInspectors); \
addProtectedField("TopMaterialAsset", TypeMaterialAssetId, Offset(mTopMaterialAssetId, MeshRoad), MeshRoad::_setTopMaterialAsset, & defaultProtectedGetFn, "Material for the upper surface of the road.");
addProtectedField("BottomMaterial", TypeMaterialName, Offset(mBottomMaterialName, MeshRoad), MeshRoad::_setBottomMaterialName, & defaultProtectedGetFn, "Material for the bottom surface of the road.", AbstractClassRep::FIELD_HideInInspectors); \
addProtectedField("BottomMaterialAsset", TypeMaterialAssetId, Offset(mBottomMaterialAssetId, MeshRoad), MeshRoad::_setBottomMaterialAsset, & defaultProtectedGetFn, "Material for the bottom surface of the road.");
addProtectedField("SideMaterial", TypeMaterialName, Offset(mSideMaterialName, MeshRoad), MeshRoad::_setSideMaterialName, & defaultProtectedGetFn, "Material for the left, right, front, and back surfaces of the road.", AbstractClassRep::FIELD_HideInInspectors); \
addProtectedField("SideMaterialAsset", TypeMaterialAssetId, Offset(mSideMaterialAssetId, MeshRoad), MeshRoad::_setSideMaterialAsset, & defaultProtectedGetFn, "Material for the left, right, front, and back surfaces of the road.");
INITPERSISTFIELD_MATERIALASSET(TopMaterial, MeshRoad, "Material for the upper surface of the road.");
INITPERSISTFIELD_MATERIALASSET(BottomMaterial, MeshRoad, "Material for the bottom surface of the road.");
INITPERSISTFIELD_MATERIALASSET(SideMaterial, MeshRoad, "Material for the side surface of the road.");
addField( "textureLength", TypeF32, Offset( mTextureLength, MeshRoad ),
"The length in meters of textures mapped to the MeshRoad." );
@ -1421,9 +1416,9 @@ U32 MeshRoad::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
stream->writeAffineTransform( mObjToWorld );
// Write Materials
packMaterialAsset(con, TopMaterial);
packMaterialAsset(con, BottomMaterial);
packMaterialAsset(con, SideMaterial);
PACK_MATERIALASSET(con, TopMaterial);
PACK_MATERIALASSET(con, BottomMaterial);
PACK_MATERIALASSET(con, SideMaterial);
stream->write( mTextureLength );
stream->write( mBreakAngle );
@ -1520,9 +1515,9 @@ void MeshRoad::unpackUpdate(NetConnection * con, BitStream * stream)
stream->readAffineTransform(&ObjectMatrix);
Parent::setTransform(ObjectMatrix);
unpackMaterialAsset(con, TopMaterial);
unpackMaterialAsset(con, BottomMaterial);
unpackMaterialAsset(con, SideMaterial);
UNPACK_MATERIALASSET(con, TopMaterial);
UNPACK_MATERIALASSET(con, BottomMaterial);
UNPACK_MATERIALASSET(con, SideMaterial);
if ( isProperlyAdded() )
_initMaterial();

View file

@ -621,9 +621,14 @@ protected:
GFXVertexBufferHandle<GFXVertexPNTT> mVB[SurfaceCount];
GFXPrimitiveBufferHandle mPB[SurfaceCount];
DECLARE_NET_MATERIALASSET(MeshRoad, TopMaterial, MeshRoadMask);
DECLARE_NET_MATERIALASSET(MeshRoad, BottomMaterial, MeshRoadMask);
DECLARE_NET_MATERIALASSET(MeshRoad, SideMaterial, MeshRoadMask);
DECLARE_MATERIALASSET(MeshRoad, TopMaterial);
DECLARE_MATERIALASSET_NET_SETGET(MeshRoad, TopMaterial, MeshRoadMask);
DECLARE_MATERIALASSET(MeshRoad, BottomMaterial);
DECLARE_MATERIALASSET_NET_SETGET(MeshRoad, BottomMaterial, MeshRoadMask);
DECLARE_MATERIALASSET(MeshRoad, SideMaterial);
DECLARE_MATERIALASSET_NET_SETGET(MeshRoad, SideMaterial, MeshRoadMask);
//String mMaterialName[SurfaceCount];
SimObjectPtr<Material> mMaterial[SurfaceCount];

View file

@ -165,8 +165,11 @@ ScatterSky::ScatterSky()
mNightColor.set( 0.0196078f, 0.0117647f, 0.109804f, 1.0f );
mNightFogColor = mNightColor;
mUseNightCubemap = false;
mNightCubemapName = StringTable->EmptyString();
mSunSize = 1.0f;
INIT_MATERIALASSET(MoonMat);
mMoonMatInst = NULL;
mNetFlags.set( Ghostable | ScopeAlways );
@ -407,8 +410,7 @@ void ScatterSky::initPersistFields()
addField( "moonEnabled", TypeBool, Offset( mMoonEnabled, ScatterSky ),
"Enable or disable rendering of the moon sprite during night." );
addField( "moonMat", TypeMaterialName, Offset( mMoonMatName, ScatterSky ),
"Material for the moon sprite." );
INITPERSISTFIELD_MATERIALASSET(MoonMat, ScatterSky, "Material for the moon sprite.");
addField( "moonScale", TypeF32, Offset( mMoonScale, ScatterSky ),
"Controls size the moon sprite renders, specified as a fractional amount of the screen height." );
@ -500,11 +502,13 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
}
stream->writeFlag( mMoonEnabled );
stream->write( mMoonMatName );
PACK_MATERIALASSET(con, MoonMat);
stream->write( mMoonScale );
stream->write( mMoonTint );
stream->writeFlag( mUseNightCubemap );
stream->write( mNightCubemapName );
stream->writeString( mNightCubemapName );
stream->write( mMoonAzimuth );
stream->write( mMoonElevation );
@ -612,11 +616,13 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
mFlareData = NULL;
mMoonEnabled = stream->readFlag();
stream->read( &mMoonMatName );
UNPACK_MATERIALASSET(con, MoonMat);
stream->read( &mMoonScale );
stream->read( &mMoonTint );
mUseNightCubemap = stream->readFlag();
stream->read( &mNightCubemapName );
mNightCubemapName = stream->readSTString();
stream->read( &mMoonAzimuth );
stream->read( &mMoonElevation );
@ -832,8 +838,10 @@ void ScatterSky::_initMoon()
if ( mMoonMatInst )
SAFE_DELETE( mMoonMatInst );
if ( mMoonMatName.isNotEmpty() )
mMoonMatInst = MATMGR->createMatInstance( mMoonMatName, MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPCT>() );
if (mMoonMatAsset.notNull())
{
mMoonMatInst = MATMGR->createMatInstance(mMoonMatAsset->getMaterialDefinitionName(), MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPCT>());
}
}
void ScatterSky::_initCurves()

View file

@ -51,6 +51,8 @@
#include "math/util/tResponseCurve.h"
#endif
#include "T3D/assets/MaterialAsset.h"
class LightInfo;
class SphereMesh;
class TimeOfDay;
@ -208,13 +210,16 @@ protected:
F32 mFlareScale;
bool mMoonEnabled;
String mMoonMatName;
DECLARE_MATERIALASSET(ScatterSky, MoonMat);
DECLARE_MATERIALASSET_NET_SETGET(ScatterSky, MoonMat, UpdateMask);
BaseMatInstance *mMoonMatInst;
F32 mMoonScale;
LinearColorF mMoonTint;
VectorF mMoonLightDir;
CubemapData *mNightCubemap;
String mNightCubemapName;
StringTableEntry mNightCubemapName;
bool mUseNightCubemap;
MatrixSet *mMatrixSet;

View file

@ -56,7 +56,7 @@ SkyBox::SkyBox()
mTypeMask |= EnvironmentObjectType | StaticObjectType;
mNetFlags.set(Ghostable | ScopeAlways);
mMatName = "";
INIT_MATERIALASSET(Material);
mMatInstance = NULL;
mIsVBDirty = false;
@ -116,8 +116,7 @@ void SkyBox::initPersistFields()
{
addGroup( "Sky Box" );
addField( "material", TypeMaterialName, Offset( mMatName, SkyBox ),
"The name of a cubemap material for the sky box." );
INITPERSISTFIELD_MATERIALASSET(Material, SkyBox, "The name of a cubemap material for the sky box.");
addField( "drawBottom", TypeBool, Offset( mDrawBottom, SkyBox ),
"If false the bottom of the skybox is not rendered." );
@ -139,8 +138,9 @@ void SkyBox::inspectPostApply()
U32 SkyBox::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
{
U32 retMask = Parent::packUpdate( conn, mask, stream );
stream->write( mMatName );
PACK_MATERIALASSET(conn, Material);
stream->writeFlag( mDrawBottom );
stream->write( mFogBandHeight );
@ -151,11 +151,10 @@ void SkyBox::unpackUpdate( NetConnection *conn, BitStream *stream )
{
Parent::unpackUpdate( conn, stream );
String tmpString( "" );
stream->read( &tmpString );
if ( !tmpString.equal( mMatName, String::NoCase ) )
StringTableEntry oldMatName = getMaterial();
UNPACK_MATERIALASSET(conn, Material);
if (oldMatName != getMaterial())
{
mMatName = tmpString;
_updateMaterial();
}
@ -620,16 +619,15 @@ void SkyBox::_initMaterial()
void SkyBox::_updateMaterial()
{
if ( mMatName.isEmpty() )
return;
Material *pMat = NULL;
if ( !Sim::findObject( mMatName, pMat ) )
Con::printf( "SkyBox::_updateMaterial, failed to find Material of name %s!", mMatName.c_str() );
else if ( isProperlyAdded() )
if (!getMaterialResource().isValid())
{
mMaterial = pMat;
_initMaterial();
//If our materialDef isn't valid, try setting it
_setMaterial(getMaterial());
}
if (getMaterialResource().isValid())
{
_initMaterial();
}
}

View file

@ -47,6 +47,8 @@
#include "gfx/gfxPrimitiveBuffer.h"
#endif
#include "T3D/assets/MaterialAsset.h"
GFXDeclareVertexFormat( GFXSkyVertex )
{
@ -98,13 +100,13 @@ public:
protected:
// Material
String mMatName;
// Material
DECLARE_MATERIALASSET(SkyBox, Material);
DECLARE_MATERIALASSET_NET_SETGET(SkyBox, Material, -1);
BaseMatInstance *mMatInstance;
SkyMatParams mMatParamHandle;
SimObjectPtr<Material> mMaterial;
GFXVertexBufferHandle<GFXVertexPNT> mVB;
GFXVertexBufferHandle<GFXVertexPC> mFogBandVB;

View file

@ -90,6 +90,8 @@ Sun::Sun()
mCoronaUseLightColor = true;
mCoronaMatInst = NULL;
INIT_MATERIALASSET(CoronaMaterial);
mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16));
constructInPlace(mMatrixSet);
@ -177,8 +179,7 @@ void Sun::initPersistFields()
addField( "coronaEnabled", TypeBool, Offset( mCoronaEnabled, Sun ),
"Enable or disable rendering of the corona sprite." );
addField( "coronaMaterial", TypeMaterialName, Offset( mCoronaMatName, Sun ),
"Texture for the corona sprite." );
INITPERSISTFIELD_MATERIALASSET(CoronaMaterial, Sun, "Material for the corona sprite.");
addField( "coronaScale", TypeF32, Offset( mCoronaScale, Sun ),
"Controls size the corona sprite renders, specified as a fractional amount of the screen height." );
@ -238,7 +239,9 @@ U32 Sun::packUpdate(NetConnection *conn, U32 mask, BitStream *stream )
}
stream->writeFlag( mCoronaEnabled );
stream->write( mCoronaMatName );
PACK_MATERIALASSET(conn, CoronaMaterial);
stream->write( mCoronaScale );
stream->write( mCoronaTint );
stream->writeFlag( mCoronaUseLightColor );
@ -282,7 +285,9 @@ void Sun::unpackUpdate( NetConnection *conn, BitStream *stream )
mFlareData = NULL;
mCoronaEnabled = stream->readFlag();
stream->read( &mCoronaMatName );
UNPACK_MATERIALASSET(conn, CoronaMaterial);
stream->read( &mCoronaScale );
stream->read( &mCoronaTint );
mCoronaUseLightColor = stream->readFlag();
@ -446,8 +451,10 @@ void Sun::_initCorona()
SAFE_DELETE( mCoronaMatInst );
if ( mCoronaMatName.isNotEmpty() )
mCoronaMatInst = MATMGR->createMatInstance( mCoronaMatName, MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPCT>() );
if (mCoronaMaterialAsset.notNull())
{
mCoronaMatInst = MATMGR->createMatInstance(mCoronaMaterialAsset->getMaterialDefinitionName(), MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPCT>());
}
}
void Sun::_renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat )

View file

@ -36,6 +36,8 @@
#include "T3D/lightFlareData.h"
#endif
#include "T3D/assets/MaterialAsset.h"
class TimeOfDay;
class MatrixSet;
@ -75,7 +77,10 @@ protected:
F32 mFlareScale;
bool mCoronaEnabled;
String mCoronaMatName;
DECLARE_MATERIALASSET(Sun, CoronaMaterial);
DECLARE_MATERIALASSET_NET_SETGET(Sun, CoronaMaterial, UpdateMask);
BaseMatInstance *mCoronaMatInst;
MatrixSet *mMatrixSet;
F32 mCoronaScale;

View file

@ -259,6 +259,12 @@ WaterObject::WaterObject()
mMatrixSet = reinterpret_cast<MatrixSet *>(dMalloc_aligned(sizeof(MatrixSet), 16));
constructInPlace(mMatrixSet);
INIT_IMAGEASSET(RippleTex);
INIT_IMAGEASSET(FoamTex);
INIT_IMAGEASSET(DepthGradientTex);
mCubemapName = StringTable->EmptyString();
}
WaterObject::~WaterObject()
@ -292,8 +298,8 @@ void WaterObject::initPersistFields()
addField( "overallWaveMagnitude", TypeF32, Offset( mOverallWaveMagnitude, WaterObject ), "Master variable affecting entire body"
" of water's undulation" );
addField( "rippleTex", TypeImageFilename, Offset( mRippleTexName, WaterObject ), "Normal map used to simulate small surface ripples" );
INITPERSISTFIELD_IMAGEASSET(RippleTex, WaterObject, "Normal map used to simulate small surface ripples");
addArray( "Ripples (texture animation)", MAX_WAVES );
@ -307,7 +313,7 @@ void WaterObject::initPersistFields()
addField( "overallRippleMagnitude", TypeF32, Offset( mOverallRippleMagnitude, WaterObject ), "Master variable affecting entire surface");
addField( "foamTex", TypeImageFilename, Offset( mFoamTexName, WaterObject ), "Diffuse texture for foam in shallow water (advanced lighting only)" );
INITPERSISTFIELD_IMAGEASSET(FoamTex, WaterObject, "Diffuse texture for foam in shallow water (advanced lighting only)");
addArray( "Foam", MAX_FOAM );
@ -358,8 +364,9 @@ void WaterObject::initPersistFields()
endGroup( "Underwater Fogging" );
addGroup( "Misc" );
addField( "depthGradientTex", TypeImageFilename, Offset( mDepthGradientTexName, WaterObject ), "1D texture defining the base water color by depth" );
INITPERSISTFIELD_IMAGEASSET(DepthGradientTex, WaterObject, "1D texture defining the base water color by depth");
addField( "depthGradientMax", TypeF32, Offset( mDepthGradientMax, WaterObject ), "Depth in world units, the max range of the color gradient texture." );
endGroup( "Misc" );
@ -539,10 +546,11 @@ U32 WaterObject::packUpdate( NetConnection * conn, U32 mask, BitStream *stream )
if ( stream->writeFlag( mask & TextureMask ) )
{
stream->write( mRippleTexName );
stream->write( mDepthGradientTexName );
stream->write( mFoamTexName );
stream->write( mCubemapName );
PACK_IMAGEASSET(conn, RippleTex);
PACK_IMAGEASSET(conn, DepthGradientTex);
PACK_IMAGEASSET(conn, FoamTex);
stream->writeString( mCubemapName );
}
if( stream->writeFlag( mask & SoundMask ) )
@ -660,10 +668,11 @@ void WaterObject::unpackUpdate( NetConnection * conn, BitStream *stream )
// TextureMask
if ( stream->readFlag() )
{
stream->read( &mRippleTexName );
stream->read( &mDepthGradientTexName );
stream->read( &mFoamTexName );
stream->read( &mCubemapName );
UNPACK_IMAGEASSET(conn, RippleTex);
UNPACK_IMAGEASSET(conn, DepthGradientTex);
UNPACK_IMAGEASSET(conn, FoamTex);
mCubemapName = stream->readSTString();
if ( isProperlyAdded() )
initTextures();
@ -1161,25 +1170,10 @@ bool WaterObject::initMaterial( S32 idx )
void WaterObject::initTextures()
{
if ( mRippleTexName.isNotEmpty() )
mRippleTex.set( mRippleTexName, &GFXStaticTextureProfile, "WaterObject::mRippleTex" );
if ( mRippleTex.isNull() )
mRippleTex.set( GFXTextureManager::getWarningTexturePath(), &GFXStaticTextureProfile, "WaterObject::mRippleTex" );
if ( mDepthGradientTexName.isNotEmpty() )
mDepthGradientTex.set( mDepthGradientTexName, &GFXStaticTextureSRGBProfile, "WaterObject::mDepthGradientTex" );
if ( mDepthGradientTex.isNull() )
mDepthGradientTex.set( GFXTextureManager::getWarningTexturePath(), &GFXStaticTextureSRGBProfile, "WaterObject::mDepthGradientTex" );
if ( mNamedDepthGradTex.isRegistered() )
mNamedDepthGradTex.setTexture( mDepthGradientTex );
if ( mFoamTexName.isNotEmpty() )
mFoamTex.set( mFoamTexName, &GFXStaticTextureSRGBProfile, "WaterObject::mFoamTex" );
if ( mFoamTex.isNull() )
mFoamTex.set( GFXTextureManager::getWarningTexturePath(), &GFXStaticTextureSRGBProfile, "WaterObject::mFoamTex" );
if ( mCubemapName.isNotEmpty() )
if ( mCubemapName != StringTable->EmptyString() )
Sim::findObject( mCubemapName, mCubemap );
if ( mCubemap )
mCubemap->createMap();

View file

@ -45,6 +45,8 @@
#include "materials/matTextureTarget.h"
#endif
#include "T3D/assets/ImageAsset.h"
GFXDeclareVertexFormat( GFXWaterVertex )
{
Point3F point;
@ -200,6 +202,10 @@ protected:
/// Callback used internally when smDisableTrueReflections changes.
void _onDisableTrueRelfections();
void onRippleTexChanged() {}
void onFoamTexChanged() {}
void onDepthGradientTexChanged() {}
protected:
static bool _setFullReflect( void *object, const char *index, const char *data );
@ -266,10 +272,14 @@ protected:
F32 mDepthGradientMax;
// Other textures
String mRippleTexName;
String mFoamTexName;
String mCubemapName;
String mDepthGradientTexName;
DECLARE_IMAGEASSET(WaterObject, RippleTex, onRippleTexChanged, GFXStaticTextureProfile);
DECLARE_IMAGEASSET_NET_SETGET(WaterObject, RippleTex, TextureMask);
DECLARE_IMAGEASSET(WaterObject, FoamTex, onFoamTexChanged, GFXStaticTextureSRGBProfile);
DECLARE_IMAGEASSET_NET_SETGET(WaterObject, FoamTex, TextureMask);
DECLARE_IMAGEASSET(WaterObject, DepthGradientTex, onDepthGradientTexChanged, GFXStaticTextureSRGBProfile);
DECLARE_IMAGEASSET_NET_SETGET(WaterObject, DepthGradientTex, TextureMask);
StringTableEntry mCubemapName;
// Sound
SFXAmbience* mSoundAmbience;
@ -309,9 +319,6 @@ protected:
WaterMatParams mMatParamHandles[NumMatTypes];
bool mUnderwater;
GFXStateBlockRef mUnderwaterSB;
GFXTexHandle mRippleTex;
GFXTexHandle mDepthGradientTex;
GFXTexHandle mFoamTex;
CubemapData *mCubemap;
MatrixSet *mMatrixSet;
NamedTexTarget mNamedDepthGradTex;