(Mostly) updated verve implementation.

This commit is contained in:
Areloch 2019-03-07 16:23:41 -06:00
parent 775ca57047
commit 87ee749801
538 changed files with 68727 additions and 49 deletions

View file

@ -0,0 +1,172 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/Torque/TAnimation.h"
#include "T3D/shapeBase.h"
//-----------------------------------------------------------------------------
//
// Animation Methods.
//
//-----------------------------------------------------------------------------
bool VTorque::isAnimationLooping( SceneObjectType *pObject, const char *pData )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape || !shape->getShape() )
{
// Sanity!
return false;
}
// Find Sequence.
const S32 sequenceIndex = shape->getShape()->findSequence( pData );
if ( sequenceIndex == -1 )
{
// Invalid Sequence.
return false;
}
// Return Cyclic.
return shape->getShape()->sequences[sequenceIndex].isCyclic();
}
String VTorque::getAnimation( SceneObjectType *pObject, const U32 &pThreadIndex )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape )
{
// Sanity!
return "";
}
// Return Name.
return shape->getThreadSequenceName( pThreadIndex );
}
F32 VTorque::getAnimationDuration( SceneObjectType *pObject, const char *pData )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape || !shape->getShape() )
{
// Sanity!
return 0.f;
}
// Find Sequence.
const S32 sequenceIndex = shape->getShape()->findSequence( pData );
if ( sequenceIndex == -1 )
{
// Invalid Sequence.
return 0.f;
}
// Return Duration.
return shape->getShape()->sequences[sequenceIndex].duration;
}
void VTorque::setAnimationPosition( SceneObjectType *pObject, const U32 &pThreadIndex, const F32 &pPosition )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape )
{
// Sanity!
return;
}
// Set Position.
shape->setThreadPosition( 0, pPosition );
}
void VTorque::setAnimationTimeScale( SceneObjectType *pObject, const U32 &pThreadIndex, const F32 &pTimeScale )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape )
{
// Sanity!
return;
}
// Set TimeScale.
shape->setThreadTimeScale( pThreadIndex, pTimeScale );
}
void VTorque::playAnimation( SceneObjectType *pObject, const U32 &pThreadIndex, const char *pData )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape || !shape->getShape() )
{
// Sanity!
return;
}
// Find Sequence.
const S32 sequenceIndex = shape->getShape()->findSequence( pData );
if ( sequenceIndex == -1 )
{
// Invalid Sequence.
return;
}
// Play Sequence.
shape->setThreadSequence( pThreadIndex, sequenceIndex );
}
void VTorque::playAnimation( SceneObjectType *pObject, const U32 &pThreadIndex )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape )
{
// Sanity!
return;
}
// Play Sequence.
shape->playThread( pThreadIndex );
}
void VTorque::stopAnimation( SceneObjectType *pObject, const U32 &pThreadIndex )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape )
{
// Sanity!
return;
}
// Pause Thread.
shape->stopThread( pThreadIndex );
}
void VTorque::pauseAnimation( SceneObjectType *pObject, const U32 &pThreadIndex )
{
ShapeBase *shape = dynamic_cast<ShapeBase*>( pObject );
if ( !shape )
{
// Sanity!
return;
}
// Pause Thread.
shape->pauseThread( pThreadIndex );
}

View file

@ -0,0 +1,57 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/VerveConfig.h"
#include "Verve/Torque/TCamera.h"
#include "Verve/Torque3D/VCameraShake.h"
#include "T3D/gameBase/gameConnection.h"
//-----------------------------------------------------------------------------
//
// Camera Methods.
//
//-----------------------------------------------------------------------------
bool VTorque::isCamera( SceneObjectType *pObject )
{
return ( dynamic_cast<GameBase*>( pObject ) != NULL );
}
void VTorque::setCamera( SceneObjectType *pObject )
{
// Fetch Game Base.
GameBase *object = dynamic_cast<GameBase*>( pObject );
// Fetch Client Group.
SimGroup* clientGroup = Sim::getClientGroup();
for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
{
GameConnection *connection = dynamic_cast<GameConnection*>( *itr );
if ( connection )
{
// Set Camera Object.
connection->setCameraObject( object );
}
}
}

View file

