mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Merge branch 'development' into defineconsolemethod
Conflicts: Engine/source/materials/materialDefinition.cpp
This commit is contained in:
commit
ae284a89ec
129 changed files with 3742 additions and 1038 deletions
349
Engine/source/T3D/accumulationVolume.cpp
Normal file
349
Engine/source/T3D/accumulationVolume.cpp
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/accumulationVolume.h"
|
||||
|
||||
#include "scene/sceneManager.h"
|
||||
#include "scene/sceneRenderState.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "gfx/sim/debugDraw.h"
|
||||
#include "util/tempAlloc.h"
|
||||
#include "materials/materialDefinition.h"
|
||||
#include "materials/materialManager.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "materials/matInstance.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "console/console.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "gfx/gfxTextureHandle.h"
|
||||
#include "scene/sceneContainer.h"
|
||||
|
||||
#include "math/mPolyhedron.impl.h"
|
||||
|
||||
Vector< SimObjectPtr<SceneObject> > AccumulationVolume::smAccuObjects;
|
||||
Vector< SimObjectPtr<AccumulationVolume> > AccumulationVolume::smAccuVolumes;
|
||||
|
||||
//#define DEBUG_DRAW
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1( AccumulationVolume );
|
||||
|
||||
ConsoleDocClass( AccumulationVolume,
|
||||
"@brief An invisible shape that allow objects within it to have an accumulation map.\n\n"
|
||||
|
||||
"AccumulationVolume is used to add additional realism to a scene. It's main use is in outdoor scenes "
|
||||
" where objects could benefit from overlaying environment accumulation textures such as sand, snow, etc.\n\n"
|
||||
|
||||
"Objects within the volume must have accumulation enabled in their material. \n\n"
|
||||
|
||||
"@ingroup enviroMisc"
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AccumulationVolume::AccumulationVolume()
|
||||
: mTransformDirty( true ),
|
||||
mSilhouetteExtractor( mPolyhedron )
|
||||
{
|
||||
VECTOR_SET_ASSOCIATION( mWSPoints );
|
||||
VECTOR_SET_ASSOCIATION( mVolumeQueryList );
|
||||
|
||||
//mObjectFlags.set( VisualOccluderFlag );
|
||||
|
||||
mNetFlags.set( Ghostable | ScopeAlways );
|
||||
mObjScale.set( 1.f, 1.f, 1.f );
|
||||
mObjBox.set(
|
||||
Point3F( -0.5f, -0.5f, -0.5f ),
|
||||
Point3F( 0.5f, 0.5f, 0.5f )
|
||||
);
|
||||
|
||||
mObjToWorld.identity();
|
||||
mWorldToObj.identity();
|
||||
|
||||
// Accumulation Texture.
|
||||
mTextureName = "";
|
||||
mAccuTexture = NULL;
|
||||
|
||||
resetWorldBox();
|
||||
}
|
||||
|
||||
AccumulationVolume::~AccumulationVolume()
|
||||
{
|
||||
mAccuTexture = NULL;
|
||||
}
|
||||
|
||||
void AccumulationVolume::initPersistFields()
|
||||
{
|
||||
addProtectedField( "texture", TypeStringFilename, Offset( mTextureName, AccumulationVolume ),
|
||||
&_setTexture, &defaultProtectedGetFn, "Accumulation texture." );
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::consoleInit()
|
||||
{
|
||||
// Disable rendering of occlusion volumes by default.
|
||||
getStaticClassRep()->mIsRenderEnabled = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AccumulationVolume::onAdd()
|
||||
{
|
||||
if( !Parent::onAdd() )
|
||||
return false;
|
||||
|
||||
// Prepare some client side things.
|
||||
if ( isClientObject() )
|
||||
{
|
||||
smAccuVolumes.push_back(this);
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
// Set up the silhouette extractor.
|
||||
mSilhouetteExtractor = SilhouetteExtractorType( mPolyhedron );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccumulationVolume::onRemove()
|
||||
{
|
||||
if ( isClientObject() )
|
||||
{
|
||||
smAccuVolumes.remove(this);
|
||||
refreshVolumes();
|
||||
}
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::_renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat )
|
||||
{
|
||||
Parent::_renderObject( ri, state, overrideMat );
|
||||
|
||||
#ifdef DEBUG_DRAW
|
||||
if( state->isDiffusePass() )
|
||||
DebugDrawer::get()->drawPolyhedronDebugInfo( mPolyhedron, getTransform(), getScale() );
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::setTransform( const MatrixF& mat )
|
||||
{
|
||||
Parent::setTransform( mat );
|
||||
mTransformDirty = true;
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::buildSilhouette( const SceneCameraState& cameraState, Vector< Point3F >& outPoints )
|
||||
{
|
||||
// Extract the silhouette of the polyhedron. This works differently
|
||||
// depending on whether we project orthogonally or in perspective.
|
||||
|
||||
TempAlloc< U32 > indices( mPolyhedron.getNumPoints() );
|
||||
U32 numPoints;
|
||||
|
||||
if( cameraState.getFrustum().isOrtho() )
|
||||
{
|
||||
// Transform the view direction into object space.
|
||||
|
||||
Point3F osViewDir;
|
||||
getWorldTransform().mulV( cameraState.getViewDirection(), &osViewDir );
|
||||
|
||||
// And extract the silhouette.
|
||||
|
||||
SilhouetteExtractorOrtho< PolyhedronType > extractor( mPolyhedron );
|
||||
numPoints = extractor.extractSilhouette( osViewDir, indices, indices.size );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a transform to go from view space to object space.
|
||||
|
||||
MatrixF camView( true );
|
||||
camView.scale( Point3F( 1.0f / getScale().x, 1.0f / getScale().y, 1.0f / getScale().z ) );
|
||||
camView.mul( getRenderWorldTransform() );
|
||||
camView.mul( cameraState.getViewWorldMatrix() );
|
||||
|
||||
// Do a perspective-correct silhouette extraction.
|
||||
|
||||
numPoints = mSilhouetteExtractor.extractSilhouette(
|
||||
camView,
|
||||
indices, indices.size );
|
||||
}
|
||||
|
||||
// If we haven't yet, transform the polyhedron's points
|
||||
// to world space.
|
||||
|
||||
if( mTransformDirty )
|
||||
{
|
||||
const U32 numPoints = mPolyhedron.getNumPoints();
|
||||
const PolyhedronType::PointType* points = getPolyhedron().getPoints();
|
||||
|
||||
mWSPoints.setSize( numPoints );
|
||||
for( U32 i = 0; i < numPoints; ++ i )
|
||||
{
|
||||
Point3F p = points[ i ];
|
||||
p.convolve( getScale() );
|
||||
getTransform().mulP( p, &mWSPoints[ i ] );
|
||||
}
|
||||
|
||||
mTransformDirty = false;
|
||||
}
|
||||
|
||||
// Now store the points.
|
||||
|
||||
outPoints.setSize( numPoints );
|
||||
for( U32 i = 0; i < numPoints; ++ i )
|
||||
outPoints[ i ] = mWSPoints[ indices[ i ] ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
U32 AccumulationVolume::packUpdate( NetConnection *connection, U32 mask, BitStream *stream )
|
||||
{
|
||||
U32 retMask = Parent::packUpdate( connection, mask, stream );
|
||||
|
||||
if (stream->writeFlag(mask & InitialUpdateMask))
|
||||
{
|
||||
stream->write( mTextureName );
|
||||
}
|
||||
|
||||
return retMask;
|
||||
}
|
||||
|
||||
void AccumulationVolume::unpackUpdate( NetConnection *connection, BitStream *stream )
|
||||
{
|
||||
Parent::unpackUpdate( connection, stream );
|
||||
|
||||
if (stream->readFlag())
|
||||
{
|
||||
stream->read( &mTextureName );
|
||||
setTexture(mTextureName);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::inspectPostApply()
|
||||
{
|
||||
Parent::inspectPostApply();
|
||||
setMaskBits(U32(-1) );
|
||||
}
|
||||
|
||||
void AccumulationVolume::setTexture( const String& name )
|
||||
{
|
||||
mTextureName = name;
|
||||
if ( isClientObject() && mTextureName.isNotEmpty() )
|
||||
{
|
||||
mAccuTexture.set(mTextureName, &GFXDefaultStaticDiffuseProfile, "AccumulationVolume::mAccuTexture");
|
||||
if ( mAccuTexture.isNull() )
|
||||
Con::warnf( "AccumulationVolume::setTexture - Unable to load texture: %s", mTextureName.c_str() );
|
||||
}
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Static Functions
|
||||
//-----------------------------------------------------------------------------
|
||||
bool AccumulationVolume::_setTexture( void *object, const char *index, const char *data )
|
||||
{
|
||||
AccumulationVolume* volume = reinterpret_cast< AccumulationVolume* >( object );
|
||||
volume->setTexture( data );
|
||||
return false;
|
||||
}
|
||||
|
||||
void AccumulationVolume::refreshVolumes()
|
||||
{
|
||||
// This function tests each accumulation object to
|
||||
// see if it's within the bounds of an accumulation
|
||||
// volume. If so, it will pass on the accumulation
|
||||
// texture of the volume to the object.
|
||||
|
||||
// This function should only be called when something
|
||||
// global like change of volume or material occurs.
|
||||
|
||||
// Clear old data.
|
||||
for (S32 n = 0; n < smAccuObjects.size(); ++n)
|
||||
{
|
||||
SimObjectPtr<SceneObject> object = smAccuObjects[n];
|
||||
if ( object.isValid() )
|
||||
object->mAccuTex = GFXTexHandle::ZERO;
|
||||
}
|
||||
|
||||
//
|
||||
for (S32 i = 0; i < smAccuVolumes.size(); ++i)
|
||||
{
|
||||
SimObjectPtr<AccumulationVolume> volume = smAccuVolumes[i];
|
||||
if ( volume.isNull() ) continue;
|
||||
|
||||
for (S32 n = 0; n < smAccuObjects.size(); ++n)
|
||||
{
|
||||
SimObjectPtr<SceneObject> object = smAccuObjects[n];
|
||||
if ( object.isNull() ) continue;
|
||||
|
||||
if ( volume->containsPoint(object->getPosition()) )
|
||||
object->mAccuTex = volume->mAccuTexture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Accumulation Object Management.
|
||||
void AccumulationVolume::addObject(SimObjectPtr<SceneObject> object)
|
||||
{
|
||||
smAccuObjects.push_back(object);
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
void AccumulationVolume::removeObject(SimObjectPtr<SceneObject> object)
|
||||
{
|
||||
smAccuObjects.remove(object);
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
void AccumulationVolume::updateObject(SceneObject* object)
|
||||
{
|
||||
// This function is called when an individual object
|
||||
// has been moved. Tests to see if it's in any of the
|
||||
// accumulation volumes.
|
||||
|
||||
// We use ZERO instead of NULL so the accumulation
|
||||
// texture will be updated in renderMeshMgr.
|
||||
object->mAccuTex = GFXTexHandle::ZERO;
|
||||
|
||||
for (S32 i = 0; i < smAccuVolumes.size(); ++i)
|
||||
{
|
||||
SimObjectPtr<AccumulationVolume> volume = smAccuVolumes[i];
|
||||
if ( volume.isNull() ) continue;
|
||||
|
||||
if ( volume->containsPoint(object->getPosition()) )
|
||||
object->mAccuTex = volume->mAccuTexture;
|
||||
}
|
||||
}
|
||||
104
Engine/source/T3D/accumulationVolume.h
Normal file
104
Engine/source/T3D/accumulationVolume.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _ACCUMULATIONVOLUME_H_
|
||||
#define _ACCUMULATIONVOLUME_H_
|
||||
|
||||
#ifndef _SCENEPOLYHEDRALSPACE_H_
|
||||
#include "scene/scenePolyhedralSpace.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MSILHOUETTEEXTRACTOR_H_
|
||||
#include "math/mSilhouetteExtractor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _GFXDEVICE_H_
|
||||
#include "gfx/gfxDevice.h"
|
||||
#endif
|
||||
|
||||
/// A volume in space that blocks visibility.
|
||||
class AccumulationVolume : public ScenePolyhedralSpace
|
||||
{
|
||||
public:
|
||||
|
||||
typedef ScenePolyhedralSpace Parent;
|
||||
|
||||
protected:
|
||||
|
||||
typedef SilhouetteExtractorPerspective< PolyhedronType > SilhouetteExtractorType;
|
||||
|
||||
/// Whether the volume's transform has changed and we need to recompute
|
||||
/// transform-based data.
|
||||
bool mTransformDirty;
|
||||
|
||||
/// World-space points of the volume's polyhedron.
|
||||
Vector< Point3F > mWSPoints;
|
||||
|
||||
/// Silhouette extractor when using perspective projections.
|
||||
SilhouetteExtractorType mSilhouetteExtractor;
|
||||
|
||||
mutable Vector< SceneObject* > mVolumeQueryList;
|
||||
|
||||
// Name (path) of the accumulation texture.
|
||||
String mTextureName;
|
||||
|
||||
// SceneSpace.
|
||||
virtual void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat );
|
||||
|
||||
public:
|
||||
|
||||
GFXTexHandle mAccuTexture;
|
||||
|
||||
AccumulationVolume();
|
||||
~AccumulationVolume();
|
||||
|
||||
// SimObject.
|
||||
DECLARE_CONOBJECT( AccumulationVolume );
|
||||
DECLARE_DESCRIPTION( "Allows objects in an area to have accumulation effect applied." );
|
||||
DECLARE_CATEGORY( "3D Scene" );
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
void inspectPostApply();
|
||||
void setTexture( const String& name );
|
||||
|
||||
// Static Functions.
|
||||
static void consoleInit();
|
||||
static void initPersistFields();
|
||||
static Vector< SimObjectPtr<SceneObject> > smAccuObjects;
|
||||
static Vector< SimObjectPtr<AccumulationVolume> > smAccuVolumes;
|
||||
static void addObject(SimObjectPtr<SceneObject> object);
|
||||
static void removeObject(SimObjectPtr<SceneObject> object);
|
||||
static void refreshVolumes();
|
||||
static bool _setTexture( void *object, const char *index, const char *data );
|
||||
static void updateObject(SceneObject* object);
|
||||
|
||||
// Network
|
||||
U32 packUpdate( NetConnection *, U32 mask, BitStream *stream );
|
||||
void unpackUpdate( NetConnection *, BitStream *stream );
|
||||
|
||||
// SceneObject.
|
||||
virtual void buildSilhouette( const SceneCameraState& cameraState, Vector< Point3F >& outPoints );
|
||||
virtual void setTransform( const MatrixF& mat );
|
||||
};
|
||||
|
||||
#endif // !_AccumulationVolume_H_
|
||||
|
|
@ -145,6 +145,7 @@ ParticleEmitterData::ParticleEmitterData()
|
|||
blendStyle = ParticleRenderInst::BlendUndefined;
|
||||
sortParticles = false;
|
||||
renderReflection = true;
|
||||
glow = false;
|
||||
reverseOrder = false;
|
||||
textureName = 0;
|
||||
textureHandle = 0;
|
||||
|
|
@ -289,6 +290,9 @@ void ParticleEmitterData::initPersistFields()
|
|||
addField( "renderReflection", TYPEID< bool >(), Offset(renderReflection, ParticleEmitterData),
|
||||
"Controls whether particles are rendered onto reflective surfaces like water." );
|
||||
|
||||
addField("glow", TYPEID< bool >(), Offset(glow, ParticleEmitterData),
|
||||
"If true, the particles are rendered to the glow buffer as well.");
|
||||
|
||||
//@}
|
||||
|
||||
endGroup( "ParticleEmitterData" );
|
||||
|
|
@ -356,6 +360,7 @@ void ParticleEmitterData::packData(BitStream* stream)
|
|||
}
|
||||
stream->writeFlag(highResOnly);
|
||||
stream->writeFlag(renderReflection);
|
||||
stream->writeFlag(glow);
|
||||
stream->writeInt( blendStyle, 4 );
|
||||
}
|
||||
|
||||
|
|
@ -418,6 +423,7 @@ void ParticleEmitterData::unpackData(BitStream* stream)
|
|||
}
|
||||
highResOnly = stream->readFlag();
|
||||
renderReflection = stream->readFlag();
|
||||
glow = stream->readFlag();
|
||||
blendStyle = stream->readInt( 4 );
|
||||
}
|
||||
|
||||
|
|
@ -909,6 +915,8 @@ void ParticleEmitter::prepRenderImage(SceneRenderState* state)
|
|||
|
||||
ri->blendStyle = mDataBlock->blendStyle;
|
||||
|
||||
ri->glow = mDataBlock->glow;
|
||||
|
||||
// use first particle's texture unless there is an emitter texture to override it
|
||||
if (mDataBlock->textureHandle)
|
||||
ri->diffuseTex = &*(mDataBlock->textureHandle);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ class ParticleEmitterData : public GameBaseData
|
|||
GFXTexHandle textureHandle; ///< Emitter texture handle from txrName
|
||||
bool highResOnly; ///< This particle system should not use the mixed-resolution particle rendering
|
||||
bool renderReflection; ///< Enables this emitter to render into reflection passes.
|
||||
bool glow; ///< Renders this emitter into the glow buffer.
|
||||
|
||||
bool reload();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -388,7 +388,9 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
|
|||
// Weight by field of view, objects directly in front
|
||||
// will be weighted 1, objects behind will be 0
|
||||
F32 dot = mDot(pos,camInfo->orientation);
|
||||
bool inFov = dot > camInfo->cosFov;
|
||||
|
||||
bool inFov = dot > camInfo->cosFov * 1.5f;
|
||||
|
||||
F32 wFov = inFov? 1.0f: 0;
|
||||
|
||||
// Weight by linear velocity parallel to the viewing plane
|
||||
|
|
@ -406,7 +408,7 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
|
|||
|
||||
// Weight by interest.
|
||||
F32 wInterest;
|
||||
if (getTypeMask() & PlayerObjectType)
|
||||
if (getTypeMask() & (PlayerObjectType || VehicleObjectType ))
|
||||
wInterest = 0.75f;
|
||||
else if (getTypeMask() & ProjectileObjectType)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@
|
|||
#ifndef _DYNAMIC_CONSOLETYPES_H_
|
||||
#include "console/dynamicTypes.h"
|
||||
#endif
|
||||
#ifndef __SCENEMANAGER_H__
|
||||
#include "scene/sceneManager.h"
|
||||
#define __SCENEMANAGER_H__
|
||||
#endif
|
||||
|
||||
class NetConnection;
|
||||
class ProcessList;
|
||||
|
|
|
|||
|
|
@ -226,6 +226,8 @@ GameConnection::GameConnection()
|
|||
mAddYawToAbsRot = false;
|
||||
mAddPitchToAbsRot = false;
|
||||
|
||||
mVisibleGhostDistance = 0.0f;
|
||||
|
||||
clearDisplayDevice();
|
||||
}
|
||||
|
||||
|
|
@ -240,6 +242,16 @@ GameConnection::~GameConnection()
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void GameConnection::setVisibleGhostDistance(F32 dist)
|
||||
{
|
||||
mVisibleGhostDistance = dist;
|
||||
}
|
||||
|
||||
F32 GameConnection::getVisibleGhostDistance()
|
||||
{
|
||||
return mVisibleGhostDistance;
|
||||
}
|
||||
|
||||
bool GameConnection::canRemoteCreate()
|
||||
{
|
||||
return true;
|
||||
|
|
@ -2199,3 +2211,21 @@ DefineEngineMethod( GameConnection, getControlSchemeAbsoluteRotation, bool, (),,
|
|||
{
|
||||
return object->getControlSchemeAbsoluteRotation();
|
||||
}
|
||||
|
||||
DefineEngineMethod( GameConnection, setVisibleGhostDistance, void, (F32 dist),,
|
||||
"@brief Sets the distance that objects around it will be ghosted. If set to 0, "
|
||||
"it may be defined by the LevelInfo.\n\n"
|
||||
"@dist - is the max distance\n\n"
|
||||
)
|
||||
{
|
||||
object->setVisibleGhostDistance(dist);
|
||||
}
|
||||
|
||||
DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),,
|
||||
"@brief Gets the distance that objects around the connection will be ghosted.\n\n"
|
||||
|
||||
"@return S32 of distance.\n\n"
|
||||
)
|
||||
{
|
||||
return object->getVisibleGhostDistance();
|
||||
}
|
||||
|
|
@ -72,6 +72,8 @@ private:
|
|||
|
||||
U32 mMissionCRC; // crc of the current mission file from the server
|
||||
|
||||
F32 mVisibleGhostDistance;
|
||||
|
||||
private:
|
||||
U32 mLastControlRequestTime;
|
||||
S32 mDataBlockModifiedKey;
|
||||
|
|
@ -155,6 +157,9 @@ public:
|
|||
|
||||
bool canRemoteCreate();
|
||||
|
||||
void setVisibleGhostDistance(F32 dist);
|
||||
F32 getVisibleGhostDistance();
|
||||
|
||||
private:
|
||||
/// @name Connection State
|
||||
/// This data is set with setConnectArgs() and setJoinPassword(), and
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
#include "console/engineAPI.h"
|
||||
#include "math/mathIO.h"
|
||||
|
||||
#include "torqueConfig.h"
|
||||
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(LevelInfo);
|
||||
|
||||
|
|
@ -77,6 +79,7 @@ static SFXAmbience sDefaultAmbience;
|
|||
LevelInfo::LevelInfo()
|
||||
: mNearClip( 0.1f ),
|
||||
mVisibleDistance( 1000.0f ),
|
||||
mVisibleGhostDistance ( 0 ),
|
||||
mDecalBias( 0.0015f ),
|
||||
mCanvasClearColor( 255, 0, 255, 255 ),
|
||||
mSoundAmbience( NULL ),
|
||||
|
|
@ -113,7 +116,8 @@ void LevelInfo::initPersistFields()
|
|||
addGroup( "Visibility" );
|
||||
|
||||
addField( "nearClip", TypeF32, Offset( mNearClip, LevelInfo ), "Closest distance from the camera's position to render the world." );
|
||||
addField( "visibleDistance", TypeF32, Offset( mVisibleDistance, LevelInfo ), "Furthest distance fromt he camera's position to render the world." );
|
||||
addField( "visibleDistance", TypeF32, Offset( mVisibleDistance, LevelInfo ), "Furthest distance from the camera's position to render the world." );
|
||||
addField( "visibleGhostDistance", TypeF32, Offset( mVisibleGhostDistance, LevelInfo ), "Furthest distance from the camera's position to render players. Defaults to visibleDistance." );
|
||||
addField( "decalBias", TypeF32, Offset( mDecalBias, LevelInfo ),
|
||||
"NearPlane bias used when rendering Decal and DecalRoad. This should be tuned to the visibleDistance in your level." );
|
||||
|
||||
|
|
@ -300,6 +304,7 @@ void LevelInfo::_updateSceneGraph()
|
|||
|
||||
scene->setNearClip( mNearClip );
|
||||
scene->setVisibleDistance( mVisibleDistance );
|
||||
scene->setVisibleGhostDistance( mVisibleGhostDistance );
|
||||
|
||||
gDecalBias = mDecalBias;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
#include "sfx/sfxCommon.h"
|
||||
#endif
|
||||
|
||||
|
||||
class SFXAmbience;
|
||||
class SFXSoundscape;
|
||||
|
||||
|
|
@ -55,6 +54,8 @@ class LevelInfo : public NetObject
|
|||
|
||||
F32 mVisibleDistance;
|
||||
|
||||
F32 mVisibleGhostDistance;
|
||||
|
||||
F32 mDecalBias;
|
||||
|
||||
ColorI mCanvasClearColor;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include "materials/materialFeatureData.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "T3D/accumulationVolume.h"
|
||||
|
||||
using namespace Torque;
|
||||
|
||||
|
|
@ -198,10 +199,10 @@ void TSStatic::initPersistFields()
|
|||
endGroup("Collision");
|
||||
|
||||
addGroup( "AlphaFade" );
|
||||
addField( "Alpha Fade Enable", TypeBool, Offset(mUseAlphaFade, TSStatic), "Turn on/off Alpha Fade" );
|
||||
addField( "Alpha Fade Start", TypeF32, Offset(mAlphaFadeStart, TSStatic), "Distance of start Alpha Fade" );
|
||||
addField( "Alpha Fade End", TypeF32, Offset(mAlphaFadeEnd, TSStatic), "Distance of end Alpha Fade" );
|
||||
addField( "Alpha Fade Inverse", TypeBool, Offset(mInvertAlphaFade, TSStatic), "Invert Alpha Fade's Start & End Distance" );
|
||||
addField( "alphaFadeEnable", TypeBool, Offset(mUseAlphaFade, TSStatic), "Turn on/off Alpha Fade" );
|
||||
addField( "alphaFadeStart", TypeF32, Offset(mAlphaFadeStart, TSStatic), "Distance of start Alpha Fade" );
|
||||
addField( "alphaFadeEnd", TypeF32, Offset(mAlphaFadeEnd, TSStatic), "Distance of end Alpha Fade" );
|
||||
addField( "alphaFadeInverse", TypeBool, Offset(mInvertAlphaFade, TSStatic), "Invert Alpha Fade's Start & End Distance" );
|
||||
endGroup( "AlphaFade" );
|
||||
|
||||
addGroup("Debug");
|
||||
|
|
@ -293,6 +294,13 @@ bool TSStatic::onAdd()
|
|||
|
||||
_updateShouldTick();
|
||||
|
||||
// Accumulation
|
||||
if ( isClientObject() && mShapeInstance )
|
||||
{
|
||||
if ( mShapeInstance->hasAccumulation() )
|
||||
AccumulationVolume::addObject(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -403,6 +411,13 @@ void TSStatic::onRemove()
|
|||
{
|
||||
SAFE_DELETE( mPhysicsRep );
|
||||
|
||||
// Accumulation
|
||||
if ( isClientObject() && mShapeInstance )
|
||||
{
|
||||
if ( mShapeInstance->hasAccumulation() )
|
||||
AccumulationVolume::removeObject(this);
|
||||
}
|
||||
|
||||
mConvexList->nukeList();
|
||||
|
||||
removeFromScene();
|
||||
|
|
@ -562,6 +577,9 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
rdata.setFadeOverride( 1.0f );
|
||||
rdata.setOriginSort( mUseOriginSort );
|
||||
|
||||
// Acculumation
|
||||
rdata.setAccuTex(mAccuTex);
|
||||
|
||||
// If we have submesh culling enabled then prepare
|
||||
// the object space frustum to pass to the shape.
|
||||
Frustum culler;
|
||||
|
|
@ -649,6 +667,13 @@ void TSStatic::setTransform(const MatrixF & mat)
|
|||
if ( mPhysicsRep )
|
||||
mPhysicsRep->setTransform( mat );
|
||||
|
||||
// Accumulation
|
||||
if ( isClientObject() && mShapeInstance )
|
||||
{
|
||||
if ( mShapeInstance->hasAccumulation() )
|
||||
AccumulationVolume::updateObject(this);
|
||||
}
|
||||
|
||||
// Since this is a static it's render transform changes 1
|
||||
// to 1 with it's collision transform... no interpolation.
|
||||
setRenderTransform(mat);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue