mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-28 22:15:49 -04:00
Added the sharedObject library
This commit is contained in:
@@ -12,6 +12,7 @@ add_subdirectory(sharedMemoryManager)
|
||||
add_subdirectory(sharedMessageDispatch)
|
||||
add_subdirectory(sharedNetwork)
|
||||
add_subdirectory(sharedNetworkMessages)
|
||||
add_subdirectory(sharedObject)
|
||||
add_subdirectory(sharedRandom)
|
||||
add_subdirectory(sharedSynchronization)
|
||||
add_subdirectory(sharedThread)
|
||||
|
||||
@@ -365,7 +365,7 @@ inline T * DataResourceList<T>::reload(Iff &source)
|
||||
NOT_NULL(ms_loaded);
|
||||
|
||||
const TemporaryCrcString sourceCrcString (source.getFileName(), true);
|
||||
typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&sourceCrcString);
|
||||
typename LoadedDataResourceMap::iterator iter = ms_loaded->find((const CrcString*)&sourceCrcString);
|
||||
if (iter == ms_loaded->end())
|
||||
{
|
||||
DEBUG_WARNING(true, ("DataResourceList::reload: trying to reload unloaded resource %s!", source.getFileName()));
|
||||
@@ -388,7 +388,7 @@ inline const bool DataResourceList<T>::isLoaded(const std::string & source)
|
||||
{
|
||||
NOT_NULL(ms_loaded);
|
||||
const TemporaryCrcString sourceCrcString (source.c_str (), true);
|
||||
typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&sourceCrcString);
|
||||
typename LoadedDataResourceMap::iterator iter = ms_loaded->find((const CrcString*)&sourceCrcString);
|
||||
return (iter != ms_loaded->end());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(sharedObject)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/private)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public)
|
||||
|
||||
add_subdirectory(src)
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/CustomizationData_Directory.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/CustomizationData_LocalDirectory.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/CustomizationData_RemoteDirectory.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/AlterResult.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/AlterScheduler.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/Appearance.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/AppearanceTemplate.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/AppearanceTemplateList.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/ArrangementDescriptor.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/ArrangementDescriptorList.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/BasicRangedIntCustomizationVariable.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/CachedNetworkId.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/CachedNetworkIdArchive.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/portal/CellProperty.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/core/ConfigSharedObject.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/ContainedByProperty.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/Container.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/controller/Controller.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/CustomizationData.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/property/CustomizationDataProperty.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/CustomizationIdManager.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/CustomizationVariable.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/DebugNotification.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/DebugYawedFloorNotification.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/Dynamics.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/core/FirstSharedObject.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/Hardpoint.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/property/LayerProperty.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/lot/LotManager.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/lot/LotType.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/MemoryBlockManagedObject.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/movement/MovementTable.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/controller/NetworkController.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/NetworkIdManager.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/NoRenderAppearance.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/NoRenderAppearanceTemplate.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/Object.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/ObjectList.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/ObjectNotification.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/controller/ObjectSetMessage.def"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/controller/ObjectSetMessage.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/ObjectTemplate.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/ObjectTemplateCustomizationDataWriter.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/ObjectTemplateList.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/ObjectWatcherList.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/PaletteColorCustomizationVariable.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/portal/Portal.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/portal/PortalProperty.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/portal/PortalPropertyTemplate.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/portal/PortalPropertyTemplateList.h"
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "../../src/shared/portal/PortallizedSphereTree.h"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/property/Property.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/property/PropertyId.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/PulseDynamics.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/customization/RangedIntCustomizationVariable.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/RotationDynamics.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/ScheduleData.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/SeesawDynamics.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/core/SetupSharedObject.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/SimpleDynamics.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlotDescriptor.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlotDescriptorList.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlotId.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlotIdArchive.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlotIdManager.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlotType.def"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlottedContainer.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/SlottedContainmentProperty.h"
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "../../src/shared/portal/SphereGrid.h"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/SpringDynamics.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/StateDynamics.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/lot/StructureFootprint.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/TextAppearance.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/dynamics/TrackingDynamics.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/appearance/Tweakable.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/VolumeContainer.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/container/VolumeContainmentProperty.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/world/World.h"
|
||||
@@ -0,0 +1,196 @@
|
||||
|
||||
set(SHARED_SOURCES
|
||||
shared/ObjectWatcherList.cpp
|
||||
shared/ObjectWatcherList.h
|
||||
|
||||
shared/appearance/Appearance.cpp
|
||||
shared/appearance/Appearance.h
|
||||
shared/appearance/AppearanceTemplate.cpp
|
||||
shared/appearance/AppearanceTemplate.h
|
||||
shared/appearance/AppearanceTemplateList.cpp
|
||||
shared/appearance/AppearanceTemplateList.h
|
||||
shared/appearance/Hardpoint.cpp
|
||||
shared/appearance/Hardpoint.h
|
||||
shared/appearance/NoRenderAppearance.cpp
|
||||
shared/appearance/NoRenderAppearance.h
|
||||
shared/appearance/NoRenderAppearanceTemplate.cpp
|
||||
shared/appearance/NoRenderAppearanceTemplate.h
|
||||
shared/appearance/TextAppearance.cpp
|
||||
shared/appearance/TextAppearance.h
|
||||
shared/appearance/Tweakable.cpp
|
||||
shared/appearance/Tweakable.h
|
||||
|
||||
shared/container/ArrangementDescriptor.cpp
|
||||
shared/container/ArrangementDescriptor.h
|
||||
shared/container/ArrangementDescriptorList.cpp
|
||||
shared/container/ArrangementDescriptorList.h
|
||||
shared/container/ContainedByProperty.cpp
|
||||
shared/container/ContainedByProperty.h
|
||||
shared/container/Container.cpp
|
||||
shared/container/Container.h
|
||||
shared/container/SlotDescriptor.cpp
|
||||
shared/container/SlotDescriptor.h
|
||||
shared/container/SlotDescriptorList.cpp
|
||||
shared/container/SlotDescriptorList.h
|
||||
shared/container/SlotIdArchive.h
|
||||
shared/container/SlotId.cpp
|
||||
shared/container/SlotId.h
|
||||
shared/container/SlotIdManager.cpp
|
||||
shared/container/SlotIdManager.h
|
||||
shared/container/SlottedContainer.cpp
|
||||
shared/container/SlottedContainer.h
|
||||
shared/container/SlottedContainmentProperty.cpp
|
||||
shared/container/SlottedContainmentProperty.h
|
||||
shared/container/SlotType.def
|
||||
shared/container/VolumeContainer.cpp
|
||||
shared/container/VolumeContainer.h
|
||||
shared/container/VolumeContainmentProperty.cpp
|
||||
shared/container/VolumeContainmentProperty.h
|
||||
|
||||
shared/controller/Controller.cpp
|
||||
shared/controller/Controller.h
|
||||
shared/controller/NetworkController.cpp
|
||||
shared/controller/NetworkController.h
|
||||
shared/controller/ObjectSetMessage.def
|
||||
shared/controller/ObjectSetMessage.h
|
||||
|
||||
shared/core/ConfigSharedObject.cpp
|
||||
shared/core/ConfigSharedObject.h
|
||||
shared/core/FirstSharedObject.h
|
||||
shared/core/SetupSharedObject.cpp
|
||||
shared/core/SetupSharedObject.h
|
||||
|
||||
shared/customization/BasicRangedIntCustomizationVariable.cpp
|
||||
shared/customization/BasicRangedIntCustomizationVariable.h
|
||||
shared/customization/CustomizationData.cpp
|
||||
shared/customization/CustomizationData_Directory.h
|
||||
shared/customization/CustomizationData.h
|
||||
shared/customization/CustomizationData_LocalDirectory.cpp
|
||||
shared/customization/CustomizationData_LocalDirectory.h
|
||||
shared/customization/CustomizationData_RemoteDirectory.cpp
|
||||
shared/customization/CustomizationData_RemoteDirectory.h
|
||||
shared/customization/CustomizationIdManager.cpp
|
||||
shared/customization/CustomizationIdManager.h
|
||||
shared/customization/CustomizationVariable.cpp
|
||||
shared/customization/CustomizationVariable.h
|
||||
shared/customization/ObjectTemplateCustomizationDataWriter.cpp
|
||||
shared/customization/ObjectTemplateCustomizationDataWriter.h
|
||||
shared/customization/PaletteColorCustomizationVariable.cpp
|
||||
shared/customization/PaletteColorCustomizationVariable.h
|
||||
shared/customization/RangedIntCustomizationVariable.cpp
|
||||
shared/customization/RangedIntCustomizationVariable.h
|
||||
|
||||
shared/dynamics/Dynamics.cpp
|
||||
shared/dynamics/Dynamics.h
|
||||
shared/dynamics/RotationDynamics.cpp
|
||||
shared/dynamics/RotationDynamics.h
|
||||
shared/dynamics/SeesawDynamics.cpp
|
||||
shared/dynamics/SeesawDynamics.h
|
||||
shared/dynamics/SimpleDynamics.cpp
|
||||
shared/dynamics/SimpleDynamics.h
|
||||
shared/dynamics/SpringDynamics.cpp
|
||||
shared/dynamics/SpringDynamics.h
|
||||
shared/dynamics/StateDynamics.cpp
|
||||
shared/dynamics/StateDynamics.h
|
||||
shared/dynamics/TrackingDynamics.cpp
|
||||
shared/dynamics/TrackingDynamics.h
|
||||
|
||||
shared/lot/LotManager.cpp
|
||||
shared/lot/LotManager.h
|
||||
shared/lot/LotType.h
|
||||
shared/lot/StructureFootprint.cpp
|
||||
shared/lot/StructureFootprint.h
|
||||
|
||||
shared/movement/MovementTable.cpp
|
||||
shared/movement/MovementTable.h
|
||||
|
||||
shared/object/AlterResult.cpp
|
||||
shared/object/AlterResult.h
|
||||
shared/object/AlterScheduler.cpp
|
||||
shared/object/AlterScheduler.h
|
||||
shared/object/CachedNetworkIdArchive.h
|
||||
shared/object/CachedNetworkId.cpp
|
||||
shared/object/CachedNetworkId.h
|
||||
shared/object/DebugNotification.cpp
|
||||
shared/object/DebugNotification.h
|
||||
shared/object/DebugYawedFloorNotification.cpp
|
||||
shared/object/DebugYawedFloorNotification.h
|
||||
shared/object/MemoryBlockManagedObject.cpp
|
||||
shared/object/MemoryBlockManagedObject.h
|
||||
shared/object/NetworkIdManager.cpp
|
||||
shared/object/NetworkIdManager.h
|
||||
shared/object/Object.cpp
|
||||
shared/object/Object.h
|
||||
shared/object/ObjectList.cpp
|
||||
shared/object/ObjectList.h
|
||||
shared/object/ObjectNotification.cpp
|
||||
shared/object/ObjectNotification.h
|
||||
shared/object/ObjectTemplate.cpp
|
||||
shared/object/ObjectTemplate.h
|
||||
shared/object/ObjectTemplateList.cpp
|
||||
shared/object/ObjectTemplateList.h
|
||||
shared/object/ScheduleData.cpp
|
||||
shared/object/ScheduleData.h
|
||||
|
||||
shared/portal/CellProperty.cpp
|
||||
shared/portal/CellProperty.h
|
||||
shared/portal/Portal.cpp
|
||||
shared/portal/Portal.h
|
||||
shared/portal/PortallizedSphereTree.h
|
||||
shared/portal/PortalProperty.cpp
|
||||
shared/portal/PortalProperty.h
|
||||
shared/portal/PortalPropertyTemplate.cpp
|
||||
shared/portal/PortalPropertyTemplate.h
|
||||
shared/portal/PortalPropertyTemplateList.cpp
|
||||
shared/portal/PortalPropertyTemplateList.h
|
||||
shared/portal/SphereGrid.h
|
||||
|
||||
shared/property/CustomizationDataProperty.cpp
|
||||
shared/property/CustomizationDataProperty.h
|
||||
shared/property/LayerProperty.cpp
|
||||
shared/property/LayerProperty.h
|
||||
shared/property/Property.cpp
|
||||
shared/property/Property.h
|
||||
shared/property/PropertyId.h
|
||||
|
||||
shared/world/World.cpp
|
||||
shared/world/World.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM_SOURCES
|
||||
win32/FirstSharedObject.cpp
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/win32)
|
||||
else()
|
||||
set(PLATFORM_SOURCES "")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCollision/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedTerrain/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
|
||||
)
|
||||
|
||||
add_library(sharedObject STATIC
|
||||
${SHARED_SOURCES}
|
||||
${PLATFORM_SOURCES}
|
||||
)
|
||||
@@ -0,0 +1,457 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ObjectWatcherList.cpp
|
||||
// Portions copyright 1998 Bootprint Entertainment
|
||||
// Portions copyright 2001, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/ObjectWatcherList.h"
|
||||
|
||||
#include "sharedObject/AlterResult.h"
|
||||
#include "sharedObject/Appearance.h"
|
||||
#include "sharedObject/Object.h"
|
||||
#include "sharedFoundation/Watcher.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace ObjectWatcherListNamespace
|
||||
{
|
||||
void setRegionOfInfluenceEnabled(Object const * const object, bool const enabled, bool skipCell)
|
||||
{
|
||||
if (skipCell && NULL != object->getCellProperty())
|
||||
return;
|
||||
|
||||
object->setRegionOfInfluenceEnabled(enabled);
|
||||
|
||||
for (int i = 0; i < object->getNumberOfChildObjects(); ++i)
|
||||
setRegionOfInfluenceEnabled(object->getChildObject(i), enabled, skipCell);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// Construct an ObjectWatcherList
|
||||
|
||||
ObjectWatcherList::ObjectWatcherList (int initialVectorSize) :
|
||||
m_altering (false),
|
||||
m_objectVector (new ObjectVector),
|
||||
m_alterSafeObjectVector (new ObjectVector),
|
||||
m_skipCellRegionOfInfluence(false)
|
||||
{
|
||||
DEBUG_FATAL(initialVectorSize < 0, ("negative vector size"));
|
||||
|
||||
// Reserve the requested amount of entries to reduce further allocation
|
||||
|
||||
m_objectVector->reserve (static_cast<size_t> (initialVectorSize));
|
||||
m_alterSafeObjectVector->reserve (static_cast<size_t> (initialVectorSize));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Destroy an ObjectWatcherList.
|
||||
*/
|
||||
|
||||
ObjectWatcherList::~ObjectWatcherList(void)
|
||||
{
|
||||
delete m_objectVector;
|
||||
m_objectVector = 0;
|
||||
delete m_alterSafeObjectVector;
|
||||
m_alterSafeObjectVector = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Add an Object to the ObjectWatcherList.
|
||||
*
|
||||
* This routine will call Fatal in debug compiles if it is passed a NULL
|
||||
* object.
|
||||
*
|
||||
* This routine will call Fatal in debug compiles if the object list
|
||||
* overflows.
|
||||
*
|
||||
* @param objectToAdd Object to add to the ObjectWatcherList
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::addObject(Object & objectToAdd)
|
||||
{
|
||||
m_objectVector->push_back(Watcher<Object>(&objectToAdd));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Remove an Object from the ObjectWatcherList.
|
||||
*
|
||||
* This routine will call Fatal in debug compiles if it is passed a NULL
|
||||
* object.
|
||||
*
|
||||
* @param objectToRemove Pointer to the object to remove
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::removeObject(const Object & objectToRemove)
|
||||
{
|
||||
int index = 0;
|
||||
if (find(objectToRemove, &index))
|
||||
removeObjectByIndex(objectToRemove, index);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ObjectWatcherList::removeObjectByIndex (const Object & object, int index)
|
||||
{
|
||||
DEBUG_FATAL(index >= static_cast<int>(m_objectVector->size()), ("Index out of range"));
|
||||
DEBUG_FATAL((*m_objectVector)[static_cast<ObjectVector::size_type>(index)] != &object, ("Object is not the one indexed."));
|
||||
|
||||
// Replace the found entry with the entry from the back of the vector
|
||||
// so there is no shifting of the items in the vector.
|
||||
(*m_objectVector)[static_cast<ObjectVector::size_type>(index)] = m_objectVector->back();
|
||||
|
||||
// Remove the last item in the vector.
|
||||
m_objectVector->pop_back();
|
||||
|
||||
// NULL the object from the alter-safe object list.
|
||||
uint size = m_alterSafeObjectVector->size();
|
||||
for (uint i = 0; i < size; ++i)
|
||||
{
|
||||
if ((*m_alterSafeObjectVector)[i] == &object)
|
||||
{
|
||||
(*m_alterSafeObjectVector)[i] = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Remove all Objects from the ObjectWatcherList.
|
||||
*
|
||||
* Removes all Objects from the ObjectWatcherList
|
||||
*
|
||||
* This routine may not be called between prepareToAlter() and alter().
|
||||
*
|
||||
* If deleteObjects is true, this routine will call delete for all objects in the list
|
||||
*
|
||||
* @param deleteObjects Flag to delete all objects when they are removed
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::removeAll (bool deleteObjects)
|
||||
{
|
||||
DEBUG_FATAL(m_altering, ("m_altering"));
|
||||
|
||||
if (deleteObjects)
|
||||
{
|
||||
ObjectVector::iterator end = m_objectVector->end();
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != end; ++i)
|
||||
delete i->getPointer();
|
||||
}
|
||||
|
||||
m_objectVector->clear();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ObjectWatcherList::addToWorld()
|
||||
{
|
||||
ObjectVector::iterator iEnd = m_objectVector->end();
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != iEnd; ++i)
|
||||
{
|
||||
Object * const object = (*i);
|
||||
if (object)
|
||||
object->addToWorld();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ObjectWatcherList::removeFromWorld()
|
||||
{
|
||||
ObjectVector::iterator iEnd = m_objectVector->end();
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != iEnd; ++i)
|
||||
{
|
||||
Object * const object = (*i);
|
||||
if (object)
|
||||
object->removeFromWorld();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Prepare to call alter() on this object list.
|
||||
*
|
||||
* This routine must be called before calling alter(). It will copy setup
|
||||
* the ObjectWatcherList so that objects may be added and removed from the ObjectWatcherList
|
||||
* during the alter() without affecting that frame's list of objects that are
|
||||
* are being altered.
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::prepareToAlter(void)
|
||||
{
|
||||
DEBUG_FATAL(m_altering, ("m_altering"));
|
||||
|
||||
m_altering = true;
|
||||
|
||||
// Duplicate the object vector
|
||||
|
||||
(*m_alterSafeObjectVector) = (*m_objectVector);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Call alter() for all objects in the ObjectWatcherList.
|
||||
*
|
||||
* prepareToAlter() must be called before this routine can be called.
|
||||
*
|
||||
* This routine will simply iterate over all the objects in the ObjectWatcherList
|
||||
* and call their alter routines with the specified time.
|
||||
*
|
||||
* @param time Time to pass to each Object's alter routine
|
||||
* @see ObjectWatcherList::prepareToAlter()
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::alter(real time)
|
||||
{
|
||||
DEBUG_FATAL(!m_altering, ("prepareToAlter was not called"));
|
||||
|
||||
for (size_t i = 0; i < m_alterSafeObjectVector->size(); ++i)
|
||||
{
|
||||
// Cache the object pointer because the iter value may be nulled if the object,
|
||||
// is removed from the list withing its alter()
|
||||
|
||||
Object * const obj = (*m_alterSafeObjectVector)[i];
|
||||
if (!obj || !obj->isInitialized())
|
||||
continue;
|
||||
|
||||
float const alterResult = obj->alter(time);
|
||||
if (alterResult == AlterResult::cms_kill)
|
||||
{
|
||||
// alter() return false, so remove and delete the object
|
||||
|
||||
// Make sure the object is still in the object list before removing it
|
||||
|
||||
if ((*m_alterSafeObjectVector)[i] != NULL)
|
||||
{
|
||||
removeObject(*obj);
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
|
||||
m_alterSafeObjectVector->clear();
|
||||
m_altering = false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Call conclude() for all objects in the ObjectWatcherList.
|
||||
*
|
||||
* This routine may not be called between prepareToAlter() and alter().
|
||||
*
|
||||
* This routine will simply iterate over all the objects in the ObjectWatcherList
|
||||
* and call their conclude routines with the specified time.
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::conclude()
|
||||
{
|
||||
DEBUG_FATAL(m_altering, ("m_altering"));
|
||||
|
||||
ObjectVector::iterator end = m_objectVector->end();
|
||||
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != end; ++i)
|
||||
{
|
||||
Object * const object = (*i);
|
||||
if (object && object->isInitialized())
|
||||
object->conclude();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Call addToScene() for all objects in the ObjectWatcherList.
|
||||
*
|
||||
* This routine may not be called between prepareToAlter() and alter().
|
||||
*
|
||||
* This routine will simply iterate over all the objects in the ObjectWatcherList
|
||||
* and call their addToScene() routine with the specified camera.
|
||||
*
|
||||
* @param camera Camera rendering the scene.
|
||||
* @param excludedObject Object to exclude from the scene.
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::setRegionOfInfluenceEnabled(bool enabled) const
|
||||
{
|
||||
ObjectVector::iterator end = m_objectVector->end();
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != end; ++i)
|
||||
{
|
||||
Object const * const object = (*i);
|
||||
if (object)
|
||||
ObjectWatcherListNamespace::setRegionOfInfluenceEnabled(object, enabled, m_skipCellRegionOfInfluence);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Call addToScene() for all objects in the ObjectWatcherList.
|
||||
*
|
||||
* This routine may not be called between prepareToAlter() and alter().
|
||||
*
|
||||
* This routine will simply iterate over all the objects in the ObjectWatcherList
|
||||
* and call their addToScene() routine with the specified camera.
|
||||
*
|
||||
* @param camera Camera rendering the scene.
|
||||
* @param excludedObject Object to exclude from the scene.
|
||||
*/
|
||||
|
||||
void ObjectWatcherList::render(const Object *excludedObject) const
|
||||
{
|
||||
DEBUG_FATAL(m_altering, ("m_altering"));
|
||||
|
||||
const ObjectVector::iterator end = m_objectVector->end();
|
||||
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != end; ++i)
|
||||
{
|
||||
Object *const object = *i;
|
||||
if (object && (object != excludedObject))
|
||||
{
|
||||
const Appearance *const appearance = object->getAppearance();
|
||||
if (appearance)
|
||||
{
|
||||
appearance->setTransform_w(object->getTransform_o2w());
|
||||
appearance->objectListCameraRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Find the index of an object in an object list.
|
||||
*
|
||||
* Accepts an optional index to be used to return the object's index
|
||||
* in the object list.
|
||||
*
|
||||
* This routine will simply iterate over all the objects in the ObjectWatcherList
|
||||
* searching for the objectToCheck, and returns true with the index if
|
||||
* found, and false otherwise.
|
||||
*
|
||||
* @param objectToCheck Object to find
|
||||
* @param index Object's index in the object list
|
||||
*/
|
||||
|
||||
bool ObjectWatcherList::find(const Object & objectToCheck, int *index) const
|
||||
{
|
||||
ObjectVector::iterator end = m_objectVector->end();
|
||||
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != end; ++i)
|
||||
{
|
||||
const Object * const obj = (*i);
|
||||
|
||||
if (obj == &objectToCheck)
|
||||
{
|
||||
if (index)
|
||||
*index = std::distance(m_objectVector->begin(), i);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
int ObjectWatcherList::removeNulls ()
|
||||
{
|
||||
int count = 0;
|
||||
for (ObjectVector::iterator i = m_objectVector->begin(); i != m_objectVector->end();)
|
||||
{
|
||||
const Object * const obj = (*i);
|
||||
|
||||
if (obj)
|
||||
++i;
|
||||
else
|
||||
{
|
||||
++count;
|
||||
i = m_objectVector->erase (i);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Return the number of objects contained in the object list.
|
||||
*
|
||||
* @return The number of objects contained in the object list
|
||||
*/
|
||||
|
||||
int ObjectWatcherList::getNumberOfObjects(void) const
|
||||
{
|
||||
return static_cast<int> (m_objectVector->size());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Get an object in the object list.
|
||||
*
|
||||
* @param index Index of the object in the object list
|
||||
*/
|
||||
|
||||
Object *ObjectWatcherList::operator [](int index)
|
||||
{
|
||||
DEBUG_FATAL(index < 0 || index >= getNumberOfObjects(), ("index out of range %d/%d", index, getNumberOfObjects()));
|
||||
return (*m_objectVector)[static_cast<unsigned int> (index)];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Get a const object from the object list.
|
||||
*
|
||||
* @param index Index of the object in the object list
|
||||
*/
|
||||
|
||||
const Object *ObjectWatcherList::operator [](int index) const
|
||||
{
|
||||
DEBUG_FATAL(index < 0 || index >= getNumberOfObjects(), ("index out of range %d/%d", index, getNumberOfObjects()));
|
||||
return (*m_objectVector)[static_cast<unsigned int> (index)];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Get an object in the object list.
|
||||
*
|
||||
* @param index Index of the object in the object list
|
||||
*/
|
||||
|
||||
Object *ObjectWatcherList::getObject(int index)
|
||||
{
|
||||
DEBUG_FATAL(index < 0 || index >= getNumberOfObjects(), ("index out of range %d/%d", index, getNumberOfObjects()));
|
||||
return (*m_objectVector)[static_cast<unsigned int> (index)];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Get a const object from the object list.
|
||||
*
|
||||
* @param index Index of the object in the object list
|
||||
*/
|
||||
|
||||
const Object *ObjectWatcherList::getObject(int index) const
|
||||
{
|
||||
DEBUG_FATAL(index < 0 || index >= getNumberOfObjects(), ("index out of range %d/%d", index, getNumberOfObjects()));
|
||||
return (*m_objectVector)[static_cast<unsigned int> (index)];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void ObjectWatcherList::setSkipCellRegionOfInfluence(bool skip)
|
||||
{
|
||||
m_skipCellRegionOfInfluence = skip;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,76 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ObjectWatcherList.h
|
||||
// copyright 2002, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_ObjectWatcherList_H
|
||||
#define INCLUDED_ObjectWatcherList_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
template <typename T> class Watcher;
|
||||
class Object;
|
||||
class Camera;
|
||||
|
||||
// ======================================================================
|
||||
// Contain a list of watchers to objects.
|
||||
//
|
||||
// Objects may exist in more than one ObjectWatcherList simultaneously.
|
||||
|
||||
class ObjectWatcherList
|
||||
{
|
||||
public:
|
||||
|
||||
explicit ObjectWatcherList (int initialVectorSize=0);
|
||||
~ObjectWatcherList ();
|
||||
|
||||
void addObject (Object & object);
|
||||
void removeObject (const Object & object);
|
||||
int removeNulls ();
|
||||
|
||||
void removeAll (bool deleteObjects=false);
|
||||
|
||||
int getNumberOfObjects () const;
|
||||
|
||||
Object * getObject (int index);
|
||||
const Object * getObject (int index) const;
|
||||
|
||||
Object * operator [] (int index);
|
||||
const Object * operator [] (int index) const;
|
||||
|
||||
bool find (const Object & objectToCheck, int* index=0) const;
|
||||
void removeObjectByIndex (const Object &, int index);
|
||||
|
||||
void addToWorld ();
|
||||
void removeFromWorld ();
|
||||
|
||||
void prepareToAlter ();
|
||||
void alter (real time);
|
||||
void conclude ();
|
||||
|
||||
void setRegionOfInfluenceEnabled (bool enabled) const;
|
||||
void render (const Object *omitObject) const;
|
||||
|
||||
void setSkipCellRegionOfInfluence(bool skip);
|
||||
|
||||
private:
|
||||
|
||||
typedef stdvector<Watcher<Object> >::fwd ObjectVector;
|
||||
bool m_altering;
|
||||
ObjectVector * m_objectVector;
|
||||
ObjectVector * m_alterSafeObjectVector;
|
||||
bool m_skipCellRegionOfInfluence;
|
||||
|
||||
private:
|
||||
|
||||
// disable these routines
|
||||
ObjectWatcherList (const ObjectWatcherList &);
|
||||
ObjectWatcherList & operator = (const ObjectWatcherList &);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,896 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Appearance.cpp
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2001 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/Appearance.h"
|
||||
|
||||
#include "sharedCollision/CollideParameters.h"
|
||||
#include "sharedCollision/ExtentList.h"
|
||||
#include "sharedCollision/Extent.h"
|
||||
#include "sharedCollision/FloorManager.h"
|
||||
#include "sharedCollision/Floor.h"
|
||||
#include "sharedCollision/CollisionProperty.h"
|
||||
#include "sharedDebug/DebugFlags.h"
|
||||
#include "sharedFoundation/CrcLowerString.h"
|
||||
#include "sharedMath/AxialBox.h"
|
||||
#include "sharedMath/DebugShapeRenderer.h"
|
||||
#include "sharedObject/AlterResult.h"
|
||||
#include "sharedObject/AppearanceTemplate.h"
|
||||
#include "sharedObject/AppearanceTemplateList.h"
|
||||
#include "sharedObject/CellProperty.h"
|
||||
#include "sharedObject/CustomizationData.h"
|
||||
#include "sharedObject/CustomizationDataProperty.h"
|
||||
#include "sharedObject/Hardpoint.h"
|
||||
#include "sharedObject/Object.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace AppearanceNamespace
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
bool ms_drawAppearanceFrames;
|
||||
#endif
|
||||
|
||||
int ms_frameNumber;
|
||||
bool ms_renderHardpoints;
|
||||
bool ms_renderHardpointNames;
|
||||
Appearance::RenderHardpointFunction ms_renderHardpointFunction;
|
||||
|
||||
bool s_renderEnabled = true;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
using namespace AppearanceNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void Appearance::install()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DebugFlags::registerFlag(ms_drawAppearanceFrames, "SharedObject", "drawAppearanceFrames");
|
||||
DebugFlags::registerFlag(ms_renderHardpoints, "SharedObject", "renderHardpoints");
|
||||
DebugFlags::registerFlag(ms_renderHardpointNames, "SharedObject", "renderHardpointNames");
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::beginNewFrame()
|
||||
{
|
||||
++ms_frameNumber;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::setRenderHardpointFunction(RenderHardpointFunction renderHardpointFunction)
|
||||
{
|
||||
ms_renderHardpointFunction = renderHardpointFunction;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// Construct a new Appearance
|
||||
|
||||
Appearance::Appearance(const AppearanceTemplate *newAppearanceTemplate) :
|
||||
m_appearanceTemplate(AppearanceTemplateList::fetch(newAppearanceTemplate)),
|
||||
m_extent(m_appearanceTemplate ? ExtentList::fetch(m_appearanceTemplate->getExtent()) : NULL),
|
||||
m_owner(NULL),
|
||||
m_renderedFrameNumber(0),
|
||||
m_scale(Vector::xyz111),
|
||||
m_keepAlive(false),
|
||||
m_useRenderEffectsFlag(false),
|
||||
m_shadowBlobAllowed(false)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Destroy an Appearance.
|
||||
*
|
||||
* This routine will release the AppearanceTemplate used by this Appearance.
|
||||
*/
|
||||
|
||||
Appearance::~Appearance()
|
||||
{
|
||||
ExtentList::release(m_extent);
|
||||
m_extent = NULL;
|
||||
|
||||
if (m_appearanceTemplate)
|
||||
{
|
||||
AppearanceTemplateList::release(m_appearanceTemplate);
|
||||
m_appearanceTemplate = NULL;
|
||||
}
|
||||
|
||||
m_owner = NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Check if the data for this appearance has been loaded.
|
||||
*/
|
||||
|
||||
bool Appearance::isLoaded() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Alter the appearance specifying the amount of time that has passed.
|
||||
*
|
||||
* This routine can be used to modify the appearance before it's rendered
|
||||
*/
|
||||
|
||||
float Appearance::alter(float deltaTime)
|
||||
{
|
||||
UNREF(deltaTime);
|
||||
return (isAlive() ? AlterResult::cms_keepNoAlter : AlterResult::cms_kill);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Get an Extent to be used for selection of this object in tools
|
||||
*
|
||||
* This routine may be overloaded in derived classes.
|
||||
*/
|
||||
|
||||
const Extent *Appearance::getSelectionExtent() const
|
||||
{
|
||||
return getExtent();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Get the Extent of this Appearance.
|
||||
*
|
||||
* This routine may be overloaded in derived classes.
|
||||
*/
|
||||
|
||||
const Extent *Appearance::getExtent() const
|
||||
{
|
||||
return m_extent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Set a new Extent for this Appearance.
|
||||
*
|
||||
* The current extent will be released.
|
||||
*
|
||||
* @param newExtent New extent for this Appearance
|
||||
*/
|
||||
|
||||
void Appearance::setExtent(const Extent *extent)
|
||||
{
|
||||
ExtentList::release(m_extent);
|
||||
m_extent = extent;
|
||||
|
||||
extentChanged();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Get the tangible axial box, if applicable, for systems such as targeting.
|
||||
* Derived appearances can choose how much of the appearance contributes.
|
||||
*/
|
||||
|
||||
AxialBox const Appearance::getTangibleExtent() const
|
||||
{
|
||||
return AxialBox();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Return the bounding sphere for the Appearance.
|
||||
*
|
||||
* This routine may be overloaded in derived classes. By default it
|
||||
* gets the spheere from its extents. If the extent doesn't exist, it
|
||||
* returns the zero sphere
|
||||
*
|
||||
* @return The bounding sphere in object space.
|
||||
*/
|
||||
|
||||
const Sphere &Appearance::getSphere() const
|
||||
{
|
||||
const Extent *const extent = getExtent();
|
||||
return extent ? extent->getSphere() : Sphere::zero;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::addToWorld()
|
||||
{
|
||||
DPVS::Object *dpvsObject = getDpvsObject();
|
||||
if (dpvsObject)
|
||||
{
|
||||
NOT_NULL(m_owner);
|
||||
m_owner->addDpvsObject(dpvsObject);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::removeFromWorld()
|
||||
{
|
||||
DPVS::Object *dpvsObject = getDpvsObject();
|
||||
if (dpvsObject)
|
||||
{
|
||||
Object *owner = getOwner();
|
||||
if (owner)
|
||||
{
|
||||
owner->removeDpvsObject(dpvsObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::preRender() const
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::render() const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
const Object *owner = getOwner();
|
||||
if (owner)
|
||||
{
|
||||
DebugShapeRenderer * const renderer = DebugShapeRenderer::create(owner);
|
||||
drawDebugShapes(renderer);
|
||||
delete renderer;
|
||||
|
||||
if (ms_renderHardpoints && ms_renderHardpointFunction)
|
||||
{
|
||||
for (int i = 0; i < getHardpointCount(); ++i)
|
||||
{
|
||||
Hardpoint const & hardpoint = getHardpoint(i);
|
||||
|
||||
Transform transform_h2w;
|
||||
transform_h2w.multiply(getTransform_w(), hardpoint.getTransform());
|
||||
|
||||
ms_renderHardpointFunction(transform_h2w, ms_renderHardpointNames, hardpoint.getName().getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void Appearance::objectListCameraRenderDescend(Object const & obj)
|
||||
{
|
||||
//-- don't descend through cells
|
||||
if (NULL != obj.getCellProperty())
|
||||
return;
|
||||
|
||||
int const childCount = obj.getNumberOfChildObjects();
|
||||
for (int i = 0; i < childCount; ++i)
|
||||
{
|
||||
// Get the child object.
|
||||
Object const *const childObject = obj.getChildObject(i);
|
||||
if (!childObject)
|
||||
continue;
|
||||
|
||||
if (!childObject->isActive())
|
||||
continue;
|
||||
|
||||
// Setup child object appearance to world transform.
|
||||
const_cast<Object*>(childObject)->setTransform_a2w(childObject->getTransform_o2w());
|
||||
|
||||
// Render its appearance.
|
||||
const Appearance *const childAppearance = childObject->getAppearance();
|
||||
if (childAppearance)
|
||||
childAppearance->objectListCameraRender();
|
||||
else
|
||||
objectListCameraRenderDescend(*childObject);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::objectListCameraRender() const
|
||||
{
|
||||
if (!usesRenderEffectsFlag() || canRenderEffects())
|
||||
{
|
||||
//-- Render this appearance.
|
||||
render();
|
||||
|
||||
setRenderedThisFrame();
|
||||
|
||||
//-- Render the owner's child objects.
|
||||
Object const *const owner = getOwner();
|
||||
if (!owner)
|
||||
return;
|
||||
|
||||
int const childCount = owner->getNumberOfChildObjects();
|
||||
for (int i = 0; i < childCount; ++i)
|
||||
{
|
||||
// Get the child object.
|
||||
Object const *const childObject = owner->getChildObject(i);
|
||||
if (!childObject)
|
||||
continue;
|
||||
|
||||
if (!childObject->isActive())
|
||||
continue;
|
||||
|
||||
const Appearance *const childAppearance = childObject->getAppearance();
|
||||
if (childAppearance)
|
||||
{
|
||||
// Setup child object appearance to world transform.
|
||||
childAppearance->setTransform_w(childObject->getTransform_o2w());
|
||||
|
||||
// Render its appearance.
|
||||
childAppearance->objectListCameraRender();
|
||||
}
|
||||
else
|
||||
objectListCameraRenderDescend(*childObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::setTexture(Tag /*tag*/, const Texture & /*texture*/)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Cast a ray through object space and return the result of the collision (if any) to result
|
||||
*
|
||||
* @param start_o Object space start position of the ray
|
||||
* @param end_o Object space end position of the ray
|
||||
* @param collideParameters Struct which contains information about the type and quality of collision
|
||||
* @param result Struct which contains information about the collision
|
||||
* @return Whether or not a collision occurred
|
||||
*/
|
||||
|
||||
bool Appearance::collide(Vector const & /*start_o*/, Vector const & /*end_o*/, CollideParameters const & /*collideParameters*/, CollisionInfo & /*result*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::implementsCollide() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Set the new owning object associated with this appearance.
|
||||
*
|
||||
* There is a 1-1 correpsondence between Object instances and Appearance
|
||||
* instances. This function is called to set the Object instance
|
||||
* associated with this Appearance instance.
|
||||
*
|
||||
* This implementation checks the owner Object instance for a
|
||||
* CustomizationDataProperty. If there is such a property, this
|
||||
* function will invoke Appearance::setCustomizationData() with the
|
||||
* appropriate value. If the property doesn't exist, this function
|
||||
* will invoke Appearance::setCustomizationData() with NULL. Note if
|
||||
* the caller sets the CustomizationDataProperty for an Object after
|
||||
* associating the Object instance with the appearance, the caller is
|
||||
* responsible for calling Appearance::setCustomizationData().
|
||||
*
|
||||
* Implementers overriding this function must ensure they chain back
|
||||
* to this function as it performs necessary state modification.
|
||||
*
|
||||
* -TRF- I'm not sure why this is virtual. I think this probably needs
|
||||
* to be made non virtual. Currently it is mandatory for descendants
|
||||
* that override this function to chain back to this function to handle
|
||||
* the CustomizationData setup.
|
||||
*/
|
||||
|
||||
void Appearance::setOwner(Object* owner)
|
||||
{
|
||||
//-- keep track of owner object.
|
||||
m_owner = owner;
|
||||
|
||||
// DBE - This was added to mimic the behavior of when the appearance-to-world
|
||||
// transform was stored in Object instead of Appearance.
|
||||
if (owner)
|
||||
{
|
||||
Appearance *ownerAppearance = owner->getAppearance();
|
||||
if (!ownerAppearance)
|
||||
{
|
||||
setTransform_w(owner->getTransform_o2w());
|
||||
}
|
||||
else if (ownerAppearance!=this)
|
||||
{
|
||||
setTransform_w(ownerAppearance->getTransform_w());
|
||||
}
|
||||
}
|
||||
|
||||
//-- retrieve customization data for new owner
|
||||
CustomizationData *customizationData = 0;
|
||||
|
||||
if (owner)
|
||||
{
|
||||
// get the property
|
||||
CustomizationDataProperty *const property = safe_cast<CustomizationDataProperty*>(owner->getProperty(CustomizationDataProperty::getClassPropertyId()));
|
||||
if (property)
|
||||
{
|
||||
// retrieve the customization data from the property
|
||||
customizationData = property->fetchCustomizationData();
|
||||
}
|
||||
}
|
||||
|
||||
//-- set the CustomizationData
|
||||
setCustomizationData(customizationData);
|
||||
|
||||
//-- release local reference
|
||||
if (customizationData)
|
||||
customizationData->release();
|
||||
|
||||
//-- clear the rendered frame number
|
||||
m_renderedFrameNumber = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::setAlpha(bool const /* opaqueEnabled */, float const /* opaqueAlpha*/, bool const /* alphaEnabled */, float const /* alphaAlpha */)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::setTransform_w(const Transform &t) const
|
||||
{
|
||||
m_appearanceToWorld=t;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const char * Appearance::getFloorName () const
|
||||
{
|
||||
if (m_appearanceTemplate)
|
||||
return m_appearanceTemplate->getFloorName();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Set the CustomizationData associated with this Appearance instance.
|
||||
*
|
||||
* This function's primary purpose is to be overridden. It allows
|
||||
* derived Appearance classes to do something with the CustomizationData
|
||||
* when the CustomizationData instance is set or changed. The CustomizationData
|
||||
* instance changes when the owning Object is initially set or changed
|
||||
* to a new Object instance.
|
||||
*
|
||||
* Derived classes are not required to chain call this function.
|
||||
*
|
||||
* Callers need only invoke this function directly if CustomizationData
|
||||
* is initialized for the owning Object after Appearance::setOwner() is
|
||||
* called. The only feasible time this should happen is when the Object
|
||||
* and Appearance instances are created and associated prior to creation
|
||||
* of CustomizationData.
|
||||
*
|
||||
* @param customizationData the new CustomizationData instance associated
|
||||
* with this Appearance instance.
|
||||
*/
|
||||
|
||||
void Appearance::setCustomizationData(CustomizationData * /* customizationData */)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Add all CustomizationData variables influencing this Appearance instance
|
||||
* to the given CustomizationData instance.
|
||||
*
|
||||
* This is primarily useful as a mechanism for tools. The game should already
|
||||
* know which customization variables it has enabled for objects via the
|
||||
* ObjectTemplate system.
|
||||
*
|
||||
* Derived classes do not need to chain down to this function.
|
||||
*
|
||||
* Implementers: there are no guarantees as to the order of calls between
|
||||
* setCustomizationData() and this function. In other words, the implementation
|
||||
* should use the given CustomizationData arg to add variables.
|
||||
*
|
||||
* @param customizationData the CustomizationData instance to which new
|
||||
* variables will be added. Assumed to be empty
|
||||
* on entry.
|
||||
*/
|
||||
|
||||
void Appearance::addCustomizationVariables(CustomizationData & /* customizationData */) const
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::setKeepAlive(bool const keepAlive)
|
||||
{
|
||||
m_keepAlive = keepAlive;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::isAlive() const
|
||||
{
|
||||
return m_keepAlive ? true : realIsAlive();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::realIsAlive() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Find and return the transform for the given hardpoint.
|
||||
*
|
||||
* The transform is returned in local Object (Appearance) space. It is a
|
||||
* hardpoint-to-Object transform.
|
||||
*
|
||||
* Note in the general case, it is not safe to look up an index for
|
||||
* a hardpoint and then use the index. For skeletal appearances, indices
|
||||
* change when wearables are applied. Name lookup is a must when
|
||||
* possibly dealing with skeletal appearances.
|
||||
*
|
||||
* @param hardpointName the name of the hardpoint to look up.
|
||||
* @param hardpointTransform the result is returned in this parameter
|
||||
* upon successful completion.
|
||||
*
|
||||
* @return true if the hardpoint with the given name was found; false
|
||||
* otherwise.
|
||||
*/
|
||||
|
||||
bool Appearance::findHardpoint(CrcString const &hardpointName, Transform &hardpointTransform) const
|
||||
{
|
||||
// There are no hardpoints if there is no appearance template.
|
||||
if (!m_appearanceTemplate)
|
||||
return false;
|
||||
|
||||
//-- The default implementation is to lookup the hardpoint via the appearance template.
|
||||
const int hardpointIndex = getHardpointIndex(hardpointName, true);
|
||||
if (hardpointIndex < 0)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
//-- Handle the appearance scale.
|
||||
Transform scaleTransform(Transform::IF_none);
|
||||
scaleTransform.setToScale(m_scale);
|
||||
|
||||
//-- Get the hardpoint transform from the hardpoint object.
|
||||
const Hardpoint &hardpoint = getHardpoint(hardpointIndex);
|
||||
hardpointTransform.multiply(scaleTransform, hardpoint.getTransform());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Notify this Appearance of a change in scale.
|
||||
*
|
||||
* Implementers of derived classes should chain down to this function to
|
||||
* ensure that the internal scale variable is set.
|
||||
*
|
||||
* @param scale the new scale factor, where a scale of (1,1,1) is equivalent to not scaling.
|
||||
*/
|
||||
|
||||
void Appearance::setScale(const Vector &scale)
|
||||
{
|
||||
Vector const oldValue = m_scale;
|
||||
m_scale = scale;
|
||||
|
||||
onScaleModified(oldValue, m_scale);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const char * Appearance::getAppearanceTemplateName () const
|
||||
{
|
||||
if (m_appearanceTemplate)
|
||||
return m_appearanceTemplate->getName ();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DPVS::Object *Appearance::getDpvsObject() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
bool Appearance::debugRenderingEnabled() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void Appearance::drawDebugShapes(DebugShapeRenderer * renderer) const
|
||||
{
|
||||
if (renderer && debugRenderingEnabled())
|
||||
{
|
||||
if(m_appearanceTemplate)
|
||||
m_appearanceTemplate->drawDebugShapes(renderer);
|
||||
|
||||
if (ms_drawAppearanceFrames)
|
||||
renderer->drawFrame(1.0f);
|
||||
|
||||
const Object *owner = getOwner();
|
||||
if (owner)
|
||||
{
|
||||
CollisionProperty const * collision = owner->getCollisionProperty();
|
||||
if(collision)
|
||||
collision->drawDebugShapes(renderer);
|
||||
|
||||
Object const * parent = owner->getParent();
|
||||
if (parent)
|
||||
{
|
||||
CellProperty const * cellProperty = parent->getCellProperty();
|
||||
if (cellProperty)
|
||||
cellProperty->drawDebugShapes(renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
int Appearance::getPolygonCount () const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void Appearance::debugDump(std::string & /*result*/, const int /*indentLevel*/) const
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const IndexedTriangleList* Appearance::getRadarShape () const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::getShadowBlobAllowed() const
|
||||
{
|
||||
return m_shadowBlobAllowed;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::setShadowBlobAllowed()
|
||||
{
|
||||
m_shadowBlobAllowed = true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::renderShadowBlob (const Vector& /*position_o*/, const float /*radius*/) const
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::renderReticle (const Vector& /*position_o*/, const float /*radius*/) const
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::setRenderedThisFrame () const
|
||||
{
|
||||
m_renderedFrameNumber = ms_frameNumber;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::getRenderedThisFrame () const
|
||||
{
|
||||
return m_renderedFrameNumber == ms_frameNumber;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::getRenderedLastFrame () const
|
||||
{
|
||||
return m_renderedFrameNumber == (ms_frameNumber - 1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SkeletalAppearance2 * Appearance::asSkeletalAppearance2()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SkeletalAppearance2 const * Appearance::asSkeletalAppearance2() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ComponentAppearance * Appearance::asComponentAppearance()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ComponentAppearance const * Appearance::asComponentAppearance() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DetailAppearance * Appearance::asDetailAppearance()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
DetailAppearance const * Appearance::asDetailAppearance() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::onEvent(LabelHash::Id /* eventId */)
|
||||
{
|
||||
// Default: handle no events.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int Appearance::getHardpointCount() const
|
||||
{
|
||||
return m_appearanceTemplate != NULL ? m_appearanceTemplate->getHardpointCount() : 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int Appearance::getHardpointIndex(CrcString const &hardpointName, bool optional) const
|
||||
{
|
||||
return m_appearanceTemplate != NULL ? m_appearanceTemplate->getHardpointIndex(hardpointName, optional) : -1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const Hardpoint & Appearance::getHardpoint(int index) const
|
||||
{
|
||||
NOT_NULL(m_appearanceTemplate);
|
||||
return m_appearanceTemplate->getHardpoint(index);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// class Appearance: PROTECTED
|
||||
// ======================================================================
|
||||
|
||||
void Appearance::extentChanged() const
|
||||
{
|
||||
const Object *owner = getOwner();
|
||||
if (owner)
|
||||
{
|
||||
const_cast<Object *>(owner)->extentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::onScaleModified(Vector const &oldScale, Vector const &newScale)
|
||||
{
|
||||
// Do nothing.
|
||||
UNREF(oldScale);
|
||||
UNREF(newScale);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::canRenderEffects()
|
||||
{
|
||||
return s_renderEnabled;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::enableRenderEffects(bool const yesno)
|
||||
{
|
||||
s_renderEnabled = yesno;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Appearance::useRenderEffectsFlag(bool const yesno)
|
||||
{
|
||||
m_useRenderEffectsFlag = yesno;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool Appearance::usesRenderEffectsFlag() const
|
||||
{
|
||||
return m_useRenderEffectsFlag;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ParticleEffectAppearance * Appearance::asParticleEffectAppearance()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ParticleEffectAppearance const * Appearance::asParticleEffectAppearance() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SwooshAppearance * Appearance::asSwooshAppearance()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SwooshAppearance const * Appearance::asSwooshAppearance() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
LightningAppearance * Appearance::asLightningAppearance()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
LightningAppearance const * Appearance::asLightningAppearance() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,273 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Appearance.h
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2001, 2002 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_Appearance_H
|
||||
#define INCLUDED_Appearance_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/LabelHash.h"
|
||||
#include "sharedFoundation/Tag.h"
|
||||
#include "sharedMath/Vector.h"
|
||||
#include "sharedMath/Transform.h"
|
||||
|
||||
class AppearanceTemplate;
|
||||
class AxialBox;
|
||||
class BoxExtent;
|
||||
class CollideParameters;
|
||||
class CollisionInfo;
|
||||
class ComponentAppearance;
|
||||
class CrcLowerString;
|
||||
class CrcString;
|
||||
class CustomizationData;
|
||||
class DebugShapeRenderer;
|
||||
class DetailAppearance;
|
||||
class Extent;
|
||||
class Hardpoint;
|
||||
class IndexedTriangleList;
|
||||
class LightningAppearance;
|
||||
class LightsaberAppearance;
|
||||
class Object;
|
||||
class ParticleEffectAppearance;
|
||||
class SkeletalAppearance2;
|
||||
class Sphere;
|
||||
class SwooshAppearance;
|
||||
class Texture;
|
||||
class Vector;
|
||||
typedef uint32 PropertyId;
|
||||
|
||||
namespace DPVS
|
||||
{
|
||||
class Object;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class Appearance
|
||||
{
|
||||
// {Detail,Component,Lightsaber}Appearance need access to Appearance::getDpvsObject()
|
||||
friend class DetailAppearance;
|
||||
friend class ComponentAppearance;
|
||||
friend class LightsaberAppearance;
|
||||
|
||||
public:
|
||||
|
||||
static void install();
|
||||
|
||||
static void beginNewFrame ();
|
||||
|
||||
typedef void (*RenderHardpointFunction)(Transform const & transform_h2w, bool renderName, char const * name);
|
||||
static void setRenderHardpointFunction(RenderHardpointFunction renderHardpointFunction);
|
||||
|
||||
static bool canRenderEffects();
|
||||
static void enableRenderEffects(bool yesno);
|
||||
|
||||
void useRenderEffectsFlag(bool yesno);
|
||||
bool usesRenderEffectsFlag() const;
|
||||
|
||||
public:
|
||||
|
||||
explicit Appearance(const AppearanceTemplate *newAppearanceTemplate);
|
||||
virtual ~Appearance();
|
||||
|
||||
const AppearanceTemplate *getAppearanceTemplate() const;
|
||||
const char * getAppearanceTemplateName () const;
|
||||
|
||||
virtual bool isLoaded() const;
|
||||
|
||||
virtual const Sphere &getSphere() const;
|
||||
|
||||
virtual bool collide(Vector const & start_o, Vector const & end_o, CollideParameters const & collideParameters, CollisionInfo & result) const;
|
||||
virtual bool implementsCollide() const;
|
||||
|
||||
virtual const Extent *getSelectionExtent() const;
|
||||
virtual const Extent *getExtent() const;
|
||||
virtual void setExtent(const Extent *newExent);
|
||||
virtual AxialBox const getTangibleExtent() const;
|
||||
|
||||
virtual float alter(float time);
|
||||
|
||||
virtual void setAlpha(bool opaqueEnabled, float opaqueAlpha, bool alphaEnabled, float alphaAlpha);
|
||||
|
||||
Object *getOwner();
|
||||
const Object *getOwner() const;
|
||||
virtual void setOwner(Object *newOwner);
|
||||
|
||||
void setTransform_w(const Transform &t) const;
|
||||
const Transform & getTransform_w() const;
|
||||
|
||||
const char *getFloorName() const;
|
||||
|
||||
virtual void setCustomizationData(CustomizationData *customizationData);
|
||||
virtual void addCustomizationVariables(CustomizationData &customizationData) const;
|
||||
|
||||
virtual void setKeepAlive(bool keepAlive);
|
||||
bool isAlive() const;
|
||||
|
||||
virtual bool findHardpoint(CrcString const &hardpointName, Transform &hardpointTransform) const;
|
||||
virtual int getHardpointCount() const;
|
||||
virtual int getHardpointIndex(CrcString const &hardpointName, bool optional = false) const;
|
||||
virtual const Hardpoint& getHardpoint(int index) const;
|
||||
|
||||
virtual void setScale(Vector const & scale);
|
||||
virtual Vector const & getScale() const;
|
||||
void setUniformScale(float scale);
|
||||
float getUniformScale() const;
|
||||
|
||||
virtual void addToWorld();
|
||||
virtual void removeFromWorld();
|
||||
virtual void preRender() const;
|
||||
virtual void render() const;
|
||||
virtual void objectListCameraRender() const;
|
||||
static void objectListCameraRenderDescend(Object const & obj);
|
||||
|
||||
virtual void setTexture(Tag tag, const Texture &texture);
|
||||
bool getShadowBlobAllowed() const;
|
||||
virtual void setShadowBlobAllowed();
|
||||
virtual void renderShadowBlob (const Vector& position_o, float radius) const;
|
||||
virtual void renderReticle (const Vector& position_o, float radius) const;
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual bool debugRenderingEnabled() const;
|
||||
virtual void drawDebugShapes ( DebugShapeRenderer * R ) const;
|
||||
virtual int getPolygonCount () const;
|
||||
virtual void debugDump(std::string &result, int indentLevel) const;
|
||||
#endif
|
||||
|
||||
virtual const IndexedTriangleList* getRadarShape () const;
|
||||
|
||||
void setRenderedThisFrame () const;
|
||||
bool getRenderedThisFrame () const;
|
||||
bool getRenderedLastFrame () const;
|
||||
int getRenderedFrameNumber() const;
|
||||
|
||||
virtual SkeletalAppearance2 * asSkeletalAppearance2();
|
||||
virtual SkeletalAppearance2 const * asSkeletalAppearance2() const;
|
||||
|
||||
virtual ComponentAppearance * asComponentAppearance();
|
||||
virtual ComponentAppearance const * asComponentAppearance() const;
|
||||
|
||||
virtual DetailAppearance * asDetailAppearance();
|
||||
virtual DetailAppearance const * asDetailAppearance() const;
|
||||
|
||||
virtual ParticleEffectAppearance * asParticleEffectAppearance();
|
||||
virtual ParticleEffectAppearance const * asParticleEffectAppearance() const;
|
||||
|
||||
virtual SwooshAppearance * asSwooshAppearance();
|
||||
virtual SwooshAppearance const * asSwooshAppearance() const;
|
||||
|
||||
virtual LightningAppearance * asLightningAppearance();
|
||||
virtual LightningAppearance const * asLightningAppearance() const;
|
||||
|
||||
virtual void onEvent(LabelHash::Id eventId);
|
||||
|
||||
protected:
|
||||
|
||||
void extentChanged() const;
|
||||
|
||||
virtual bool realIsAlive() const;
|
||||
virtual void onScaleModified(Vector const &oldScale, Vector const &newScale);
|
||||
|
||||
private:
|
||||
|
||||
// disabled
|
||||
Appearance();
|
||||
Appearance(const Appearance &);
|
||||
Appearance &operator =(const Appearance &);
|
||||
|
||||
virtual DPVS::Object *getDpvsObject() const;
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const AppearanceTemplate *m_appearanceTemplate;
|
||||
|
||||
protected:
|
||||
|
||||
const Extent *m_extent;
|
||||
|
||||
private:
|
||||
|
||||
Object *m_owner;
|
||||
mutable int m_renderedFrameNumber;
|
||||
Vector m_scale;
|
||||
bool m_keepAlive;
|
||||
bool m_useRenderEffectsFlag;
|
||||
bool m_shadowBlobAllowed;
|
||||
mutable Transform m_appearanceToWorld;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
/**
|
||||
* Get the AppearanceTemplate for this Appearance.
|
||||
*
|
||||
* The AppearanceTemplate may be NULL.
|
||||
*
|
||||
* AppearanceTemplates may be shared by multiple Appearances.
|
||||
*
|
||||
* @return const pointer to the AppearanceTemplate.
|
||||
*/
|
||||
|
||||
inline const AppearanceTemplate *Appearance::getAppearanceTemplate() const
|
||||
{
|
||||
return m_appearanceTemplate;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline Object *Appearance::getOwner()
|
||||
{
|
||||
return m_owner;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const Object *Appearance::getOwner() const
|
||||
{
|
||||
return m_owner;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const Transform &Appearance::getTransform_w() const
|
||||
{
|
||||
return m_appearanceToWorld;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline Vector const &Appearance::getScale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inline void Appearance::setUniformScale(float const scale)
|
||||
{
|
||||
setScale(Vector(scale, scale, scale));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inline float Appearance::getUniformScale() const
|
||||
{
|
||||
// When requesting a uniform scale, the x-axis is the only one considered.
|
||||
return getScale().x;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inline int Appearance::getRenderedFrameNumber() const
|
||||
{
|
||||
return m_renderedFrameNumber;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,494 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AppearanceTemplate.cpp
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2001-2002 Sony Online Entertainment
|
||||
// All Rights Reserved
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/AppearanceTemplate.h"
|
||||
|
||||
#include "sharedCollision/ConfigSharedCollision.h"
|
||||
#include "sharedCollision/ExtentList.h"
|
||||
#include "sharedCollision/Extent.h"
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedCollision/FloorManager.h"
|
||||
#include "sharedCollision/FloorMesh.h"
|
||||
#include "sharedObject/Appearance.h"
|
||||
#include "sharedObject/AppearanceTemplateList.h"
|
||||
#include "sharedObject/Hardpoint.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedFoundation/CrashReportInformation.h"
|
||||
#include "sharedFoundation/CrcLowerString.h"
|
||||
#include "sharedFoundation/DataResourceList.h"
|
||||
#include "sharedFoundation/PointerDeleter.h"
|
||||
#include "sharedFoundation/ExitChain.h"
|
||||
#include "sharedMath/Transform.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
namespace AppearanceTemplateNamespace
|
||||
{
|
||||
const Tag TAG_APPR = TAG (A,P,P,R);
|
||||
const Tag TAG_HPTS = TAG (H,P,T,S);
|
||||
const Tag TAG_HPNT = TAG (H,P,N,T);
|
||||
const Tag TAG_FLOR = TAG (F,L,O,R);
|
||||
|
||||
bool ms_verboseWarnings;
|
||||
|
||||
char ms_crashReportInfo[MAX_PATH * 2];
|
||||
|
||||
void remove();
|
||||
}
|
||||
|
||||
using namespace AppearanceTemplateNamespace;
|
||||
|
||||
// ======================================================================
|
||||
// PRIVATE AppearanceTemplate::PreloadManager
|
||||
// ======================================================================
|
||||
|
||||
class AppearanceTemplate::PreloadManager
|
||||
{
|
||||
public:
|
||||
|
||||
explicit PreloadManager (const AppearanceTemplate* appearanceTemplate);
|
||||
~PreloadManager ();
|
||||
|
||||
private:
|
||||
|
||||
PreloadManager ();
|
||||
PreloadManager (const PreloadManager&);
|
||||
PreloadManager& operator= (const PreloadManager&);
|
||||
|
||||
private:
|
||||
|
||||
const FloorMesh* m_preloadFloorMesh;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AppearanceTemplate::PreloadManager::PreloadManager (const AppearanceTemplate* const appearanceTemplate) :
|
||||
m_preloadFloorMesh (0)
|
||||
{
|
||||
if (appearanceTemplate->m_floorName)
|
||||
m_preloadFloorMesh = FloorMeshList::fetch (appearanceTemplate->m_floorName);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AppearanceTemplate::PreloadManager::~PreloadManager ()
|
||||
{
|
||||
if (m_preloadFloorMesh)
|
||||
{
|
||||
m_preloadFloorMesh->releaseReference ();
|
||||
m_preloadFloorMesh = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// Construct an AppearanceTemplate
|
||||
|
||||
AppearanceTemplate::AppearanceTemplate(const char *newName)
|
||||
: m_referenceCount(0),
|
||||
m_crcName(new CrcLowerString(newName)),
|
||||
m_extent(NULL),
|
||||
m_collisionExtent(NULL),
|
||||
m_hardpoints(NULL),
|
||||
m_floorName(NULL),
|
||||
m_preloadManager (0)
|
||||
{
|
||||
//-- Save info on most recently constructed appearance template.
|
||||
IGNORE_RETURN(snprintf(ms_crashReportInfo, sizeof(ms_crashReportInfo) - 1, "AppearanceTemplate: %s\n", newName ? newName : "<NULL>"));
|
||||
ms_crashReportInfo[sizeof(ms_crashReportInfo) - 1] = '\0';
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Destroy an AppearanceTemplate.
|
||||
*/
|
||||
|
||||
AppearanceTemplate::~AppearanceTemplate(void)
|
||||
{
|
||||
delete m_crcName;
|
||||
|
||||
ExtentList::release(m_extent);
|
||||
m_extent = NULL;
|
||||
|
||||
ExtentList::release(m_collisionExtent);
|
||||
m_collisionExtent = NULL;
|
||||
|
||||
if (m_hardpoints)
|
||||
{
|
||||
std::for_each(m_hardpoints->begin(), m_hardpoints->end(), PointerDeleter());
|
||||
delete m_hardpoints;
|
||||
m_hardpoints = 0;
|
||||
}
|
||||
|
||||
delete [] m_floorName;
|
||||
|
||||
if (m_preloadManager)
|
||||
{
|
||||
delete m_preloadManager;
|
||||
m_preloadManager = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::install()
|
||||
{
|
||||
AppearanceTemplateList::assignBinding(TAG_APPR, create);
|
||||
|
||||
ms_crashReportInfo[0] = '\0';
|
||||
CrashReportInformation::addDynamicText(ms_crashReportInfo);
|
||||
|
||||
ExitChain::add(remove, "AppearanceTemplateList::remove");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplateNamespace::remove()
|
||||
{
|
||||
AppearanceTemplateList::removeBinding(TAG_APPR);
|
||||
CrashReportInformation::removeDynamicText(ms_crashReportInfo);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AppearanceTemplate *AppearanceTemplate::create(const char *newName, Iff *iff)
|
||||
{
|
||||
AppearanceTemplate * temp = new AppearanceTemplate(newName);
|
||||
temp->load(*iff);
|
||||
return temp;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Create a unique Appearance for this AppearanceTemplate.
|
||||
*
|
||||
* This routine should be overloaded in derived classes as appropriate.
|
||||
*
|
||||
* Derived classes should not chain down to this routine.
|
||||
*
|
||||
* @return An Appearance for the specified AppearanceTemplate
|
||||
*/
|
||||
|
||||
Appearance *AppearanceTemplate::createAppearance() const
|
||||
{
|
||||
return new Appearance(this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::load(Iff & iff)
|
||||
{
|
||||
iff.enterForm(TAG_APPR);
|
||||
|
||||
#ifdef _DEBUG
|
||||
DEBUG_WARNING (DataLint::isEnabled () && iff.getCurrentName () < TAG_0003, ("AppearanceTemplate [%s] loading older version -- this asset will need to be reexported", getCrcName ().getString ()));
|
||||
#endif
|
||||
|
||||
switch (iff.getCurrentName())
|
||||
{
|
||||
case TAG_0001:
|
||||
load_0001(iff);
|
||||
break;
|
||||
|
||||
case TAG_0002:
|
||||
load_0002(iff);
|
||||
break;
|
||||
|
||||
case TAG_0003:
|
||||
load_0003(iff);
|
||||
break;
|
||||
|
||||
default:
|
||||
FATAL (true, ("AppearanceTemplate::load - unsupported format"));
|
||||
break;
|
||||
}
|
||||
|
||||
iff.exitForm(TAG_APPR);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::load_0001(Iff &iff)
|
||||
{
|
||||
iff.enterForm(TAG_0001);
|
||||
|
||||
loadExtents(iff);
|
||||
loadHardpoints(iff);
|
||||
|
||||
iff.exitForm(TAG_0001);
|
||||
}
|
||||
|
||||
// ----------
|
||||
|
||||
void AppearanceTemplate::load_0002(Iff &iff)
|
||||
{
|
||||
iff.enterForm(TAG_0002);
|
||||
|
||||
loadExtents(iff);
|
||||
loadHardpoints(iff);
|
||||
IGNORE_RETURN(loadFloors(iff));
|
||||
|
||||
iff.exitForm(TAG_0002);
|
||||
}
|
||||
|
||||
// ----------
|
||||
|
||||
void AppearanceTemplate::load_0003(Iff & iff)
|
||||
{
|
||||
iff.enterForm(TAG_0003);
|
||||
|
||||
loadExtents(iff);
|
||||
loadCollisionExtents(iff);
|
||||
loadHardpoints(iff);
|
||||
IGNORE_RETURN(loadFloors(iff));
|
||||
|
||||
iff.exitForm(TAG_0003);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Load the extents out of an Iff.
|
||||
*
|
||||
* @param iff Iff containing the extent information
|
||||
*/
|
||||
|
||||
void AppearanceTemplate::loadExtents (Iff & iff)
|
||||
{
|
||||
m_extent = ExtentList::fetch(iff);
|
||||
}
|
||||
|
||||
void AppearanceTemplate::loadCollisionExtents (Iff & iff)
|
||||
{
|
||||
m_collisionExtent = ExtentList::fetch(iff);
|
||||
|
||||
if(m_collisionExtent && !m_collisionExtent->validate())
|
||||
{
|
||||
DEBUG_WARNING(true,("AppearanceTemplate::loadCollisionExtents - Extent loaded from %s is invalid",iff.getFileName()));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Load the hardpoints out of an Iff.
|
||||
*/
|
||||
|
||||
void AppearanceTemplate::loadHardpoints (Iff& iff)
|
||||
{
|
||||
// This enterForm call MUST be optional, as older versions of the exporter
|
||||
// just didn't write out this form if there weren't any hardpoints
|
||||
// (instead of writing an empty form)
|
||||
|
||||
if(iff.enterForm(TAG_HPTS,true))
|
||||
{
|
||||
char hardpointName[256];
|
||||
Transform hardpointTransform;
|
||||
|
||||
int nHardpoints = iff.getNumberOfBlocksLeft();
|
||||
|
||||
if (m_hardpoints)
|
||||
{
|
||||
std::for_each(m_hardpoints->begin(), m_hardpoints->end(), PointerDeleter());
|
||||
m_hardpoints->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hardpoints = new HardpointList();
|
||||
m_hardpoints->reserve(static_cast<HardpointList::size_type>(nHardpoints));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nHardpoints; ++i)
|
||||
{
|
||||
iff.enterChunk(TAG_HPNT);
|
||||
hardpointTransform = iff.read_floatTransform();
|
||||
iff.readRest_char(hardpointName, sizeof(hardpointName));
|
||||
iff.exitChunk(TAG_HPNT);
|
||||
|
||||
m_hardpoints->push_back(new Hardpoint (hardpointName, hardpointTransform));
|
||||
}
|
||||
|
||||
iff.exitForm(TAG_HPTS);
|
||||
|
||||
//-- Sort the hardpoints by crc name.
|
||||
std::sort(m_hardpoints->begin(), m_hardpoints->end(), Hardpoint::LessNameComparator());
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool AppearanceTemplate::loadFloors( Iff & iff )
|
||||
{
|
||||
iff.enterForm (TAG_FLOR);
|
||||
|
||||
iff.enterChunk(TAG_DATA);
|
||||
|
||||
bool hasFloor = iff.read_bool8();
|
||||
if(hasFloor)
|
||||
m_floorName = iff.read_string();
|
||||
|
||||
iff.exitChunk(TAG_DATA);
|
||||
|
||||
iff.exitForm(TAG_FLOR);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
char const * AppearanceTemplate::getFloorName() const
|
||||
{
|
||||
return m_floorName;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Set a new Extent for this AppearanceTemplate.
|
||||
*
|
||||
* The current extent will be released.
|
||||
*
|
||||
* @param newExtent New extent for this AppearanceTemplate
|
||||
*/
|
||||
|
||||
void AppearanceTemplate::setExtent(const Extent *newExtent)
|
||||
{
|
||||
ExtentList::release(m_extent);
|
||||
m_extent = newExtent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::setCollisionExtent ( Extent const * newExtent )
|
||||
{
|
||||
ExtentList::release(m_collisionExtent);
|
||||
m_collisionExtent = newExtent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* retrieve the index of a hardpoint given the hardpoint name.
|
||||
*
|
||||
* Hardpoint names are compared in a case-insensitive manner.
|
||||
*
|
||||
* The argument "optional" controls activity when the hardpoint name is not
|
||||
* found. The routine will FATAL if optional is false and the hardpoint name
|
||||
* is not found. The routine will return -1 if optional is true and the
|
||||
* hardpoint name isn't found.
|
||||
*
|
||||
* @return index of hardpoint with given name if found, -1 or FATAL otherwise (see remarks).
|
||||
*/
|
||||
|
||||
int AppearanceTemplate::getHardpointIndex(CrcString const &hardpointName, bool optional) const
|
||||
{
|
||||
//-- Handle no-hardpoint case.
|
||||
if (!m_hardpoints)
|
||||
{
|
||||
FATAL(!optional, ("getHardpointIndex(%s) called non-optionally on appearance template [%s] with no hardpoints.", hardpointName.getString(), m_crcName->getString()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-- Search for the hardpoint in Crc order.
|
||||
std::pair<HardpointList::iterator, HardpointList::iterator> const rangePair = std::equal_range(m_hardpoints->begin(), m_hardpoints->end(), hardpointName, Hardpoint::LessNameComparator());
|
||||
if (rangePair.first == rangePair.second)
|
||||
{
|
||||
FATAL(!optional, ("getHardpointIndex(%s) called non-optionally on appearance template [%s], hardpoint doesn't exist.", hardpointName.getString(), m_crcName->getString()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return std::distance(m_hardpoints->begin(), rangePair.first);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
const Hardpoint& AppearanceTemplate::getHardpoint(int index) const
|
||||
{
|
||||
NOT_NULL(m_hardpoints);
|
||||
VALIDATE_RANGE_INCLUSIVE_EXCLUSIVE(0, index, getHardpointCount());
|
||||
|
||||
return *((*m_hardpoints)[static_cast<HardpointList::size_type>(index)]);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int AppearanceTemplate::getHardpointCount(void) const
|
||||
{
|
||||
return m_hardpoints ? static_cast<int>(m_hardpoints->size()) : 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::drawDebugShapes ( DebugShapeRenderer * renderer ) const
|
||||
{
|
||||
UNREF(renderer);
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(ConfigSharedCollision::getDrawExtents())
|
||||
{
|
||||
if(m_collisionExtent)
|
||||
{
|
||||
m_collisionExtent->drawDebugShapes(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::preloadAssets() const
|
||||
{
|
||||
if (!m_preloadManager)
|
||||
m_preloadManager = new PreloadManager (this);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::preloadAssetsLight () const
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplate::garbageCollect() const
|
||||
{
|
||||
if (m_preloadManager)
|
||||
{
|
||||
delete m_preloadManager;
|
||||
m_preloadManager = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
*Get the CrcLowerString for this AppearanceTemplate.
|
||||
*/
|
||||
|
||||
const CrcLowerString &AppearanceTemplate::getCrcName() const
|
||||
{
|
||||
return *m_crcName;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
*Get the name of this AppearanceTemplate.
|
||||
*
|
||||
*This routine may return NULL.
|
||||
*/
|
||||
|
||||
const char *AppearanceTemplate::getName() const
|
||||
{
|
||||
return m_crcName->getString();
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AppearanceTemplate.h
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2001 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_AppearanceTemplate_H
|
||||
#define INCLUDED_AppearanceTemplate_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class Appearance;
|
||||
class Camera;
|
||||
class CrcLowerString;
|
||||
class CrcString;
|
||||
class Extent;
|
||||
class Hardpoint;
|
||||
class Iff;
|
||||
class Object;
|
||||
class Sphere;
|
||||
class Vector;
|
||||
class DebugShapeRenderer;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class AppearanceTemplate
|
||||
{
|
||||
public:
|
||||
|
||||
static void install();
|
||||
|
||||
static AppearanceTemplate *create(const char *newName, Iff *iff);
|
||||
|
||||
public:
|
||||
|
||||
explicit AppearanceTemplate(const char *newName);
|
||||
virtual ~AppearanceTemplate();
|
||||
|
||||
virtual Appearance *createAppearance() const;
|
||||
virtual void drawDebugShapes(DebugShapeRenderer *renderer) const;
|
||||
|
||||
virtual void preloadAssets () const;
|
||||
//-- we use this function to do some preloading but nothing big. Characters use it in preloading since loading all .MGNs as done by preloadAssets() generally is too heavy.
|
||||
virtual void preloadAssetsLight () const;
|
||||
virtual void garbageCollect () const;
|
||||
|
||||
const CrcLowerString &getCrcName() const;
|
||||
const char *getName() const;
|
||||
|
||||
const Extent *getExtent() const;
|
||||
void setExtent(const Extent *newExent);
|
||||
|
||||
const Extent *getCollisionExtent() const;
|
||||
void setCollisionExtent(Extent const *newExtent);
|
||||
|
||||
|
||||
int getHardpointCount() const;
|
||||
int getHardpointIndex(CrcString const &hardpointName, bool optional = false) const;
|
||||
const Hardpoint& getHardpoint(int index) const;
|
||||
|
||||
const char *getFloorName() const;
|
||||
|
||||
int getReferenceCount() const;
|
||||
int incrementReference() const;
|
||||
int decrementReference() const;
|
||||
|
||||
void load(Iff &iff);
|
||||
|
||||
protected:
|
||||
|
||||
void load_0001(Iff &iff);
|
||||
void load_0002(Iff &iff);
|
||||
void load_0003(Iff &iff);
|
||||
|
||||
void loadExtents(Iff &iff);
|
||||
void loadCollisionExtents(Iff &iff);
|
||||
void loadHardpoints(Iff &iff);
|
||||
|
||||
bool loadFloors(Iff &iff);
|
||||
|
||||
private:
|
||||
|
||||
typedef stdvector<Hardpoint*>::fwd HardpointList;
|
||||
|
||||
private:
|
||||
|
||||
AppearanceTemplate();
|
||||
AppearanceTemplate(const AppearanceTemplate &);
|
||||
AppearanceTemplate &operator =(const AppearanceTemplate &);
|
||||
|
||||
private:
|
||||
|
||||
mutable int m_referenceCount;
|
||||
CrcLowerString *const m_crcName;
|
||||
const Extent *m_extent;
|
||||
|
||||
const Extent *m_collisionExtent;
|
||||
|
||||
HardpointList *m_hardpoints;
|
||||
|
||||
char * m_floorName;
|
||||
|
||||
class PreloadManager;
|
||||
friend class PreloadManager;
|
||||
mutable PreloadManager* m_preloadManager;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
*Return the Extent for this AppearanceTemplate.
|
||||
*/
|
||||
|
||||
inline const Extent *AppearanceTemplate::getExtent() const
|
||||
{
|
||||
return m_extent;
|
||||
}
|
||||
|
||||
inline const Extent *AppearanceTemplate::getCollisionExtent() const
|
||||
{
|
||||
return m_collisionExtent;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int AppearanceTemplate::getReferenceCount() const
|
||||
{
|
||||
return m_referenceCount;
|
||||
}
|
||||
|
||||
// ----------
|
||||
|
||||
inline int AppearanceTemplate::incrementReference() const
|
||||
{
|
||||
m_referenceCount++;
|
||||
|
||||
return m_referenceCount;
|
||||
}
|
||||
|
||||
// ----------
|
||||
|
||||
inline int AppearanceTemplate::decrementReference() const
|
||||
{
|
||||
m_referenceCount--;
|
||||
|
||||
return m_referenceCount;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,736 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AppearanceTemplateList.cpp
|
||||
// copyright 1999 Bootprint Entertainment
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/AppearanceTemplateList.h"
|
||||
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedDebug/DebugFlags.h"
|
||||
#include "sharedFoundation/CrcLowerString.h"
|
||||
#include "sharedFoundation/ExitChain.h"
|
||||
#include "sharedFoundation/LessPointerComparator.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/PointerDeleter.h"
|
||||
#include "sharedFoundation/PersistentCrcString.h"
|
||||
#include "sharedFoundation/TemporaryCrcString.h"
|
||||
#include "sharedFile/AsynchronousLoader.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedObject/AppearanceTemplate.h"
|
||||
#include "sharedObject/ConfigSharedObject.h"
|
||||
#include "sharedRandom/Random.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
// ======================================================================
|
||||
// AppearanceTemplateListNamespace
|
||||
// ======================================================================
|
||||
|
||||
namespace AppearanceTemplateListNamespace
|
||||
{
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
typedef std::map<Tag, AppearanceTemplateList::CreateFunction> TagBindingMap;
|
||||
typedef std::map<const CrcString *, const CrcString *, LessPointerComparator> RedirectorMap;
|
||||
typedef std::set<AppearanceTemplate *> AnonymousTemplates;
|
||||
typedef std::map<const CrcString *, AppearanceTemplate *, LessPointerComparator> NamedTemplates;
|
||||
typedef std::pair<float, AppearanceTemplate *> TimedTemplate;
|
||||
typedef std::map<const CrcString *, TimedTemplate, LessPointerComparator> NamedTimedTemplates;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
const Tag TAG_APT = TAG3(A,P,T);
|
||||
const Tag TAG_MESH = TAG(M,E,S,H);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
const char* const ms_defaultAppearanceTemplateName = "appearance/defaultappearance.apt";
|
||||
float ms_keepTime;
|
||||
float ms_keepEpsilon;
|
||||
bool ms_installed;
|
||||
bool ms_debugReport;
|
||||
bool ms_debugReportVerbose;
|
||||
bool ms_debugReportTimedTemplates;
|
||||
TagBindingMap ms_tagBindingMap;
|
||||
RedirectorMap ms_redirectorMap;
|
||||
AnonymousTemplates ms_anonymousTemplates;
|
||||
NamedTemplates ms_namedTemplates;
|
||||
NamedTimedTemplates ms_namedTimedTemplates;
|
||||
bool ms_allowTimedTemplates;
|
||||
bool ms_useTimedTemplates;
|
||||
bool ms_logCreate;
|
||||
bool ms_logFetch;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
void remove();
|
||||
AppearanceTemplate *create(const char *fileName);
|
||||
void addAnonymousAppearanceTemplate(AppearanceTemplate *appearanceTemplate);
|
||||
void addNamedAppearanceTemplate(AppearanceTemplate *appearanceTemplate);
|
||||
void addNamedTimedAppearanceTemplate(AppearanceTemplate *appearanceTemplate);
|
||||
void removeAppearanceTemplate(AppearanceTemplate *appearanceTemplate);
|
||||
void debugReport();
|
||||
void debugReportVerbose();
|
||||
void debugReportTimedTemplates();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
}
|
||||
|
||||
using namespace AppearanceTemplateListNamespace;
|
||||
|
||||
// ======================================================================
|
||||
// STATIC PUBLIC AppearanceTemplateList
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Install the AppearanceTemplateList.
|
||||
*/
|
||||
void AppearanceTemplateList::install(bool useTimedTemplates, bool ensureDefaultAppearanceExists)
|
||||
{
|
||||
DEBUG_FATAL(ms_installed, ("double install"));
|
||||
ms_installed = true;
|
||||
|
||||
DebugFlags::registerFlag(ms_debugReport, "SharedObject/AppearanceTemplateList", "debugReport", debugReport);
|
||||
DebugFlags::registerFlag(ms_debugReportTimedTemplates, "SharedObject/AppearanceTemplateList", "reportTimedTemplates", debugReportTimedTemplates);
|
||||
DebugFlags::registerFlag(ms_debugReportVerbose, "SharedObject/AppearanceTemplateList", "debugReportVerbose", debugReportVerbose);
|
||||
DebugFlags::registerFlag(ms_useTimedTemplates, "SharedObject/AppearanceTemplateList", "useTimedTemplates");
|
||||
DebugFlags::registerFlag(ms_logCreate, "SharedObject/AppearanceTemplateList", "logCreate");
|
||||
DebugFlags::registerFlag(ms_logFetch, "SharedObject/AppearanceTemplateList", "logFetch");
|
||||
|
||||
ms_useTimedTemplates = useTimedTemplates;
|
||||
ms_keepTime = ConfigSharedObject::getAppearanceTemplateListKeepTime();
|
||||
ms_keepEpsilon = ConfigSharedObject::getAppearanceTemplateListKeepEpsilon();
|
||||
|
||||
//-- verify the default appearance exists
|
||||
if (ensureDefaultAppearanceExists)
|
||||
FATAL(!TreeFile::exists(getDefaultAppearanceTemplateName()), ("%s could not be found. Are your paths set up correctly?", getDefaultAppearanceTemplateName()));
|
||||
|
||||
if (TreeFile::isLoggingFiles())
|
||||
delete TreeFile::open(getDefaultAppearanceTemplateName(), AbstractFile::PriorityData, true);
|
||||
|
||||
ExitChain::add(AppearanceTemplateListNamespace::remove, "AppearanceTemplateList::remove", 0, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Assign a binding between a Tag and a CreateFunction.
|
||||
*
|
||||
* If a previous binding for the specified tag exists, it will be replaced
|
||||
* by the new binding.
|
||||
*
|
||||
* @param tag Tag for the binding
|
||||
* @param createFunction Create function to call for data files with the tag
|
||||
*/
|
||||
|
||||
void AppearanceTemplateList::assignBinding(const Tag tag, const CreateFunction createFunction)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
NOT_NULL(createFunction);
|
||||
|
||||
#ifdef _DEBUG
|
||||
char tagString[5];
|
||||
ConvertTagToString(tag, tagString);
|
||||
DEBUG_REPORT_LOG_PRINT(ms_debugReport, ("Added AppearanceTemplateList binding %s\n", tagString));
|
||||
#endif
|
||||
|
||||
ms_tagBindingMap[tag] = createFunction;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Remove a binding from the AppearanceTemplateList.
|
||||
*
|
||||
* If the specified Tag is not bound, the routine will return without
|
||||
* error.
|
||||
*
|
||||
* @param tag Tag for the binding to remove
|
||||
*/
|
||||
|
||||
void AppearanceTemplateList::removeBinding(const Tag tag)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
|
||||
IGNORE_RETURN(ms_tagBindingMap.erase(tag));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplateList::update(const float elapsedTime)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
|
||||
//-- walk the timed appearance template list and tick down
|
||||
NamedTimedTemplates::iterator iter = ms_namedTimedTemplates.begin();
|
||||
NamedTimedTemplates::iterator end = ms_namedTimedTemplates.end();
|
||||
|
||||
while (iter != end)
|
||||
{
|
||||
//-- see if the appearance template has expired
|
||||
iter->second.first -= elapsedTime;
|
||||
if (iter->second.first <= 0.f)
|
||||
{
|
||||
DEBUG_REPORT_LOG(ms_logCreate, ("Destroying timed appearance %s\n", iter->first->getString()));
|
||||
delete const_cast<AppearanceTemplate *>(iter->second.second);
|
||||
|
||||
ms_namedTimedTemplates.erase(iter++);
|
||||
end = ms_namedTimedTemplates.end();
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplateList::setAllowTimedTemplates(const bool allowTimedTemplates)
|
||||
{
|
||||
ms_allowTimedTemplates = allowTimedTemplates;
|
||||
|
||||
if (!ms_allowTimedTemplates)
|
||||
update(ms_keepTime + ms_keepEpsilon);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const AppearanceTemplate *AppearanceTemplateList::fetch(const char *const fileName)
|
||||
{
|
||||
bool found = false;
|
||||
return fetch(fileName, found);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
const AppearanceTemplate *AppearanceTemplateList::fetch(const char *const fileName, bool & found)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
NOT_NULL(fileName);
|
||||
|
||||
DEBUG_REPORT_LOG(ms_logFetch, ("[fetch] AppearanceTemplateList::fetch: %s\n", fileName));
|
||||
|
||||
found = false;
|
||||
char const * actualFileName = fileName;
|
||||
if (!fileName)
|
||||
{
|
||||
DEBUG_WARNING(true, ("AppearanceTemplateList::fetch passed NULL fileName, using default"));
|
||||
actualFileName = getDefaultAppearanceTemplateName();
|
||||
}
|
||||
else if (!*fileName)
|
||||
{
|
||||
DEBUG_WARNING(true, ("AppearanceTemplateList::fetch passed empty fileName, using default"));
|
||||
actualFileName = getDefaultAppearanceTemplateName();
|
||||
}
|
||||
else if (!TreeFile::exists(fileName))
|
||||
{
|
||||
DEBUG_WARNING(true, ("AppearanceTemplateList::fetch could not open '%s', using default", fileName));
|
||||
actualFileName = getDefaultAppearanceTemplateName();
|
||||
}
|
||||
else
|
||||
found = true;
|
||||
|
||||
//-- search for the appearance
|
||||
AppearanceTemplate *const appearanceTemplate = create(actualFileName);
|
||||
|
||||
//-- up the reference count
|
||||
return fetch(appearanceTemplate);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Add a reference to the specified Appearance.
|
||||
*
|
||||
* This routine will do nothing if passed in NULL. Otherwise, it will
|
||||
* increase the reference count of the specified AppearanceTemplate
|
||||
* by one.
|
||||
*
|
||||
* @param appearanceTemplate AppearanceTemplate to remove the reference count from
|
||||
* @return The AppearanceTemplate that was passed into the routine.
|
||||
* @see AppearanceTemplateList::release()
|
||||
*/
|
||||
|
||||
const AppearanceTemplate *AppearanceTemplateList::fetch(const AppearanceTemplate *const appearanceTemplate)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
if (appearanceTemplate)
|
||||
IGNORE_RETURN(appearanceTemplate->incrementReference());
|
||||
|
||||
return appearanceTemplate;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Fetch an AppearanceTemplate from an Iff.
|
||||
*
|
||||
* This routine will increment the reference count of the AppearanceTemplate
|
||||
* by one.
|
||||
*
|
||||
* @param iff File from which to load the AppearanceTemplate
|
||||
*/
|
||||
|
||||
const AppearanceTemplate *AppearanceTemplateList::fetch(Iff *const iff)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
NOT_NULL(iff);
|
||||
|
||||
const Tag tag = iff->getCurrentName();
|
||||
|
||||
TagBindingMap::iterator iter = ms_tagBindingMap.find(tag);
|
||||
if (iter == ms_tagBindingMap.end())
|
||||
{
|
||||
char tagString[5];
|
||||
ConvertTagToString(tag, tagString);
|
||||
DEBUG_FATAL(true, ("AppearanceTemplate binding %s not found", tagString));
|
||||
return 0; //lint !e527 // unreachable
|
||||
}
|
||||
|
||||
AppearanceTemplate *const appearanceTemplate = (*iter).second(NULL, iff);
|
||||
NOT_NULL(appearanceTemplate);
|
||||
|
||||
addAnonymousAppearanceTemplate(appearanceTemplate);
|
||||
|
||||
//-- up the reference count
|
||||
return fetch(appearanceTemplate);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Fetch an AppearanceTemplate from an existing object and add the object
|
||||
* to the AppearanceTemplateList.
|
||||
*
|
||||
* The AppearanceTemplate object is assumed to be created outside the
|
||||
* AppearanceTemplateList fetch-from-file or fetch-from-iff mechanism.
|
||||
* This may happen within an editor that creates an AppearanceTemplate
|
||||
* object from scratch. In this case, the object is created outside
|
||||
* the AppearanceTemplateList and must be added to the list. Use this
|
||||
* function to do so. Failure to add the object to this
|
||||
* list likely will cause failures when an Appearance making use of the
|
||||
* AppearanceTemplate object gets released.
|
||||
*
|
||||
* @param appearanceTemplate the AppearanceTemplate object to add to the AppearanceTemplateList
|
||||
*
|
||||
* @return the AppearanceTemplate object, returned just like all the other fetch routines
|
||||
*/
|
||||
|
||||
const AppearanceTemplate *AppearanceTemplateList::fetchNew(AppearanceTemplate *const appearanceTemplate)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
NOT_NULL(appearanceTemplate);
|
||||
|
||||
const CrcLowerString &crcName = appearanceTemplate->getCrcName();
|
||||
const char *const crcString = crcName.getString();
|
||||
if (crcString && *crcString)
|
||||
{
|
||||
//-- we've got a named appearance template list
|
||||
addNamedAppearanceTemplate(appearanceTemplate);
|
||||
}
|
||||
else
|
||||
{
|
||||
//-- we've got an anonymous appearance template list
|
||||
addAnonymousAppearanceTemplate(appearanceTemplate);
|
||||
}
|
||||
|
||||
//-- up the reference count
|
||||
return fetch(appearanceTemplate);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Remove a reference to the specified AppearanceTemplate.
|
||||
*
|
||||
* This routine will do nothing if passed in NULL.
|
||||
*
|
||||
* If the reference count drops to 0, the AppearanceTemplate will be deleted.
|
||||
*
|
||||
* @param appearanceTemplate AppearanceTemplate to remove the reference count from
|
||||
* @see AppearanceTemplateList::release()
|
||||
*/
|
||||
|
||||
void AppearanceTemplateList::release(const AppearanceTemplate *const appearanceTemplate)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
if (appearanceTemplate && appearanceTemplate->decrementReference() <= 0)
|
||||
{
|
||||
DEBUG_FATAL(appearanceTemplate->getReferenceCount() < 0, ("referenceCount is negative"));
|
||||
|
||||
AppearanceTemplate *const nonConstAppearanceTemplate = const_cast<AppearanceTemplate *>(appearanceTemplate);
|
||||
|
||||
//-- remove from list
|
||||
removeAppearanceTemplate(nonConstAppearanceTemplate);
|
||||
CrcLowerString const & crcName = appearanceTemplate->getCrcName();
|
||||
char const * const crcString = crcName.getString();
|
||||
|
||||
//-- add it to the timed template list
|
||||
if (ms_useTimedTemplates && ms_allowTimedTemplates && crcString && *crcString)
|
||||
{
|
||||
DEBUG_REPORT_LOG(ms_logCreate, ("Adding timed appearance %s\n", appearanceTemplate->getName()));
|
||||
addNamedTimedAppearanceTemplate(nonConstAppearanceTemplate);
|
||||
}
|
||||
else
|
||||
delete nonConstAppearanceTemplate;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Create an Appearance for the specified AppearanceTemplate.
|
||||
*
|
||||
* @param fileName Name of the AppearanceTemplate
|
||||
* @return An appearance for the specified AppearanceTemplate
|
||||
*/
|
||||
|
||||
Appearance *AppearanceTemplateList::createAppearance(const char *const fileName)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
|
||||
#ifdef _DEBUG
|
||||
DataLint::pushAsset(fileName);
|
||||
#endif
|
||||
|
||||
//-- get the appearance template
|
||||
const AppearanceTemplate *const appearanceTemplate = fetch(fileName);
|
||||
|
||||
//-- creating the appearance will increment the reference count
|
||||
Appearance *const appearance = appearanceTemplate->createAppearance();
|
||||
|
||||
#ifdef _DEBUG
|
||||
DataLint::popAsset();
|
||||
#endif // _DEBUG
|
||||
|
||||
//-- release the appearance template, since the appearance now holds a ref count for it
|
||||
release(appearanceTemplate);
|
||||
|
||||
return appearance;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const char* AppearanceTemplateList::getDefaultAppearanceTemplateName()
|
||||
{
|
||||
return ms_defaultAppearanceTemplateName;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplateList::garbageCollect ()
|
||||
{
|
||||
//-- release the timed (cached) appearance templates
|
||||
if (ms_allowTimedTemplates)
|
||||
{
|
||||
setAllowTimedTemplates (false);
|
||||
setAllowTimedTemplates (true);
|
||||
}
|
||||
|
||||
//-- call garbage collect on all appearance templates
|
||||
{
|
||||
NamedTemplates::iterator end = ms_namedTemplates.end ();
|
||||
NamedTemplates::iterator iter = ms_namedTemplates.begin ();
|
||||
for (; iter != end; ++iter)
|
||||
const_cast<AppearanceTemplate*> (iter->second)->garbageCollect ();
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// STATIC PRIVATE AppearanceTemplateList
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Remove a AppearanceTemplateList.
|
||||
*/
|
||||
void AppearanceTemplateListNamespace::remove()
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
ms_installed = false;
|
||||
|
||||
DebugFlags::unregisterFlag(ms_debugReport);
|
||||
DebugFlags::unregisterFlag(ms_debugReportTimedTemplates);
|
||||
DebugFlags::unregisterFlag(ms_debugReportVerbose);
|
||||
DebugFlags::unregisterFlag(ms_useTimedTemplates);
|
||||
DebugFlags::unregisterFlag(ms_logCreate);
|
||||
DebugFlags::unregisterFlag(ms_logFetch);
|
||||
|
||||
{
|
||||
//-- report if we leaked anonymous appearance templates
|
||||
const size_t entryCount = ms_anonymousTemplates.size();
|
||||
DEBUG_WARNING(entryCount, ("leaked %u anonymous appearance templates", entryCount));
|
||||
UNREF(entryCount);
|
||||
// shouldn't delete because item may depend on items that are memory block managed and already deleted, which could cause a crash
|
||||
}
|
||||
|
||||
{
|
||||
//-- report if we leaked named appearance templates
|
||||
#ifdef _DEBUG
|
||||
const size_t entryCount = ms_namedTemplates.size();
|
||||
DEBUG_WARNING(entryCount, ("leaked %u named appearance templates", entryCount));
|
||||
|
||||
NamedTemplates::iterator end = ms_namedTemplates.end();
|
||||
for (NamedTemplates::iterator it = ms_namedTemplates.begin(); it != end; ++it)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("--leaked [%s]\n", it->second->getCrcName().getString()));
|
||||
// shouldn't delete because item may depend on items that are memory block managed and already deleted, which could cause a crash
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
const size_t entryCount = ms_namedTimedTemplates.size();
|
||||
if (entryCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("%u timed appearance templates remain\n", entryCount));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
DEBUG_REPORT_LOG(ms_debugReport, ("AppearanceTemplateList redirector map:\n"));
|
||||
|
||||
//-- delete the redirector map
|
||||
for (RedirectorMap::iterator iter = ms_redirectorMap.begin(); iter != ms_redirectorMap.end(); ++iter)
|
||||
{
|
||||
DEBUG_REPORT_LOG(ms_debugReport, (" %4i %s -> %s\n", std::distance(ms_redirectorMap.begin(), iter), iter->first->getString(), iter->second->getString()));
|
||||
delete const_cast<CrcString *>(iter->first);
|
||||
delete const_cast<CrcString *>(iter->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AppearanceTemplate *AppearanceTemplateListNamespace::create(const char *const fileName)
|
||||
{
|
||||
NOT_NULL(fileName);
|
||||
|
||||
TemporaryCrcString actualFileName(fileName, true);
|
||||
|
||||
//-- does the filename end in apt?
|
||||
if (strstr(fileName, ".apt") != 0)
|
||||
{
|
||||
//-- is the filename in the redirector map?
|
||||
RedirectorMap::iterator iter = ms_redirectorMap.find((const CrcString*)&actualFileName);
|
||||
if (iter == ms_redirectorMap.end())
|
||||
{
|
||||
//-- extract the real name from the apt
|
||||
Iff iff(fileName);
|
||||
iff.enterForm(TAG_APT);
|
||||
iff.enterForm(TAG_0000);
|
||||
iff.enterChunk(TAG_NAME);
|
||||
|
||||
char redirectedFileName[Os::MAX_PATH_LENGTH];
|
||||
iff.read_string(redirectedFileName, Os::MAX_PATH_LENGTH);
|
||||
|
||||
//-- make sure redirector name is not an apt file
|
||||
FATAL(strstr(redirectedFileName, ".apt") != 0, ("multiple levels of indirection found for appearance template redirector files %s(%s)", fileName, redirectedFileName));
|
||||
|
||||
//-- add it to the redirector map
|
||||
iter = ms_redirectorMap.insert(RedirectorMap::value_type(new PersistentCrcString(actualFileName), new PersistentCrcString(redirectedFileName, true))).first;
|
||||
|
||||
iff.exitChunk(TAG_NAME);
|
||||
iff.exitForm(TAG_0000);
|
||||
iff.exitForm(TAG_APT);
|
||||
}
|
||||
|
||||
//-- create the target name instead
|
||||
return create(iter->second->getString());
|
||||
}
|
||||
|
||||
//-- search for the appearance in the named list
|
||||
{
|
||||
NamedTemplates::iterator iter = ms_namedTemplates.find((const CrcString*)&actualFileName);
|
||||
if (iter != ms_namedTemplates.end())
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
AppearanceTemplate *appearanceTemplate = 0;
|
||||
|
||||
//-- search for the appearance in the named timed list
|
||||
if (ms_useTimedTemplates)
|
||||
{
|
||||
NamedTimedTemplates::iterator iter = ms_namedTimedTemplates.find((const CrcString*)&actualFileName);
|
||||
if (iter != ms_namedTimedTemplates.end())
|
||||
{
|
||||
appearanceTemplate = iter->second.second;
|
||||
ms_namedTimedTemplates.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_REPORT_LOG(ms_logCreate, ("Creating appearance %s\n", actualFileName.getString()));
|
||||
|
||||
//-- hack to asynchronously load .msh files
|
||||
if (!appearanceTemplate && AsynchronousLoader::isEnabled() && (strstr(actualFileName.getString(), ".msh") != 0 || strstr(actualFileName.getString(), ".MSH") != 0))
|
||||
{
|
||||
// DEBUG_REPORT_LOG_PRINT(true, ("Loading mesh %s\n", actualFileName.getString()));
|
||||
TagBindingMap::iterator iter = ms_tagBindingMap.find(TAG_MESH);
|
||||
if (iter != ms_tagBindingMap.end())
|
||||
appearanceTemplate = iter->second(actualFileName.getString(), NULL);
|
||||
}
|
||||
|
||||
//-- we now need to create the appearance from disk
|
||||
if (!appearanceTemplate)
|
||||
{
|
||||
Iff iff;
|
||||
if (!iff.open(actualFileName.getString(), true))
|
||||
FATAL(true, ("Could not open appearance file %s", actualFileName.getString()));
|
||||
|
||||
const Tag tag = iff.getCurrentName();
|
||||
TagBindingMap::iterator iter = ms_tagBindingMap.find(tag);
|
||||
if (iter != ms_tagBindingMap.end())
|
||||
appearanceTemplate = iter->second(actualFileName.getString(), &iff);
|
||||
else
|
||||
{
|
||||
char tagString[5];
|
||||
ConvertTagToString(tag, tagString);
|
||||
DEBUG_FATAL(true, ("AppearanceTemplate binding %s not found", tagString));
|
||||
}
|
||||
}
|
||||
|
||||
//-- add the appearance template to the named list
|
||||
if (appearanceTemplate)
|
||||
{
|
||||
addNamedAppearanceTemplate(appearanceTemplate);
|
||||
}
|
||||
|
||||
return appearanceTemplate;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Add an anonymous appearance template to the AppearanceTemplateList.
|
||||
*
|
||||
* @param appearanceTemplate AppearanceTemplate to add
|
||||
*/
|
||||
|
||||
void AppearanceTemplateListNamespace::addAnonymousAppearanceTemplate(AppearanceTemplate *const appearanceTemplate)
|
||||
{
|
||||
NOT_NULL(appearanceTemplate);
|
||||
|
||||
//-- add to anonymous list
|
||||
std::pair<AnonymousTemplates::iterator, bool> result = ms_anonymousTemplates.insert(appearanceTemplate);
|
||||
|
||||
//-- make sure it's not already there
|
||||
DEBUG_FATAL(!result.second, ("tried to add an existing anonymous appearanceTemplate"));
|
||||
UNREF(result);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Add a named appearance template to the AppearanceTemplateList.
|
||||
*
|
||||
* @param appearanceTemplate AppearanceTemplate to add
|
||||
*/
|
||||
|
||||
void AppearanceTemplateListNamespace::addNamedAppearanceTemplate(AppearanceTemplate *const appearanceTemplate)
|
||||
{
|
||||
NOT_NULL(appearanceTemplate);
|
||||
|
||||
//-- add to named list
|
||||
std::pair<NamedTemplates::iterator, bool> result = ms_namedTemplates.insert(std::make_pair(&appearanceTemplate->getCrcName(), appearanceTemplate));
|
||||
|
||||
//-- make sure it's not already there
|
||||
DEBUG_FATAL(!result.second, ("tried to add existing named appearanceTemplate %s", appearanceTemplate->getName()));
|
||||
UNREF(result);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Add a named timed appearance template to the AppearanceTemplateList.
|
||||
*
|
||||
* @param appearanceTemplate AppearanceTemplate to add
|
||||
*/
|
||||
|
||||
void AppearanceTemplateListNamespace::addNamedTimedAppearanceTemplate(AppearanceTemplate *const appearanceTemplate)
|
||||
{
|
||||
NOT_NULL(appearanceTemplate);
|
||||
|
||||
//-- add to named list
|
||||
std::pair<NamedTimedTemplates::iterator, bool> result = ms_namedTimedTemplates.insert(std::make_pair(&appearanceTemplate->getCrcName(), std::make_pair(ms_keepTime + Random::randomReal(ms_keepEpsilon), appearanceTemplate)));
|
||||
|
||||
//-- make sure it's not already there
|
||||
DEBUG_FATAL(!result.second, ("tried to add existing named timed appearanceTemplate %s", appearanceTemplate->getName()));
|
||||
UNREF(result);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Remove an appearance template from the AppearanceTemplateList.
|
||||
*
|
||||
* @param appearanceTemplate AppearanceTemplate to remove
|
||||
*/
|
||||
|
||||
void AppearanceTemplateListNamespace::removeAppearanceTemplate(AppearanceTemplate *const appearanceTemplate)
|
||||
{
|
||||
NOT_NULL(appearanceTemplate);
|
||||
CrcLowerString const & crcName = appearanceTemplate->getCrcName();
|
||||
char const * const crcString = crcName.getString();
|
||||
|
||||
if (crcString && *crcString)
|
||||
{
|
||||
//-- remove appearance template from the named list
|
||||
NamedTemplates::iterator iter = ms_namedTemplates.find((const CrcString*)&appearanceTemplate->getCrcName());
|
||||
if (iter != ms_namedTemplates.end())
|
||||
ms_namedTemplates.erase(iter);
|
||||
else
|
||||
DEBUG_FATAL(true, ("AppearanceTemplateListNamespace::removeAppearanceTemplate: could not find appearance template %s in named list", crcString));
|
||||
}
|
||||
else
|
||||
{
|
||||
//-- remove appearance template from the anonymous list
|
||||
AnonymousTemplates::iterator iter = ms_anonymousTemplates.find(appearanceTemplate);
|
||||
if (iter != ms_anonymousTemplates.end())
|
||||
ms_anonymousTemplates.erase(iter);
|
||||
else
|
||||
DEBUG_FATAL(true, ("AppearanceTemplateListNamespace::removeAppearanceTemplate: could not find anonymous appearance template in anonymous list"));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplateListNamespace::debugReport()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DEBUG_REPORT_PRINT(true, ("Tags installed = %i\n", ms_tagBindingMap.size()));
|
||||
DEBUG_REPORT_PRINT(true, ("Named templates = %i\n", ms_namedTemplates.size()));
|
||||
DEBUG_REPORT_PRINT(true, ("Named timed templates = %i\n", ms_namedTimedTemplates.size()));
|
||||
DEBUG_REPORT_PRINT(true, ("Anonymous templates = %i\n", ms_anonymousTemplates.size()));
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplateListNamespace::debugReportVerbose()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DEBUG_REPORT_PRINT(true, ("AppearanceTemplates loaded:\n"));
|
||||
|
||||
DEBUG_OUTPUT_STATIC_VIEW_BEGINFRAME("Engine\\AppearanceTemplateList");
|
||||
DEBUG_OUTPUT_STATIC_VIEW("Engine\\AppearanceTemplateList", ("AppearanceTemplates loaded:\n"));
|
||||
|
||||
for (NamedTemplates::iterator iter = ms_namedTemplates.begin(); iter != ms_namedTemplates.end(); ++iter)
|
||||
{
|
||||
const AppearanceTemplate *const t = (*iter).second;
|
||||
DEBUG_REPORT_PRINT(true, (" %s %d\n", t->getCrcName().getString(), t->getReferenceCount()));
|
||||
DEBUG_OUTPUT_STATIC_VIEW("Engine\\AppearanceTemplateList", (" %s %d\n", t->getCrcName().getString(), t->getReferenceCount()));
|
||||
UNREF(t);
|
||||
}
|
||||
|
||||
DEBUG_OUTPUT_STATIC_VIEW_ENDFRAME("Engine\\AppearanceTemplateList");
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AppearanceTemplateListNamespace::debugReportTimedTemplates()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
for (NamedTimedTemplates::iterator iter = ms_namedTimedTemplates.begin(); iter != ms_namedTimedTemplates.end(); ++iter)
|
||||
DEBUG_REPORT_PRINT(true, ("% 2.1f %s\n", iter->second.first, iter->first->getString()));
|
||||
#endif
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,62 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AppearanceTemplateList.h
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2000-2002 Sony Online Entertainment
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_AppearanceTemplateList_H
|
||||
#define INCLUDED_AppearanceTemplateList_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/Tag.h"
|
||||
|
||||
class Appearance;
|
||||
class AppearanceTemplate;
|
||||
class Iff;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class AppearanceTemplateList
|
||||
{
|
||||
public:
|
||||
|
||||
typedef AppearanceTemplate *(*CreateFunction)(const char *name, Iff *iff);
|
||||
|
||||
public:
|
||||
|
||||
static void install(bool useTimedTemplates, bool ensureDefaultAppearanceExists);
|
||||
|
||||
static void assignBinding(Tag tag, CreateFunction createFunction);
|
||||
static void removeBinding(Tag tag);
|
||||
|
||||
static void update(float elapsedTime);
|
||||
static void setAllowTimedTemplates (bool allowTimedTemplates);
|
||||
|
||||
static const AppearanceTemplate *fetch(const char *fileName);
|
||||
static const AppearanceTemplate *fetch(const char *fileName, bool & found);
|
||||
static const AppearanceTemplate *fetch(Iff *iff);
|
||||
static const AppearanceTemplate *fetch(const AppearanceTemplate *appearanceTemplate);
|
||||
static const AppearanceTemplate *fetchNew(AppearanceTemplate *appearanceTemplate);
|
||||
static void release(const AppearanceTemplate *appearanceTemplate);
|
||||
|
||||
static Appearance *createAppearance(const char *fileName);
|
||||
|
||||
static const char* getDefaultAppearanceTemplateName();
|
||||
|
||||
static void garbageCollect ();
|
||||
|
||||
private:
|
||||
|
||||
// disabled
|
||||
AppearanceTemplateList();
|
||||
AppearanceTemplateList(const AppearanceTemplateList &);
|
||||
AppearanceTemplateList &operator =(const AppearanceTemplateList &);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Hardpoint.cpp
|
||||
// Copyright 2000 - 2002 Sony Online Entertainment, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/Hardpoint.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
Hardpoint::Hardpoint (const char* newName, const Transform& newTransform) :
|
||||
m_name (newName, false),
|
||||
m_transform (newTransform)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
CrcString const& Hardpoint::getName () const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Transform const& Hardpoint::getTransform () const
|
||||
{
|
||||
return m_transform;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,91 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// HardPoint.h
|
||||
// Copyright 2000 - 2002 Sony Online Entertainment, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_Hardpoint_H
|
||||
#define INCLUDED_Hardpoint_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/PersistentCrcString.h"
|
||||
#include "sharedMath/Transform.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class Hardpoint
|
||||
{
|
||||
public:
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
struct LessNameComparator
|
||||
{
|
||||
bool operator () (Hardpoint const* lhs, Hardpoint const* rhs) const;
|
||||
bool operator () (CrcString const& lhs, Hardpoint const* rhs) const;
|
||||
bool operator () (Hardpoint const* lhs, CrcString const& rhs) const;
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
typedef const Hardpoint* ConstIterator;
|
||||
|
||||
public:
|
||||
|
||||
Hardpoint (const char* newName, const Transform& newTransform);
|
||||
|
||||
CrcString const& getName () const;
|
||||
Transform const& getTransform () const;
|
||||
|
||||
private:
|
||||
|
||||
// Disabled.
|
||||
Hardpoint (void);
|
||||
Hardpoint (const Hardpoint&);
|
||||
Hardpoint& operator= (const Hardpoint&);
|
||||
|
||||
private:
|
||||
|
||||
PersistentCrcString const m_name;
|
||||
Transform const m_transform;
|
||||
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
// struct LessNameComparator
|
||||
// ======================================================================
|
||||
|
||||
// Define these comparator functions inline so that STL sorts/searches are inlined.
|
||||
|
||||
inline bool Hardpoint::LessNameComparator::operator () (Hardpoint const* lhs, Hardpoint const* rhs) const
|
||||
{
|
||||
NOT_NULL (lhs);
|
||||
NOT_NULL (rhs);
|
||||
|
||||
return lhs->getName () < rhs->getName ();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool Hardpoint::LessNameComparator::operator () (CrcString const& lhs, Hardpoint const* rhs) const
|
||||
{
|
||||
NOT_NULL (rhs);
|
||||
|
||||
return lhs < rhs->getName ();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool Hardpoint::LessNameComparator::operator () (Hardpoint const* lhs, CrcString const& rhs) const
|
||||
{
|
||||
NOT_NULL (lhs);
|
||||
|
||||
return lhs->getName () < rhs;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// NoRenderAppearance.cpp
|
||||
// Portions copyright 2004 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/NoRenderAppearance.h"
|
||||
|
||||
#include "sharedObject/NoRenderAppearanceTemplate.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
NoRenderAppearance::NoRenderAppearance(NoRenderAppearanceTemplate const * myAppearanceTemplate)
|
||||
: Appearance(myAppearanceTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,38 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// NoRenderAppearance.h
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2001, 2002 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_NoRenderAppearance_H
|
||||
#define INCLUDED_NoRenderAppearance_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class NoRenderAppearanceTemplate;
|
||||
|
||||
#include "sharedObject/Appearance.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class NoRenderAppearance : public Appearance
|
||||
{
|
||||
friend class NoRenderAppearanceTemplate;
|
||||
|
||||
private:
|
||||
|
||||
NoRenderAppearance(NoRenderAppearanceTemplate const * appearanceTemplate);
|
||||
|
||||
private:
|
||||
// disabled
|
||||
NoRenderAppearance();
|
||||
NoRenderAppearance(NoRenderAppearance const &);
|
||||
NoRenderAppearance & operator = (NoRenderAppearance const &);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// NoRenderAppearanceTemplate.cpp
|
||||
// Portions copyright 2004 Sony Online Entertainment
|
||||
// All Rights Reserved
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/NoRenderAppearanceTemplate.h"
|
||||
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedFoundation/Tag.h"
|
||||
#include "sharedObject/AppearanceTemplateList.h"
|
||||
#include "sharedObject/NoRenderAppearance.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace NoRenderAppearanceTemplateNamespace
|
||||
{
|
||||
const Tag TAG_NRND = TAG(N,R,N,D);
|
||||
|
||||
AppearanceTemplate *create(const char *newName, Iff *iff);
|
||||
};
|
||||
using namespace NoRenderAppearanceTemplateNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void NoRenderAppearanceTemplate::install()
|
||||
{
|
||||
AppearanceTemplateList::assignBinding(TAG_NRND, NoRenderAppearanceTemplateNamespace::create);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AppearanceTemplate *NoRenderAppearanceTemplateNamespace::create(const char *newName, Iff *iff)
|
||||
{
|
||||
return new NoRenderAppearanceTemplate(newName, iff);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
NoRenderAppearanceTemplate::NoRenderAppearanceTemplate(const char *name, Iff *iff)
|
||||
: AppearanceTemplate(name)
|
||||
{
|
||||
iff->enterForm(TAG_NRND);
|
||||
iff->exitForm(TAG_NRND);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
NoRenderAppearanceTemplate::~NoRenderAppearanceTemplate()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Appearance * NoRenderAppearanceTemplate::createAppearance() const
|
||||
{
|
||||
return new NoRenderAppearance(this);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,40 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// NoRenderAppearanceTemplate.h
|
||||
// Portions copyright 2004 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_NoRenderAppearanceTemplate_H
|
||||
#define INCLUDED_NoRenderAppearanceTemplate_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/AppearanceTemplate.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class NoRenderAppearanceTemplate : public AppearanceTemplate
|
||||
{
|
||||
public:
|
||||
|
||||
static void install();
|
||||
|
||||
public:
|
||||
|
||||
NoRenderAppearanceTemplate(const char *name, Iff *iff);
|
||||
virtual ~NoRenderAppearanceTemplate();
|
||||
|
||||
virtual Appearance * createAppearance() const;
|
||||
|
||||
private:
|
||||
|
||||
NoRenderAppearanceTemplate();
|
||||
NoRenderAppearanceTemplate(NoRenderAppearanceTemplate const &);
|
||||
NoRenderAppearanceTemplate & operator = (NoRenderAppearanceTemplate const &);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TextAppearance.cpp
|
||||
// Copyright 2001, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/TextAppearance.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TextAppearance::TextAppearance () :
|
||||
Appearance (0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TextAppearance::~TextAppearance ()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,38 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// TextAppearance.h
|
||||
// Copyright 2001, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_TextAppearance_H
|
||||
#define INCLUDED_TextAppearance_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/Appearance.h"
|
||||
|
||||
class VectorArgb;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class TextAppearance : public Appearance
|
||||
{
|
||||
public:
|
||||
|
||||
TextAppearance ();
|
||||
virtual ~TextAppearance ()=0;
|
||||
|
||||
virtual void setText(const char* text)=0;
|
||||
virtual void setColor(const VectorArgb& color)=0;
|
||||
|
||||
private:
|
||||
|
||||
TextAppearance (const TextAppearance& rhs);
|
||||
TextAppearance& operator= (const TextAppearance& rhs);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Tweakable.cpp
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2001 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedObject/FirstSharedObject.h"
|
||||
#include "sharedObject/Tweakable.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
Tweakable::~Tweakable()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
float Tweakable::getTweakValue ( int whichValue ) const
|
||||
{
|
||||
UNREF(whichValue);
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Tweakable::setTweakValue ( int whichValue, float newValue )
|
||||
{
|
||||
UNREF(whichValue);
|
||||
UNREF(newValue);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,40 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Tweakable.h
|
||||
// Portions copyright 1999 Bootprint Entertainment
|
||||
// Portions copyright 2001, 2002 Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_Tweakable_H
|
||||
#define INCLUDED_Tweakable_H
|
||||
|
||||
// ======================================================================
|
||||
// Simple interface for setting/getting tweak values on objects.
|
||||
|
||||
class Tweakable
|
||||
{
|
||||
public:
|
||||
|
||||
Tweakable();
|
||||
virtual ~Tweakable();
|
||||
|
||||
virtual float getTweakValue ( int whichValue ) const;
|
||||
virtual void setTweakValue ( int whichValue, float newValue );
|
||||
|
||||
private:
|
||||
|
||||
Tweakable(const Tweakable &);
|
||||
Tweakable &operator =(const Tweakable &);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
inline Tweakable::Tweakable()
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user