@ -0,0 +1,245 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/Torque3D/VCameraShake.h"
#include "T3D/gameBase/gameConnection.h"
#include "core/stream/bitStream.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CO_CLIENTEVENT_V1( VCameraShakeNetEvent );
//-----------------------------------------------------------------------------
// ShakeCamera( 1, 10, "1 0 0", "1 0 0" );
ConsoleFunction( ShakeCamera, void, 5, 5, "( pDuration, pFalloff, pAmplitude, pFrequency )" )
{
// Duration.
const F32 duration = dAtof( argv[1] );
// Falloff.
const F32 falloff = dAtof( argv[2] );
// Amplitude.
VectorF amplitude;
dSscanf( argv[3], "%g %g %g", &amplitude.x, &amplitude.y, &amplitude.z );
// Frequency.
VectorF frequency;
dSscanf( argv[4], "%g %g %g", &frequency.x, &frequency.y, &frequency.z );
// Shake Camera.
VTorque::startCameraShake( duration, falloff, amplitude, frequency );
}
void VTorque::startCameraShake( const F32 &pDuration, const F32 &pFalloff, const VectorF &pAmplitude, const VectorF &pFrequency )
{
#ifdef VT_EDITOR
// Create FX Event
CameraShake *camShake = new CameraShake();
// Set Duration.
camShake->setDuration( pDuration );
// Set Falloff.
camShake->setFalloff( pFalloff );
// Set Amplitude.
VectorF amp = pAmplitude;
camShake->setAmplitude( amp );
// Set Frequency.
VectorF freq = pFrequency;
camShake->setFrequency( freq );
// Initialise.
camShake->init();
// Add to Manager.
gCamFXMgr.addFX( camShake );
#else
// Fetch Client Group.
SimGroup* clientGroup = Sim::getClientGroup();
for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
{
NetConnection *connection = static_cast<NetConnection*>( *itr );
if ( connection )
{
// Create Event.
VCameraShakeNetEvent *event = new VCameraShakeNetEvent();
// Setup Event.
event->mEventType |= ( VCameraShakeNetEvent::k_TypeClear | VCameraShakeNetEvent::k_TypeMake );
event->mDuration = pDuration;
event->mFalloff = pFalloff;
event->mAmplitude = pAmplitude;
event->mFrequency = pFrequency;
// Post Event.
connection->postNetEvent( event );
}
}
#endif
}
void VTorque::stopCameraShake( void )
{
#ifdef VT_EDITOR
// Clear Manager.
gCamFXMgr.clear();
#else
// Fetch Client Group.
SimGroup* clientGroup = Sim::getClientGroup();
for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
{
NetConnection *connection = static_cast<NetConnection*>( *itr );
if ( connection )
{
// Create Event.
VCameraShakeNetEvent *event = new VCameraShakeNetEvent();
// Setup Event.
event->mEventType |= VCameraShakeNetEvent::k_TypeClear;
// Post Event.
connection->postNetEvent( event );
}
}
#endif
}
//-----------------------------------------------------------------------------
VCameraShakeNetEvent::VCameraShakeNetEvent( void ) : mEventType( 0 ),
mDuration( 0.f ),
mFalloff( 10.f ),
mAmplitude( Point3F::Zero ),
mFrequency( Point3F::Zero )
{
// Void.
}
void VCameraShakeNetEvent::write( NetConnection *pConnection, BitStream *pStream )
{
// Void.
}
void VCameraShakeNetEvent::pack( NetConnection *pConnection, BitStream *pStream )
{
// Clear Manager?
pStream->write( mEventType & k_TypeClear );
// Make Event?
if ( pStream->write( mEventType & k_TypeMake ) )
{
// Duration.
pStream->write( mDuration );
// Falloff.
pStream->write( mFalloff );
// Amplitude.
pStream->write( mAmplitude.x );
pStream->write( mAmplitude.y );
pStream->write( mAmplitude.z );
// Frequency.
pStream->write( mFrequency.x );
pStream->write( mFrequency.y );
pStream->write( mFrequency.z );
}
}
void VCameraShakeNetEvent::unpack( NetConnection *pConnection, BitStream *pStream )
{
// Clear Manager?
if ( pStream->readFlag() )
{
// Update State.
mEventType |= k_TypeClear;
}
// Make Event?
if ( pStream->readFlag() )
{
// Update State.
mEventType |= k_TypeMake;
// Duration.
pStream->read( &mDuration );
// Falloff.
pStream->read( &mFalloff );
// Amplitude.
pStream->read( &mAmplitude.x );
pStream->read( &mAmplitude.y );
pStream->read( &mAmplitude.z );
// Frequency.
pStream->read( &mFrequency.x );
pStream->read( &mFrequency.y );
pStream->read( &mFrequency.z );
}
}
void VCameraShakeNetEvent::process( NetConnection *pConnection )
{
if ( mEventType & k_TypeClear )
{
// Clear Manager.
gCamFXMgr.clear();
}
if ( mEventType & k_TypeMake )
{
// Create FX Event
CameraShake *camShake = new CameraShake();
// Set Duration.
camShake->setDuration( mDuration );
// Set Falloff.
camShake->setFalloff( mFalloff );
// Set Amplitude.
camShake->setAmplitude( mAmplitude );
// Set Frequency.
camShake->setFrequency( mFrequency );
// Initialise.
camShake->init();
// Add to Manager.
gCamFXMgr.addFX( camShake );
}
}

