mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge branch 'VerveMergeWIP' of https://github.com/Areloch/Torque3D into development
This commit is contained in:
commit
82c74b4511
76
Engine/modules/Verve/Core/ITreeNode.h
Normal file
76
Engine/modules/Verve/Core/ITreeNode.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_ITREENODE_H_
|
||||
#define _VT_ITREENODE_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class ITreeNode
|
||||
{
|
||||
public:
|
||||
|
||||
ITreeNode *mParentNode;
|
||||
ITreeNode *mChildNode;
|
||||
|
||||
ITreeNode *mSiblingPrevNode;
|
||||
ITreeNode *mSiblingNextNode;
|
||||
|
||||
public:
|
||||
|
||||
ITreeNode( void ) :
|
||||
mParentNode( 0 ),
|
||||
mChildNode( 0 ),
|
||||
mSiblingPrevNode( 0 ),
|
||||
mSiblingNextNode( 0 )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
|
||||
virtual ~ITreeNode( void )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
|
||||
virtual void clear( void ) = 0; // Clear the Node.
|
||||
|
||||
virtual ITreeNode *getRoot( void ) = 0; // Get Root Node.
|
||||
virtual ITreeNode *getParent( void ) = 0; // Get Parent Node.
|
||||
virtual ITreeNode *getChild( void ) = 0; // Get Child Node.
|
||||
virtual ITreeNode *getLastChild( void ) = 0; // Get Last Child Node.
|
||||
|
||||
virtual ITreeNode *getPrevSibling( void ) = 0; // Get Previous Sibling Node.
|
||||
virtual ITreeNode *getNextSibling( void ) = 0; // Get Next Sibling Node.
|
||||
|
||||
virtual void addTo( ITreeNode *pNode ) = 0; // Add Node to target node.
|
||||
virtual void remove( void ) = 0; // Remove this Node from the tree.
|
||||
virtual void moveTo( ITreeNode* node ) = 0; // Move to specified Node.
|
||||
|
||||
virtual void onAttach( void ) = 0; // Attach Callback.
|
||||
virtual void onDetach( void ) = 0; // Detach Callback.
|
||||
|
||||
virtual bool inTree( void ) = 0; // Is Node in a tree?
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_ITREENODE_H_
|
||||
137
Engine/modules/Verve/Core/Persistence/VPersistence.cpp
Normal file
137
Engine/modules/Verve/Core/Persistence/VPersistence.cpp
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/Persistence/VPersistence.h"
|
||||
|
||||
#include "Verve/Core/VController.h"
|
||||
#include "Verve/Core/VObject.h"
|
||||
|
||||
namespace VPersistence
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VController
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template <>
|
||||
bool write( TiXmlElement *pElement, VController *pObject )
|
||||
{
|
||||
// Write Properties.
|
||||
if ( !writeProperties( pElement, pObject ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write Data Table.
|
||||
if ( !pObject->writeDataTable( pElement ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write Objects.
|
||||
return writeObjects( pElement, pObject );
|
||||
}
|
||||
|
||||
template <>
|
||||
bool read( TiXmlElement *pElement, VController *pObject )
|
||||
{
|
||||
// Read Properties.
|
||||
if ( !readProperties( pElement, pObject ) )
|
||||
{
|
||||
// Invalid Properties.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read Data Table.
|
||||
if ( !pObject->readDataTable( pElement ) )
|
||||
{
|
||||
// Invalid Data Table.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read Objects.
|
||||
if ( !readObjects( pElement, pObject ) )
|
||||
{
|
||||
// Invalid Read.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Valid Read.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template <>
|
||||
bool write( TiXmlElement *pElement, VObject *pObject )
|
||||
{
|
||||
// Create Element.
|
||||
TiXmlElement *objectElement = new TiXmlElement( "VObject" );
|
||||
pElement->LinkEndChild( objectElement );
|
||||
|
||||
// Attributes.
|
||||
objectElement->SetAttribute( "Type", pObject->getClassName() );
|
||||
|
||||
// Write Properties.
|
||||
if ( !writeProperties( objectElement, pObject ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write Objects.
|
||||
return writeObjects( objectElement, pObject );
|
||||
}
|
||||
|
||||
template <>
|
||||
bool read( TiXmlElement *pElement, VObject *pObject )
|
||||
{
|
||||
// Read Properties.
|
||||
if ( !readProperties( pElement, pObject ) )
|
||||
{
|
||||
// Invalid Properties.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set Name Unique.
|
||||
pObject->setLabelUnique( pObject->getLabel() );
|
||||
|
||||
// Read Objects.
|
||||
if ( !readObjects( pElement, pObject ) )
|
||||
{
|
||||
// Invalid Objects.
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
// Callback.
|
||||
Con::executef( pObject, "onRead" );
|
||||
#endif
|
||||
|
||||
// Valid Read.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
286
Engine/modules/Verve/Core/Persistence/VPersistence.h
Normal file
286
Engine/modules/Verve/Core/Persistence/VPersistence.h
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VPERSISTENCE_H_
|
||||
#define _VT_VPERSISTENCE_H_
|
||||
|
||||
#ifndef TINYXML_INCLUDED
|
||||
#include "tinyxml/tinyxml.h"
|
||||
#endif
|
||||
|
||||
#ifndef _SIMOBJECT_H_
|
||||
#include "console/simObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VOBJECT_H_
|
||||
#include "Verve/Core/VObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace VPersistence
|
||||
{
|
||||
static const char *VSFVersionString = "0.0.0a";
|
||||
|
||||
// This object is used to filter fields which belong to SimObject's.
|
||||
// There is no need to serialize these fields, so they are skipped
|
||||
// entirely.
|
||||
static SimObject DummySimObject;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
template <class T> bool writeFile( const char* pFileName, T *pObject )
|
||||
{
|
||||
// Create Doc.
|
||||
TiXmlDocument xmlDocument;
|
||||
TiXmlDeclaration *xmlDeclaration = new TiXmlDeclaration( "1.0", "", "" );
|
||||
xmlDocument.LinkEndChild( xmlDeclaration );
|
||||
|
||||
// Create Root.
|
||||
TiXmlElement *xmlRoot = new TiXmlElement( "VerveControllerSequence" );
|
||||
xmlDocument.LinkEndChild( xmlRoot );
|
||||
|
||||
// Write Version.
|
||||
xmlRoot->SetAttribute( "Version", VSFVersionString );
|
||||
|
||||
// Write Object.
|
||||
if ( !write( xmlRoot, pObject ) )
|
||||
{
|
||||
Con::errorf( "VPersistence::writeFile() - Unable to Write Object." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save File.
|
||||
return xmlDocument.SaveFile( pFileName );
|
||||
};
|
||||
|
||||
template <class T> bool write( TiXmlElement *pElement, T *pObject );
|
||||
|
||||
template <class T> bool writeProperties( TiXmlElement *pElement, T *pObject )
|
||||
{
|
||||
const AbstractClassRep::FieldList &fieldList = pObject->getFieldList();
|
||||
const AbstractClassRep::Field *field = NULL;
|
||||
|
||||
// Create Property Root.
|
||||
TiXmlElement *propertyRoot = new TiXmlElement( "Properties" );
|
||||
pElement->LinkEndChild( propertyRoot );
|
||||
|
||||
const S32 fieldCount = fieldList.size();
|
||||
for ( S32 i = 0; i < fieldCount; i++ )
|
||||
{
|
||||
field = &fieldList[i];
|
||||
|
||||
if ( field->type >= AbstractClassRep::ARCFirstCustomField )
|
||||
{
|
||||
// Ignore Special Fields.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fetch the Field Name.
|
||||
const char *fieldName = field->pFieldname;
|
||||
// SimObject Field?
|
||||
if ( DummySimObject.findField( fieldName ) != NULL )
|
||||
{
|
||||
// Skip SimObject Fields.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fetch the Field Value.
|
||||
const char *fieldValue = ( *field->getDataFn )( pObject, Con::getData( field->type, ( void * ) ( ( ( const char * )pObject ) + field->offset ), 0, field->table, field->flag ) );
|
||||
|
||||
if ( fieldValue )
|
||||
{
|
||||
// Create Element.
|
||||
TiXmlElement *propertyElement = new TiXmlElement( fieldName );
|
||||
|
||||
// Apply Value.
|
||||
propertyElement->InsertEndChild( TiXmlText( fieldValue ) );
|
||||
|
||||
// Add.
|
||||
propertyRoot->LinkEndChild( propertyElement );
|
||||
}
|
||||
}
|
||||
|
||||
// Valid Write.
|
||||
return true;
|
||||
};
|
||||
|
||||
template <class T> bool writeObjects( TiXmlElement *pElement, T *pObject )
|
||||
{
|
||||
for ( ITreeNode *node = pObject->mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
// Write Group.
|
||||
if ( !write( pElement, ( VObject* )node ) )
|
||||
{
|
||||
// Invalid Write.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Valid Write.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
template <class T> bool readFile( const char* pFileName, T *pObject )
|
||||
{
|
||||
TiXmlDocument xmlDocument;
|
||||
if ( !xmlDocument.LoadFile( pFileName ) )
|
||||
{
|
||||
Con::errorf( "VPersistence::readFile() - Unable to load file '%s'.", pFileName );
|
||||
return false;
|
||||
}
|
||||
|
||||
TiXmlElement *rootElement = xmlDocument.RootElement();
|
||||
if ( !rootElement )
|
||||
{
|
||||
Con::errorf( "VPersistence::readFile() - Invalid Document '%s'.", pFileName );
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *docVersion = rootElement->Attribute( "Version" );
|
||||
if ( !docVersion || dStrcmp( VSFVersionString, docVersion ) != 0 )
|
||||
{
|
||||
Con::errorf( "VPersistence::readFile() - Invalid file version." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read Object.
|
||||
if ( !read( rootElement, pObject ) )
|
||||
{
|
||||
// Invalid Read.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Valid.
|
||||
return true;
|
||||
};
|
||||
|
||||
template <class T> bool read( TiXmlElement *pElement, T *pObject );
|
||||
|
||||
template <class T> bool readProperties( TiXmlElement *pElement, T *pObject )
|
||||
{
|
||||
TiXmlElement *propertyRoot = pElement->FirstChildElement( "Properties" );
|
||||
if ( propertyRoot )
|
||||
{
|
||||
for ( TiXmlElement *child = propertyRoot->FirstChildElement(); child != NULL; child = child->NextSiblingElement() )
|
||||
{
|
||||
// Get Field Data.
|
||||
const char *fieldName = child->Value();
|
||||
const char *fieldValue = child->GetText();
|
||||
|
||||
if ( !fieldValue )
|
||||
{
|
||||
// Clear Value.
|
||||
pObject->setField( fieldName, "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply Field Value.
|
||||
if ( !pObject->setField( fieldName, fieldValue ) )
|
||||
{
|
||||
// Invalid.
|
||||
Con::warnf( "VPersistence::readProperties() - Invalid property '%s'", fieldName );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Valid Read.
|
||||
return true;
|
||||
};
|
||||
|
||||
template <class T> bool readObjects( TiXmlElement *pElement, T *pObject )
|
||||
{
|
||||
for ( TiXmlElement *child = pElement->FirstChildElement( "VObject" ); child != NULL; child = child->NextSiblingElement( "VObject" ) )
|
||||
{
|
||||
// Get Object Type.
|
||||
const char *type = child->Attribute( "Type" );
|
||||
if ( !type || !AbstractClassRep::findClassRep( type ) )
|
||||
{
|
||||
// Invalid Type.
|
||||
Con::errorf( "VController::readObjects() - Invalid object type specified '%s'.", ( ( type ) ? type : "NULL" ) );
|
||||
|
||||
// Invalid Read.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create Object.
|
||||
VObject *object = dynamic_cast<VObject*>( ConsoleObject::create( type ) );
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
// Register SimObject.
|
||||
if ( !object->registerObject() )
|
||||
{
|
||||
// Delete.
|
||||
delete object;
|
||||
|
||||
// Invalid Read.
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Add Reference.
|
||||
object->addTo( pObject );
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
// Valid Method?
|
||||
if ( object->isMethod( "onAdd" ) )
|
||||
{
|
||||
// Callback.
|
||||
const char *retValue = Con::executef( object, "onAdd" );
|
||||
if ( !dAtob( retValue ) )
|
||||
{
|
||||
// Delete.
|
||||
object->deleteObject();
|
||||
|
||||
// Invalid Read.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Read Object.
|
||||
if ( !read( child, object ) )
|
||||
{
|
||||
#ifdef VT_EDITOR
|
||||
// Delete.
|
||||
object->deleteObject();
|
||||
#else
|
||||
// Delete.
|
||||
delete object;
|
||||
#endif
|
||||
|
||||
// Invalid Read.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Valid Read.
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VPERSISTENCE_H_
|
||||
31
Engine/modules/Verve/Core/Util/VSharedEnum.cpp
Normal file
31
Engine/modules/Verve/Core/Util/VSharedEnum.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VSharedEnum.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Implement the Action enum list.
|
||||
ImplementEnumType( VActionToggle, "" )
|
||||
{ VSharedEnum::k_ActionTurnOn, "ON" },
|
||||
{ VSharedEnum::k_ActionTurnOff, "OFF" },
|
||||
EndImplementEnumType;
|
||||
49
Engine/modules/Verve/Core/Util/VSharedEnum.h
Normal file
49
Engine/modules/Verve/Core/Util/VSharedEnum.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSHAREDENUM_H_
|
||||
#define _VT_VSHAREDENUM_H_
|
||||
|
||||
#ifndef _DYNAMIC_CONSOLETYPES_H_
|
||||
#include "console/dynamicTypes.h"
|
||||
#endif
|
||||
|
||||
namespace VSharedEnum
|
||||
{
|
||||
enum eActionToggle
|
||||
{
|
||||
k_ActionTurnOn,
|
||||
k_ActionTurnOff,
|
||||
};
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Define Types.
|
||||
typedef VSharedEnum::eActionToggle VActionToggle;
|
||||
|
||||
// Declare Enum Types.
|
||||
DefineEnumType( VActionToggle );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSHAREDENUM_H_
|
||||
1160
Engine/modules/Verve/Core/VController.cpp
Normal file
1160
Engine/modules/Verve/Core/VController.cpp
Normal file
File diff suppressed because it is too large
Load diff
246
Engine/modules/Verve/Core/VController.h
Normal file
246
Engine/modules/Verve/Core/VController.h
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VCONTROLLER_H_
|
||||
#define _VT_VCONTROLLER_H_
|
||||
|
||||
#ifndef _VT_VERVECONFIG_H_
|
||||
#include "Verve/VerveConfig.h"
|
||||
#endif
|
||||
|
||||
#ifndef _PLATFORM_H_
|
||||
#include "platform/platform.h"
|
||||
#endif
|
||||
|
||||
#ifndef _PROCESSLIST_H_
|
||||
#include "T3D/gameBase/processList.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ITICKABLE_H_
|
||||
#include "core/iTickable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VPERSISTENCE_H_
|
||||
#include "Verve/Core/Persistence/VPersistence.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VTREENODE_H_
|
||||
#include "Verve/Core/VTreeNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VDATATABLE_H_
|
||||
#include "Verve/Core/VDataTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_CAMERA_H_
|
||||
#include "Verve/Torque/TCamera.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class VObject;
|
||||
|
||||
class VTrack;
|
||||
class VEvent;
|
||||
class VGroup;
|
||||
|
||||
class VDirectorGroup;
|
||||
class VDirectorTrack;
|
||||
|
||||
typedef VectorPtr<VTrack*> VTrackVector;
|
||||
typedef VTrackVector::iterator VTrackIterator;
|
||||
|
||||
typedef VectorPtr<VEvent*> VEventVector;
|
||||
typedef VEventVector::iterator VEventIterator;
|
||||
|
||||
typedef VectorPtr<VGroup*> VGroupVector;
|
||||
typedef VGroupVector::iterator VGroupIterator;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VController : public SimObject,
|
||||
public virtual ITickable,
|
||||
public VTreeNode
|
||||
{
|
||||
typedef SimObject Parent;
|
||||
|
||||
public:
|
||||
|
||||
enum eControllerStatus
|
||||
{
|
||||
k_StatusInit = BIT( 0 ),
|
||||
|
||||
k_StatusPlaying = BIT( 1 ),
|
||||
k_StatusPaused = BIT( 2 ),
|
||||
k_StatusStopped = BIT( 3 ),
|
||||
};
|
||||
|
||||
enum eControllerEventType
|
||||
{
|
||||
k_EventInit,
|
||||
k_EventReset,
|
||||
|
||||
k_EventPlay,
|
||||
k_EventPause,
|
||||
k_EventStop,
|
||||
|
||||
k_EventLoop,
|
||||
};
|
||||
|
||||
enum eControllerJumpType
|
||||
{
|
||||
k_JumpTime,
|
||||
k_JumpDelta,
|
||||
|
||||
k_JumpInvalid,
|
||||
};
|
||||
|
||||
typedef Signal<void( const S32 &pTime, const S32 &pDelta )> ControllerUpdateSignal;
|
||||
typedef Signal<bool( eControllerEventType )> ControllerEventSignal;
|
||||
|
||||
private:
|
||||
|
||||
// Data.
|
||||
|
||||
VDataTable mDataTable;
|
||||
|
||||
// Event Signal.
|
||||
|
||||
ControllerUpdateSignal mControllerUpdateSignal;
|
||||
ControllerEventSignal mControllerEventSignal;
|
||||
|
||||
// Properties.
|
||||
|
||||
S32 mStatus;
|
||||
|
||||
S32 mTime;
|
||||
U32 mLastTime;
|
||||
S32 mDuration;
|
||||
F32 mTimeScale;
|
||||
|
||||
bool mLoop;
|
||||
bool mLoopBackwards;
|
||||
S32 mLoopCount;
|
||||
S32 mLoopIndex;
|
||||
S32 mLoopDelay;
|
||||
S32 mLoopDelayTime;
|
||||
|
||||
eControllerJumpType mJump;
|
||||
S32 mJumpTime;
|
||||
|
||||
bool mResetOnCompletion;
|
||||
|
||||
public:
|
||||
|
||||
VController();
|
||||
~VController();
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// ITickable.
|
||||
|
||||
void interpolateTick( F32 pDelta ) { };
|
||||
void advanceTime( F32 pDelta ) { };
|
||||
void processTick( void );
|
||||
void onPostTick( void );
|
||||
|
||||
// Controller.
|
||||
|
||||
void reset( void );
|
||||
void reset( const S32 &pTime );
|
||||
|
||||
void play( void );
|
||||
void play( const S32 &pTime );
|
||||
|
||||
void pause( void );
|
||||
void stop( const bool &pReset = true );
|
||||
|
||||
void jump( void );
|
||||
void jump( const eControllerJumpType &pType, const S32 &pDelta );
|
||||
|
||||
void updateStatus( const S32 &pStatus );
|
||||
|
||||
// Reference.
|
||||
|
||||
VGroup *getObject( const String &pLabel );
|
||||
template <class T> inline bool getObject( const String &pLabel, T *&pObject )
|
||||
{
|
||||
// Reference Group.
|
||||
pObject = dynamic_cast<T*>( getObject( pLabel ) );
|
||||
|
||||
// Valid?
|
||||
return ( pObject != NULL );
|
||||
}
|
||||
|
||||
bool getDataValue( const String &pFieldName, String &pValue );
|
||||
void clearData( void );
|
||||
void clearData( const S32 &pIndex );
|
||||
void clearData( const String &pFieldName );
|
||||
|
||||
void sort( void );
|
||||
|
||||
// Saving.
|
||||
|
||||
bool writeDataTable( TiXmlElement *pElement );
|
||||
|
||||
// Reading.
|
||||
|
||||
bool readDataTable( TiXmlElement *pElement );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VController );
|
||||
|
||||
public:
|
||||
|
||||
inline VDataTable &getDataTable( void ) { return mDataTable; };
|
||||
|
||||
inline ControllerUpdateSignal &getControllerUpdateSignal( void ) { return mControllerUpdateSignal; };
|
||||
inline ControllerEventSignal &getControllerEventSignal( void ) { return mControllerEventSignal; };
|
||||
void postEvent( const eControllerEventType &pEvent );
|
||||
|
||||
VDirectorGroup *getDirectorGroup( void );
|
||||
VDirectorTrack *getDirectorTrack( void );
|
||||
|
||||
inline void setTime( const S32 &pTime ) { mTime = pTime; };
|
||||
inline void setDuration( const S32 &pDuration ) { mDuration = pDuration; };
|
||||
void setTimeScale( const F32 &pTimeScale );
|
||||
|
||||
inline bool isLooping( void ) { return mLoop; };
|
||||
inline bool isPlaying( void ) { return ( mStatus & k_StatusPlaying ); };
|
||||
inline bool isPaused( void ) { return ( mStatus & k_StatusPaused ); };
|
||||
inline bool isStopped( void ) { return ( mStatus & k_StatusStopped ); };
|
||||
inline bool isPlayingForward( void ) { return ( mTimeScale > 0.f ); };
|
||||
|
||||
inline S32 getTime( void ) { return mTime; };
|
||||
inline S32 getDuration( void ) { return mDuration; };
|
||||
inline F32 getTimeScale( void ) { return mTimeScale; };
|
||||
inline S32 getLoopDelayTime( void ) { return mLoopDelayTime; };
|
||||
|
||||
protected:
|
||||
|
||||
static bool setTime( void *pObject, const char *pArray, const char *pData ) { static_cast<VController*>( pObject )->setTime( dAtoi( pData ) ); return false; };
|
||||
static bool setDuration( void *pObject, const char *pArray, const char *pData ) { static_cast<VController*>( pObject )->setDuration( dAtoi( pData ) ); return false; };
|
||||
static bool setTimeScale( void *pObject, const char *pArray, const char *pData ) { static_cast<VController*>( pObject )->setTimeScale( dAtof( pData ) ); return false; };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCONTROLLER_H_
|
||||
254
Engine/modules/Verve/Core/VDataTable.cpp
Normal file
254
Engine/modules/Verve/Core/VDataTable.cpp
Normal file
|
|
@ -0,0 +1,254 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VDataTable.h"
|
||||
|
||||
#include "console/simObject.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Implement the DataType enum list.
|
||||
ImplementEnumType( VDataTableDataType, "" )
|
||||
{ VDataTable::k_TypeExpression, "EXPRESSION" },
|
||||
{ VDataTable::k_TypeStatic, "STATIC" },
|
||||
{ VDataTable::k_TypeVariable, "VARIABLE" },
|
||||
EndImplementEnumType;
|
||||
|
||||
VDataTable::eDataType VDataTable::getDataTypeEnum( const char *pLabel )
|
||||
{
|
||||
VDataTable::eDataType out;
|
||||
if ( !castConsoleTypeFromString( out, pLabel ) )
|
||||
{
|
||||
// Bah!
|
||||
return VDataTable::k_TypeInvalid;
|
||||
}
|
||||
|
||||
// Return.
|
||||
return out;
|
||||
}
|
||||
|
||||
const char *VDataTable::getDataTypeDescription( const VDataTable::eDataType pEnum )
|
||||
{
|
||||
// Return.
|
||||
return castConsoleTypeToString( pEnum );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VDataTable::VDataTable( void )
|
||||
{
|
||||
mDataMap.clear();
|
||||
}
|
||||
|
||||
VDataTable::~VDataTable( void )
|
||||
{
|
||||
mDataMap.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDataTable::insert( pType, pFieldName );
|
||||
//
|
||||
// Add a DataTable entry, referencing the field name and assign it the given
|
||||
// data type.
|
||||
//
|
||||
// For a full list of possible data types, see the 'eDataType' declaration in
|
||||
// VDataTable.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VDataTable::insert( eDataType pType, const String &pFieldName )
|
||||
{
|
||||
if ( mDataMap.contains( pFieldName ) )
|
||||
{
|
||||
// Change Field Type.
|
||||
mDataMap.find( pFieldName )->value.Type = pType;
|
||||
|
||||
// Return.
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert Item.
|
||||
mDataMap.insert( pFieldName, sDataItem( pType, pFieldName ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDataTable::clear( pFieldName );
|
||||
//
|
||||
// Clear the DataTable entry with the given field name.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VDataTable::clear( const String &pFieldName )
|
||||
{
|
||||
// Clear Item.
|
||||
mDataMap.erase( pFieldName );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDataTable::clear();
|
||||
//
|
||||
// Clear the contents of the DataTable entirely.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VDataTable::clear( void )
|
||||
{
|
||||
// Clear.
|
||||
mDataMap.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDataTable::getCount();
|
||||
//
|
||||
// Return the number of DataTable entries.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
S32 VDataTable::getCount( void )
|
||||
{
|
||||
return mDataMap.size();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDataTable::getItem( pIndex, *pDataItem );
|
||||
//
|
||||
// Return the item with the given index. This method will return false if there
|
||||
// is no valid data entry with that index.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VDataTable::getItem( const S32 &pIndex, sDataItem *pDataItem )
|
||||
{
|
||||
if ( pIndex < 0 || pIndex >= mDataMap.size() )
|
||||
{
|
||||
// Invalid Field.
|
||||
return false;
|
||||
}
|
||||
|
||||
S32 index = 0;
|
||||
for ( VDataMap::Iterator itr = mDataMap.begin(); itr != mDataMap.end(); ++itr )
|
||||
{
|
||||
if ( index == pIndex )
|
||||
{
|
||||
if ( pDataItem )
|
||||
{
|
||||
// Store Reference.
|
||||
*pDataItem = ( itr->value );
|
||||
}
|
||||
|
||||
// Valid Field.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Increment.
|
||||
++index;
|
||||
}
|
||||
|
||||
// Invalid Field.
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDataTable::getItem( pFieldName, *pDataItem );
|
||||
//
|
||||
// Return the item with the given field name. This method will return false if
|
||||
// there is no valid data entry with that name.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VDataTable::getItem( const String &pFieldName, sDataItem *pDataItem )
|
||||
{
|
||||
if ( mDataMap.contains( pFieldName ) )
|
||||
{
|
||||
if ( pDataItem )
|
||||
{
|
||||
// Fetch Item
|
||||
*pDataItem = mDataMap.find( pFieldName )->value;
|
||||
}
|
||||
|
||||
// Valid Field.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invalid Field.
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDataTable::getValue( pObject, pFieldName, *pValue );
|
||||
//
|
||||
// Evaluate and return the expression provided in the data field.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VDataTable::getValue( SimObject *pObject, const String &pFieldName, String &pValue )
|
||||
{
|
||||
if ( !pObject || pFieldName.isEmpty() )
|
||||
{
|
||||
// Sanity!
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fetch Data.
|
||||
sDataItem *data = &( mDataMap.find( pFieldName )->value );
|
||||
if ( !data )
|
||||
{
|
||||
// No Field.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Field Value.
|
||||
const char *fieldValue = pObject->getDataField( StringTable->insert( data->FieldName ), NULL );
|
||||
|
||||
switch ( data->Type )
|
||||
{
|
||||
case VDataTable::k_TypeExpression :
|
||||
{
|
||||
|
||||
// Evaluate.
|
||||
pValue = Con::evaluate( fieldValue, false );
|
||||
|
||||
} break;
|
||||
|
||||
case VDataTable::k_TypeStatic :
|
||||
{
|
||||
// Use Value.
|
||||
pValue = fieldValue;
|
||||
|
||||
} break;
|
||||
|
||||
case VDataTable::k_TypeVariable :
|
||||
{
|
||||
|
||||
// Fetch Variable.
|
||||
pValue = Con::getVariable( fieldValue );
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
// Valid Field.
|
||||
return true;
|
||||
}
|
||||
118
Engine/modules/Verve/Core/VDataTable.h
Normal file
118
Engine/modules/Verve/Core/VDataTable.h
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VDATATABLE_H_
|
||||
#define _VT_VDATATABLE_H_
|
||||
|
||||
#ifndef CORE_TDICTIONARY_H
|
||||
#include "core/util/tDictionary.h"
|
||||
#endif
|
||||
|
||||
#ifndef _CONSOLE_H_
|
||||
#include "console/console.h"
|
||||
#endif
|
||||
|
||||
#ifndef _DYNAMIC_CONSOLETYPES_H_
|
||||
#include "console/dynamicTypes.h"
|
||||
#endif
|
||||
|
||||
#ifndef _STRINGTABLE_H_
|
||||
#include "core/stringTable.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VDataTable
|
||||
{
|
||||
public:
|
||||
|
||||
enum eDataType
|
||||
{
|
||||
k_TypeExpression,
|
||||
k_TypeStatic,
|
||||
k_TypeVariable,
|
||||
|
||||
k_TypeInvalid,
|
||||
};
|
||||
|
||||
struct sDataItem
|
||||
{
|
||||
eDataType Type;
|
||||
String FieldName;
|
||||
|
||||
sDataItem( void ) :
|
||||
Type( k_TypeInvalid ),
|
||||
FieldName( String::EmptyString )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
|
||||
sDataItem( eDataType pType, const String &pFieldName ) :
|
||||
Type( pType ),
|
||||
FieldName( pFieldName )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
};
|
||||
|
||||
// Enum Lookup.
|
||||
static VDataTable::eDataType getDataTypeEnum( const char *pLabel );
|
||||
static const char *getDataTypeDescription( const VDataTable::eDataType pEnum );
|
||||
|
||||
// Map Type.
|
||||
typedef Map<String, sDataItem> VDataMap;
|
||||
|
||||
public:
|
||||
|
||||
VDataMap mDataMap;
|
||||
|
||||
public:
|
||||
|
||||
VDataTable( void );
|
||||
~VDataTable( void );
|
||||
|
||||
// Data.
|
||||
|
||||
void insert( eDataType pType, const String &pFieldName );
|
||||
void clear( const String &pFieldName );
|
||||
void clear( void );
|
||||
|
||||
// Reference.
|
||||
|
||||
S32 getCount( void );
|
||||
bool getItem( const S32 &pIndex, sDataItem *pDataItem = NULL );
|
||||
bool getItem( const String &pFieldName, sDataItem *pDataItem = NULL );
|
||||
|
||||
bool getValue( SimObject *pObject, const String &pFieldName, String &pValue );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Define Types.
|
||||
typedef VDataTable::eDataType VDataTableDataType;
|
||||
|
||||
// Declare Enum Types.
|
||||
DefineEnumType( VDataTableDataType );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VDATATABLE_H_
|
||||
406
Engine/modules/Verve/Core/VEvent.cpp
Normal file
406
Engine/modules/Verve/Core/VEvent.cpp
Normal file
|
|
@ -0,0 +1,406 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VEvent.h"
|
||||
#include "Verve/Core/VGroup.h"
|
||||
#include "Verve/Core/VTrack.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "math/mMathFn.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VEvent::VEvent( void ) :
|
||||
mIsPlaying( false ),
|
||||
mTriggered( false ),
|
||||
mTriggerTime( 0 ),
|
||||
mDuration( 0 )
|
||||
{
|
||||
setLabel( "DefaultEvent" );
|
||||
}
|
||||
|
||||
void VEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addProtectedField( "TriggerTime", TypeS32, Offset( mTriggerTime, VEvent ), &setTriggerTime, &defaultProtectedGetFn, "The time that this event is triggered." );
|
||||
addProtectedField( "Duration", TypeS32, Offset( mDuration, VEvent ), &setDuration, &defaultProtectedGetFn, "The total duration that this event plays for." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Reset the status of the event. If the given time is between the event's
|
||||
// start and finish times, then the isPlaying flag will be true. This means
|
||||
// that the event is free to be triggered upon playback.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VEvent::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Reset Status.
|
||||
mIsPlaying = ( pTime > mTriggerTime && pTime < ( mTriggerTime + mDuration ) );
|
||||
mTriggered = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::onControllerUpdate( pTime, pDelta )
|
||||
//
|
||||
// Integrate is only called when this event is the Next Event for the parent
|
||||
// track. For each track, there is only ever *one* event being integrated - the
|
||||
// event that needs to be triggered next.
|
||||
//
|
||||
// If the event has a duration greater than 0, then this event will continue to
|
||||
// integrate until its time is up, or the controller finishes playing
|
||||
// (whichever happens first).
|
||||
//
|
||||
// If a value of true is returned, then this event will continue to integrate
|
||||
// until a value of false is returned to the parent track. When this happens,
|
||||
// this event ceases to be the track's Next Event and will not continue
|
||||
// updating.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VEvent::onControllerUpdate( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const S32 newTime = ( pTime + pDelta );
|
||||
const S32 &startTime = getStartTime();
|
||||
const S32 &finishTime = getFinishTime();
|
||||
|
||||
if ( !mIsPlaying || !mTriggered )
|
||||
{
|
||||
if ( !mIsPlaying )
|
||||
{
|
||||
if ( ( pDelta > 0 && newTime < startTime )
|
||||
|| ( pDelta < 0 && newTime > startTime ) )
|
||||
{
|
||||
// Not Time to Trigger.
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ( pDelta > 0 && pTime > startTime )
|
||||
|| ( pDelta < 0 && pTime < startTime ) )
|
||||
{
|
||||
//AssertFatal( false, "VEvent::onControllerUpdate() - Event has been skipped." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mTriggered )
|
||||
{
|
||||
// Play and Trigger.
|
||||
mIsPlaying = ( mDuration > 0 );
|
||||
mTriggered = true;
|
||||
|
||||
// Callback.
|
||||
onTrigger( pTime, pDelta );
|
||||
|
||||
if ( mDuration == 0 )
|
||||
{
|
||||
// Stop Integrating.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return Here.
|
||||
// Note: If Duration is non-zero this event will continue to update
|
||||
// so that VEvent:: onUpdate is processed for the full event
|
||||
// duration.
|
||||
return ( mDuration != 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// Complete?
|
||||
const bool isComplete = ( ( pDelta > 0 && newTime > finishTime )
|
||||
|| ( pDelta < 0 && newTime < finishTime ) );
|
||||
|
||||
if ( !isComplete )
|
||||
{
|
||||
// Callback.
|
||||
onUpdate( pTime, pDelta );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Complete.
|
||||
mIsPlaying = false;
|
||||
|
||||
// Callback.
|
||||
onComplete( pTime, pDelta );
|
||||
}
|
||||
|
||||
// Continue?
|
||||
return !isComplete;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// This method is called when an event is due to be triggered. This method is
|
||||
// meant to be overloaded by derived classes.
|
||||
//
|
||||
// For examples of what an event might do, please refer to some of the included
|
||||
// events with Verve.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::onUpdate( pTime, pDelta );
|
||||
//
|
||||
// This method is called each tick once an event has been triggered and ceases
|
||||
// to be called when it is completed. This method is meant to be overloaded by
|
||||
// derived classes.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VEvent::onUpdate( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::onComplete( pTime, pDelta );
|
||||
//
|
||||
// This method is called once an event has finished being updated. It is not
|
||||
// called on events that have a duration of 0. This method is meant to be
|
||||
// overloaded by derived classes.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VEvent::onComplete( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Property Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::getGroup();
|
||||
//
|
||||
// Returns the parent group.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VGroup *VEvent::getGroup( void )
|
||||
{
|
||||
VTrack *track = getTrack();
|
||||
if ( track )
|
||||
{
|
||||
return track->getGroup();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::getTrack();
|
||||
//
|
||||
// Returns the parent track.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VTrack *VEvent::getTrack( void )
|
||||
{
|
||||
return dynamic_cast<VTrack*>( mParentNode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::getNextEvent();
|
||||
//
|
||||
// Returns the next event.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VEvent *VEvent::getNextEvent( void )
|
||||
{
|
||||
if ( !isControllerPlayingForward() )
|
||||
{
|
||||
return dynamic_cast<VEvent*>( mSiblingPrevNode );
|
||||
}
|
||||
|
||||
return dynamic_cast<VEvent*>( mSiblingNextNode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::getPreviousEvent();
|
||||
//
|
||||
// Returns the previous event.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VEvent *VEvent::getPreviousEvent( void )
|
||||
{
|
||||
if ( !isControllerPlayingForward() )
|
||||
{
|
||||
return dynamic_cast<VEvent*>( mSiblingNextNode );
|
||||
}
|
||||
|
||||
return dynamic_cast<VEvent*>( mSiblingPrevNode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::getStartTime();
|
||||
//
|
||||
// Returns the time, in milliseconds, that the event is due to trigger.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
S32 VEvent::getStartTime( void )
|
||||
{
|
||||
return ( mTriggerTime + ( !isControllerPlayingForward() * mDuration ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::getFinishTime();
|
||||
//
|
||||
// Returns the time, in milliseconds, that the event will cease updating.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
S32 VEvent::getFinishTime( void )
|
||||
{
|
||||
return ( mTriggerTime + ( isControllerPlayingForward() * mDuration ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::setTriggerTime( pTime );
|
||||
//
|
||||
// Apply the given trigger time to the object.
|
||||
//
|
||||
// If the project was built using the VT_EDITOR preprocessor argument, then
|
||||
// the validity of the passed value is verified. It also cannot be changed
|
||||
// while the controller is playing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VEvent::setTriggerTime( const S32 &pTime )
|
||||
{
|
||||
#ifdef VT_EDITOR
|
||||
|
||||
VTrack *track = getTrack();
|
||||
if ( !track )
|
||||
{
|
||||
// Apply Time.
|
||||
mTriggerTime = pTime;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( track->isControllerPlaying() )
|
||||
{
|
||||
// Don't Change While Playing.
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
// Check For Overlap.
|
||||
for ( ITreeNode *node = mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
VEvent *event = ( VEvent* )node;
|
||||
if ( event == this )
|
||||
{
|
||||
// Skip.
|
||||
continue;
|
||||
}
|
||||
|
||||
const U32 startTime = getStartTime();
|
||||
const U32 finishTime = getFinishTime();
|
||||
|
||||
if ( ( pTime > startTime && pTime < finishTime )
|
||||
|| ( ( pTime + mDuration ) > startTime && ( pTime + mDuration ) < finishTime )
|
||||
|| ( pTime < startTime && ( pTime + mDuration ) > finishTime ) )
|
||||
{
|
||||
// Overlap!
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Apply Time.
|
||||
mTriggerTime = mClamp( pTime, 0, getControllerDuration() );
|
||||
|
||||
// Sort Events.
|
||||
track->sort();
|
||||
|
||||
// Reset Track.
|
||||
track->onControllerReset( getControllerTime(), isControllerPlayingForward() );
|
||||
|
||||
#else
|
||||
|
||||
// Apply Time.
|
||||
mTriggerTime = pTime;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VEvent::setDuration( pDuration );
|
||||
//
|
||||
// Apply the given duration time to the object.
|
||||
//
|
||||
// If the project was built using the VT_EDITOR preprocessor argument, then
|
||||
// the validity of the passed value is verified. It also cannot be changed
|
||||
// while the controller is playing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VEvent::setDuration( const S32 &pDuration )
|
||||
{
|
||||
#ifdef VT_EDITOR
|
||||
|
||||
if ( isControllerPlaying() )
|
||||
{
|
||||
// Don't Change While Playing.
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Apply Duration.
|
||||
mDuration = pDuration;
|
||||
}
|
||||
109
Engine/modules/Verve/Core/VEvent.h
Normal file
109
Engine/modules/Verve/Core/VEvent.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VEVENT_H_
|
||||
#define _VT_VEVENT_H_
|
||||
|
||||
#ifndef _VT_VOBJECT_H_
|
||||
#include "Verve/Core/VObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class VGroup;
|
||||
class VTrack;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VEvent : public VObject
|
||||
{
|
||||
typedef VObject Parent;
|
||||
|
||||
protected:
|
||||
|
||||
bool mIsPlaying;
|
||||
bool mTriggered;
|
||||
|
||||
S32 mTriggerTime;
|
||||
S32 mDuration;
|
||||
|
||||
public:
|
||||
|
||||
VEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
virtual bool onControllerUpdate( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Callback Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onUpdate( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VEvent );
|
||||
|
||||
public:
|
||||
|
||||
// Property Methods.
|
||||
|
||||
VGroup *getGroup( void );
|
||||
template <class T> inline bool getGroup( T *&pGroup )
|
||||
{
|
||||
// Reference Group.
|
||||
pGroup = dynamic_cast<T*>( getGroup() );
|
||||
// Validate.
|
||||
return ( pGroup != NULL );
|
||||
}
|
||||
|
||||
VTrack *getTrack( void );
|
||||
template <class T> inline bool getTrack( T *&pTrack )
|
||||
{
|
||||
// Reference Track.
|
||||
pTrack = dynamic_cast<T*>( getTrack() );
|
||||
// Validate.
|
||||
return ( pTrack != NULL );
|
||||
}
|
||||
|
||||
VEvent *getNextEvent( void );
|
||||
VEvent *getPreviousEvent( void );
|
||||
|
||||
inline bool isPlaying( void ) { return mIsPlaying; };
|
||||
inline S32 getTriggerTime( void ) { return mTriggerTime; };
|
||||
inline S32 getDuration( void ) { return mDuration; };
|
||||
|
||||
virtual S32 getStartTime( void );
|
||||
virtual S32 getFinishTime( void );
|
||||
|
||||
virtual void setTriggerTime( const S32 &pTime );
|
||||
virtual void setDuration( const S32 &pDuration );
|
||||
|
||||
static bool setTriggerTime( void *obj, const char *pArray, const char *data ) { static_cast<VEvent*>( obj )->setTriggerTime( dAtoi( data ) ); return false; };
|
||||
static bool setDuration( void *obj, const char *pArray, const char *data ) { static_cast<VEvent*>( obj )->setDuration( dAtoi( data ) ); return false; };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VEVENT_H_
|
||||
32
Engine/modules/Verve/Core/VGroup.cpp
Normal file
32
Engine/modules/Verve/Core/VGroup.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VGroup.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VGroup::VGroup( void )
|
||||
{
|
||||
setLabel( "DefaultGroup" );
|
||||
};
|
||||
47
Engine/modules/Verve/Core/VGroup.h
Normal file
47
Engine/modules/Verve/Core/VGroup.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VGROUP_H_
|
||||
#define _VT_VGROUP_H_
|
||||
|
||||
#ifndef _VT_VOBJECT_H_
|
||||
#include "Verve/Core/VObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VGroup : public VObject
|
||||
{
|
||||
typedef VObject Parent;
|
||||
|
||||
public:
|
||||
|
||||
VGroup( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VGROUP_H_
|
||||
483
Engine/modules/Verve/Core/VObject.cpp
Normal file
483
Engine/modules/Verve/Core/VObject.cpp
Normal file
|
|
@ -0,0 +1,483 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VObject.h"
|
||||
#include "Verve/Core/VController.h"
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VObject );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VObject::VObject( void ) :
|
||||
mController( NULL ),
|
||||
mLabel( String::EmptyString ),
|
||||
mEnabled( true )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
|
||||
VObject::~VObject( void )
|
||||
{
|
||||
// Remove.
|
||||
remove();
|
||||
}
|
||||
|
||||
void VObject::initPersistFields( void )
|
||||
{
|
||||
// Don't Use Parent Fields.
|
||||
// Parent::initPersistFields();
|
||||
|
||||
addProtectedField( "Enabled", TypeBool, Offset( mEnabled, VObject ), &setEnabled, &defaultProtectedGetFn, "Enable or Disable the object from playback." );
|
||||
addProtectedField( "Label", TypeRealString, Offset( mLabel, VObject ), &setLabel, &defaultProtectedGetFn, "The label this object is referenced by." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::getObject( pLabel );
|
||||
//
|
||||
// Returns the object with the given label. If no object belongs to this object
|
||||
// with that label, then a NULL value is returned.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VObject *VObject::getObject( const String &pLabel )
|
||||
{
|
||||
VObject *node = ( VObject* )mChildNode;
|
||||
while ( node )
|
||||
{
|
||||
// Compare Names.
|
||||
if ( node->getLabel().equal( pLabel, String::NoCase ) )
|
||||
{
|
||||
// Valid.
|
||||
return node;
|
||||
}
|
||||
|
||||
// Next Sibling.
|
||||
node = ( VObject* )node->mSiblingNextNode;
|
||||
}
|
||||
|
||||
// Invalid.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Property Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::isEnabled();
|
||||
//
|
||||
// Returns whether this object is enabled.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VObject::isEnabled( void )
|
||||
{
|
||||
VObject *parent = dynamic_cast<VObject*>( getParent() );
|
||||
if ( parent && !parent->isEnabled() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::isControllerPlaying();
|
||||
//
|
||||
// Returns whether the root controller is currently playing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VObject::isControllerPlaying( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->isPlaying();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::isControllerPaused();
|
||||
//
|
||||
// Returns whether the root controller is currently paused.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VObject::isControllerPaused( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->isPaused();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::isControllerStopped();
|
||||
//
|
||||
// Returns whether the root controller is currently stopped.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VObject::isControllerStopped( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->isStopped();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::isControllerPlayingForward();
|
||||
//
|
||||
// Returns whether the root controller is currently playing forward.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VObject::isControllerPlayingForward( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->isPlayingForward();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::isControllerLooping();
|
||||
//
|
||||
// Returns whether the root controller is looping the sequence.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VObject::isControllerLooping( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->isLooping();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::getControllerTime();
|
||||
//
|
||||
// Returns the current time of the root controller.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
S32 VObject::getControllerTime( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->getTime();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::getControllerTimeScale();
|
||||
//
|
||||
// Returns the current timescale of the root controller.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
F32 VObject::getControllerTimeScale( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->getTimeScale();
|
||||
}
|
||||
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::getControllerDuration();
|
||||
//
|
||||
// Returns the duration of the root controller.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
S32 VObject::getControllerDuration( void )
|
||||
{
|
||||
if ( getController() )
|
||||
{
|
||||
return getController()->getDuration();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::setLabel( pLabel );
|
||||
//
|
||||
// Set the label property.
|
||||
//
|
||||
// If the project was built using the VT_EDITOR preprocessor argument, then the
|
||||
// label will not be changed if the target name is already used in the parent
|
||||
// object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VObject::setLabel( const String &pLabel )
|
||||
{
|
||||
#ifdef VT_EDITOR
|
||||
if ( mParentNode )
|
||||
{
|
||||
// Empty Label?
|
||||
if ( mLabel.isEmpty() )
|
||||
{
|
||||
// Set Uniqu Label.
|
||||
setLabelUnique( pLabel );
|
||||
return;
|
||||
}
|
||||
|
||||
for ( VObject *walk = ( VObject* )mChildNode; walk != NULL; walk = ( VObject* )walk->mSiblingNextNode )
|
||||
{
|
||||
if ( walk != this )
|
||||
{
|
||||
if ( pLabel == walk->getLabel() )
|
||||
{
|
||||
// Exit.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set Label.
|
||||
mLabel = pLabel;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::setLabelUnique( pLabel );
|
||||
//
|
||||
// If the label that has been passed is already in use, then a new label will
|
||||
// be generated by appending an index to the label. For example: MyLabel
|
||||
// becomes MyLabel0 ... MyLabelN
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VObject::setLabelUnique( const String &pLabel )
|
||||
{
|
||||
if ( mParentNode && pLabel.isNotEmpty() )
|
||||
{
|
||||
for ( VObject *walk = ( VObject* )mChildNode; walk != NULL; walk = ( VObject* )walk->mSiblingNextNode )
|
||||
{
|
||||
if ( walk != this )
|
||||
{
|
||||
if ( pLabel == walk->getLabel() )
|
||||
{
|
||||
// Strip Trailing Number.
|
||||
S32 i = -1;
|
||||
String labelBase( String::GetTrailingNumber( pLabel, i ) );
|
||||
i++;
|
||||
|
||||
// Construct New Name.
|
||||
String labelBuffer = String::ToString( "%s%d", labelBase.c_str(), i );
|
||||
|
||||
// Set Name.
|
||||
setLabelUnique( labelBuffer );
|
||||
|
||||
// Exit.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set Name.
|
||||
mLabel = pLabel;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::onAttach();
|
||||
//
|
||||
// Callback made when this object is attached to another node.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VObject::onAttach( void )
|
||||
{
|
||||
VTreeNode::onAttach();
|
||||
|
||||
// Store Controller.
|
||||
mController = dynamic_cast<VController*>( getRoot() );
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
if ( isProperlyAdded() )
|
||||
{
|
||||
Con::executef( this, "onAttach" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VObject::onDetach();
|
||||
//
|
||||
// Callback made when this object is detached from a parent node.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VObject::onDetach( void )
|
||||
{
|
||||
VTreeNode::onDetach();
|
||||
|
||||
// Clear Controller.
|
||||
mController = NULL;
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
if ( isProperlyAdded() )
|
||||
{
|
||||
Con::executef( this, "onDetach" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Debug Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VObject, writeFile, bool, 3, 3, "( string pFileName ) - Save to a given filename.\n"
|
||||
"@param pFileName The target file to write to.\n"
|
||||
"@return Returns true if the write was successful." )
|
||||
{
|
||||
// Write Target File.
|
||||
return VPersistence::writeFile( argv[2], object );
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, readFile, bool, 3, 3, "( string pFileName ) - Clears the object and loads the new data from the given filename.\n"
|
||||
"@param pFileName The target file to read from.\n"
|
||||
"@return Returns true if the read was successful." )
|
||||
{
|
||||
// Read Target File.
|
||||
return VPersistence::readFile( argv[2], object );
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, getRoot, S32, 2, 2, "( void ) - Get the root object.\n"
|
||||
"@return Returns the SimObjectId for the root object." )
|
||||
{
|
||||
// Fetch Object.
|
||||
VObject *objectRef = ( VObject* )object->getRoot();
|
||||
|
||||
// Return Object ID.
|
||||
return ( objectRef ) ? objectRef->getId() : 0;
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, getParent, S32, 2, 2, "( void ) - Get the parent object.\n"
|
||||
"@return Returns the SimObjectId for the parent object." )
|
||||
{
|
||||
// Fetch Object.
|
||||
VObject *objectRef = ( VObject* )object->mParentNode;
|
||||
|
||||
// Return Object ID.
|
||||
return ( objectRef ) ? objectRef->getId() : 0;
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, getIndex, S32, 2, 2, "( void ) - Get the index of this object relative to its siblings.\n"
|
||||
"@return Returns the index of this object." )
|
||||
{
|
||||
return object->getIndex();
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, getCount, S32, 2, 2, "( void ) - Get the number of child objects.\n"
|
||||
"@return Returns the number of child objects." )
|
||||
{
|
||||
return object->size();
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, getObject, S32, 3, 3, "( int pIndex ) - Get the object corresponding to the given index.\n"
|
||||
"@param pIndex The index of the object you wish to retrieve.\n"
|
||||
"@return Returns the SimObjectID for the object." )
|
||||
{
|
||||
// Fetch Object.
|
||||
VObject *objectRef = ( VObject* )object->at( dAtoi( argv[2] ) );
|
||||
|
||||
// Return Object ID.
|
||||
return ( objectRef ) ? objectRef->getId() : 0;
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, clear, void, 2, 2, "( void ) - Detaches and deletes all of the child objects.\n"
|
||||
"@return No return value." )
|
||||
{
|
||||
// Clear Sequence Lists.
|
||||
object->clear();
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, addObject, void, 3, 3, "( SimObject pObject ) - Add a child object to this node.\n"
|
||||
"@param pObject The SimObjectID of the object to be added to this node.\n"
|
||||
"@return No return value." )
|
||||
{
|
||||
VObject *child = dynamic_cast<VObject*>( Sim::findObject( argv[2] ) );
|
||||
if ( child )
|
||||
{
|
||||
child->addTo( object );
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, removeObject, void, 3, 3, "( SimObject pObject ) - Remove the target object from this node.\n"
|
||||
"@param pObject The SimObjectID of the object to be removed from this node.\n"
|
||||
"@return No return value." )
|
||||
{
|
||||
VObject *child = dynamic_cast<VObject*>( Sim::findObject( argv[2] ) );
|
||||
if ( child && child->getParent() == object )
|
||||
{
|
||||
child->remove();
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( VObject, setLabelUnique, void, 3, 3, "( string pLabel ) - Force this label to be unique.\n"
|
||||
"@param pLabel The name you wish to reference this object by.\n"
|
||||
"@return No return value." )
|
||||
{
|
||||
// Set Label.
|
||||
object->setLabelUnique( argv[2] );
|
||||
}
|
||||
#endif
|
||||
126
Engine/modules/Verve/Core/VObject.h
Normal file
126
Engine/modules/Verve/Core/VObject.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VOBJECT_H_
|
||||
#define _VT_VOBJECT_H_
|
||||
|
||||
#ifndef _VT_VERVECONFIG_H_
|
||||
#include "Verve/VerveConfig.h"
|
||||
#endif
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
#ifndef _SIMOBJECT_H_
|
||||
#include "console/simObject.h"
|
||||
#endif
|
||||
|
||||
#define VObjectRep SimObject
|
||||
#else
|
||||
#ifndef _CONSOLEOBJECT_H_
|
||||
#include "console/consoleObject.h"
|
||||
#endif
|
||||
|
||||
#define VObjectRep ConsoleObject
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VTREENODE_H_
|
||||
#include "Verve/Core/VTreeNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef TINYXML_INCLUDED
|
||||
#include "tinyxml/tinyxml.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class VController;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VObject : public VObjectRep,
|
||||
public VTreeNode
|
||||
{
|
||||
typedef VObjectRep Parent;
|
||||
|
||||
protected:
|
||||
|
||||
VController *mController;
|
||||
|
||||
String mLabel;
|
||||
bool mEnabled;
|
||||
|
||||
public:
|
||||
|
||||
VObject( void );
|
||||
virtual ~VObject( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
VObject *getObject( const String &pLabel );
|
||||
template <class T> inline bool getObject( const String &pLabel, T *&pObject )
|
||||
{
|
||||
// Reference Object.
|
||||
pObject = dynamic_cast<T*>( getObject( pLabel ) );
|
||||
|
||||
// Valid?
|
||||
return ( pObject != NULL );
|
||||
}
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VObject );
|
||||
|
||||
public:
|
||||
|
||||
// Property Methods.
|
||||
|
||||
inline VController *getController( void ) { return mController; };
|
||||
|
||||
inline const String &getLabel( void ) const { return mLabel; };
|
||||
bool isEnabled( void );
|
||||
|
||||
bool isControllerPlaying( void );
|
||||
bool isControllerPaused( void );
|
||||
bool isControllerStopped( void );
|
||||
bool isControllerPlayingForward( void );
|
||||
bool isControllerLooping( void );
|
||||
S32 getControllerTime( void );
|
||||
F32 getControllerTimeScale( void );
|
||||
S32 getControllerDuration( void );
|
||||
|
||||
virtual void setLabel( const String &pLabel );
|
||||
void setLabelUnique( const String &pLabel );
|
||||
inline void setEnabled( const bool &pEnabled ) { mEnabled = pEnabled; };
|
||||
|
||||
// Callback Methods.
|
||||
|
||||
virtual void onAttach( void );
|
||||
virtual void onDetach( void );
|
||||
|
||||
// Static Methods.
|
||||
|
||||
static bool setEnabled( void *pObject, const char *pArray, const char *pData ) { static_cast<VObject*>( pObject )->setEnabled( dAtob( pData ) ); return false; };
|
||||
static bool setLabel( void *pObject, const char *pArray, const char *pData ) { static_cast<VObject*>( pObject )->setLabel( pData ); return false; };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VOBJECT_H_
|
||||
448
Engine/modules/Verve/Core/VTrack.cpp
Normal file
448
Engine/modules/Verve/Core/VTrack.cpp
Normal file
|
|
@ -0,0 +1,448 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VTrack.h"
|
||||
#include "Verve/Core/VGroup.h"
|
||||
#include "Verve/Core/VController.h"
|
||||
#include "math/mMath.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VTrack::VTrack( void ) :
|
||||
mNextEvent( NULL )
|
||||
{
|
||||
setLabel( "DefaultTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Tree Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::onAttach();
|
||||
//
|
||||
// This callback subscribes this object to the controller's event signal.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTrack::onAttach( void )
|
||||
{
|
||||
Parent::onAttach();
|
||||
|
||||
// Valid Controller?
|
||||
if ( getController() )
|
||||
{
|
||||
// Subscribe to Updates.
|
||||
getController()->getControllerUpdateSignal().notify( this, &VTrack::onControllerUpdate );
|
||||
|
||||
// Subscribe to Events.
|
||||
getController()->getControllerEventSignal().notify( this, &VTrack::onControllerEvent );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::onAttach();
|
||||
//
|
||||
// This callback removes this object from the controller's event signal
|
||||
// notification list.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTrack::onDetach( void )
|
||||
{
|
||||
// Valid Controller?
|
||||
if ( getController() )
|
||||
{
|
||||
// Remove Update Notification.
|
||||
getController()->getControllerUpdateSignal().remove( this, &VTrack::onControllerUpdate );
|
||||
|
||||
// Remove Event Notification.
|
||||
getController()->getControllerEventSignal().remove( this, &VTrack::onControllerEvent );
|
||||
}
|
||||
|
||||
Parent::onDetach();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::onControllerUpdate( pTime, pDelta );
|
||||
//
|
||||
// The Next Event is integrated until has finished its execution. Once it has
|
||||
// finished, the next event to be triggered becomes the Current Event. Doing
|
||||
// this means that only one event is ever checked to see if it should be
|
||||
// triggered.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTrack::onControllerUpdate( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
if ( !isEnabled() || !mNextEvent )
|
||||
{
|
||||
// Don't Update.
|
||||
return;
|
||||
}
|
||||
|
||||
// Update Next Event.
|
||||
while ( !mNextEvent->onControllerUpdate( pTime, pDelta ) )
|
||||
{
|
||||
// Next Event?
|
||||
if ( !updateNextEvent() )
|
||||
{
|
||||
// No Valid Events.
|
||||
mNextEvent = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// When the controller's state changes, this method is called. If the
|
||||
// controller is reset the virtual method, onControllerReset is called.
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !getController() )
|
||||
{
|
||||
AssertFatal( false, "VTrack::onControllerEvent() - Invalid Controller." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch( pEvent )
|
||||
{
|
||||
case VController::k_EventReset :
|
||||
{
|
||||
|
||||
// Reset.
|
||||
onControllerReset( getControllerTime(), isControllerPlayingForward() );
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Reset the status of the track. The Next Event is allocated here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Clear Next Event.
|
||||
mNextEvent = NULL;
|
||||
|
||||
for ( ITreeNode *node = mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
VEvent *event = ( VEvent* )node;
|
||||
|
||||
// Reset Event.
|
||||
event->onControllerReset( pTime, pForward );
|
||||
|
||||
if ( ( event->isPlaying() )
|
||||
|| ( pForward && event->getTriggerTime() >= pTime ) )
|
||||
{
|
||||
if ( !mNextEvent )
|
||||
{
|
||||
// Use as Next Event.
|
||||
mNextEvent = event;
|
||||
}
|
||||
}
|
||||
else if ( !pForward && pTime >= event->getTriggerTime() )
|
||||
{
|
||||
VEvent *nextEvent = ( VEvent* )node->mSiblingNextNode;
|
||||
if ( !nextEvent || pTime < nextEvent->getTriggerTime() )
|
||||
{
|
||||
// Use as Next Event.
|
||||
mNextEvent = event;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::sort();
|
||||
//
|
||||
// Sort the track's events by the event's trigger time.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTrack::sort( void )
|
||||
{
|
||||
const S32 count = size();
|
||||
for ( S32 j = 0; j < count; j++ )
|
||||
{
|
||||
for ( ITreeNode *node = mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
VEvent *eventA = ( VEvent* )node;
|
||||
VEvent *eventB = ( VEvent* )node->mSiblingNextNode;
|
||||
if ( !eventB )
|
||||
{
|
||||
// No Node.
|
||||
break;
|
||||
}
|
||||
|
||||
// Swap?
|
||||
if ( eventA->getTriggerTime() > eventB->getTriggerTime() )
|
||||
{
|
||||
// Get Outer Siblings.
|
||||
ITreeNode *prevNode = eventA->mSiblingPrevNode;
|
||||
ITreeNode *nextNode = eventB->mSiblingNextNode;
|
||||
|
||||
if ( eventA->mParentNode && eventA->mParentNode->mChildNode == eventA )
|
||||
{
|
||||
// New Child Node.
|
||||
eventA->mParentNode->mChildNode = eventB;
|
||||
}
|
||||
|
||||
//
|
||||
// Move A.
|
||||
eventA->mSiblingPrevNode = eventB;
|
||||
eventA->mSiblingNextNode = nextNode;
|
||||
|
||||
if ( nextNode )
|
||||
{
|
||||
// Update Outer Sibling.
|
||||
nextNode->mSiblingPrevNode = eventA;
|
||||
}
|
||||
|
||||
//
|
||||
// Move B.
|
||||
|
||||
eventB->mSiblingPrevNode = prevNode;
|
||||
eventB->mSiblingNextNode = eventA;
|
||||
|
||||
if ( prevNode )
|
||||
{
|
||||
// Update Outer Sibling.
|
||||
prevNode->mSiblingNextNode = eventB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::updateNextEvent( pForward );
|
||||
//
|
||||
// Point mNextEvent to the next valid event in the track's sequence.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VTrack::updateNextEvent( void )
|
||||
{
|
||||
if ( !mNextEvent )
|
||||
{
|
||||
// Invalid Event.
|
||||
return false;
|
||||
}
|
||||
|
||||
while ( ( mNextEvent = mNextEvent->getNextEvent() ) != NULL )
|
||||
{
|
||||
if ( mNextEvent->isEnabled() )
|
||||
{
|
||||
// Valid Event.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Invalid Event.
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Property Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::getGroup();
|
||||
//
|
||||
// Returns the Track's parent group.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VGroup *VTrack::getGroup( void )
|
||||
{
|
||||
return dynamic_cast<VGroup*>( mParentNode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::getNextEvent();
|
||||
//
|
||||
// Returns the Event that the Track is currently observing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VEvent *VTrack::getNextEvent( void )
|
||||
{
|
||||
return mNextEvent;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::getCurrentEvent();
|
||||
//
|
||||
// Returns the Event that the Track is currently observing and playing. This
|
||||
// will only ever be non-null when the track is observing an Event that has a
|
||||
// non-zero duration and has been triggered.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VEvent *VTrack::getCurrentEvent( void )
|
||||
{
|
||||
if ( mNextEvent && mNextEvent->isPlaying() )
|
||||
{
|
||||
return mNextEvent;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::getPreviousEvent();
|
||||
//
|
||||
// Returns the Event that the Track was last intergrating.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VEvent *VTrack::getPreviousEvent( void )
|
||||
{
|
||||
if ( mNextEvent )
|
||||
{
|
||||
return mNextEvent->getPreviousEvent();
|
||||
}
|
||||
|
||||
if ( !isControllerPlayingForward() )
|
||||
{
|
||||
return dynamic_cast<VEvent*>( getChild() );
|
||||
}
|
||||
|
||||
return dynamic_cast<VEvent*>( getLastChild() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTrack::calclateInterp( pTime );
|
||||
//
|
||||
// This method returns the interp time between or within events. If the given
|
||||
// time is between two events, the return time is:
|
||||
//
|
||||
// ( pTime - last_event_finish_time )
|
||||
// / ( next_event_start_time - last_event_finish_time )
|
||||
//
|
||||
// If the given time is within an event, the return time is:
|
||||
//
|
||||
// ( pTime - event_start_time ) / ( event_duration )
|
||||
//
|
||||
// The value returned here is between 0.0 and 1.0.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
F32 VTrack::calculateInterp( S32 pTime )
|
||||
{
|
||||
if ( !isControllerPlayingForward() )
|
||||
{
|
||||
return ( 1.f - _calculateInterp( pTime ) );
|
||||
}
|
||||
|
||||
return _calculateInterp( pTime );
|
||||
}
|
||||
|
||||
F32 VTrack::_calculateInterp( S32 pTime )
|
||||
{
|
||||
// Fetch Duration.
|
||||
const S32 sequenceDuration = getControllerDuration();
|
||||
if ( sequenceDuration == 0 || pTime == sequenceDuration )
|
||||
{
|
||||
// Sanity!
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
if ( !mChildNode )
|
||||
{
|
||||
// Quick Interp.
|
||||
return F32( pTime / sequenceDuration );
|
||||
}
|
||||
|
||||
// Last Time.
|
||||
S32 lastTime = 0;
|
||||
|
||||
VEvent *walk = ( VEvent* )mChildNode;
|
||||
while ( walk )
|
||||
{
|
||||
const S32 startTime = walk->getStartTime();
|
||||
const S32 finishTime = walk->getFinishTime();
|
||||
|
||||
if ( pTime < startTime )
|
||||
{
|
||||
return ( F32( pTime - lastTime ) / F32( startTime - lastTime ) );
|
||||
}
|
||||
|
||||
// Update Last Time.
|
||||
lastTime = startTime;
|
||||
|
||||
if ( pTime < finishTime )
|
||||
{
|
||||
return ( F32( pTime - lastTime ) / F32( finishTime - lastTime ) );
|
||||
}
|
||||
|
||||
// Update Last Time.
|
||||
lastTime = finishTime;
|
||||
|
||||
// Fetch Next Node.
|
||||
walk = ( VEvent* )walk->mSiblingNextNode;
|
||||
}
|
||||
|
||||
// Return.
|
||||
return ( F32( pTime - lastTime ) / F32( sequenceDuration - lastTime ) );
|
||||
}
|
||||
123
Engine/modules/Verve/Core/VTrack.h
Normal file
123
Engine/modules/Verve/Core/VTrack.h
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VTRACK_H_
|
||||
#define _VT_VTRACK_H_
|
||||
|
||||
#ifndef _VT_VCONTROLLER_H_
|
||||
#include "Verve/Core/VController.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_SCENEOBJECT_H_
|
||||
#include "Verve/Torque/TSceneObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class VGroup;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VTrack : public VObject
|
||||
{
|
||||
typedef VObject Parent;
|
||||
|
||||
public:
|
||||
|
||||
// Controller Members.
|
||||
|
||||
VEvent *mNextEvent;
|
||||
|
||||
public:
|
||||
|
||||
VTrack();
|
||||
|
||||
// Tree Methods.
|
||||
|
||||
virtual void onAttach( void );
|
||||
virtual void onDetach( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual void onControllerUpdate( const S32 &pTime, const S32 &pDelta );
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
void sort( void );
|
||||
bool updateNextEvent( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VTrack );
|
||||
|
||||
public:
|
||||
|
||||
// Property Methods.
|
||||
|
||||
VGroup *getGroup( void );
|
||||
template <class T> inline bool getGroup( T *&pGroup )
|
||||
{
|
||||
// Reference Group.
|
||||
pGroup = dynamic_cast<T*>( getGroup() );
|
||||
// Validate.
|
||||
return ( pGroup != NULL );
|
||||
}
|
||||
|
||||
VEvent *getNextEvent( void );
|
||||
template <class T> inline bool getNextEvent( T *&pEvent )
|
||||
{
|
||||
// Reference Object.
|
||||
pEvent = dynamic_cast<T*>( getNextEvent() );
|
||||
// Validate.
|
||||
return ( pEvent != NULL );
|
||||
}
|
||||
|
||||
VEvent *getCurrentEvent( void );
|
||||
template <class T> inline bool getCurrentEvent( T *&pEvent )
|
||||
{
|
||||
// Reference Object.
|
||||
pEvent = dynamic_cast<T*>( getCurrentEvent() );
|
||||
// Validate.
|
||||
return ( pEvent != NULL );
|
||||
}
|
||||
|
||||
VEvent *getPreviousEvent( void );
|
||||
template <class T> inline bool getPreviousEvent( T *&pEvent )
|
||||
{
|
||||
// Reference Object.
|
||||
pEvent = dynamic_cast<T*>( getPreviousEvent() );
|
||||
// Validate.
|
||||
return ( pEvent != NULL );
|
||||
}
|
||||
|
||||
F32 calculateInterp( S32 pTime );
|
||||
F32 _calculateInterp( S32 pTime );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VTRACK_H_
|
||||
471
Engine/modules/Verve/Core/VTreeNode.cpp
Normal file
471
Engine/modules/Verve/Core/VTreeNode.cpp
Normal file
|
|
@ -0,0 +1,471 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VTreeNode.h"
|
||||
#include "console/simObject.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VTreeNode::VTreeNode( void )
|
||||
{
|
||||
mParentNode = NULL;
|
||||
mChildNode = NULL;
|
||||
mSiblingPrevNode = NULL;
|
||||
mSiblingNextNode = NULL;
|
||||
}
|
||||
|
||||
VTreeNode::~VTreeNode( void )
|
||||
{
|
||||
// Delete Children.
|
||||
clear();
|
||||
|
||||
// Detach.
|
||||
remove();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::clear();
|
||||
//
|
||||
// Delete all child nodes.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTreeNode::clear( void )
|
||||
{
|
||||
if ( !mChildNode )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ( mChildNode )
|
||||
{
|
||||
// Fetch Child Node.
|
||||
ITreeNode *node = mChildNode;
|
||||
|
||||
// Clear It.
|
||||
node->clear();
|
||||
|
||||
// Detach It.
|
||||
node->remove();
|
||||
|
||||
// Delete It.
|
||||
SimObject *object = dynamic_cast<SimObject*>( node );
|
||||
if ( object )
|
||||
{
|
||||
object->deleteObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ITreeNode Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::getRoot();
|
||||
//
|
||||
// Returns the root object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
ITreeNode *VTreeNode::getRoot( void )
|
||||
{
|
||||
ITreeNode *parent = this;
|
||||
while ( parent->mParentNode )
|
||||
{
|
||||
parent = parent->mParentNode;
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::getParent();
|
||||
//
|
||||
// Returns the parent object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
ITreeNode *VTreeNode::getParent( void )
|
||||
{
|
||||
return mParentNode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::getChild();
|
||||
//
|
||||
// Returns the first child object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
ITreeNode *VTreeNode::getChild( void )
|
||||
{
|
||||
return mChildNode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::getChild();
|
||||
//
|
||||
// Returns the first child object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
ITreeNode *VTreeNode::getLastChild( void )
|
||||
{
|
||||
// Any Nodes?
|
||||
if ( !mChildNode )
|
||||
{
|
||||
// Null.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Front Node.
|
||||
ITreeNode *lastNode = mChildNode;
|
||||
|
||||
// Fetch Last Node.
|
||||
while ( lastNode->mSiblingNextNode )
|
||||
{
|
||||
lastNode = lastNode->mSiblingNextNode;
|
||||
}
|
||||
|
||||
// Return.
|
||||
return lastNode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::getPrevSibling();
|
||||
//
|
||||
// Returns the previous object in the linked list.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
ITreeNode *VTreeNode::getPrevSibling( void )
|
||||
{
|
||||
return mSiblingPrevNode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::getNextSibling();
|
||||
//
|
||||
// Returns the next object in the linked list.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
ITreeNode *VTreeNode::getNextSibling( void )
|
||||
{
|
||||
return mSiblingNextNode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::size();
|
||||
//
|
||||
// Returns the number of child objects. Only includes top level.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int VTreeNode::size( void )
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
ITreeNode *node = mChildNode;
|
||||
while ( node )
|
||||
{
|
||||
size++;
|
||||
|
||||
node = node->mSiblingNextNode;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::at( pIndex );
|
||||
//
|
||||
// Returns the object at the given index.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
ITreeNode *VTreeNode::at( const int pIndex )
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
ITreeNode *node = mChildNode;
|
||||
while ( node )
|
||||
{
|
||||
if ( index++ == pIndex )
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
node = node->mSiblingNextNode;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::getIndex();
|
||||
//
|
||||
// Returns the index of the object in relation to the sibling nodes.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int VTreeNode::getIndex( void )
|
||||
{
|
||||
if ( !inTree() )
|
||||
{
|
||||
// No Index.
|
||||
return 0;
|
||||
}
|
||||
|
||||
ITreeNode *walk = NULL;
|
||||
if ( mParentNode )
|
||||
{
|
||||
walk = mParentNode->mChildNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
walk = this;
|
||||
while ( walk->mSiblingPrevNode )
|
||||
{
|
||||
// Walk Up.
|
||||
walk = walk->mSiblingPrevNode;
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; walk; walk = walk->mSiblingNextNode, i++ )
|
||||
{
|
||||
if ( walk == this )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
AssertFatal( false, "VTreeNode::getIndex() - Node List Broken?" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::addTo( pNode );
|
||||
//
|
||||
// Attach this node to the back of the target node.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTreeNode::addTo( ITreeNode *pNode )
|
||||
{
|
||||
if ( inTree() )
|
||||
{
|
||||
// Already In Tree.
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Parent.
|
||||
mParentNode = pNode;
|
||||
|
||||
if ( !pNode->mChildNode )
|
||||
{
|
||||
// Store Child Node.
|
||||
pNode->mChildNode = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Front Node.
|
||||
ITreeNode *headNode = pNode->mChildNode;
|
||||
|
||||
// Fetch Head Node.
|
||||
while ( headNode->mSiblingNextNode )
|
||||
{
|
||||
headNode = headNode->mSiblingNextNode;
|
||||
}
|
||||
|
||||
// Reference Next Node.
|
||||
headNode->mSiblingNextNode = this;
|
||||
|
||||
// Reference Previous Node.
|
||||
mSiblingPrevNode = headNode;
|
||||
}
|
||||
|
||||
// Callback.
|
||||
onAttach();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::addToFront( pNode );
|
||||
//
|
||||
// Attach this node to the front of the target node.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTreeNode::addToFront( ITreeNode *pNode )
|
||||
{
|
||||
if ( inTree() )
|
||||
{
|
||||
// Already In Tree.
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Parent.
|
||||
mParentNode = pNode;
|
||||
|
||||
if ( !pNode->mChildNode )
|
||||
{
|
||||
// Store Child Node.
|
||||
pNode->mChildNode = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
// First Node.
|
||||
ITreeNode *childNode = pNode->mChildNode;
|
||||
|
||||
// Reference Previous Node.
|
||||
childNode->mSiblingPrevNode = this;
|
||||
|
||||
// Reference Next Node.
|
||||
mSiblingNextNode = childNode;
|
||||
|
||||
// Store Child Node.
|
||||
pNode->mChildNode = this;
|
||||
}
|
||||
|
||||
// Callback.
|
||||
onAttach();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::remove();
|
||||
//
|
||||
// Detach this node from the current parent node.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTreeNode::remove( void )
|
||||
{
|
||||
if ( !inTree() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Callback.
|
||||
onDetach();
|
||||
|
||||
if ( mParentNode && mParentNode->mChildNode == this )
|
||||
{
|
||||
// Update Parent Reference.
|
||||
mParentNode->mChildNode = mSiblingNextNode;
|
||||
}
|
||||
|
||||
if ( mSiblingNextNode )
|
||||
{
|
||||
// Update Previous Node.
|
||||
mSiblingNextNode->mSiblingPrevNode = mSiblingPrevNode;
|
||||
}
|
||||
|
||||
if ( mSiblingPrevNode )
|
||||
{
|
||||
// Update Next Node.
|
||||
mSiblingPrevNode->mSiblingNextNode = mSiblingNextNode;
|
||||
}
|
||||
|
||||
// Remove References.
|
||||
mParentNode = mSiblingPrevNode = mSiblingNextNode = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::moveTo( pNode );
|
||||
//
|
||||
// Detach this node and attach it to the target node.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTreeNode::moveTo( ITreeNode *pNode )
|
||||
{
|
||||
if ( inTree() )
|
||||
{
|
||||
// Remove from Tree.
|
||||
remove();
|
||||
}
|
||||
|
||||
// Add to tree.
|
||||
addTo( pNode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::onAttach();
|
||||
//
|
||||
// This method will be called when this node, or a parent node, is attached to
|
||||
// a node.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTreeNode::onAttach( void )
|
||||
{
|
||||
// Notify Children.
|
||||
for ( ITreeNode *node = mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
node->onAttach();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::onDetach();
|
||||
//
|
||||
// This method will be called when this node, or a parent node, is detached.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VTreeNode::onDetach( void )
|
||||
{
|
||||
// Notify Children.
|
||||
for ( ITreeNode *node = mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
node->onDetach();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VTreeNode::inTree();
|
||||
//
|
||||
// Returns true if the node is the a member of a node tree.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VTreeNode::inTree( void )
|
||||
{
|
||||
return !( mParentNode == NULL &&
|
||||
mSiblingPrevNode == NULL &&
|
||||
mSiblingNextNode == NULL );
|
||||
}
|
||||
73
Engine/modules/Verve/Core/VTreeNode.h
Normal file
73
Engine/modules/Verve/Core/VTreeNode.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VTREENODE_H_
|
||||
#define _VT_VTREENODE_H_
|
||||
|
||||
#ifndef _VT_ITREENODE_H_
|
||||
#include "Verve/Core/ITreeNode.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VTreeNode : public ITreeNode
|
||||
{
|
||||
typedef ITreeNode Parent;
|
||||
|
||||
public:
|
||||
|
||||
VTreeNode( void );
|
||||
~VTreeNode( void );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
virtual void clear( void );
|
||||
|
||||
// ITreeNode Methods.
|
||||
|
||||
virtual ITreeNode *getRoot( void );
|
||||
virtual ITreeNode *getParent( void );
|
||||
virtual ITreeNode *getChild( void );
|
||||
virtual ITreeNode *getLastChild( void );
|
||||
|
||||
virtual ITreeNode *getPrevSibling( void );
|
||||
virtual ITreeNode *getNextSibling( void );
|
||||
|
||||
virtual ITreeNode *at( const int pIndex );
|
||||
virtual int size( void );
|
||||
|
||||
virtual int getIndex( void );
|
||||
|
||||
virtual void addTo( ITreeNode *pNode );
|
||||
virtual void addToFront( ITreeNode *pNode );
|
||||
virtual void remove( void );
|
||||
virtual void moveTo( ITreeNode *pNode );
|
||||
|
||||
virtual void onAttach( void );
|
||||
virtual void onDetach( void );
|
||||
|
||||
virtual bool inTree( void );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VTREENODE_H_
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Animation/VShapeAnimationEvent.h"
|
||||
#include "Verve/Extension/Animation/VShapeAnimationTrack.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VShapeAnimationEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VShapeAnimationEvent::VShapeAnimationEvent( void ) :
|
||||
mAnimationData( String::EmptyString ),
|
||||
mAutoDuration( true )
|
||||
{
|
||||
setLabel( "AnimationEvent" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VShapeAnimationEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "AnimationData", TypeRealString, Offset( mAnimationData, VShapeAnimationEvent ), "The name of the Animation Sequence to play upon triggering." );
|
||||
addField( "AutoDuration", TypeBool, Offset( mAutoDuration, VShapeAnimationEvent ), "Force the Event's Duration to match the length of the Animation." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VShapeAnimationEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Play the desired animation. Also account for any offet in playtime, and
|
||||
// timescale.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VShapeAnimationEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
VShapeAnimationTrack *track;
|
||||
if ( !object || !getTrack( track ) )
|
||||
{
|
||||
// Sanity!
|
||||
return;
|
||||
}
|
||||
|
||||
// Play Animation.
|
||||
VTorque::playAnimation( object, track->getThreadIndex(), mAnimationData );
|
||||
|
||||
// Set Position.
|
||||
VTorque::setAnimationPosition( object, track->getThreadIndex(), getAnimationPosition( pTime + pDelta ) );
|
||||
|
||||
// Set Time Scale.
|
||||
VTorque::setAnimationTimeScale( object, track->getThreadIndex(), ( ( pDelta > 0 ) ? 1.f : -1.f ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VShapeAnimationEvent::onComplete( pTime, pDelta );
|
||||
//
|
||||
// If the animation is cyclic, then it needs to be paused once the event has
|
||||
// finished playing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VShapeAnimationEvent::onComplete( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
// Fetch Object.
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
VShapeAnimationTrack *track;
|
||||
if ( object && VTorque::isAnimationLooping( object, mAnimationData ) && getTrack( track ) )
|
||||
{
|
||||
// Pause Animation.
|
||||
VTorque::pauseAnimation( object, track->getThreadIndex() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Property Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VShapeAnimationEvent::getAnimationPosition( pTime );
|
||||
//
|
||||
// Returns the time that the animation should be positioned at, at the given
|
||||
// time. This method considers whether the animation is cyclic or not and will
|
||||
// return the appropriate time regardless. Time is expressed in seconds and not
|
||||
// milliseconds.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
F32 VShapeAnimationEvent::getAnimationPosition( const S32 &pTime )
|
||||
{
|
||||
// Fetch Object.
|
||||
VSceneObjectTrack *track;
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !getTrack( track ) || !object )
|
||||
{
|
||||
// Null.
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
// Fetch Interp.
|
||||
F32 interp = track->calculateInterp( pTime );
|
||||
if ( !isControllerPlayingForward() )
|
||||
{
|
||||
// Flip.
|
||||
interp = ( 1.f - interp );
|
||||
}
|
||||
|
||||
// Not Looping?
|
||||
if ( !VTorque::isAnimationLooping( object, mAnimationData ) )
|
||||
{
|
||||
// Return Interp.
|
||||
return interp;
|
||||
}
|
||||
|
||||
// Fetch Sequence Duration.
|
||||
const S32 duration = ( S32 )( 1000 * VTorque::getAnimationDuration( object, mAnimationData ) );
|
||||
|
||||
// Fetch Loop Interp.
|
||||
const S32 loopInterp = S32( mDuration * interp ) % duration;
|
||||
|
||||
return ( F32 )loopInterp / ( F32 )duration;
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSHAPEANIMATIONEVENT_H_
|
||||
#define _VT_VSHAPEANIMATIONEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_ANIMATION_H_
|
||||
#include "Verve/Torque/TAnimation.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VShapeAnimationEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VSceneObjectEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
bool mAutoDuration;
|
||||
String mAnimationData;
|
||||
|
||||
public:
|
||||
|
||||
VShapeAnimationEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Callback Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VShapeAnimationEvent );
|
||||
|
||||
public:
|
||||
|
||||
// Property Methods.
|
||||
|
||||
F32 getAnimationPosition( const S32 &pTime );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSHAPEANIMATIONEVENT_H_
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Animation/VShapeAnimationTrack.h"
|
||||
#include "Verve/Extension/Animation/VShapeAnimationEvent.h"
|
||||
#include "Verve/Core/VGroup.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VShapeAnimationTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VShapeAnimationTrack::VShapeAnimationTrack( void ) :
|
||||
mThreadIndex( 0 )
|
||||
{
|
||||
setLabel( "AnimationTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VShapeAnimationTrack::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "ThreadIndex", TypeS32, Offset( mThreadIndex, VShapeAnimationTrack ), "The index of the Animation Thread to play." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VShapeAnimationTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// When the controller's state changes, this method is called. If the
|
||||
// controller is paused, or stops playing, then the animation will cease to
|
||||
// play. If the controller resumes play, the animation will continue.
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VShapeAnimationTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventPlay :
|
||||
{
|
||||
|
||||
// Play Animation.
|
||||
VTorque::setAnimationTimeScale( getSceneObject(), mThreadIndex, ( ( isControllerPlayingForward() ) ? 1.f : -1.f ) );
|
||||
|
||||
} break;
|
||||
|
||||
case VController::k_EventPause :
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Stop Animation.
|
||||
VTorque::setAnimationTimeScale( getSceneObject(), mThreadIndex, 0.f );
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VShapeAnimationTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Reset the animation state of the target object. If there is a Next Event,
|
||||
// then the animation is positioned accordingly.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VShapeAnimationTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !object )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
return;
|
||||
}
|
||||
|
||||
VShapeAnimationEvent *event;
|
||||
if ( getCurrentEvent( event ) )
|
||||
{
|
||||
// Stop Animation.
|
||||
VTorque::stopAnimation( object, mThreadIndex );
|
||||
}
|
||||
|
||||
// Parent Call.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
if ( getCurrentEvent( event ) )
|
||||
{
|
||||
// Play Animation.
|
||||
VTorque::playAnimation( object, mThreadIndex, event->mAnimationData );
|
||||
|
||||
// Set Position.
|
||||
VTorque::setAnimationPosition( object, mThreadIndex, event->getAnimationPosition( pTime ) );
|
||||
|
||||
// Stop Animation.
|
||||
VTorque::setAnimationTimeScale( object, mThreadIndex, 0.f );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Debug Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VShapeAnimationTrack, updateTrack, void, 2, 2, "( void ) - Update the Track.\n"
|
||||
"@return No return value." )
|
||||
{
|
||||
for ( ITreeNode *node = object->mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
VShapeAnimationEvent *currEvent = ( VShapeAnimationEvent* )node;
|
||||
VShapeAnimationEvent *nextEvent = ( VShapeAnimationEvent* )node->mSiblingNextNode;
|
||||
if ( !currEvent->mAutoDuration )
|
||||
{
|
||||
// Skip.
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( VTorque::isAnimationLooping( object->getSceneObject(), currEvent->mAnimationData ) )
|
||||
{
|
||||
if ( !nextEvent )
|
||||
{
|
||||
// Update Duration.
|
||||
currEvent->setDuration( object->getControllerDuration() - currEvent->getTriggerTime() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update Duration.
|
||||
currEvent->setDuration( mAbs( nextEvent->getTriggerTime() - currEvent->getTriggerTime() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update Duration.
|
||||
currEvent->setDuration( ( S32 )( 1000 * VTorque::getAnimationDuration( object->getSceneObject(), currEvent->mAnimationData ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSHAPEANIMATIONTRACK_H_
|
||||
#define _VT_VSHAPEANIMATIONTRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_ANIMATION_H_
|
||||
#include "Verve/Torque/TAnimation.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VShapeAnimationTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
U32 mThreadIndex;
|
||||
|
||||
public:
|
||||
|
||||
VShapeAnimationTrack( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VShapeAnimationTrack );
|
||||
|
||||
public:
|
||||
|
||||
inline U32 &getThreadIndex( void ) { return mThreadIndex; };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSHAPEANIMATIONTRACK_H_
|
||||
224
Engine/modules/Verve/Extension/Camera/VCameraGroup.cpp
Normal file
224
Engine/modules/Verve/Extension/Camera/VCameraGroup.cpp
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Camera/VCameraGroup.h"
|
||||
#include "Verve/Extension/Camera/VCameraTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraGroup *VCameraGroup::mActiveGroup = NULL;
|
||||
VCameraGroup::CameraChangeSignal VCameraGroup::mCameraChangeSignal;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraGroup::VCameraGroup( void )
|
||||
{
|
||||
setLabel( "CameraGroup" );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Tree Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::onAttach();
|
||||
//
|
||||
// This callback subscribes this object to the controller's event signal.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::onAttach( void )
|
||||
{
|
||||
Parent::onAttach();
|
||||
|
||||
// Valid Controller?
|
||||
if ( getController() )
|
||||
{
|
||||
// Subscribe to Events.
|
||||
getController()->getControllerEventSignal().notify( this, &VCameraGroup::onControllerEvent );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::onAttach();
|
||||
//
|
||||
// This callback removes this object from the controller's event signal
|
||||
// notification list.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::onDetach( void )
|
||||
{
|
||||
// Valid Controller?
|
||||
if ( getController() )
|
||||
{
|
||||
// Remove Event Notification.
|
||||
getController()->getControllerEventSignal().remove( this, &VCameraGroup::onControllerEvent );
|
||||
}
|
||||
|
||||
Parent::onDetach();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::onControllerEvent( pEvent );
|
||||
//
|
||||
// When the controller's state changes, this method is called.
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VCameraGroup::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !getController() )
|
||||
{
|
||||
AssertFatal( false, "VCameraGroup::onControllerEvent() - Invalid Controller." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch( pEvent )
|
||||
{
|
||||
#ifdef VT_EDITOR
|
||||
case VController::k_EventPause :
|
||||
#endif
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Clear the Camera.
|
||||
clearActiveGroup();
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Camera Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::setActive();
|
||||
//
|
||||
// Set this Group to Active.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::setActive( void )
|
||||
{
|
||||
// Set Active.
|
||||
setActiveGroup( this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::clearActiveGroup();
|
||||
//
|
||||
// Clear the Active Camera.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::clearActiveGroup( void )
|
||||
{
|
||||
if ( mActiveGroup )
|
||||
{
|
||||
// Deactivate Signal.
|
||||
mActiveGroup->getCameraEventSignal().trigger( k_EventDeactivate );
|
||||
}
|
||||
|
||||
// Store.
|
||||
mActiveGroup = NULL;
|
||||
|
||||
// Clear Camera Object.
|
||||
VTorque::setCamera( NULL );
|
||||
|
||||
// Change Signal.
|
||||
getCameraChangeSignal().trigger( NULL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::setActiveGroup( pCameraGroup );
|
||||
//
|
||||
// Change the current camera group. The actual camera object is the object that
|
||||
// the group references.
|
||||
//
|
||||
// A NULL value of pCameraGroup will clear the active camera, which generally
|
||||
// reverts to the connection's control object. The camera is also cleared when
|
||||
// the Controller stops playing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::setActiveGroup( VCameraGroup *pCameraGroup )
|
||||
{
|
||||
// Change Camera?
|
||||
if ( pCameraGroup == mActiveGroup ||
|
||||
pCameraGroup && !pCameraGroup->isEnabled() )
|
||||
{
|
||||
// Invalid Target.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mActiveGroup )
|
||||
{
|
||||
// Deactivate Signal.
|
||||
mActiveGroup->getCameraEventSignal().trigger( k_EventDeactivate );
|
||||
}
|
||||
|
||||
// Store.
|
||||
mActiveGroup = pCameraGroup;
|
||||
|
||||
if ( mActiveGroup )
|
||||
{
|
||||
// Set Camera Object.
|
||||
VTorque::setCamera( mActiveGroup->getSceneObject() );
|
||||
|
||||
// Activate Signal.
|
||||
mActiveGroup->getCameraEventSignal().trigger( k_EventActivate );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear Camera Object.
|
||||
VTorque::setCamera( NULL );
|
||||
}
|
||||
|
||||
// Change Signal.
|
||||
getCameraChangeSignal().trigger( mActiveGroup );
|
||||
}
|
||||
97
Engine/modules/Verve/Extension/Camera/VCameraGroup.h
Normal file
97
Engine/modules/Verve/Extension/Camera/VCameraGroup.h
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VCAMERAGROUP_H_
|
||||
#define _VT_VCAMERAGROUP_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTGROUP_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VCONTROLLER_H
|
||||
#include "Verve/Core/VController.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraGroup;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraGroup : public VSceneObjectGroup
|
||||
{
|
||||
typedef VSceneObjectGroup Parent;
|
||||
|
||||
public:
|
||||
|
||||
enum eCameraEventType
|
||||
{
|
||||
k_EventActivate,
|
||||
k_EventDeactivate,
|
||||
};
|
||||
|
||||
typedef Signal<bool( const eCameraEventType & )> CameraEventSignal;
|
||||
typedef Signal<void( VCameraGroup* )> CameraChangeSignal;
|
||||
|
||||
protected:
|
||||
|
||||
static VCameraGroup *mActiveGroup;
|
||||
static CameraChangeSignal mCameraChangeSignal;
|
||||
|
||||
CameraEventSignal mCameraEventSignal;
|
||||
|
||||
public:
|
||||
|
||||
VCameraGroup( void );
|
||||
|
||||
// Tree Methods.
|
||||
|
||||
void onAttach( void );
|
||||
void onDetach( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
|
||||
// Camera Methods.
|
||||
|
||||
inline bool isActive( void ) { return ( bool )( this == getActiveGroup() ); };
|
||||
inline VCameraGroup *getActiveGroup( void ) { return mActiveGroup; };
|
||||
|
||||
void setActive( void );
|
||||
|
||||
static void clearActiveGroup( void );
|
||||
static void setActiveGroup( VCameraGroup *pCameraGroup );
|
||||
|
||||
// Signal Methods.
|
||||
|
||||
static inline CameraChangeSignal &getCameraChangeSignal( void ) { return mCameraChangeSignal; };
|
||||
inline CameraEventSignal &getCameraEventSignal( void ) { return mCameraEventSignal; };
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERAGROUP_H_
|
||||
83
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.cpp
Normal file
83
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VGroup.h"
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
#include "Verve/Extension/Camera/VCameraShakeEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraShakeEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraShakeEvent::VCameraShakeEvent( void ) :
|
||||
mAmplitude( Point3F::Zero ),
|
||||
mFalloff( 10.f ),
|
||||
mFrequency( Point3F::Zero )
|
||||
{
|
||||
// Clear Label.
|
||||
setLabel( "CameraShakeEvent" );
|
||||
}
|
||||
|
||||
void VCameraShakeEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Amplitude", TypePoint3F, Offset( mAmplitude, VCameraShakeEvent ), "Amplitude of the Camera Shake event." );
|
||||
addField( "Falloff", TypeF32, Offset( mFalloff, VCameraShakeEvent ), "Falloff of the Camera Shake event." );
|
||||
addField( "Frequency", TypePoint3F, Offset( mFrequency, VCameraShakeEvent ), "Frequency of the Camera Shake event." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraShakeEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Start shaking the camera. Also account for any offet in playtime, and
|
||||
// timescale.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraShakeEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch Group.
|
||||
VCameraGroup *group;
|
||||
if ( !getGroup( group ) || !group->isActive() )
|
||||
{
|
||||
// Inactive.
|
||||
return;
|
||||
}
|
||||
|
||||
// Duration.
|
||||
//const F32 duration = ( mDuration - mAbs( pTime - getStartTime() ) ) / ( 1000.f * mFabs( getControllerTimeScale() ) );
|
||||
const F32 duration = ( mDuration - mAbs( pTime - getStartTime() ) ) / 1000.f;
|
||||
|
||||
// Shake Camera.
|
||||
VTorque::startCameraShake( duration, mFalloff, mAmplitude, mFrequency );
|
||||
}
|
||||
59
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.h
Normal file
59
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VCAMERASHAKEEVENT_H_
|
||||
#define _VT_VCAMERASHAKEEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraShakeEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VectorF mAmplitude;
|
||||
F32 mFalloff;
|
||||
VectorF mFrequency;
|
||||
|
||||
public:
|
||||
|
||||
VCameraShakeEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraShakeEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERASHAKEEVENT_H_
|
||||
114
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.cpp
Normal file
114
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.cpp
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Camera/VCameraShakeTrack.h"
|
||||
#include "Verve/Extension/Camera/VCameraShakeEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraShakeTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraShakeTrack::VCameraShakeTrack( void )
|
||||
{
|
||||
setLabel( "CameraShakeTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Camera Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraShakeTrack::onCameraEvent( pEvent );
|
||||
//
|
||||
// When the Camera changes, this method is called on both the outgoing and
|
||||
// incoming Camera Groups.
|
||||
//
|
||||
// For a full list of possible events, see the 'eCameraEventType' declaration
|
||||
// in VCameraGroup.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VCameraShakeTrack::onCameraEvent( const VCameraGroup::eCameraEventType &pEvent )
|
||||
{
|
||||
// Parent Call.
|
||||
if ( !Parent::onCameraEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch( pEvent )
|
||||
{
|
||||
case VCameraGroup::k_EventActivate :
|
||||
{
|
||||
|
||||
VCameraShakeEvent *event;
|
||||
if ( getCurrentEvent( event ) )
|
||||
{
|
||||
// Re-Trigger Event.
|
||||
event->onTrigger( getControllerTime(), 0 );
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case VCameraGroup::k_EventDeactivate :
|
||||
{
|
||||
|
||||
// Stop Camera Shake.
|
||||
VTorque::stopCameraShake();
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraShakeTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Stop all camera shake events.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraShakeTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Default Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
// Stop Camera Shake.
|
||||
VTorque::stopCameraShake();
|
||||
}
|
||||
55
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.h
Normal file
55
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.h
Normal 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_VCAMERASHAKETRACK_H_
|
||||
#define _VT_VCAMERASHAKETRACK_H_
|
||||
|
||||
#ifndef _VT_VCAMERATRACK_H_
|
||||
#include "Verve/Extension/Camera/VCameraTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraShakeTrack : public VCameraTrack
|
||||
{
|
||||
typedef VCameraTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VCameraShakeTrack( void );
|
||||
|
||||
// Camera Methods.
|
||||
|
||||
bool onCameraEvent( const VCameraGroup::eCameraEventType &pEvent );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraShakeTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERASHAKETRACK_H_
|
||||
108
Engine/modules/Verve/Extension/Camera/VCameraTrack.cpp
Normal file
108
Engine/modules/Verve/Extension/Camera/VCameraTrack.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Camera/VCameraTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraTrack::VCameraTrack( void )
|
||||
{
|
||||
setLabel( "CameraTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Tree Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraTrack::onAttach();
|
||||
//
|
||||
// This callback subscribes this object to the Camera Group's event signal.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraTrack::onAttach( void )
|
||||
{
|
||||
Parent::onAttach();
|
||||
|
||||
// Valid Controller & Group?
|
||||
VCameraGroup *group;
|
||||
if ( getController() && getGroup( group ) )
|
||||
{
|
||||
// Add Event Notification.
|
||||
group->getCameraEventSignal().notify( this, &VCameraTrack::onCameraEvent );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraTrack::onAttach();
|
||||
//
|
||||
// This callback removes this object from the Camera Group's event signal
|
||||
// notification list.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraTrack::onDetach( void )
|
||||
{
|
||||
// Valid Controller & Group?
|
||||
VCameraGroup *group;
|
||||
if ( getController() && getGroup( group ) )
|
||||
{
|
||||
// Clear Event Notification.
|
||||
group->getCameraEventSignal().remove( this, &VCameraTrack::onCameraEvent );
|
||||
}
|
||||
|
||||
Parent::onDetach();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Camera Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraTrack::onCameraEvent( pEvent );
|
||||
//
|
||||
// When the Camera changes, this method is called on both the outgoing and
|
||||
// incomming Camera Groups.
|
||||
//
|
||||
// For a full list of possible events, see the 'eCameraEventType' declaration
|
||||
// in VCameraGroup.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VCameraTrack::onCameraEvent( const VCameraGroup::eCameraEventType &pEvent )
|
||||
{
|
||||
if ( !getController() )
|
||||
{
|
||||
AssertFatal( false, "VCameraTrack::onControllerEvent() - Invalid Controller." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ok.
|
||||
return true;
|
||||
}
|
||||
60
Engine/modules/Verve/Extension/Camera/VCameraTrack.h
Normal file
60
Engine/modules/Verve/Extension/Camera/VCameraTrack.h
Normal 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_VCAMERATRACK_H_
|
||||
#define _VT_VCAMERATRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VCAMERAGROUP_H_
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VCameraTrack( void );
|
||||
|
||||
// Tree Methods.
|
||||
|
||||
void onAttach( void );
|
||||
void onDetach( void );
|
||||
|
||||
// Camera Methods.
|
||||
|
||||
virtual bool onCameraEvent( const VCameraGroup::eCameraEventType &pEvent );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERATRACK_H_
|
||||
75
Engine/modules/Verve/Extension/Director/VDirectorEvent.cpp
Normal file
75
Engine/modules/Verve/Extension/Director/VDirectorEvent.cpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VGroup.h"
|
||||
#include "Verve/Extension/Director/VDirectorEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VDirectorEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VDirectorEvent::VDirectorEvent( void ) :
|
||||
mTarget( String::EmptyString )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
void VDirectorEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Target", TypeRealString, Offset( mTarget, VDirectorEvent ), "The name of the CameraGroup that will be activated upon triggering." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDirectorEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Cut the camera to the target group.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VDirectorEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch Controller.
|
||||
VController *controller = getController();
|
||||
|
||||
// Valid Target?
|
||||
VCameraGroup *targetGroup = NULL;
|
||||
if ( !controller->getObject( mTarget, targetGroup ) )
|
||||
{
|
||||
Con::warnf( "VDirectorEvent::onTrigger() - Invalid Target Group specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
// Change Camera.
|
||||
targetGroup->setActive();
|
||||
}
|
||||
61
Engine/modules/Verve/Extension/Director/VDirectorEvent.h
Normal file
61
Engine/modules/Verve/Extension/Director/VDirectorEvent.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VDIRECTOREVENT_H_
|
||||
#define _VT_VDIRECTOREVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VCAMERAGROUP_H_
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VDirectorEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
String mTarget;
|
||||
|
||||
public:
|
||||
|
||||
VDirectorEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VDirectorEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VDIRECTOREVENT_H_
|
||||
57
Engine/modules/Verve/Extension/Director/VDirectorGroup.cpp
Normal file
57
Engine/modules/Verve/Extension/Director/VDirectorGroup.cpp
Normal 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/Extension/Director/VDirectorGroup.h"
|
||||
#include "Verve/Extension/Director/VDirectorTrack.h"
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VDirectorGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VDirectorGroup::VDirectorGroup( void ) :
|
||||
mActiveCamera( NULL )
|
||||
{
|
||||
setLabel( "DirectorGroup" );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VDirectorGroup::getDirectorTrack();
|
||||
//
|
||||
// Returns the DirectorTrack reference.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VDirectorTrack *VDirectorGroup::getDirectorTrack( void )
|
||||
{
|
||||
for ( ITreeNode *node = mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
if ( VDirectorTrack *track = dynamic_cast<VDirectorTrack*>( node ) )
|
||||
{
|
||||
// Return Track.
|
||||
return track;
|
||||
}
|
||||
}
|
||||
|
||||
// Invalid Track.
|
||||
return NULL;
|
||||
}
|
||||
59
Engine/modules/Verve/Extension/Director/VDirectorGroup.h
Normal file
59
Engine/modules/Verve/Extension/Director/VDirectorGroup.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VDIRECTORGROUP_H_
|
||||
#define _VT_VDIRECTORGROUP_H_
|
||||
|
||||
#ifndef _VT_VGROUP_H_
|
||||
#include "Verve/Core/VGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VDirectorTrack;
|
||||
class VCameraGroup;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VDirectorGroup : public VGroup
|
||||
{
|
||||
typedef VGroup Parent;
|
||||
|
||||
protected:
|
||||
|
||||
// Camera.
|
||||
VCameraGroup *mActiveCamera;
|
||||
|
||||
public:
|
||||
|
||||
VDirectorGroup( void );
|
||||
|
||||
VDirectorTrack *getDirectorTrack( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VDirectorGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VDIRECTORGROUP_H_
|
||||
63
Engine/modules/Verve/Extension/Director/VDirectorTrack.cpp
Normal file
63
Engine/modules/Verve/Extension/Director/VDirectorTrack.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Director/VDirectorTrack.h"
|
||||
|
||||
#include "math/mMathFn.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VDirectorTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VDirectorTrack::VDirectorTrack( void )
|
||||
{
|
||||
setLabel( "DirectorTrack" );
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Debug Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VDirectorTrack, updateTrack, void, 2, 2, "( void ) - Update the Track.\n"
|
||||
"@return No return value." )
|
||||
{
|
||||
for ( ITreeNode *node = object->mChildNode; node != NULL; node = node->mSiblingNextNode )
|
||||
{
|
||||
VEvent *currEvent = ( VEvent* )node;
|
||||
VEvent *nextEvent = ( VEvent* )node->mSiblingNextNode;
|
||||
|
||||
if ( !nextEvent )
|
||||
{
|
||||
// Update Duration.
|
||||
currEvent->setDuration( object->getControllerDuration() - currEvent->getTriggerTime() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update Duration.
|
||||
currEvent->setDuration( mAbs( nextEvent->getTriggerTime() - currEvent->getTriggerTime() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
47
Engine/modules/Verve/Extension/Director/VDirectorTrack.h
Normal file
47
Engine/modules/Verve/Extension/Director/VDirectorTrack.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VDIRECTORTRACK_H_
|
||||
#define _VT_VDIRECTORTRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VDirectorTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VDirectorTrack( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VDirectorTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VDIRECTORTRACK_H_
|
||||
82
Engine/modules/Verve/Extension/Director/VSceneJumpEvent.cpp
Normal file
82
Engine/modules/Verve/Extension/Director/VSceneJumpEvent.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VController.h"
|
||||
#include "Verve/Extension/Director/VSceneJumpEvent.h"
|
||||
#include "Verve/Extension/Director/VDirectorGroup.h"
|
||||
#include "Verve/Extension/Director/VDirectorTrack.h"
|
||||
#include "Verve/Extension/Director/VDirectorEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSceneJumpEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSceneJumpEvent::VSceneJumpEvent( void ) :
|
||||
mTarget( String::EmptyString )
|
||||
{
|
||||
setLabel( "SceneJumpEvent" );
|
||||
}
|
||||
|
||||
void VSceneJumpEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Target", TypeRealString, Offset( mTarget, VSceneJumpEvent ), "The name of the Scene that the controller will jump to upon triggering." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSceneJumpEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Tell the controller to jump to a new scene.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSceneJumpEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
VDirectorTrack *track = getController()->getDirectorTrack();
|
||||
if ( !track )
|
||||
{
|
||||
// Invalid Track.
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Event.
|
||||
VDirectorEvent *event;
|
||||
if ( !track->getObject( mTarget, event ) )
|
||||
{
|
||||
// Can't Jump.
|
||||
return;
|
||||
}
|
||||
|
||||
// Go To Scene.
|
||||
getController()->jump( VController::k_JumpTime, event->getTriggerTime() );
|
||||
}
|
||||
57
Engine/modules/Verve/Extension/Director/VSceneJumpEvent.h
Normal file
57
Engine/modules/Verve/Extension/Director/VSceneJumpEvent.h
Normal 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_VSCENEJUMPEVENT_H_
|
||||
#define _VT_VSCENEJUMPEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSceneJumpEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
String mTarget;
|
||||
|
||||
public:
|
||||
|
||||
VSceneJumpEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSceneJumpEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSCENEJUMPEVENT_H_
|
||||
32
Engine/modules/Verve/Extension/Director/VSceneJumpTrack.cpp
Normal file
32
Engine/modules/Verve/Extension/Director/VSceneJumpTrack.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Director/VSceneJumpTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSceneJumpTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSceneJumpTrack::VSceneJumpTrack( void )
|
||||
{
|
||||
setLabel( "SceneJumpTrack" );
|
||||
}
|
||||
47
Engine/modules/Verve/Extension/Director/VSceneJumpTrack.h
Normal file
47
Engine/modules/Verve/Extension/Director/VSceneJumpTrack.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSCENEJUMPTRACK_H_
|
||||
#define _VT_VSCENEJUMPTRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSceneJumpTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSceneJumpTrack( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSceneJumpTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSCENEJUMPTRACK_H_
|
||||
130
Engine/modules/Verve/Extension/Director/VSlowMoEvent.cpp
Normal file
130
Engine/modules/Verve/Extension/Director/VSlowMoEvent.cpp
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VController.h"
|
||||
#include "Verve/Extension/Director/VSlowMoEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSlowMoEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSlowMoEvent::VSlowMoEvent( void ) :
|
||||
mTimeScale( 1.f ),
|
||||
mTimeScaleTickDelta( 0.f )
|
||||
{
|
||||
setLabel( "SlowMoEvent" );
|
||||
}
|
||||
|
||||
void VSlowMoEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "TimeScale", TypeF32, Offset( mTimeScale, VSlowMoEvent ), "The Time Scale to be applied to the Root Controller." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSlowMoEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSlowMoEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
VController *controller = getController();
|
||||
if ( !controller )
|
||||
{
|
||||
// Invalid Controller.
|
||||
return;
|
||||
}
|
||||
|
||||
// Instant Update?
|
||||
if ( getDuration() == 0 )
|
||||
{
|
||||
// Apply & Return.
|
||||
controller->setTimeScale( mTimeScale );
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine the Number of Ticks.
|
||||
const F32 tickCount = ( ( F32 )getDuration() ) / TickMs;
|
||||
|
||||
// Determine the Tick Delta.
|
||||
mTimeScaleTickDelta = ( mTimeScale - controller->getTimeScale() ) / tickCount;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSlowMoEvent::onUpdate( pTime, pDelta );
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSlowMoEvent::onUpdate( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onUpdate( pTime, pDelta );
|
||||
|
||||
VController *controller = getController();
|
||||
if ( !controller )
|
||||
{
|
||||
// Invalid Controller.
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch Current Time Scale.
|
||||
const F32 timeScale = controller->getTimeScale();
|
||||
|
||||
// Apply Update.
|
||||
controller->setTimeScale( timeScale + mTimeScaleTickDelta );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSlowMoEvent::onComplete( pTime, pDelta );
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSlowMoEvent::onComplete( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onComplete( pTime, pDelta );
|
||||
|
||||
VController *controller = getController();
|
||||
if ( !controller )
|
||||
{
|
||||
// Invalid Controller.
|
||||
return;
|
||||
}
|
||||
|
||||
// Tidy Up.
|
||||
controller->setTimeScale( mTimeScale );
|
||||
}
|
||||
60
Engine/modules/Verve/Extension/Director/VSlowMoEvent.h
Normal file
60
Engine/modules/Verve/Extension/Director/VSlowMoEvent.h
Normal 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_VSLOWMOEVENT_H_
|
||||
#define _VT_VSLOWMOEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSlowMoEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
F32 mTimeScale;
|
||||
F32 mTimeScaleTickDelta;
|
||||
|
||||
public:
|
||||
|
||||
VSlowMoEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onUpdate( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSlowMoEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSLOWMOEVENT_H_
|
||||
93
Engine/modules/Verve/Extension/Director/VSlowMoTrack.cpp
Normal file
93
Engine/modules/Verve/Extension/Director/VSlowMoTrack.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Director/VSlowMoTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSlowMoTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSlowMoTrack::VSlowMoTrack( void )
|
||||
{
|
||||
setLabel( "SlowMoTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSlowMoTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VSlowMoTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Reset Time Scale.
|
||||
getController()->setTimeScale( ( isControllerPlayingForward() ) ? 1.f : -1.f );
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSlowMoTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSlowMoTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Parent Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
// Reset Time Scale.
|
||||
getController()->setTimeScale( ( pForward ) ? 1.f : -1.f );
|
||||
}
|
||||
52
Engine/modules/Verve/Extension/Director/VSlowMoTrack.h
Normal file
52
Engine/modules/Verve/Extension/Director/VSlowMoTrack.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSLOWMOTRACK_H_
|
||||
#define _VT_VSLOWMOTRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSlowMoTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSlowMoTrack( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSlowMoTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSLOWMOTRACK_H_
|
||||
111
Engine/modules/Verve/Extension/GUI/VFadeEvent.cpp
Normal file
111
Engine/modules/Verve/Extension/GUI/VFadeEvent.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/GUI/VFadeEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VFadeEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VFadeEvent::VFadeEvent( void )
|
||||
{
|
||||
setLabel( "FadeEvent" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Start the fade sequence if a valid fade control can be found.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VFadeEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl;
|
||||
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
// Start Fade.
|
||||
fadeControl->start( getFadeType(), mDuration );
|
||||
|
||||
// Set Elapsed Time.
|
||||
fadeControl->mElapsedTime = mAbs( pTime - getStartTime() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeEvent::onComplete( pTime, pDelta );
|
||||
//
|
||||
// Tidy up the fade control once the event has finished.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VFadeEvent::onComplete( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl;
|
||||
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Elapsed Time.
|
||||
fadeControl->mElapsedTime = mDuration;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Property Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeEvent::getFadeType();
|
||||
//
|
||||
// Returns the type of fade (in or out) that this event will use. Zero and Even
|
||||
// indices will Fade Out, while Odd numbers will Fade In.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VFadeControl::eFadeType VFadeEvent::getFadeType( void )
|
||||
{
|
||||
if ( !isControllerPlayingForward() )
|
||||
{
|
||||
return ( getIndex() % 2 == 0 ) ? VFadeControl::k_TypeOut : VFadeControl::k_TypeIn;
|
||||
}
|
||||
|
||||
return ( getIndex() % 2 == 0 ) ? VFadeControl::k_TypeIn : VFadeControl::k_TypeOut;
|
||||
}
|
||||
60
Engine/modules/Verve/Extension/GUI/VFadeEvent.h
Normal file
60
Engine/modules/Verve/Extension/GUI/VFadeEvent.h
Normal 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_VFADEEVENT_H_
|
||||
#define _VT_VFADEEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VFADECONTROL_H_
|
||||
#include "Verve/GUI/VFadeControl.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VFadeEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VFadeEvent( void );
|
||||
|
||||
// Callback Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VFadeEvent );
|
||||
|
||||
public:
|
||||
|
||||
VFadeControl::eFadeType getFadeType( void );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VFADEEVENT_H_
|
||||
139
Engine/modules/Verve/Extension/GUI/VFadeTrack.cpp
Normal file
139
Engine/modules/Verve/Extension/GUI/VFadeTrack.cpp
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/GUI/VFadeTrack.h"
|
||||
#include "Verve/Extension/GUI/VFadeEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VFadeTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VFadeTrack::VFadeTrack( void )
|
||||
{
|
||||
setLabel( "FadeTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// When the controller's state changes, this method is called. If the
|
||||
// controller is paused, or stops playing, then the fade control will cease
|
||||
// playing. If the controller resumes play, the fade control will continue.
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VFadeTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fetch the next Event.
|
||||
VFadeEvent *event;
|
||||
if ( !getNextEvent( event ) )
|
||||
{
|
||||
// No Event.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl = dynamic_cast<VFadeControl*>( Sim::findObject( "VFadeControlGui" ) );
|
||||
if ( !fadeControl )
|
||||
{
|
||||
// No Control.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventPlay:
|
||||
{
|
||||
// Play?
|
||||
const S32 &time = getControllerTime();
|
||||
fadeControl->mActive = ( time > event->getTriggerTime()
|
||||
&& time < event->getFinishTime() ) ;
|
||||
|
||||
} break;
|
||||
|
||||
case VController::k_EventPause :
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Pause.
|
||||
fadeControl->mActive = false;
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Reset the fade state of the fade control.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VFadeTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl;
|
||||
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
VFadeEvent *event;
|
||||
if ( !getNextEvent( event ) )
|
||||
{
|
||||
// No Events.
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply Settings.
|
||||
fadeControl->mActive = false;
|
||||
fadeControl->mFadeType = event->getFadeType();
|
||||
fadeControl->mDuration = event->getDuration();
|
||||
fadeControl->mElapsedTime = getMax( pTime - event->getTriggerTime(), 0 );
|
||||
}
|
||||
52
Engine/modules/Verve/Extension/GUI/VFadeTrack.h
Normal file
52
Engine/modules/Verve/Extension/GUI/VFadeTrack.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VFADETRACK_H_
|
||||
#define _VT_VFADETRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VFadeTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VFadeTrack( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VFadeTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VFADETRACK_H_
|
||||
32
Engine/modules/Verve/Extension/Game/VSpawnSphereGroup.cpp
Normal file
32
Engine/modules/Verve/Extension/Game/VSpawnSphereGroup.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Game/VSpawnSphereGroup.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSpawnSphereGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSpawnSphereGroup::VSpawnSphereGroup( void )
|
||||
{
|
||||
setLabel( "SpawnSphereGroup" );
|
||||
};
|
||||
47
Engine/modules/Verve/Extension/Game/VSpawnSphereGroup.h
Normal file
47
Engine/modules/Verve/Extension/Game/VSpawnSphereGroup.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSPAWNSPHEREGROUP_H_
|
||||
#define _VT_VSPAWNSPHEREGROUP_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTGROUP_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSpawnSphereGroup : public VSceneObjectGroup
|
||||
{
|
||||
typedef VSceneObjectGroup Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSpawnSphereGroup( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSpawnSphereGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSPAWNSPHEREGROUP_H_
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Game/VSpawnSphereSpawnTargetEvent.h"
|
||||
#include "Verve/Extension/Game/VSpawnSphereSpawnTargetTrack.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSpawnSphereSpawnTargetEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSpawnSphereSpawnTargetEvent::VSpawnSphereSpawnTargetEvent( void )
|
||||
{
|
||||
setLabel( "SpawnTargetEvent" );
|
||||
}
|
||||
|
||||
void VSpawnSphereSpawnTargetEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSpawnSphereSpawnTargetEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Spawn the Target.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSpawnSphereSpawnTargetEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch Track.
|
||||
VSpawnSphereSpawnTargetTrack *track;
|
||||
if ( !getTrack( track ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn the Target.
|
||||
track->spawnTarget();
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSPAWNSPHERESPAWNTARGETEVENT_H_
|
||||
#define _VT_VSPAWNSPHERESPAWNTARGETEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_SPAWNSPHERE_H_
|
||||
#include "Verve/Torque/TSpawnSphere.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSpawnSphereSpawnTargetEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
public:
|
||||
|
||||
VSpawnSphereSpawnTargetEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSpawnSphereSpawnTargetEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSPAWNSPHERESPAWNTARGETEVENT_H_
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Game/VSpawnSphereSpawnTargetTrack.h"
|
||||
#include "Verve/Torque/TSpawnSphere.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSpawnSphereSpawnTargetTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSpawnSphereSpawnTargetTrack::VSpawnSphereSpawnTargetTrack( void )
|
||||
{
|
||||
setLabel( "SpawnTargetTrack" );
|
||||
}
|
||||
|
||||
void VSpawnSphereSpawnTargetTrack::initPersistFields( void )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "DespawnOnLoop", TypeBool, Offset( mDespawnOnLoop, VSpawnSphereSpawnTargetTrack ), "Despawn all targets when the Controller loops?" );
|
||||
addField( "DespawnOnStop", TypeBool, Offset( mDespawnOnStop, VSpawnSphereSpawnTargetTrack ), "Despawn all targets when the Controller stops playing?" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSpawnSphereSpawnTargetTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VSpawnSphereSpawnTargetTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventLoop :
|
||||
{
|
||||
if ( mDespawnOnLoop )
|
||||
{
|
||||
despawnTargets();
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
if ( mDespawnOnStop )
|
||||
{
|
||||
despawnTargets();
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Spawn Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSpawnSphereSpawnTargetTrack::spawnTarget( pTime, pForward );
|
||||
//
|
||||
// Spawn an Object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSpawnSphereSpawnTargetTrack::spawnTarget( void )
|
||||
{
|
||||
VTorque::SpawnSphereType *object;
|
||||
if ( !getSceneObject( object ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn the Object.
|
||||
SimObject *spawnedObject = object->spawnObject();
|
||||
|
||||
// Scene Object?
|
||||
VTorque::SceneObjectType *sceneObject = dynamic_cast<VTorque::SceneObjectType*>( spawnedObject );
|
||||
if ( sceneObject )
|
||||
{
|
||||
sceneObject->setPosition( object->getPosition() );
|
||||
}
|
||||
|
||||
// Valid?
|
||||
if ( spawnedObject )
|
||||
{
|
||||
// Add Reference.
|
||||
mSpawnList.addObject( spawnedObject );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSpawnSphereSpawnTargetTrack::despawnTargets();
|
||||
//
|
||||
// Despawn all of the objects spawned by this track.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSpawnSphereSpawnTargetTrack::despawnTargets( void )
|
||||
{
|
||||
while( mSpawnList.size() > 0 )
|
||||
{
|
||||
// Fetch the Last Object
|
||||
SimObject *object = mSpawnList.last();
|
||||
// Remove it.
|
||||
mSpawnList.popObject();
|
||||
|
||||
// Delete the Object.
|
||||
object->deleteObject();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSPAWNSPHERESPAWNTARGETTRACK_H_
|
||||
#define _VT_VSPAWNSPHERESPAWNTARGETTRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
|
||||
#include "Verve/Torque/TLightObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSpawnSphereSpawnTargetTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
protected:
|
||||
|
||||
SimSet mSpawnList;
|
||||
|
||||
bool mDespawnOnStop;
|
||||
bool mDespawnOnLoop;
|
||||
|
||||
public:
|
||||
|
||||
VSpawnSphereSpawnTargetTrack( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
|
||||
// Spawn Methods.
|
||||
|
||||
virtual void spawnTarget( void );
|
||||
virtual void despawnTargets( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSpawnSphereSpawnTargetTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSPAWNSPHERESPAWNTARGETTRACK_H_
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/LightObject/VLightObjectAnimationEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VLightObjectAnimationEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VLightObjectAnimationEvent::VLightObjectAnimationEvent( void ) :
|
||||
mAnimationData( NULL )
|
||||
{
|
||||
setLabel( "AnimationEvent" );
|
||||
}
|
||||
|
||||
void VLightObjectAnimationEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "AnimationData", TYPEID<VTorque::LightAnimationDataType>(), Offset( mAnimationData, VLightObjectAnimationEvent ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VLightObjectAnimationEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// When this Event is triggered the light object will begin to play the target
|
||||
// animation.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VLightObjectAnimationEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch the Light Object.
|
||||
VTorque::LightObjectType *lightObject;
|
||||
if ( getSceneObject( lightObject ) )
|
||||
{
|
||||
// Play the Animation.
|
||||
VTorque::playAnimation( lightObject, mAnimationData );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VLightObjectAnimationEvent::onComplete( pTime, pDelta );
|
||||
//
|
||||
// The current animation played by the light object will be paused when this
|
||||
// Event completes its updates.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VLightObjectAnimationEvent::onComplete( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch the Light Object.
|
||||
VTorque::LightObjectType *lightObject;
|
||||
if ( getSceneObject( lightObject ) )
|
||||
{
|
||||
// Pause the Animation.
|
||||
VTorque::pauseAnimation( lightObject );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VLIGHTOBJECTANIMATIONEVENT_H_
|
||||
#define _VT_VLIGHTOBJECTANIMATIONEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
|
||||
#include "Verve/Torque/TLightObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VLightObjectAnimationEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
SimObjectPtr<VTorque::LightAnimationDataType> mAnimationData;
|
||||
|
||||
public:
|
||||
|
||||
VLightObjectAnimationEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VLightObjectAnimationEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VLIGHTOBJECTANIMATIONEVENT_H_
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/LightObject/VLightObjectAnimationTrack.h"
|
||||
#include "Verve/Extension/LightObject/VLightObjectAnimationEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VLightObjectAnimationTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VLightObjectAnimationTrack::VLightObjectAnimationTrack( void )
|
||||
{
|
||||
setLabel( "AnimationTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VLightObjectAnimationTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VLightObjectAnimationTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fetch the Light Object.
|
||||
VTorque::LightObjectType *lightObject;
|
||||
if ( !getSceneObject( lightObject ) )
|
||||
{
|
||||
// Skip.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventPlay :
|
||||
{
|
||||
|
||||
// Play Animation?
|
||||
VLightObjectAnimationEvent *event;
|
||||
if ( getCurrentEvent( event ) )
|
||||
{
|
||||
// Play.
|
||||
VTorque::playAnimation( lightObject );
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case VController::k_EventPause :
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Stop the Animation.
|
||||
VTorque::pauseAnimation( lightObject );
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VLightObjectAnimationTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VLightObjectAnimationTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Default Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
// Fetch the Light Object.
|
||||
VTorque::LightObjectType *lightObject;
|
||||
if ( getSceneObject( lightObject ) )
|
||||
{
|
||||
// Stop the Animation.
|
||||
VTorque::pauseAnimation( lightObject );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VLIGHTOBJECTANIMATIONTRACK_H_
|
||||
#define _VT_VLIGHTOBJECTANIMATIONTRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
|
||||
#include "Verve/Torque/TLightObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VLightObjectAnimationTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VLightObjectAnimationTrack( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VLightObjectAnimationTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VLIGHTOBJECTANIMATIONTRACK_H_
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/LightObject/VLightObjectGroup.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VLightObjectGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VLightObjectGroup::VLightObjectGroup( void )
|
||||
{
|
||||
setLabel( "LightObjectGroup" );
|
||||
};
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VLIGHTOBJECTGROUP_H_
|
||||
#define _VT_VLIGHTOBJECTGROUP_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTGROUP_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VLightObjectGroup : public VSceneObjectGroup
|
||||
{
|
||||
typedef VSceneObjectGroup Parent;
|
||||
|
||||
public:
|
||||
|
||||
VLightObjectGroup( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VLightObjectGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VLIGHTOBJECTGROUP_H_
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/LightObject/VLightObjectToggleEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VLightObjectToggleEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VLightObjectToggleEvent::VLightObjectToggleEvent( void ) :
|
||||
mEventType( VSharedEnum::k_ActionTurnOn )
|
||||
{
|
||||
setLabel( "ToggleEvent" );
|
||||
}
|
||||
|
||||
void VLightObjectToggleEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Action", TYPEID<VActionToggle>(), Offset( mEventType, VLightObjectToggleEvent ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VLightObjectToggleEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Toggle the Light Object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VLightObjectToggleEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
VTorque::LightObjectType *lightObject;
|
||||
if ( getSceneObject( lightObject ) )
|
||||
{
|
||||
// Turn On?
|
||||
const bool turnOn = ( mEventType == VSharedEnum::k_ActionTurnOn );
|
||||
|
||||
// Toggle Light.
|
||||
VTorque::setLightObjectOn( lightObject, turnOn );
|
||||
}
|
||||
}
|
||||
|
|
@ -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_VLIGHTOBJECTTOGGLEEVENT_H_
|
||||
#define _VT_VLIGHTOBJECTTOGGLEEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
|
||||
#include "Verve/Torque/TLightObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VSHAREDENUM_H_
|
||||
#include "Verve/Core/Util/VSharedEnum.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VLightObjectToggleEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSharedEnum::eActionToggle mEventType;
|
||||
|
||||
public:
|
||||
|
||||
VLightObjectToggleEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VLightObjectToggleEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VLIGHTOBJECTTOGGLEEVENT_H_
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/LightObject/VLightObjectToggleTrack.h"
|
||||
#include "Verve/Extension/LightObject/VLightObjectToggleEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VLightObjectToggleTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VLightObjectToggleTrack::VLightObjectToggleTrack( void )
|
||||
{
|
||||
setLabel( "ToggleTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VLightObjectToggleTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Enable or Disable the light object after a reset.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VLightObjectToggleTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Default Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
VLightObjectToggleEvent *event;
|
||||
VTorque::LightObjectType *lightObject;
|
||||
if ( getSceneObject( lightObject ) && getPreviousEvent( event ) )
|
||||
{
|
||||
// Turn On?
|
||||
const bool turnOn = ( event->mEventType == VSharedEnum::k_ActionTurnOn );
|
||||
|
||||
// Toggle the Light.
|
||||
VTorque::setLightObjectOn( lightObject, turnOn );
|
||||
}
|
||||
}
|
||||
|
|
@ -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_VLIGHTOBJECTTOGGLETRACK_H_
|
||||
#define _VT_VLIGHTOBJECTTOGGLETRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
|
||||
#include "Verve/Torque/TLightObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VLightObjectToggleTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VLightObjectToggleTrack( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VLightObjectToggleTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VLIGHTOBJECTTOGGLETRACK_H_
|
||||
212
Engine/modules/Verve/Extension/Motion/VMotionEvent.cpp
Normal file
212
Engine/modules/Verve/Extension/Motion/VMotionEvent.cpp
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VController.h"
|
||||
#include "Verve/Core/VGroup.h"
|
||||
#include "Verve/Extension/Motion/VMotionEvent.h"
|
||||
#include "Verve/Extension/Motion/VMotionTrack.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "math/mMathFn.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VMotionEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VMotionEvent::VMotionEvent( void )
|
||||
{
|
||||
setLabel( "MotionEvent" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionEvent::onTrigger( pDelta, pDelta );
|
||||
//
|
||||
// The path object is told to move to the next node. If this event corresponds
|
||||
// to Node 0, the object will move to Node 1. If the object reaches the node
|
||||
// before the next event is triggered, then the object will stop moving.
|
||||
//
|
||||
// The object's position is only reset when the track is reset and not when an
|
||||
// event is triggered.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VMotionEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch Parent Track.
|
||||
VMotionTrack *track;
|
||||
if ( !getTrack( track ) )
|
||||
{
|
||||
// Invalid Track.
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch Path & Reference Object.
|
||||
VTorque::PathObjectType *path = track->getPath();
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !path || !object )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
// Valid Destination Node?
|
||||
if ( !isControllerLooping() && !getNextEvent() )
|
||||
{
|
||||
// Clear Active.
|
||||
VTorque::setPathObjectActive( path, object, false );
|
||||
// Quit.
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Active.
|
||||
VTorque::setPathObjectActive( path, object, true );
|
||||
|
||||
// Apply Speed.
|
||||
VTorque::setPathObjectSpeed( path, object, getObjectSpeed() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::getPath();
|
||||
//
|
||||
// Returns the path that this track is referencing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VTorque::PathObjectType *VMotionEvent::getPath( void )
|
||||
{
|
||||
// Fetch Track.
|
||||
VMotionTrack *track;
|
||||
if ( !getTrack( track ) )
|
||||
{
|
||||
// Invalid.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Return Path.
|
||||
return track->getPath();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::getObjectSpeed();
|
||||
//
|
||||
// Determine the Speed that an object must move at to travel over the segment
|
||||
// length of the Path.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
F32 VMotionEvent::getObjectSpeed( void )
|
||||
{
|
||||
// Fetch Parent Track.
|
||||
VMotionTrack *track;
|
||||
if ( !getTrack( track ) )
|
||||
{
|
||||
// Invalid Track.
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
// Fetch Path & Reference Object.
|
||||
VTorque::PathObjectType *path = track->getPath();
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !path || !object )
|
||||
{
|
||||
// Invalid Object(s).
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
// Fetch Node Index.
|
||||
const S32 &srcNodeIndex = getNodeIndex( ( isControllerPlayingForward() ) ? 0 : -1 );
|
||||
|
||||
// Fetch the Next Event.
|
||||
VEvent *nextEvent = getNextEvent();
|
||||
|
||||
// Valid Destination Node?
|
||||
if ( !isControllerLooping() && !nextEvent )
|
||||
{
|
||||
// No Next Node.
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
// Valid Next Node?
|
||||
if ( nextEvent )
|
||||
{
|
||||
// Fetch Segment Length & Duration.
|
||||
const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex );
|
||||
const F32 &duration = mAbs( getTriggerTime() - nextEvent->getTriggerTime() );
|
||||
|
||||
// Speed = Distance / Duration.
|
||||
return ( length / ( duration / 1000.f ) );
|
||||
}
|
||||
|
||||
// Playing Forwards?
|
||||
if ( isControllerPlayingForward() )
|
||||
{
|
||||
// Fetch the First Event.
|
||||
VEvent *firstEvent = dynamic_cast<VEvent*>( track->getChild() );
|
||||
|
||||
// Fetch Segment Length & Duration.
|
||||
const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex );
|
||||
const F32 &duration = ( getControllerDuration() - getTriggerTime() ) + firstEvent->getTriggerTime();
|
||||
|
||||
// Speed = Distance / Duration.
|
||||
return ( length / ( duration / 1000.f ) );
|
||||
}
|
||||
|
||||
// Fetch the Last Event.
|
||||
VEvent *lastEvent = dynamic_cast<VEvent*>( track->getLastChild() );
|
||||
|
||||
// Fetch Segment Length & Duration.
|
||||
const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex );
|
||||
const F32 &duration = ( getControllerDuration() - lastEvent->getTriggerTime() ) + getTriggerTime();
|
||||
|
||||
// Speed = Distance / Duration.
|
||||
return ( length / ( duration / 1000.f ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionEvent::getNodeIndex( pDelta );
|
||||
//
|
||||
// Returns the index of the path node associated with this event object.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
S32 VMotionEvent::getNodeIndex( const S32 &pDelta )
|
||||
{
|
||||
// Fetch Event Count.
|
||||
const S32 eventCount = ( ( VTreeNode* )getParent() )->size();
|
||||
|
||||
// Return Index.
|
||||
return ( getIndex() + pDelta ) % eventCount;
|
||||
}
|
||||
61
Engine/modules/Verve/Extension/Motion/VMotionEvent.h
Normal file
61
Engine/modules/Verve/Extension/Motion/VMotionEvent.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VMOTIONEVENT_H_
|
||||
#define _VT_VMOTIONEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_MOTION_H_
|
||||
#include "Verve/Torque/TMotion.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VMotionEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VSceneObjectEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VMotionEvent( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
virtual VTorque::PathObjectType *getPath( void );
|
||||
F32 getObjectSpeed( void );
|
||||
S32 getNodeIndex( const S32 &pDelta = 0 );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VMotionEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VMOTIONEVENT_H_
|
||||
442
Engine/modules/Verve/Extension/Motion/VMotionTrack.cpp
Normal file
442
Engine/modules/Verve/Extension/Motion/VMotionTrack.cpp
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VGroup.h"
|
||||
#include "Verve/Extension/Motion/VMotionTrack.h"
|
||||
#include "Verve/Extension/Motion/VMotionEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VMotionTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VMotionTrack::VMotionTrack( void ) :
|
||||
mDataReference( String::EmptyString ),
|
||||
mOrientationMode( "FREE" ),
|
||||
mOrientationData( String::EmptyString ),
|
||||
mRelative( false )
|
||||
{
|
||||
setLabel( "MotionTrack" );
|
||||
}
|
||||
|
||||
void VMotionTrack::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Reference", TypeRealString, Offset( mDataReference, VMotionTrack ), "The name of the data field referencing the object to be attached to the path." );
|
||||
|
||||
addProtectedField( "OrientationMode", TypeRealString, Offset( mOrientationMode, VMotionTrack ), &setOrientationMode, &defaultProtectedGetFn, "The orientation mode of the object attached to the path." );
|
||||
addProtectedField( "OrientationData", TypeRealString, Offset( mOrientationData, VMotionTrack ), &setOrientationData, &defaultProtectedGetFn, "The name of the data field holding the orientation data (used for Orientation Modes, ToObject & ToPoint)." );
|
||||
addField( "Relative", TypeBool, Offset( mRelative, VMotionTrack ), "Attach the object with an offset based on its initial position." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// When the controller's state changes, this method is called. If the
|
||||
// controller is paused, then the path object will cease to move. If the
|
||||
// controller resumes play, the object will continue on its path.
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VMotionTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fetch Path & Reference Object.
|
||||
VTorque::PathObjectType *path = getPath();
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !path || !object || !VTorque::isPathObjectAttached( path, object ) )
|
||||
{
|
||||
// Invalid.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventPlay :
|
||||
{
|
||||
|
||||
// Continue Advancing.
|
||||
VTorque::setPathObjectActive( path, object, true );
|
||||
|
||||
} break;
|
||||
|
||||
case VController::k_EventPause :
|
||||
{
|
||||
|
||||
// Stop Advancing.
|
||||
VTorque::setPathObjectActive( path, object, false );
|
||||
|
||||
} break;
|
||||
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Detach the Object.
|
||||
detachObject();
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Reposition the path object on the path appropriately. The position is
|
||||
// interpolated between two nodes, the last node and the next node. These
|
||||
// correspond to the last and current events.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VMotionTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Parent Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
// Valid Track?
|
||||
// Note: We must have at least 2 Events/Nodes to path.
|
||||
if ( size() < 2 )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Object References.
|
||||
VController *controller = getController();
|
||||
VTorque::PathObjectType *path = getPath();
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !controller || !path || !object )
|
||||
{
|
||||
// Invalid Object(s).
|
||||
return;
|
||||
}
|
||||
|
||||
// Attached?
|
||||
if ( !VTorque::isPathObjectAttached( path, object ) )
|
||||
{
|
||||
// No, Attach Now.
|
||||
attachObject();
|
||||
}
|
||||
|
||||
// Reset Object.
|
||||
resetObject( pTime );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::getPath();
|
||||
//
|
||||
// Returns the path that this track is referencing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VTorque::PathObjectType *VMotionTrack::getPath( void )
|
||||
{
|
||||
// Fetch the Controller.
|
||||
VController *controller = getController();
|
||||
if ( !controller )
|
||||
{
|
||||
// Invalid Controller.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Evalulate the Data Field.
|
||||
String fieldValue;
|
||||
if ( controller->getDataValue( mDataReference, fieldValue ) )
|
||||
{
|
||||
// Return Object.
|
||||
return dynamic_cast<VTorque::PathObjectType*>( Sim::findObject( fieldValue ) );
|
||||
}
|
||||
|
||||
// No Data!
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::attachObject();
|
||||
//
|
||||
// Attach the underlying Scene Object to the target Path at the first Node.
|
||||
// Default settings are applied and must be updated after the object is
|
||||
// attached.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VMotionTrack::attachObject( void )
|
||||
{
|
||||
// Get Object References.
|
||||
VTorque::PathObjectType *path = getPath();
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !path || !object )
|
||||
{
|
||||
// Invalid Object(s).
|
||||
return;
|
||||
}
|
||||
|
||||
// Object Attached?
|
||||
if ( VTorque::isPathObjectAttached( path, object ) )
|
||||
{
|
||||
// Already Attached.
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch Forwards.
|
||||
const bool &forward = isControllerPlayingForward();
|
||||
// Select the Node.
|
||||
const S32 node = ( forward ) ? 0 : ( size() - 1 );
|
||||
|
||||
// Fetch the value from the controller data table.
|
||||
String orientationDataValue = String::EmptyString;
|
||||
if ( mOrientationData != String::EmptyString
|
||||
&& !getController()->getDataValue( mOrientationData, orientationDataValue ) )
|
||||
{
|
||||
// Sanity!
|
||||
Con::warnf( "Unable to located the value for the given orientation data key, '%s'", mOrientationData );
|
||||
// Clear.
|
||||
orientationDataValue = String::EmptyString;
|
||||
}
|
||||
|
||||
// Attach Object.
|
||||
VTorque::attachPathObject( path, object, forward, mRelative, node, -1, mOrientationMode, orientationDataValue );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::detachObject( void );
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VMotionTrack::detachObject( void )
|
||||
{
|
||||
// Get Object References.
|
||||
VTorque::PathObjectType *path = getPath();
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !path || !object )
|
||||
{
|
||||
// Invalid Object(s).
|
||||
return;
|
||||
}
|
||||
|
||||
// Object Attached?
|
||||
if ( !VTorque::isPathObjectAttached( path, object ) )
|
||||
{
|
||||
// Not Attached.
|
||||
return;
|
||||
}
|
||||
|
||||
// Detach.
|
||||
VTorque::detachPathObject( path, object );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VMotionTrack::resetObject( pTime );
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VMotionTrack::resetObject( const S32 &pTime )
|
||||
{
|
||||
// Get Object References.
|
||||
VTorque::PathObjectType *path = getPath();
|
||||
VTorque::SceneObjectType *object = getSceneObject();
|
||||
if ( !path || !object )
|
||||
{
|
||||
// Invalid Object(s).
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch Controller Info.
|
||||
const bool &isPlaying = isControllerPlaying();
|
||||
const bool &isPlayingForward = isControllerPlayingForward();
|
||||
const bool &isLooping = isControllerLooping();
|
||||
|
||||
// Init Variables.
|
||||
bool objectActive = false;
|
||||
F32 objectInterp = 0.f;
|
||||
F32 objectSpeed = 0.f;
|
||||
S32 srcNodeIndex = 0;
|
||||
S32 dstNodeIndex = 0;
|
||||
|
||||
VMotionEvent *event;
|
||||
if ( !getNextEvent( event ) || event->getTriggerTime() == pTime )
|
||||
{
|
||||
// Note: This case deals with a target time that is greater than the
|
||||
// trigger time of the Last Event on this track. It will clamp
|
||||
// the position of the object to the corresponding node of the
|
||||
// Last Event.
|
||||
|
||||
// Note: If pTime is exactly equal to the Next Event's trigger time,
|
||||
// then it will set the Source Node to the Last Node and
|
||||
// set its Interp to 0.f - which is incorrect!
|
||||
if ( !event || event->getTriggerTime() != pTime )
|
||||
{
|
||||
// Fetch the Last Event.
|
||||
getPreviousEvent( event );
|
||||
}
|
||||
|
||||
// Set the Info.
|
||||
objectInterp = 0.f;
|
||||
objectSpeed = event->getObjectSpeed();
|
||||
srcNodeIndex = event->getNodeIndex();
|
||||
dstNodeIndex = srcNodeIndex;
|
||||
}
|
||||
else if ( !event->getPreviousEvent() )
|
||||
{
|
||||
// Note: This case deals with a target time that is less than the
|
||||
// trigger time of the First Event on this track. It will clamp
|
||||
// the position of the object to the corresponding node of the
|
||||
// First Event.
|
||||
|
||||
// Set the Info.
|
||||
objectInterp = 0.f;
|
||||
objectSpeed = event->getObjectSpeed();
|
||||
srcNodeIndex = event->getNodeIndex();
|
||||
dstNodeIndex = srcNodeIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Note: This case deals with a target time that is between two Events
|
||||
// on this track. It will position the object on the path,
|
||||
// between the two nodes corresponding to the Events.
|
||||
|
||||
// Fetch the Last Event.
|
||||
VMotionEvent *lastEvent;
|
||||
getPreviousEvent( lastEvent );
|
||||
|
||||
// Set the Info.
|
||||
objectActive = isPlaying;
|
||||
objectInterp = calculateInterp( pTime );
|
||||
objectSpeed = lastEvent->getObjectSpeed();
|
||||
srcNodeIndex = event->getNodeIndex( ( isPlayingForward ) ? -1 : 1 );
|
||||
dstNodeIndex = event->getNodeIndex();
|
||||
}
|
||||
|
||||
// Set Active.
|
||||
VTorque::setPathObjectActive( path, object, objectActive );
|
||||
|
||||
// Set Forward.
|
||||
VTorque::setPathObjectForward( path, object, isPlayingForward );
|
||||
|
||||
// Set Speed.
|
||||
VTorque::setPathObjectSpeed( path, object, objectSpeed );
|
||||
|
||||
// Set Current Node.
|
||||
VTorque::setPathObjectNode( path, object, srcNodeIndex );
|
||||
|
||||
// Set End Node.
|
||||
VTorque::setPathObjectEndNode( path, object, ( ( isLooping ) ? -1 : ( size() - 1 ) ) );
|
||||
|
||||
// Set Interp.
|
||||
VTorque::setPathObjectInterp( path, object, objectInterp );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Static Field Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool VMotionTrack::setOrientationMode( void *pObject, const char *pArray, const char *pData )
|
||||
{
|
||||
// Fetch Track.
|
||||
VMotionTrack *track = static_cast<VMotionTrack*>( pObject );
|
||||
|
||||
// Store Data.
|
||||
track->mOrientationMode = pData;
|
||||
|
||||
VTorque::PathObjectType *path = track->getPath();
|
||||
VTorque::SceneObjectType *object = track->getSceneObject();
|
||||
if ( VTorque::isPathObjectAttached( path, object ) )
|
||||
{
|
||||
// Set Orientation Mode.
|
||||
VTorque::setPathObjectOrientation( path, object, track->mOrientationMode, track->mOrientationData );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VMotionTrack::setOrientationData( void *pObject, const char *pArray, const char *pData )
|
||||
{
|
||||
// Fetch Track.
|
||||
VMotionTrack *track = static_cast<VMotionTrack*>( pObject );
|
||||
|
||||
// Store Data.
|
||||
track->mOrientationData = pData;
|
||||
|
||||
VTorque::PathObjectType *path = track->getPath();
|
||||
VTorque::SceneObjectType *object = track->getSceneObject();
|
||||
if ( VTorque::isPathObjectAttached( path, object ) )
|
||||
{
|
||||
// Set Orientation Mode.
|
||||
VTorque::setPathObjectOrientation( path, object, track->mOrientationMode, track->mOrientationData );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Debug Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VMotionTrack, getPath, S32, 2, 2, "( void ) - Get the path object this track references.\n"
|
||||
"@return Returns the SimObjectID for the object." )
|
||||
{
|
||||
// Fetch Path.
|
||||
SimObject *pathReference = object->getPath();
|
||||
|
||||
// Return.
|
||||
return ( pathReference ) ? pathReference->getId() : 0;
|
||||
}
|
||||
#endif
|
||||
85
Engine/modules/Verve/Extension/Motion/VMotionTrack.h
Normal file
85
Engine/modules/Verve/Extension/Motion/VMotionTrack.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VMOTIONTRACK_H_
|
||||
#define _VT_VMOTIONTRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_MOTION_H_
|
||||
#include "Verve/Torque/TMotion.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VMotionTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
// Reference Members.
|
||||
|
||||
String mDataReference;
|
||||
|
||||
// Path Members.
|
||||
|
||||
String mOrientationMode;
|
||||
String mOrientationData;
|
||||
bool mRelative;
|
||||
|
||||
public:
|
||||
|
||||
VMotionTrack( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
VTorque::PathObjectType *getPath( void );
|
||||
void attachObject( void );
|
||||
void detachObject( void );
|
||||
|
||||
void resetObject( const S32 &pTime );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VMotionTrack );
|
||||
|
||||
protected:
|
||||
|
||||
// Static Field Methods.
|
||||
|
||||
static bool setOrientationMode( void *pObject, const char *pArray, const char *pData );
|
||||
static bool setOrientationData( void *pObject, const char *pArray, const char *pData );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VMOTIONTRACK_H_
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/ParticleEffect/VParticleEffectGroup.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VParticleEffectGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VParticleEffectGroup::VParticleEffectGroup( void )
|
||||
{
|
||||
setLabel( "ParticleEffectGroup" );
|
||||
};
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VPARTICLEEFFECTGROUP_H_
|
||||
#define _VT_VPARTICLEEFFECTGROUP_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTGROUP_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VParticleEffectGroup : public VSceneObjectGroup
|
||||
{
|
||||
typedef VSceneObjectGroup Parent;
|
||||
|
||||
public:
|
||||
|
||||
VParticleEffectGroup( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VParticleEffectGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VPARTICLEEFFECTGROUP_H_
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/ParticleEffect/VParticleEffectToggleEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VParticleEffectToggleEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VParticleEffectToggleEvent::VParticleEffectToggleEvent( void ) :
|
||||
mEventType( VSharedEnum::k_ActionTurnOn )
|
||||
{
|
||||
setLabel( "ToggleEvent" );
|
||||
}
|
||||
|
||||
void VParticleEffectToggleEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Action", TYPEID<VActionToggle>(), Offset( mEventType, VParticleEffectToggleEvent ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VParticleEffectToggleEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Toggle the Particle Effect.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VParticleEffectToggleEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
VTorque::ParticleEffectType *particleEffect;
|
||||
if ( getSceneObject( particleEffect ) )
|
||||
{
|
||||
// Turn On?
|
||||
const bool turnOn = ( mEventType == VSharedEnum::k_ActionTurnOn );
|
||||
|
||||
// Toggle Particle Effect.
|
||||
VTorque::setParticleEffectOn( particleEffect, turnOn );
|
||||
}
|
||||
}
|
||||
|
|
@ -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_VPARTICLEFFECTTOGGLEEVENT_H_
|
||||
#define _VT_VPARTICLEFFECTTOGGLEEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_PARTICLEEFFECT_H_
|
||||
#include "Verve/Torque/TParticleEffect.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VSHAREDENUM_H_
|
||||
#include "Verve/Core/Util/VSharedEnum.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VParticleEffectToggleEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSharedEnum::eActionToggle mEventType;
|
||||
|
||||
public:
|
||||
|
||||
VParticleEffectToggleEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VParticleEffectToggleEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VPARTICLEFFECTTOGGLEEVENT_H_
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/ParticleEffect/VParticleEffectToggleTrack.h"
|
||||
#include "Verve/Extension/ParticleEffect/VParticleEffectToggleEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VParticleEffectToggleTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VParticleEffectToggleTrack::VParticleEffectToggleTrack( void )
|
||||
{
|
||||
setLabel( "ToggleTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VParticleEffectToggleTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Enable or Disable the particle effect after a reset.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VParticleEffectToggleTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Default Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
VParticleEffectToggleEvent *event;
|
||||
VTorque::ParticleEffectType *particleEffect;
|
||||
if ( getSceneObject( particleEffect ) && getPreviousEvent( event ) )
|
||||
{
|
||||
// Turn On?
|
||||
const bool turnOn = ( event->mEventType == VSharedEnum::k_ActionTurnOn );
|
||||
|
||||
// Toggle the Particle Effect.
|
||||
VTorque::setParticleEffectOn( particleEffect, turnOn );
|
||||
}
|
||||
}
|
||||
|
|
@ -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_VPARTICLEEFFECTTOGGLETRACK_H_
|
||||
#define _VT_VPARTICLEEFFECTTOGGLETRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_PARTICLEEFFECT_H_
|
||||
#include "Verve/Torque/TParticleEffect.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VParticleEffectToggleTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VParticleEffectToggleTrack( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VParticleEffectToggleTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VPARTICLEEFFECTTOGGLETRACK_H_
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/PostEffect/VPostEffectToggleEvent.h"
|
||||
#include "Verve/Extension/PostEffect/VPostEffectToggleTrack.h"
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VPostEffectToggleEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VPostEffectToggleEvent::VPostEffectToggleEvent( void ) :
|
||||
mEventType( VSharedEnum::k_ActionTurnOn )
|
||||
{
|
||||
setLabel( "ToggleEvent" );
|
||||
}
|
||||
|
||||
void VPostEffectToggleEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Action", TYPEID<VActionToggle>(), Offset( mEventType, VPostEffectToggleEvent ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VPostEffectToggleEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Only enable this effect if the parent group is currently active.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VPostEffectToggleEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch Parent Objects.
|
||||
VCameraGroup *group;
|
||||
VPostEffectToggleTrack *track;
|
||||
if ( ( !getGroup( group ) || !group->isActive() ) || !getTrack( track ) )
|
||||
{
|
||||
// Quit.
|
||||
return;
|
||||
}
|
||||
|
||||
// Turn On?
|
||||
const bool turnOn = ( mEventType == VSharedEnum::k_ActionTurnOn );
|
||||
|
||||
// Enable Effect.
|
||||
VTorque::setPostEffectOn( track->getPostEffect(), turnOn );
|
||||
}
|
||||
|
|
@ -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_VPOSTEFFECTTOGGLEEVENT_H_
|
||||
#define _VT_VPOSTEFFECTTOGGLEEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_POSTEFFECT_H_
|
||||
#include "Verve/Torque/TPostEffect.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VSHAREDENUM_H_
|
||||
#include "Verve/Core/Util/VSharedEnum.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VPostEffectToggleEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSharedEnum::eActionToggle mEventType;
|
||||
|
||||
public:
|
||||
|
||||
VPostEffectToggleEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VPostEffectToggleEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VPOSTEFFECTTOGGLEEVENT_H_
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/PostEffect/VPostEffectToggleTrack.h"
|
||||
#include "Verve/Extension/PostEffect/VPostEffectToggleEvent.h"
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VPostEffectToggleTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VPostEffectToggleTrack::VPostEffectToggleTrack( void ) :
|
||||
mPostEffect( NULL )
|
||||
{
|
||||
setLabel( "PostEffectTrack" );
|
||||
}
|
||||
|
||||
void VPostEffectToggleTrack::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "PostEffect", TYPEID<VTorque::PostEffectType>(), Offset( mPostEffect, VPostEffectToggleTrack ), "The name of the PostEffect object to be triggered." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Camera Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VPostEffectToggleTrack::onCameraEvent( pEvent );
|
||||
//
|
||||
// When the Camera changes, this method is called on both the outgoing and
|
||||
// incoming Camera Groups.
|
||||
//
|
||||
// For a full list of possible events, see the 'eCameraEventType' declaration
|
||||
// in VCameraGroup.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VPostEffectToggleTrack::onCameraEvent( const VCameraGroup::eCameraEventType &pEvent )
|
||||
{
|
||||
// Parent Call.
|
||||
if ( !Parent::onCameraEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() || !mPostEffect.isValid() )
|
||||
{
|
||||
// Quit Now.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch( pEvent )
|
||||
{
|
||||
case VCameraGroup::k_EventActivate :
|
||||
{
|
||||
|
||||
VPostEffectToggleEvent *event;
|
||||
if ( getPreviousEvent( event ) && event->mEventType == VSharedEnum::k_ActionTurnOn )
|
||||
{
|
||||
// Toggle Post Effect On.
|
||||
VTorque::setPostEffectOn( mPostEffect, true );
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case VCameraGroup::k_EventDeactivate :
|
||||
{
|
||||
|
||||
// Turn Post Effect Off.
|
||||
VTorque::setPostEffectOn( mPostEffect, false );
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -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_VPOSTEFFECTTOGGLETRACK_H_
|
||||
#define _VT_VPOSTEFFECTTOGGLETRACK_H_
|
||||
|
||||
#ifndef _VT_VCAMERATRACK_H_
|
||||
#include "Verve/Extension/Camera/VCameraTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_POSTEFFECT_H_
|
||||
#include "Verve/Torque/TPostEffect.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VPostEffectToggleTrack : public VCameraTrack
|
||||
{
|
||||
typedef VCameraTrack Parent;
|
||||
|
||||
protected:
|
||||
|
||||
SimObjectPtr<VTorque::PostEffectType> mPostEffect;
|
||||
|
||||
public:
|
||||
|
||||
VPostEffectToggleTrack( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Camera Methods.
|
||||
|
||||
bool onCameraEvent( const VCameraGroup::eCameraEventType &pEvent );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VPostEffectToggleTrack );
|
||||
|
||||
public:
|
||||
|
||||
VTorque::PostEffectType *getPostEffect( void ) { return mPostEffect; };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VPOSTEFFECTTOGGLETRACK_H_
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSceneObjectEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSceneObjectEvent::VSceneObjectEvent( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSceneObjectEvent::getSceneObject();
|
||||
//
|
||||
// Returns the parent group's object reference.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VTorque::SceneObjectType *VSceneObjectEvent::getSceneObject( void )
|
||||
{
|
||||
VSceneObjectGroup *group;
|
||||
if ( !getGroup( group ) )
|
||||
{
|
||||
// No Group!
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Return Object.
|
||||
return group->getSceneObject();
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Debug Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VSceneObjectEvent, getSceneObject, S32, 2, 2, "( void ) - Get the object this group references.\n"
|
||||
"@return Returns the SimObjectID for the object." )
|
||||
{
|
||||
// Fetch Object.
|
||||
VTorque::SceneObjectType *objReference = object->getSceneObject();
|
||||
|
||||
// Return.
|
||||
return ( objReference ) ? objReference->getId() : 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSCENEOBJECTEVENT_H_
|
||||
#define _VT_VSCENEOBJECTEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTGROUP_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSceneObjectEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSceneObjectEvent( void );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
VTorque::SceneObjectType *getSceneObject( void );
|
||||
template <class T> inline bool getSceneObject( T *&pSceneObject )
|
||||
{
|
||||
// Reference Scene Object.
|
||||
pSceneObject = dynamic_cast<T*>( getSceneObject() );
|
||||
|
||||
// Valid?
|
||||
return ( pSceneObject != NULL );
|
||||
}
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSceneObjectEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSCENEOBJECTEVENT_H_
|
||||
104
Engine/modules/Verve/Extension/SceneObject/VSceneObjectGroup.cpp
Normal file
104
Engine/modules/Verve/Extension/SceneObject/VSceneObjectGroup.cpp
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#include "Verve/Core/VController.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSceneObjectGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSceneObjectGroup::VSceneObjectGroup( void ) :
|
||||
mDataReference( String::EmptyString ),
|
||||
mSceneObject( NULL )
|
||||
{
|
||||
setLabel( "SceneObjectGroup" );
|
||||
};
|
||||
|
||||
void VSceneObjectGroup::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Reference", TypeRealString, Offset( mDataReference, VSceneObjectGroup ), "The name of the data field referencing the targeted object." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSceneObjectGroup::getObject();
|
||||
//
|
||||
// Returns the group's object reference.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VTorque::SceneObjectType *VSceneObjectGroup::getSceneObject( void )
|
||||
{
|
||||
#ifndef VT_EDITOR
|
||||
// Already Referenced?
|
||||
if ( mSceneObject )
|
||||
{
|
||||
// Return Object.
|
||||
return mSceneObject;
|
||||
}
|
||||
#endif
|
||||
|
||||
VController *controller = getController();
|
||||
if ( !controller )
|
||||
{
|
||||
// No Controller!
|
||||
return NULL;
|
||||
}
|
||||
|
||||
String fieldValue;
|
||||
if ( controller->getDataValue( mDataReference, fieldValue ) )
|
||||
{
|
||||
// Store Object.
|
||||
mSceneObject = dynamic_cast<VTorque::SceneObjectType*>( Sim::findObject( fieldValue ) );
|
||||
}
|
||||
|
||||
// Return.
|
||||
return mSceneObject;
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Debug Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VSceneObjectGroup, getSceneObject, S32, 2, 2, "( void ) - Get the object this group references.\n"
|
||||
"@return Returns the SimObjectID for the object." )
|
||||
{
|
||||
// Fetch Object.
|
||||
VTorque::SceneObjectType *objReference = object->getSceneObject();
|
||||
|
||||
// Return.
|
||||
return ( objReference ) ? objReference->getId() : 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSCENEOBJECTGROUP_H_
|
||||
#define _VT_VSCENEOBJECTGROUP_H_
|
||||
|
||||
#ifndef _VT_VGROUP_H_
|
||||
#include "Verve/Core/VGroup.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_SCENEOBJECT_H_
|
||||
#include "Verve/Torque/TSceneObject.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSceneObjectGroup : public VGroup
|
||||
{
|
||||
typedef VGroup Parent;
|
||||
|
||||
public:
|
||||
|
||||
// Reference Members.
|
||||
|
||||
String mDataReference;
|
||||
VTorque::SceneObjectType *mSceneObject;
|
||||
|
||||
public:
|
||||
|
||||
VSceneObjectGroup( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
VTorque::SceneObjectType *getSceneObject( void );
|
||||
template <class T> inline bool getSceneObject( T *&pSceneObject )
|
||||
{
|
||||
// Reference Scene Object.
|
||||
pSceneObject = dynamic_cast<T*>( getSceneObject() );
|
||||
|
||||
// Valid?
|
||||
return ( pSceneObject != NULL );
|
||||
}
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSceneObjectGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSCENEOBJECTGROUP_H_
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSceneObjectTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSceneObjectTrack::VSceneObjectTrack( void )
|
||||
{
|
||||
setLabel( "SceneObjectTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Reference Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSceneObjectTrack::getSceneObject();
|
||||
//
|
||||
// Returns the parent group's object reference.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VTorque::SceneObjectType *VSceneObjectTrack::getSceneObject( void )
|
||||
{
|
||||
VSceneObjectGroup *group;
|
||||
if ( !getGroup( group ) )
|
||||
{
|
||||
// No Group!
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Return Object.
|
||||
return group->getSceneObject();
|
||||
}
|
||||
|
||||
#ifdef VT_EDITOR
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Debug Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VSceneObjectTrack, getSceneObject, S32, 2, 2, "( void ) - Get the object this group references.\n"
|
||||
"@return Returns the SimObjectID for the object." )
|
||||
{
|
||||
// Fetch Object.
|
||||
VTorque::SceneObjectType *objReference = object->getSceneObject();
|
||||
|
||||
// Return.
|
||||
return ( objReference ) ? objReference->getId() : 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSCENEOBJECTTRACK_H_
|
||||
#define _VT_VSCENEOBJECTTRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTGROUP_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSceneObjectTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VSceneObjectTrack( void );
|
||||
|
||||
// Reference Methods.
|
||||
|
||||
VTorque::SceneObjectType *getSceneObject( void );
|
||||
template <class T> inline bool getSceneObject( T *&pSceneObject )
|
||||
{
|
||||
// Reference Scene Object.
|
||||
pSceneObject = dynamic_cast<T*>( getSceneObject() );
|
||||
|
||||
// Valid?
|
||||
return ( pSceneObject != NULL );
|
||||
}
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSceneObjectTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSCENEOBJECTTRACK_H_
|
||||
101
Engine/modules/Verve/Extension/Script/VScriptEvent.cpp
Normal file
101
Engine/modules/Verve/Extension/Script/VScriptEvent.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VGroup.h"
|
||||
#include "Verve/Core/VTrack.h"
|
||||
|
||||
#include "Verve/Extension/Script/VScriptEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VScriptEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Implement the Command Type enum list.
|
||||
ImplementEnumType( VScriptEventCommandType, "" )
|
||||
{ VScriptEvent::k_TypeExpression, "EXPRESSION" },
|
||||
{ VScriptEvent::k_TypeMethod, "METHOD" },
|
||||
EndImplementEnumType;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VScriptEvent::VScriptEvent( void ) :
|
||||
mCommandType( k_TypeMethod ),
|
||||
mCommand( String::EmptyString )
|
||||
{
|
||||
setLabel( "ScriptEvent" );
|
||||
}
|
||||
|
||||
void VScriptEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "CommandType", TYPEID<eCommandType>(), Offset( mCommandType, VScriptEvent ), "The type of command to be evaluated." );
|
||||
addField( "Command", TypeRealString, Offset( mCommand, VScriptEvent ), "The command to be evaluated." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VScriptEvet::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Execute a method or evaluate a command.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VScriptEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
switch ( mCommandType )
|
||||
{
|
||||
case k_TypeExpression :
|
||||
{
|
||||
|
||||
// Evaluate Expression.
|
||||
Con::evaluate( mCommand, false, NULL );
|
||||
|
||||
} break;
|
||||
|
||||
case k_TypeMethod :
|
||||
{
|
||||
|
||||
SimObject *object = getSceneObject();
|
||||
if ( object )
|
||||
{
|
||||
// Execute Method.
|
||||
Con::executef( object, mCommand );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Execute Function.
|
||||
Con::executef( mCommand );
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
74
Engine/modules/Verve/Extension/Script/VScriptEvent.h
Normal file
74
Engine/modules/Verve/Extension/Script/VScriptEvent.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSCRIPTEVENT_H_
|
||||
#define _VT_VSCRIPTEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VScriptEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VSceneObjectEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
enum eCommandType
|
||||
{
|
||||
k_TypeExpression,
|
||||
k_TypeMethod,
|
||||
|
||||
k_TypeInvalid,
|
||||
};
|
||||
|
||||
eCommandType mCommandType;
|
||||
String mCommand;
|
||||
|
||||
public:
|
||||
|
||||
VScriptEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VScriptEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Define Types.
|
||||
typedef VScriptEvent::eCommandType VScriptEventCommandType;
|
||||
|
||||
// Declare Enum Types.
|
||||
DefineEnumType( VScriptEventCommandType );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSCRIPTEVENT_H_
|
||||
32
Engine/modules/Verve/Extension/Script/VScriptEventTrack.cpp
Normal file
32
Engine/modules/Verve/Extension/Script/VScriptEventTrack.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/Script/VScriptEventTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VScriptEventTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VScriptEventTrack::VScriptEventTrack( void )
|
||||
{
|
||||
setLabel( "ScriptEventTrack" );
|
||||
}
|
||||
47
Engine/modules/Verve/Extension/Script/VScriptEventTrack.h
Normal file
47
Engine/modules/Verve/Extension/Script/VScriptEventTrack.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSCRIPTEVENTTRACK_H_
|
||||
#define _VT_VSCRIPTEVENTTRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VScriptEventTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VScriptEventTrack( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VScriptEventTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSCRIPTEVENTTRACK_H_
|
||||
131
Engine/modules/Verve/Extension/SoundEffect/VSoundEffectEvent.cpp
Normal file
131
Engine/modules/Verve/Extension/SoundEffect/VSoundEffectEvent.cpp
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Core/VGroup.h"
|
||||
#include "Verve/Extension/SoundEffect/VSoundEffectEvent.h"
|
||||
#include "Verve/Extension/SoundEffect/VSoundEffectTrack.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSoundEffectEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSoundEffectEvent::VSoundEffectEvent( void ) :
|
||||
mSoundEffect( NULL )
|
||||
{
|
||||
setLabel( "SoundEvent" );
|
||||
}
|
||||
|
||||
void VSoundEffectEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addProtectedField( "SoundEffect", TYPEID<VTorque::SoundEffectType>(), Offset( mSoundEffect, VSoundEffectEvent ), &setSoundData, &defaultProtectedGetFn, "" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSoundEffectEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Play the target sound effect. If this track belongs to a SceneObjectGroup,
|
||||
// then the sound will play with the reference object's transform. If this is
|
||||
// not the case, then a 2D sound will be played.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSoundEffectEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch Track.
|
||||
VSoundEffectTrack *track;
|
||||
if ( !getTrack( track ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Position & Pitch.
|
||||
U32 position = mAbs( ( pTime + pDelta ) - getStartTime() );
|
||||
F32 pitch = mFabs( getControllerTimeScale() );
|
||||
if ( position < SFXStartBuffer )
|
||||
{
|
||||
// Zero.
|
||||
position = 0;
|
||||
}
|
||||
|
||||
VSceneObjectGroup *group;
|
||||
if ( getGroup( group ) )
|
||||
{
|
||||
// Play Sound With Reference.
|
||||
track->mSource = VTorque::playSound( mSoundEffect, group->getSceneObject(), position, pitch );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Play Sound.
|
||||
track->mSource = VTorque::playSound( mSoundEffect, position, pitch );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Property Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSoundEffectEvent::setDuration( pDuration );
|
||||
//
|
||||
// This event's duration is always set to the sound object's duration.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSoundEffectEvent::setDuration( const S32 &pDuration )
|
||||
{
|
||||
// Clear Duration.
|
||||
mDuration = VTorque::getSoundDuration( mSoundEffect );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Static Field Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool VSoundEffectEvent::setSoundData( void *pObject, const char *pArray, const char *pData )
|
||||
{
|
||||
// Fetch Event.
|
||||
VSoundEffectEvent *event = static_cast<VSoundEffectEvent*>( pObject );
|
||||
|
||||
// Use Object.
|
||||
event->mSoundEffect = dynamic_cast<VTorque::SoundEffectType*>( Sim::findObject( pData ) );
|
||||
|
||||
// Set Duration.
|
||||
event->setDuration( 0 );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VSOUNDEFFECTEVENT_H_
|
||||
#define _VT_VSOUNDEFFECTEVENT_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTEVENT_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_SOUNDEFFECT_H_
|
||||
#include "Verve/Torque/TSoundEffect.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSoundEffectEvent : public VSceneObjectEvent
|
||||
{
|
||||
typedef VSceneObjectEvent Parent;
|
||||
|
||||
enum
|
||||
{
|
||||
SFXStartBuffer = 100,
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
SimObjectPtr<VTorque::SoundEffectType> mSoundEffect;
|
||||
|
||||
public:
|
||||
|
||||
VSoundEffectEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
static bool setSoundData( void *pObject, const char *pArray, const char *pData );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSoundEffectEvent );
|
||||
|
||||
public:
|
||||
|
||||
// Property Methods.
|
||||
|
||||
virtual void setDuration( const S32 &pDuration );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSOUNDEFFECTEVENT_H_
|
||||
111
Engine/modules/Verve/Extension/SoundEffect/VSoundEffectTrack.cpp
Normal file
111
Engine/modules/Verve/Extension/SoundEffect/VSoundEffectTrack.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/Extension/SoundEffect/VSoundEffectTrack.h"
|
||||
#include "Verve/Extension/SoundEffect/VSoundEffectEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VSoundEffectTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VSoundEffectTrack::VSoundEffectTrack( void ) :
|
||||
mSource( NULL )
|
||||
{
|
||||
setLabel( "SoundTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSoundEffectTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// If the controller ceases playback and the track has a valid reference to a
|
||||
// source provider, then the sound is stopped.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VSoundEffectTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventPause :
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
#ifdef VT_EDITOR
|
||||
|
||||
if ( mSource )
|
||||
{
|
||||
// Stop Sound.
|
||||
VTorque::stopSound( mSource );
|
||||
|
||||
// Clear Source.
|
||||
mSource = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VSoundEffectTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// If the track is reset and it has a valid reference to a source provider,
|
||||
// then the sound is stopped.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VSoundEffectTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Default Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
if ( mSource )
|
||||
{
|
||||
// Stop Sound.
|
||||
VTorque::stopSound( mSource );
|
||||
}
|
||||
|
||||
// Clear Source.
|
||||
mSource = NULL;
|
||||
}
|
||||
|
|
@ -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_VSOUNDEFFECTTRACK_H_
|
||||
#define _VT_VSOUNDEFFECTTRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TORQUE_SOUNDEFFECT_H_
|
||||
#include "Verve/Torque/TSoundEffect.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VSoundEffectTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VTorque::SoundSourceType *mSource;
|
||||
|
||||
public:
|
||||
|
||||
VSoundEffectTrack( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VSoundEffectTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VSOUNDEFFECTTRACK_H_
|
||||
216
Engine/modules/Verve/GUI/VEditorButton.cpp
Normal file
216
Engine/modules/Verve/GUI/VEditorButton.cpp
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/GUI/VEditorButton.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "gui/core/guiCanvas.h"
|
||||
#include "gui/core/guiDefaultControlRender.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VEditorButton );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VEditorButton::VEditorButton( void ) :
|
||||
mIsDraggable( false )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
void VEditorButton::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "IsDraggable", TypeBool, Offset( mIsDraggable, VEditorButton ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VEditorButton::onMouseDown( const GuiEvent &pEvent )
|
||||
{
|
||||
if ( !mActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::onMouseDown( pEvent );
|
||||
|
||||
onMouseEvent( "onMouseDown", pEvent );
|
||||
}
|
||||
|
||||
void VEditorButton::onMouseUp( const GuiEvent &pEvent )
|
||||
{
|
||||
if ( !mActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::onMouseUp( pEvent );
|
||||
|
||||
if ( mIsDraggable && isMouseLocked() )
|
||||
{
|
||||
// Unlock.
|
||||
mouseUnlock();
|
||||
}
|
||||
|
||||
onMouseEvent( "onMouseUp", pEvent );
|
||||
}
|
||||
|
||||
void VEditorButton::onMouseDragged( const GuiEvent &pEvent )
|
||||
{
|
||||
if ( !mActive || !mIsDraggable )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::onMouseDragged( pEvent );
|
||||
|
||||
if ( !isMouseLocked() )
|
||||
{
|
||||
GuiCanvas *canvas = getRoot();
|
||||
if ( canvas->getMouseLockedControl() )
|
||||
{
|
||||
GuiEvent event;
|
||||
canvas->getMouseLockedControl()->onMouseLeave( event );
|
||||
canvas->mouseUnlock( canvas->getMouseLockedControl() );
|
||||
}
|
||||
|
||||
// Lock.
|
||||
mouseLock();
|
||||
}
|
||||
|
||||
onMouseEvent( "onMouseDragged", pEvent );
|
||||
}
|
||||
|
||||
void VEditorButton::onRightMouseDown( const GuiEvent &pEvent )
|
||||
{
|
||||
if ( !mActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::onRightMouseDown( pEvent );
|
||||
|
||||
onMouseEvent( "onRightMouseDown", pEvent );
|
||||
}
|
||||
|
||||
void VEditorButton::onRightMouseUp( const GuiEvent &pEvent )
|
||||
{
|
||||
if ( !mActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::onRightMouseUp( pEvent );
|
||||
|
||||
onMouseEvent( "onRightMouseUp", pEvent );
|
||||
}
|
||||
|
||||
void VEditorButton::onMouseEnter( const GuiEvent &pEvent )
|
||||
{
|
||||
if ( !mActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::onMouseEnter( pEvent );
|
||||
|
||||
onMouseEvent( "onMouseEnter", pEvent );
|
||||
}
|
||||
|
||||
void VEditorButton::onMouseLeave( const GuiEvent &pEvent )
|
||||
{
|
||||
if ( !mActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::onMouseLeave( pEvent );
|
||||
|
||||
onMouseEvent( "onMouseLeave", pEvent );
|
||||
}
|
||||
|
||||
void VEditorButton::onMouseEvent( const char *pEventName, const GuiEvent &pEvent )
|
||||
{
|
||||
// Argument Buffers.
|
||||
char argBuffer[3][32];
|
||||
|
||||
// Format Event-Position Buffer.
|
||||
dSprintf( argBuffer[0], 32, "%d %d", pEvent.mousePoint.x, pEvent.mousePoint.y );
|
||||
|
||||
// Format Event-Modifier Buffer.
|
||||
dSprintf( argBuffer[1], 32, "%d", pEvent.modifier );
|
||||
|
||||
// Format Mouse-Click Count Buffer.
|
||||
dSprintf( argBuffer[2], 32, "%d", pEvent.mouseClickCount );
|
||||
|
||||
// Call Scripts.
|
||||
Con::executef( this, pEventName, argBuffer[0], argBuffer[1], argBuffer[2] );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VEditorButton::onRender( Point2I offset, const RectI& updateRect )
|
||||
{
|
||||
// Fetch Texture.
|
||||
GFXTexHandle texture = getTextureForCurrentState();
|
||||
|
||||
// Valid?
|
||||
if ( texture )
|
||||
{
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmapStretch( texture, RectI( offset, getExtent() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mProfile->mBorder != 0 )
|
||||
{
|
||||
RectI boundsRect( offset, getExtent() );
|
||||
|
||||
if ( mDepressed || mStateOn || mMouseOver )
|
||||
{
|
||||
renderFilledBorder( boundsRect, mProfile->mBorderColorHL, mProfile->mFillColorHL );
|
||||
}
|
||||
else
|
||||
{
|
||||
renderFilledBorder( boundsRect, mProfile->mBorderColor, mProfile->mFillColor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render Text.
|
||||
GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColor );
|
||||
renderJustifiedText( offset + mProfile->mTextOffset, getExtent(), mButtonText );
|
||||
|
||||
renderChildControls( offset, updateRect);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Console Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VEditorButton, getState, bool, 2, 2, "()" )
|
||||
{
|
||||
return object->getStateOn();
|
||||
}
|
||||
62
Engine/modules/Verve/GUI/VEditorButton.h
Normal file
62
Engine/modules/Verve/GUI/VEditorButton.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VEDITORBUTTON_H_
|
||||
#define _VT_VEDITORBUTTON_H_
|
||||
|
||||
#ifndef _GUIBITMAPBUTTON_H_
|
||||
#include "gui/buttons/guiBitmapButtonCtrl.h"
|
||||
#endif
|
||||
|
||||
class VEditorButton : public GuiBitmapButtonTextCtrl
|
||||
{
|
||||
typedef GuiBitmapButtonTextCtrl Parent;
|
||||
|
||||
public:
|
||||
|
||||
bool mIsDraggable;
|
||||
|
||||
public:
|
||||
|
||||
VEditorButton();
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
void onMouseDown( const GuiEvent &pEvent );
|
||||
void onMouseUp( const GuiEvent &pEvent );
|
||||
void onMouseDragged( const GuiEvent &pEvent );
|
||||
|
||||
void onRightMouseDown( const GuiEvent &pEvent );
|
||||
void onRightMouseUp( const GuiEvent &pEvent );
|
||||
|
||||
void onMouseEnter( const GuiEvent &pEvent );
|
||||
void onMouseLeave( const GuiEvent &pEvent );
|
||||
void onMouseEvent( const char *pEventName, const GuiEvent &pEvent );
|
||||
|
||||
void onRender( Point2I offset, const RectI &updateRect );
|
||||
|
||||
public:
|
||||
|
||||
DECLARE_CONOBJECT( VEditorButton );
|
||||
};
|
||||
|
||||
#endif //_VT_VEDITORBUTTON_H_
|
||||
97
Engine/modules/Verve/GUI/VEditorScrollControl.cpp
Normal file
97
Engine/modules/Verve/GUI/VEditorScrollControl.cpp
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/GUI/VEditorScrollControl.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VEditorScrollControl );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Mouse Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VEditorScrollControl::onMouseUp( const GuiEvent &pEvent )
|
||||
{
|
||||
Parent::onMouseUp( pEvent );
|
||||
|
||||
// Event.
|
||||
onMouseEvent( "onMouseUp", pEvent );
|
||||
}
|
||||
|
||||
void VEditorScrollControl::onRightMouseUp( const GuiEvent &pEvent )
|
||||
{
|
||||
Parent::onMouseUp( pEvent );
|
||||
|
||||
// Event.
|
||||
onMouseEvent( "onRightMouseUp", pEvent );
|
||||
}
|
||||
|
||||
void VEditorScrollControl::onMouseEvent( const char *pEventName, const GuiEvent &pEvent )
|
||||
{
|
||||
const S32 offsetX = ( mHasVScrollBar ) ? mScrollBarThickness : 0;
|
||||
const S32 offsetY = ( mHasHScrollBar ) ? mScrollBarThickness : 0;
|
||||
|
||||
const RectI contentRect( 2, 2, getWidth() - offsetX - 4 - 1, getHeight() - offsetY - 4 - ( mHasHScrollBar ) );
|
||||
if ( !contentRect.pointInRect( pEvent.mousePoint ) )
|
||||
{
|
||||
// Return!
|
||||
return;
|
||||
}
|
||||
|
||||
// Argument Buffers.
|
||||
char argBuffer[3][32];
|
||||
|
||||
// Format Event-Position Buffer.
|
||||
dSprintf( argBuffer[0], 32, "%d %d", pEvent.mousePoint.x, pEvent.mousePoint.y );
|
||||
|
||||
// Format Event-Modifier Buffer.
|
||||
dSprintf( argBuffer[1], 32, "%d", pEvent.modifier );
|
||||
|
||||
// Format Mouse-Click Count Buffer.
|
||||
dSprintf( argBuffer[2], 32, "%d", pEvent.mouseClickCount );
|
||||
|
||||
// Call Scripts.
|
||||
Con::executef( this, pEventName, argBuffer[0], argBuffer[1], argBuffer[2] );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Render Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VEditorScrollControl::onRender( Point2I pOffset, const RectI &pUpdateRect )
|
||||
{
|
||||
Parent::onRender( pOffset, pUpdateRect );
|
||||
|
||||
const S32 offsetX = ( mHasVScrollBar ) ? mScrollBarThickness : 1;
|
||||
const S32 offsetY = ( mHasHScrollBar ) ? mScrollBarThickness : 1;
|
||||
|
||||
RectI contentRect( pOffset.x + 1, pOffset.y + 1, getWidth() - offsetX - 1, getHeight() - offsetY - 1 );
|
||||
contentRect.intersect( pUpdateRect );
|
||||
|
||||
GFX->getDrawUtil()->drawRect( contentRect, mProfile->mBorderColor );
|
||||
}
|
||||
56
Engine/modules/Verve/GUI/VEditorScrollControl.h
Normal file
56
Engine/modules/Verve/GUI/VEditorScrollControl.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VEDITORSCROLLCONTROL_H_
|
||||
#define _VT_VEDITORSCROLLCONTROL_H_
|
||||
|
||||
#ifndef _GUISCROLLCTRL_H_
|
||||
#include "gui/containers/guiScrollCtrl.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VEditorScrollControl : public GuiScrollCtrl
|
||||
{
|
||||
typedef GuiScrollCtrl Parent;
|
||||
|
||||
public:
|
||||
|
||||
// Mouse.
|
||||
|
||||
virtual void onMouseUp( const GuiEvent &pEvent );
|
||||
virtual void onRightMouseUp( const GuiEvent &pEvent );
|
||||
|
||||
void onMouseEvent( const char *pEventName, const GuiEvent &pEvent );
|
||||
|
||||
// Rendering.
|
||||
|
||||
void onRender( Point2I pOffset, const RectI &pUpdateRect );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VEditorScrollControl );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VEDITORSCROLLCONTROL_H_
|
||||
158
Engine/modules/Verve/GUI/VEditorWindow.cpp
Normal file
158
Engine/modules/Verve/GUI/VEditorWindow.cpp
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/GUI/VEditorWindow.h"
|
||||
#include "gfx/gfxInit.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VEditorWindow );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool VEditorWindow::onAdd( void )
|
||||
{
|
||||
if ( !Parent::onAdd() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GFXAdapter *adapter = GFXInit::getBestAdapterChoice();
|
||||
if ( adapter && adapter->mType != NullDevice )
|
||||
{
|
||||
mPlatformWindow->setMinimumWindowSize( Point2I( 904, 287 ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( VEditorWindow, resetCursor, void, 2, 2, "( )" )
|
||||
{
|
||||
S32 currCursor = PlatformCursorController::curArrow;
|
||||
if ( object->mCursorChanged == currCursor )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformWindow *window = object->getPlatformWindow();
|
||||
PlatformCursorController *controller = window->getCursorController();
|
||||
|
||||
if( object->mCursorChanged != -1)
|
||||
{
|
||||
controller->popCursor();
|
||||
}
|
||||
|
||||
controller->pushCursor(currCursor);
|
||||
object->mCursorChanged = currCursor;
|
||||
|
||||
Platform::setWindowLocked( false );
|
||||
}
|
||||
|
||||
ConsoleMethod( VEditorWindow, setVideoMode, void, 5, 8,
|
||||
"(int width, int height, bool fullscreen, [int bitDepth], [int refreshRate])\n"
|
||||
"Change the video mode of this canvas. This method has the side effect of setting the $pref::Video::mode to the new values.\n\n"
|
||||
"\\param width The screen width to set.\n"
|
||||
"\\param height The screen height to set.\n"
|
||||
"\\param fullscreen Specify true to run fullscreen or false to run in a window\n"
|
||||
"\\param bitDepth [optional] The desired bit-depth. Defaults to the current setting. This parameter is ignored if you are running in a window.\n"
|
||||
"\\param refreshRate [optional] The desired refresh rate. Defaults to the current setting. This parameter is ignored if you are running in a window"
|
||||
"\\param antialiasLevel [optional] The level of anti-aliasing to apply 0 = none" )
|
||||
{
|
||||
if (!object->getPlatformWindow())
|
||||
return;
|
||||
|
||||
// Update the video mode and tell the window to reset.
|
||||
GFXVideoMode vm = object->getPlatformWindow()->getVideoMode();
|
||||
|
||||
U32 width = dAtoi(argv[2]);
|
||||
U32 height = dAtoi(argv[3]);
|
||||
|
||||
bool changed = false;
|
||||
if (width == 0 && height > 0)
|
||||
{
|
||||
// Our width is 0 but our height isn't...
|
||||
// Try to find a matching width
|
||||
for(S32 i=0; i<object->getPlatformWindow()->getGFXDevice()->getVideoModeList()->size(); i++)
|
||||
{
|
||||
const GFXVideoMode &newVm = (*(object->getPlatformWindow()->getGFXDevice()->getVideoModeList()))[i];
|
||||
|
||||
if(newVm.resolution.y == height)
|
||||
{
|
||||
width = newVm.resolution.x;
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (height == 0 && width > 0)
|
||||
{
|
||||
// Our height is 0 but our width isn't...
|
||||
// Try to find a matching height
|
||||
for(S32 i=0; i<object->getPlatformWindow()->getGFXDevice()->getVideoModeList()->size(); i++)
|
||||
{
|
||||
const GFXVideoMode &newVm = (*(object->getPlatformWindow()->getGFXDevice()->getVideoModeList()))[i];
|
||||
|
||||
if(newVm.resolution.x == width)
|
||||
{
|
||||
height = newVm.resolution.y;
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
// Got a bad size for both of our dimensions or one of our dimensions and
|
||||
// didn't get a match for the other default back to our current resolution
|
||||
width = vm.resolution.x;
|
||||
height = vm.resolution.y;
|
||||
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
Con::errorf("GuiCanvas::setVideoMode(): Error - Invalid resolution of (%d, %d) - attempting (%d, %d)", dAtoi(argv[2]), dAtoi(argv[3]), width, height);
|
||||
|
||||
vm.resolution = Point2I(width, height);
|
||||
vm.fullScreen = dAtob(argv[4]);
|
||||
|
||||
// These optional params are set to default at construction of vm. If they
|
||||
// aren't specified, just leave them at whatever they were set to.
|
||||
if ((argc > 5) && (dStrlen(argv[5]) > 0))
|
||||
{
|
||||
vm.bitDepth = dAtoi(argv[5]);
|
||||
}
|
||||
if ((argc > 6) && (dStrlen(argv[6]) > 0))
|
||||
{
|
||||
vm.refreshRate = dAtoi(argv[6]);
|
||||
}
|
||||
|
||||
if ((argc > 7) && (dStrlen(argv[7]) > 0))
|
||||
{
|
||||
vm.antialiasLevel = dAtoi(argv[7]);
|
||||
}
|
||||
|
||||
#ifndef TORQUE_OS_XENON
|
||||
object->getPlatformWindow()->setVideoMode(vm);
|
||||
#endif
|
||||
}
|
||||
49
Engine/modules/Verve/GUI/VEditorWindow.h
Normal file
49
Engine/modules/Verve/GUI/VEditorWindow.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VEDITORWINDOW_H_
|
||||
#define _VT_VEDITORWINDOW_H_
|
||||
|
||||
#ifndef _GUICANVAS_H_
|
||||
#include "gui/core/guiCanvas.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VEditorWindow : public GuiCanvas
|
||||
{
|
||||
typedef GuiCanvas Parent;
|
||||
|
||||
public:
|
||||
|
||||
// Properties.
|
||||
|
||||
virtual bool onAdd( void );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VEditorWindow );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VEDITORWINDOW_H_
|
||||
114
Engine/modules/Verve/GUI/VFadeControl.cpp
Normal file
114
Engine/modules/Verve/GUI/VFadeControl.cpp
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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/GUI/VFadeControl.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "math/mMathFn.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VFadeControl );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VFadeControl::VFadeControl( void ) :
|
||||
mActive( false ),
|
||||
mFadeType( k_TypeInvalid ),
|
||||
mElapsedTime( 0 ),
|
||||
mDuration( 1000 ),
|
||||
mLastTime( 0 )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Render Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VFadeControl::onRender( Point2I pOffset, const RectI &pUpdateRect )
|
||||
{
|
||||
Parent::onRender( pOffset, pUpdateRect );
|
||||
|
||||
if ( mFadeType == k_TypeInvalid )
|
||||
{
|
||||
// Invalid Fade State.
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch Time.
|
||||
const U32 time = Platform::getRealMilliseconds();
|
||||
// Fetch Delta.
|
||||
const U32 delta = ( time - mLastTime );
|
||||
// Store Time.
|
||||
mLastTime = time;
|
||||
|
||||
if ( mActive )
|
||||
{
|
||||
// Update Elapsed Time.
|
||||
mElapsedTime += delta;
|
||||
}
|
||||
|
||||
F32 alpha = 1.f - mClampF( F32( mElapsedTime ) / F32( mDuration ), 0.f, 1.f );
|
||||
|
||||
if ( mFadeType == k_TypeOut )
|
||||
{
|
||||
// Flip.
|
||||
alpha = 1.f - alpha;
|
||||
}
|
||||
|
||||
if ( alpha > 0.f )
|
||||
{
|
||||
// Render.
|
||||
GFX->getDrawUtil()->drawRectFill( pOffset, pOffset + getExtent(), ColorF( 0, 0, 0, alpha ) );
|
||||
}
|
||||
|
||||
if ( mElapsedTime >= mDuration )
|
||||
{
|
||||
// Stop.
|
||||
mActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Control Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VFadeControl::start( eFadeType pType, S32 pDuration )
|
||||
{
|
||||
mActive = true;
|
||||
|
||||
mFadeType = pType;
|
||||
|
||||
mElapsedTime = 0;
|
||||
mDuration = pDuration;
|
||||
|
||||
mLastTime = Platform::getRealMilliseconds();
|
||||
}
|
||||
|
||||
void VFadeControl::pause( void )
|
||||
{
|
||||
mActive = false;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue