VSceneObjectGroup.cpp
Engine/source/Verve/Extension/SceneObject/VSceneObjectGroup.cpp
Public Functions
Detailed Description
Public Functions
IMPLEMENT_CONOBJECT(VSceneObjectGroup )
1 2//----------------------------------------------------------------------------- 3// Verve 4// Copyright (C) 2014 - Violent Tulip 5// 6// Permission is hereby granted, free of charge, to any person obtaining a copy 7// of this software and associated documentation files (the "Software"), to 8// deal in the Software without restriction, including without limitation the 9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10// sell copies of the Software, and to permit persons to whom the Software is 11// furnished to do so, subject to the following conditions: 12// 13// The above copyright notice and this permission notice shall be included in 14// all copies or substantial portions of the Software. 15// 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22// IN THE SOFTWARE. 23//----------------------------------------------------------------------------- 24#include "Verve/Extension/SceneObject/VSceneObjectGroup.h" 25#include "Verve/Core/VController.h" 26 27#include "console/consoleTypes.h" 28 29//----------------------------------------------------------------------------- 30IMPLEMENT_CONOBJECT( VSceneObjectGroup ); 31//----------------------------------------------------------------------------- 32 33VSceneObjectGroup::VSceneObjectGroup( void ) : 34 mDataReference( String::EmptyString ), 35 mSceneObject( NULL ) 36{ 37 setLabel( "SceneObjectGroup" ); 38}; 39 40void VSceneObjectGroup::initPersistFields( void ) 41{ 42 Parent::initPersistFields(); 43 44 addField( "Reference", TypeRealString, Offset( mDataReference, VSceneObjectGroup ), "The name of the data field referencing the targeted object." ); 45} 46 47//----------------------------------------------------------------------------- 48// 49// Reference Methods. 50// 51//----------------------------------------------------------------------------- 52 53//----------------------------------------------------------------------------- 54// 55// VSceneObjectGroup::getObject(); 56// 57// Returns the group's object reference. 58// 59//----------------------------------------------------------------------------- 60VTorque::SceneObjectType *VSceneObjectGroup::getSceneObject( void ) 61{ 62#ifndef VT_EDITOR 63 // Already Referenced? 64 if ( mSceneObject ) 65 { 66 // Return Object. 67 return mSceneObject; 68 } 69#endif 70 71 VController *controller = getController(); 72 if ( !controller ) 73 { 74 // No Controller! 75 return NULL; 76 } 77 78 String fieldValue; 79 if ( controller->getDataValue( mDataReference, fieldValue ) ) 80 { 81 // Store Object. 82 mSceneObject = dynamic_cast<VTorque::SceneObjectType*>( Sim::findObject( fieldValue ) ); 83 } 84 85 // Return. 86 return mSceneObject; 87} 88 89#ifdef VT_EDITOR 90//----------------------------------------------------------------------------- 91// 92// Debug Methods. 93// 94//----------------------------------------------------------------------------- 95 96DefineEngineMethod( VSceneObjectGroup, getSceneObject, S32, (),, "( void ) - Get the object this group references.\n" 97 "@return Returns the SimObjectID for the object." ) 98{ 99 // Fetch Object. 100 VTorque::SceneObjectType *objReference = object->getSceneObject(); 101 102 // Return. 103 return ( objReference ) ? objReference->getId() : 0; 104} 105#endif 106