View file

@ -0,0 +1,65 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 _VT_VTORQUE3D_CAMERASHAKE_H_
#define _VT_VTORQUE3D_CAMERASHAKE_H_
#ifndef _VT_TORQUE_CAMERA_H_
#include "Verve/Torque/TCamera.h"
#endif
#ifndef _NETCONNECTION_H_
#include "sim/netConnection.h"
#endif
class VCameraShakeNetEvent : public NetEvent
{
typedef NetEvent Parent;
public:
enum eEventType
{
k_TypeClear = BIT( 0 ),
k_TypeMake = BIT( 1 ),
};
U32 mEventType;
F32 mDuration;
F32 mFalloff;
VectorF mAmplitude;
VectorF mFrequency;
public:
VCameraShakeNetEvent( void );
void write( NetConnection *pConnection, BitStream *pStream );
void pack( NetConnection *pConnection, BitStream *pStream );
void unpack( NetConnection *pConnection, BitStream *pStream );
void process( NetConnection *pConnection );
DECLARE_CONOBJECT( VCameraShakeNetEvent );
};
#endif // _VT_VTORQUE3D_CAMERASHAKE_H_

View file

@ -0,0 +1,89 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/Torque/TLightObject.h"
//-----------------------------------------------------------------------------
//
// Light Object Methods.
//
//-----------------------------------------------------------------------------
bool VTorque::isLightObjectEnabled( LightObjectType *pLightObject )
{
if ( !pLightObject )
{
// Sanity!
return false;
}
// Get Enabled.
return pLightObject->getLightEnabled();
}
void VTorque::setLightObjectOn( LightObjectType *pLightObject, const bool &pStatus )
{
if ( !pLightObject )
{
// Sanity!
return;
}
// Set Enabled.
pLightObject->setLightEnabled( pStatus );
}
void VTorque::playAnimation( LightObjectType *pLightObject, LightAnimationDataType *pLightAnimationData )
{
if ( !pLightObject || !pLightAnimationData )
{
// Sanity!
return;
}
// Play Animation.
pLightObject->playAnimation( pLightAnimationData );
}
void VTorque::playAnimation( LightObjectType *pLightObject )
{
if ( !pLightObject )
{
// Sanity!
return;
}
// Play Animation.
pLightObject->playAnimation();
}
void VTorque::pauseAnimation( LightObjectType *pLightObject )
{
if ( !pLightObject )
{
// Sanity!
return;
}
// Play Animation.
pLightObject->pauseAnimation();
}

View file

