mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Adds support for multiple textures used in the strike rendering per @RichardsGameStudio's help.
This commit is contained in:
parent
c7b041f545
commit
ec8b657b71
4 changed files with 22 additions and 2 deletions
|
|
@ -243,6 +243,7 @@ LightningData::LightningData()
|
||||||
dMemset( strikeTextureNames, 0, sizeof( strikeTextureNames ) );
|
dMemset( strikeTextureNames, 0, sizeof( strikeTextureNames ) );
|
||||||
dMemset( strikeTextures, 0, sizeof( strikeTextures ) );
|
dMemset( strikeTextures, 0, sizeof( strikeTextures ) );
|
||||||
dMemset( thunderSounds, 0, sizeof( thunderSounds ) );
|
dMemset( thunderSounds, 0, sizeof( thunderSounds ) );
|
||||||
|
mNumStrikeTextures = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LightningData::~LightningData()
|
LightningData::~LightningData()
|
||||||
|
|
@ -297,10 +298,14 @@ bool LightningData::preload(bool server, String &errorStr)
|
||||||
if( !sfxResolve( &strikeSound, sfxErrorStr ) )
|
if( !sfxResolve( &strikeSound, sfxErrorStr ) )
|
||||||
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str());
|
Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str());
|
||||||
|
|
||||||
|
mNumStrikeTextures = 0;
|
||||||
for (U32 i = 0; i < MaxTextures; i++)
|
for (U32 i = 0; i < MaxTextures; i++)
|
||||||
{
|
{
|
||||||
if (strikeTextureNames[i][0])
|
if (strikeTextureNames[i][0])
|
||||||
|
{
|
||||||
strikeTextures[i] = GFXTexHandle(strikeTextureNames[i], &GFXDefaultStaticDiffuseProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, i, __LINE__));
|
strikeTextures[i] = GFXTexHandle(strikeTextureNames[i], &GFXDefaultStaticDiffuseProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, i, __LINE__));
|
||||||
|
mNumStrikeTextures++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,6 +322,9 @@ void LightningData::packData(BitStream* stream)
|
||||||
U32 i;
|
U32 i;
|
||||||
for (i = 0; i < MaxThunders; i++)
|
for (i = 0; i < MaxThunders; i++)
|
||||||
sfxWrite( stream, thunderSounds[ i ] );
|
sfxWrite( stream, thunderSounds[ i ] );
|
||||||
|
|
||||||
|
stream->writeInt(mNumStrikeTextures, 4);
|
||||||
|
|
||||||
for (i = 0; i < MaxTextures; i++) {
|
for (i = 0; i < MaxTextures; i++) {
|
||||||
stream->writeString(strikeTextureNames[i]);
|
stream->writeString(strikeTextureNames[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -331,6 +339,9 @@ void LightningData::unpackData(BitStream* stream)
|
||||||
U32 i;
|
U32 i;
|
||||||
for (i = 0; i < MaxThunders; i++)
|
for (i = 0; i < MaxThunders; i++)
|
||||||
sfxRead( stream, &thunderSounds[ i ] );
|
sfxRead( stream, &thunderSounds[ i ] );
|
||||||
|
|
||||||
|
mNumStrikeTextures = stream->readInt(4);
|
||||||
|
|
||||||
for (i = 0; i < MaxTextures; i++) {
|
for (i = 0; i < MaxTextures; i++) {
|
||||||
strikeTextureNames[i] = stream->readSTString();
|
strikeTextureNames[i] = stream->readSTString();
|
||||||
}
|
}
|
||||||
|
|
@ -479,7 +490,7 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base
|
||||||
desc.setCullMode(GFXCullNone);
|
desc.setCullMode(GFXCullNone);
|
||||||
desc.zWriteEnable = false;
|
desc.zWriteEnable = false;
|
||||||
|
|
||||||
if (mDataBlock->strikeTextures[0].isValid())
|
if (mDataBlock->mNumStrikeTextures != 0)
|
||||||
{
|
{
|
||||||
desc.samplersDefined = true;
|
desc.samplersDefined = true;
|
||||||
desc.samplers[0].magFilter = GFXTextureFilterLinear;
|
desc.samplers[0].magFilter = GFXTextureFilterLinear;
|
||||||
|
|
@ -498,8 +509,14 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base
|
||||||
Strike* walk = mStrikeListHead;
|
Strike* walk = mStrikeListHead;
|
||||||
while (walk != NULL)
|
while (walk != NULL)
|
||||||
{
|
{
|
||||||
if (mDataBlock->strikeTextures[0].isValid())
|
if (mDataBlock->mNumStrikeTextures > 1)
|
||||||
|
{
|
||||||
|
GFX->setTexture(0, mDataBlock->strikeTextures[sgLightningRand.randI(0, mDataBlock->mNumStrikeTextures - 1)]);
|
||||||
|
}
|
||||||
|
else if (mDataBlock->mNumStrikeTextures > 0)
|
||||||
|
{
|
||||||
GFX->setTexture(0, mDataBlock->strikeTextures[0]);
|
GFX->setTexture(0, mDataBlock->strikeTextures[0]);
|
||||||
|
}
|
||||||
|
|
||||||
for( U32 i=0; i<3; i++ )
|
for( U32 i=0; i<3; i++ )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ class LightningData : public GameBaseData
|
||||||
|
|
||||||
GFXTexHandle strikeTextures[MaxTextures];
|
GFXTexHandle strikeTextures[MaxTextures];
|
||||||
U32 numThunders;
|
U32 numThunders;
|
||||||
|
U32 mNumStrikeTextures;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onAdd();
|
bool onAdd();
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ datablock LightningData(DefaultStorm)
|
||||||
thunderSounds[1] = ThunderCrash2Sound;
|
thunderSounds[1] = ThunderCrash2Sound;
|
||||||
thunderSounds[2] = ThunderCrash3Sound;
|
thunderSounds[2] = ThunderCrash3Sound;
|
||||||
thunderSounds[3] = ThunderCrash4Sound;
|
thunderSounds[3] = ThunderCrash4Sound;
|
||||||
|
|
||||||
|
strikeTextures[0] = "art/environment/lightning";
|
||||||
};
|
};
|
||||||
|
|
||||||
datablock ReflectorDesc( DefaultCubeDesc )
|
datablock ReflectorDesc( DefaultCubeDesc )
|
||||||
|
|
|
||||||
BIN
Templates/Full/game/art/environment/lightning.png
Normal file
BIN
Templates/Full/game/art/environment/lightning.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Loading…
Add table
Add a link
Reference in a new issue