@ -0,0 +1,458 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/Torque/TMotion.h"
#include "Verve/VPath/VPath.h"
//-----------------------------------------------------------------------------
// Sync the local connection when editing path objects?
// Note: This was originally done so that editing was very smooth, but it turns
// out that any lag was due to errors in the pathing operations
// themselves. If issues persist, then uncomment this definition and you
// might see a marked improvement in performance while editing in Verve.
//#define VT_SYNC_LOCALCLIENT
//-----------------------------------------------------------------------------
//
// Utility Methods.
//
//-----------------------------------------------------------------------------
NetObject *getClientObject( NetObject *pObject )
{
if ( !pObject )
{
return NULL;
}
NetConnection *toServer = NetConnection::getConnectionToServer();
NetConnection *toClient = NetConnection::getLocalClientConnection();
if ( !toServer || !toClient )
{
return NULL;
}
const S32 ghostIndex = toClient->getGhostIndex( pObject );
if ( ghostIndex == -1 )
{
return NULL;
}
return toServer->resolveGhost( ghostIndex );
}
void _attachPathObject( VPath *pPath, SceneObject *pObject, const bool &pForward, const bool &pRelative, const S32 &pStartNodeIndex, const S32 &pEndNodeIndex, const String &pOrientation, const String &pOrientationData )
{
if ( pOrientation == String::EmptyString )
{
// Attach Object.
pPath->attachObject( pObject, pForward, 0.f, pRelative, pStartNodeIndex, pEndNodeIndex );
// Quit.
return;
}
// Fetch Orientation.
const VPathObject::eOrientationType type = VPathObject::getOrientationTypeEnum( pOrientation );
switch ( type )
{
case VPathObject::k_OrientationFree :
case VPathObject::k_OrientationInterpolate :
case VPathObject::k_OrientationToPath :
{
// Attach Object.
pPath->attachObject( pObject, pForward, 0.f, pRelative, pStartNodeIndex, pEndNodeIndex, type, NULL );
} break;
case VPathObject::k_OrientationToObject :
{
// Fetch Object.
SceneObject *lookAtObject = dynamic_cast<SceneObject*>( Sim::findObject( pOrientationData ) );
// Valid Object?
if ( lookAtObject != NULL )
{
// Attach Object.
pPath->attachObject( pObject, pForward, 0.f, pRelative, pStartNodeIndex, pEndNodeIndex, type, (void*)lookAtObject );
}
} break;
case VPathObject::k_OrientationToPoint:
{
// Fetch Point.
Point3F lookAtPoint( 0.f, 0.f, 0.f );
if ( dSscanf( pOrientationData, "%g %g %g", &lookAtPoint.x, &lookAtPoint.y, &lookAtPoint.z ) == 3 )
{
// Attach Object.
pPath->attachObject( pObject, pForward, 0.f, pRelative, pStartNodeIndex, pEndNodeIndex, type, (void*)lookAtPoint );
}
} break;
}
}
//-----------------------------------------------------------------------------
//
// Path Methods.
//
//-----------------------------------------------------------------------------
bool VTorque::isMovable( SimObject *pObject )
{
return ( dynamic_cast<SceneObjectType*>( pObject ) != NULL );
}
bool VTorque::isPath( SimObject *pObject )
{
return ( dynamic_cast<PathObjectType*>( pObject ) != NULL );
}
bool VTorque::isPathObjectAttached( PathObjectType *pPath, SceneObjectType *pObject )
{
if ( !pPath || !pObject )
{
// Sanity!
return false;
}
// Return.
return pPath->isObjectAttached( pObject );
}
F32 VTorque::getPathNodeLength( PathObjectType *pPath, const S32 &pNode )
{
if ( !pPath )
{
// Sanity!
return false;
}
// Normalize Node Index.
S32 nodeIndex = pNode;
pPath->normalizeNodeIndex( nodeIndex );
// Fetch Node.
VPathNode *node = pPath->getNode( nodeIndex );
// Return Length.
return node->getLength();
}
void VTorque::attachPathObject( PathObjectType *pPath, SceneObjectType *pObject, const bool &pForward, const bool &pRelative, const S32 &pStartNodeIndex, const S32 &pEndNodeIndex, const String &pOrientation, const String &pOrientationData )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Attach Object.
_attachPathObject( pPath, pObject, pForward, pRelative, pStartNodeIndex, pEndNodeIndex, pOrientation, pOrientationData );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Attach Object.
_attachPathObject( clientPath, clientObject, pForward, pRelative, pStartNodeIndex, pEndNodeIndex, pOrientation, pOrientationData );
}
#endif
}
void VTorque::detachPathObject( PathObjectType *pPath, SceneObjectType *pObject )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Detach Object.
pPath->detachObject( pObject );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Detach Object.
clientPath->detachObject( clientObject );
}
#endif
}
void VTorque::setPathObjectActive( PathObjectType *pPath, SceneObjectType *pObject, const bool &pActive )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Update Object State.
pPath->setPathObjectActive( pObject, pActive );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Update Object State.
clientPath->setPathObjectActive( clientObject, pActive );
}
#endif
}
void VTorque::setPathObjectInterp( PathObjectType *pPath, SceneObjectType *pObject, const F32 &pInterp )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Update Path Object Interp.
pPath->setPathObjectInterp( pObject, pInterp );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Apply the same action.
clientPath->setPathObjectInterp( clientObject, pInterp );
}
#endif
}
void VTorque::setPathObjectOffset( PathObjectType *pPath, SceneObjectType *pObject, const Point3F &pOffset )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Update Path Object Offset.
pPath->setPathObjectOffset( pObject, pOffset );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Apply the same action.
clientPath->setPathObjectOffset( clientObject, pOffset );
}
#endif
}
void VTorque::setPathObjectSpeed( PathObjectType *pPath, SceneObjectType *pObject, const F32 &pSpeed )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Update Path Speed.
pPath->setPathObjectSpeed( pObject, pSpeed );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Apply the same action.
clientPath->setPathObjectSpeed( clientObject, pSpeed );
}
#endif
}
void VTorque::setPathObjectOrientation( PathObjectType *pPath, SceneObjectType *pObject, const String &pOrientation, const String &pOrientationData )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Set the orientation mode.
// Note: Call the console method so we don't have to handle all the different modes here.
Con::executef( pPath, "setPathObjectOrientationMode", pObject->getIdString(), pOrientation, pOrientationData );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// TODO: Handle synching the client path immediately.
#endif
/*
// Set the Default Mode.
if ( pOrientation == String::EmptyString )
{
// Apply Mode.
pPath->setPathObjectOrientationMode( pObject, VPathObject::k_OrientationToPath );
return;
}
// Fetch Orientation.
const VPathObject::eOrientationType type = VPathObject::getOrientationTypeEnum( pOrientation );
switch ( type )
{
case VPathObject::k_OrientationFree :
case VPathObject::k_OrientationInterpolate :
case VPathObject::k_OrientationToPath :
{
// Apply Mode.
pPath->setPathObjectOrientationMode( pObject, type );
} break;
case VPathObject::k_OrientationToObject :
{
// Fetch Object.
SceneObjectType *lookAtObject;
if ( !Sim::findObject( pOrientationData, lookAtObject ) )
{
// Invalid Object.
return;
}
// Apply Mode.
pPath->setPathObjectOrientationMode( pObject, type, lookAtObject );
} break;
case VPathObject::k_OrientationToPoint:
{
// Fetch Point.
Point3F lookAtPoint( 0.f, 0.f, 0.f );
dSscanf( pOrientationData, "%g %g %g", &lookAtPoint.x, &lookAtPoint.y, &lookAtPoint.z );
// Apply Mode.
pPath->setPathObjectOrientationMode( pObject, type, lookAtPoint );
} break;
}
*/
}
void VTorque::setPathObjectForward( PathObjectType *pPath, SceneObjectType *pObject, const bool &pForward )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Update Path Object Forward.
pPath->setPathObjectForward( pObject, pForward );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Apply the same action.
clientPath->setPathObjectForward( clientObject, pForward );
}
#endif
}
void VTorque::setPathObjectNode( PathObjectType *pPath, SceneObjectType *pObject, const S32 &pNode )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Update Object Current Node.
pPath->setPathObjectNode( pObject, pNode );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Update Object Current Node.
clientPath->setPathObjectNode( clientObject, pNode );
}
#endif
}
void VTorque::setPathObjectEndNode( PathObjectType *pPath, SceneObjectType *pObject, const S32 &pNode )
{
if ( !pPath || !pObject )
{
// Sanity!
return;
}
// Update Object End Node.
pPath->setPathObjectEndNode( pObject, pNode );
#if defined( VT_EDITOR ) && defined( VT_SYNC_LOCALCLIENT )
// Fetch the client Path.
VPath *clientPath = dynamic_cast<VPath*>( getClientObject( pPath ) );
SceneObjectType *clientObject = dynamic_cast<SceneObjectType*>( getClientObject( pObject ) );
if ( clientPath && clientObject )
{
// Update Object End Node.
clientPath->setPathObjectEndNode( clientObject, pNode );
}
#endif
}

View file

@ -0,0 +1,53 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/Torque/TParticleEffect.h"
//-----------------------------------------------------------------------------
//
// Particle Effect Methods.
//
//-----------------------------------------------------------------------------
bool VTorque::isParticleEffectEnabled( ParticleEffectType *pParticleEffect )
{
if ( !pParticleEffect )
{
// Sanity!
return false;
}
// Get Active.
return pParticleEffect->getActive();
}
void VTorque::setParticleEffectOn( ParticleEffectType *pParticleEffect, const bool &pStatus )
{
if ( !pParticleEffect )
{
// Sanity!
return;
}
// Set Active.
pParticleEffect->setActive( pStatus );
}

View file

@ -0,0 +1,152 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/VerveConfig.h"
#include "Verve/Torque3D/VPostEffect.h"
#include "T3D/gameBase/gameConnection.h"
#include "core/stream/bitStream.h"
//-----------------------------------------------------------------------------
//
// Post Effect Methods.
//
//-----------------------------------------------------------------------------
bool VTorque::isPostEffectEnabled( PostEffectType *pPostEffect )
{
if ( !pPostEffect )
{
// Sanity!
return false;
}
return pPostEffect->isEnabled();
}
void VTorque::setPostEffectOn( PostEffectType *pPostEffect, const bool &pStatus )
{
if ( !pPostEffect )
{
// Sanity!
return;
}
#ifdef VT_EDITOR
if ( pStatus )
{
// Enable Effect.
pPostEffect->enable();
}
else
{
// Disable Effect.
pPostEffect->disable();
}
#else
// Fetch Name.
StringTableEntry name = pPostEffect->getName();
if ( !name || name == StringTable->insert( "" ) )
{
Con::warnf( "VTorque::setPostEffectOn() - Invalid Object Name." );
return;
}
// Fetch Client Group.
SimGroup* clientGroup = Sim::getClientGroup();
for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
{
NetConnection *connection = static_cast<NetConnection*>( *itr );
if ( connection )
{
// Create Event.
VPostEffectNetEvent *event = new VPostEffectNetEvent();
// Setup Event.
event->mPostEffect = name;
event->mEnabled = pStatus;
// Post Event.
connection->postNetEvent( event );
}
}
#endif
}
//-----------------------------------------------------------------------------
IMPLEMENT_CO_CLIENTEVENT_V1( VPostEffectNetEvent );
//-----------------------------------------------------------------------------
VPostEffectNetEvent::VPostEffectNetEvent( void ) : mPostEffect( StringTable->insert( "" ) ),
mEnabled( false )
{
// Void.
}
void VPostEffectNetEvent::write( NetConnection *pConnection, BitStream *pStream )
{
// Void.
}
void VPostEffectNetEvent::pack( NetConnection *pConnection, BitStream *pStream )
{
// Object Name.
pStream->writeString( mPostEffect );
// Status.
pStream->writeFlag( mEnabled );
}
void VPostEffectNetEvent::unpack( NetConnection *pConnection, BitStream *pStream )
{
// Object Name.
mPostEffect = pStream->readSTString();
// Status.
mEnabled = pStream->readFlag();
}
void VPostEffectNetEvent::process( NetConnection *pConnection )
{
PostEffect *postEffect;
if ( !Sim::findObject( mPostEffect, postEffect ) )
{
Con::warnf( "VPostEffectNetEvent::process() - Unable to find PostEffect Object '%s'", mPostEffect );
return;
}
if ( mEnabled )
{
// Enable Effect.
postEffect->enable();
}
else
{
// Disable Effect.
postEffect->disable();
}
}

View file

@ -0,0 +1,55 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 _VT_VTORQUE3D_POSTEFFECT_H_
#define _VT_VTORQUE3D_POSTEFFECT_H_
#ifndef _VT_TORQUE_POSTEFFECT_H_
#include "Verve/Torque/TPostEffect.h"
#endif
#ifndef _NETCONNECTION_H_
#include "sim/netConnection.h"
#endif
class VPostEffectNetEvent : public NetEvent
{
typedef NetEvent Parent;
public:
StringTableEntry mPostEffect;
bool mEnabled;
public:
VPostEffectNetEvent( void );
void write( NetConnection *pConnection, BitStream *pStream );
void pack( NetConnection *pConnection, BitStream *pStream );
void unpack( NetConnection *pConnection, BitStream *pStream );
void process( NetConnection *pConnection );
DECLARE_CONOBJECT( VPostEffectNetEvent );
};
#endif // _VT_VTORQUE3D_POSTEFFECT_H_

View file

@ -0,0 +1,354 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 "Verve/VerveConfig.h"
#include "Verve/Torque3D/VSoundEffect.h"
#include "T3D/gameBase/gameConnection.h"
#include "core/stream/bitStream.h"
#include "math/mathIO.h"
#include "sfx/sfxSystem.h"
#include "sfx/sfxDescription.h"
//-----------------------------------------------------------------------------
//
// Sound Methods.
//
//-----------------------------------------------------------------------------
bool VTorque::isSoundLooping( SoundEffectType *pSoundProfile )
{
if ( !pSoundProfile )
{
// Sanity!
return false;
}
// Return Looping.
return pSoundProfile->getDescription()->mIsLooping;
}
S32 VTorque::getSoundDuration( SoundEffectType *pSoundProfile )
{
if ( !pSoundProfile )
{
// Sanity!
return 0;
}
// Return Duration.
return pSoundProfile->getSoundDuration();
}
VTorque::SoundSourceType *VTorque::playSound( SoundEffectType *pSoundProfile, const U32 &pPosition, const F32 &pPitch )
{
if ( !pSoundProfile )
{
// Sanity!
return NULL;
}
#ifdef VT_EDITOR
// Play Sound.
SFXSound *source = ( SFXSound* )SFX->playOnce( pSoundProfile );
if ( source )
{
// Set Position.
source->setPosition( pPosition );
// Set Pitch.
source->setPitch( pPitch );
}
// Return Source.
return source;
#else
// Fetch Client Group.
SimGroup* clientGroup = Sim::getClientGroup();
for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
{
NetConnection *connection = static_cast<NetConnection*>( *itr );
if ( connection )
{
// Create Event.
VSoundEffectNetEvent *event = new VSoundEffectNetEvent();
// Setup Event.
event->mProfile = pSoundProfile;
event->mPosition = pPosition;
event->mPitch = pPitch;
event->mIs3D = false;
// Post Event.
connection->postNetEvent( event );
}
}
return NULL;
#endif
}
VTorque::SoundSourceType *VTorque::playSound( SoundEffectType *pSoundProfile, SceneObjectType *pObject, const U32 &pPosition, const F32 &pPitch )
{
if ( !pSoundProfile )
{
// Sanity!
return NULL;
}
#ifdef VT_EDITOR
// Fetch Reference Transform.
const MatrixF &transform = pObject->getTransform();
// Play Sound.
SFXSound *source = ( SFXSound* )SFX->playOnce( pSoundProfile, &transform );
if ( source )
{
// Set Position.
source->setPosition( pPosition );
// Set Pitch.
source->setPitch( pPitch );
}
// Return Source.
return source;
#else
// Fetch Client Group.
SimGroup* clientGroup = Sim::getClientGroup();
for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
{
NetConnection *connection = static_cast<NetConnection*>( *itr );
if ( connection )
{
// Create Event.
VSoundEffectNetEvent *event = new VSoundEffectNetEvent();
// Setup Event.
event->mProfile = pSoundProfile;
event->mPosition = pPosition;
event->mPitch = pPitch;
event->mIs3D = true;
event->mTransform = pObject->getTransform();
// Post Event.
connection->postNetEvent( event );
}
}
return NULL;
#endif
}
void VTorque::playSound( SoundSourceType *pSource )
{
if ( !pSource )
{
// Sanity!
return;
}
// Play.
pSource->play();
}
void VTorque::pauseSound( SoundSourceType *pSource )
{
if ( !pSource )
{
// Sanity!
return;
}
// Pause.
pSource->pause();
}
void VTorque::stopSound( SoundSourceType *pSource )
{
if ( !pSource )
{
// Sanity!
return;
}
// Stop.
pSource->stop();
}
void VTorque::setSoundPosition( SoundSourceType *pSource, const U32 &pPosition )
{
if ( !pSource )
{
// Sanity!
return;
}
// Set Position.
pSource->setPosition( pPosition );
}
void VTorque::setSoundPitch( SoundSourceType *pSource, const F32 &pPitch )
{
if ( !pSource )
{
// Sanity!
return;
}
// Set Pitch.
pSource->setPitch( pPitch );
}
//-----------------------------------------------------------------------------
IMPLEMENT_CO_CLIENTEVENT_V1( VSoundEffectNetEvent );
//-----------------------------------------------------------------------------
VSoundEffectNetEvent::VSoundEffectNetEvent( void ) : mProfile( NULL ),
mPosition( 0.f ),
mPitch( 1.f ),
mIs3D( false ),
mTransform( MatrixF::Identity )
{
// Void.
}
void VSoundEffectNetEvent::write( NetConnection *pConnection, BitStream *pStream )
{
// Void.
}
void VSoundEffectNetEvent::pack( NetConnection *pConnection, BitStream *pStream )
{
// Valid?
if ( !pStream->writeFlag( mProfile != NULL ) )
{
return;
}
// Profile.
pStream->writeInt( mProfile->getId() - DataBlockObjectIdFirst, DataBlockObjectIdBitSize );
// Position.
pStream->write( mPosition );
// Pitch.
pStream->write( mPitch );
// 3D?
if ( pStream->writeFlag( mIs3D ) )
{
// Rotation.
SFXDescription* description = mProfile->getDescription();
if ( pStream->writeFlag( description->mConeInsideAngle || description->mConeOutsideAngle ) )
{
// Entire Transform.
pStream->writeAffineTransform( mTransform );
}
else
{
// Position.
mathWrite( *pStream, mTransform.getColumn3F( 3 ) );
}
}
}
void VSoundEffectNetEvent::unpack( NetConnection *pConnection, BitStream *pStream )
{
// Valid?
if ( !pStream->readFlag() )
{
return;
}
// Profile.
Sim::findObject( pStream->readInt( DataBlockObjectIdBitSize ) + DataBlockObjectIdFirst, mProfile );
// Position.
pStream->read( &mPosition );
// Pitch.
pStream->read( &mPitch );
// 3D?
if ( pStream->readFlag() )
{
// Yup!
mIs3D = true;
// Rotation?
if ( pStream->readFlag() )
{
// Transform.
pStream->readAffineTransform( &mTransform );
}
else
{
// Position.
Point3F pos;
mathRead( *pStream, &pos );
mTransform.setColumn( 3, pos );
}
}
}
void VSoundEffectNetEvent::process( NetConnection *pConnection )
{
// Valid?
if ( !mProfile )
{
return;
}
SFXSound *source = NULL;
if ( mIs3D )
{
// Play 3D Sound.
source = ( SFXSound* )SFX->playOnce( mProfile, &mTransform );
}
else
{
// Play 2D Sound.
source = ( SFXSound* )SFX->playOnce( mProfile );
}
if ( source )
{
// Set Position.
source->setPosition( mPosition );
// Set Pitch.
source->setPitch( mPitch );
}
}

View file

@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) 2014 - Violent Tulip
//
// 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 _VT_VTORQUE3D_SOUNDEFFECT_H_
#define _VT_VTORQUE3D_SOUNDEFFECT_H_
#ifndef _VT_TORQUE_SOUNDEFFECT_H_
#include "Verve/Torque/TSoundEffect.h"
#endif
#ifndef _NETCONNECTION_H_
#include "sim/netConnection.h"
#endif
class VSoundEffectNetEvent : public NetEvent
{
typedef NetEvent Parent;
public:
SFXProfile *mProfile;
F32 mPosition;
F32 mPitch;
bool mIs3D;
MatrixF mTransform;
public:
VSoundEffectNetEvent( void );
void write( NetConnection *pConnection, BitStream *pStream );
void pack( NetConnection *pConnection, BitStream *pStream );
void unpack( NetConnection *pConnection, BitStream *pStream );
void process( NetConnection *pConnection );
DECLARE_CONOBJECT( VSoundEffectNetEvent );
};
#endif // _VT_VTORQUE3D_SOUNDEFFECT_H_