diff options
Diffstat (limited to 'tools/statepropbuilder/inc')
3 files changed, 230 insertions, 0 deletions
diff --git a/tools/statepropbuilder/inc/stateprop/stateprop.hpp b/tools/statepropbuilder/inc/stateprop/stateprop.hpp new file mode 100644 index 0000000..4c0c766 --- /dev/null +++ b/tools/statepropbuilder/inc/stateprop/stateprop.hpp @@ -0,0 +1,86 @@ +#ifndef _STATEPROP_HPP_ +#define _STATEPROP_HPP_ + +#include <radmath/radmath.hpp> + +#include <p3d/anim/compositedrawable.hpp> + +//============================================================================= +// Forward Class/Struct Declarations +//============================================================================= + +class tFrameController; +class tAnimatedObject; +class CStatePropData; +class CStateProp; + + +//============================================================================= +// Class Declarations +// PropListener +//============================================================================= + +class CStatePropListener +{ +public: + virtual void RecieveEvent( int callback , CStateProp* stateProp ) = 0; +}; + +//============================================================================= +// Definitions +//============================================================================= +#define MAX_LISTENERS 10 + +const int STATEPROP_CHANGE_STATE_EVENT = -1; + +//============================================================================= +// Class Declarations +// CStateProp +//============================================================================= +class CStateProp : public tEntity +{ +public: + + //Static function to create a new CStateProp instance + static CStateProp* CreateStateProp( CStatePropData* statePropData , unsigned int state = 0 ); + + CStateProp( tAnimatedObject* animatedObject , CStatePropData* statePropData , unsigned int state = 0 ); + ~CStateProp(); + + //Per frame update + void Update( float dt ); + + //call before render + void UpdateFrameControllersForRender(); + + unsigned int GetState(); + void SetState( unsigned int state ); + void NextState(); + void PrevState(); + + void OnEvent( unsigned int eventID ); + + void AddStatePropListener( CStatePropListener* statePropListener ); + void RemoveStatePropListener( CStatePropListener* statePropListener ); + + tDrawable* GetDrawable(); + +private: + + //accessor helpers + unsigned int GetNumberOfFrameControllers(); + tFrameController* GetFrameControllerByIndex( unsigned int i ); + unsigned int GetNumberOfDrawableElements(); + tCompositeDrawable::DrawableElement* GetDrawableElement( unsigned int i ); + + //Private members + CStatePropData* m_StatePropData; + tAnimatedObject* m_AnimatedObject; + tFrameController* m_BaseFrameController; + unsigned int m_CurrentState; + + unsigned int m_NumStatePropListeners; + CStatePropListener* m_StatePropListener[MAX_LISTENERS]; +}; + +#endif //_STATEPROP_HPP_
\ No newline at end of file diff --git a/tools/statepropbuilder/inc/stateprop/statepropdata.hpp b/tools/statepropbuilder/inc/stateprop/statepropdata.hpp new file mode 100644 index 0000000..b454f34 --- /dev/null +++ b/tools/statepropbuilder/inc/stateprop/statepropdata.hpp @@ -0,0 +1,99 @@ +#ifndef _STATEPROPDATA_HPP_ +#define _STATEPROPDATA_HPP_ + + +#include <radmath/radmath.hpp> +#include <p3d/loadmanager.hpp> + +#include "stateprop/statepropdatatypes.hpp" + +//============================================================================= +// Forward Class/Struct Declarations +//============================================================================= + +class CStateProp; +class tAnimatedObjectFactory; +class CStatePropDataLoader; + +//============================================================================= +// Definitions +//============================================================================= + +//State data +struct StateData +{ + TransitionData transitionData; + VisibilityData* visibilityData; + FrameControllerData* frameControllerData; + EventData* eventData; + CallbackData* callbackData; + + unsigned int numEvents; + unsigned int numCallbacks; +}; + +//============================================================================= +// Class Declarations +// Prop +//============================================================================= + +class CStatePropData : public tEntity +{ + +public: + + friend class CStatePropDataLoader; + + CStatePropData(); + ~CStatePropData(); + + // State Data ===================================================================================== + unsigned int GetNumberOfStates(); + StateData GetStateData( unsigned int state ); + + //Transition Data ================================================================================== + TransitionData GetTransitionData( int state ); + + //Visibility Data ================================================================================== + VisibilityData GetVisibilityData( int state , int index); + + //Frame Controller Data ============================================================================= + FrameControllerData GetFrameControllerData( int state, int fc ); + + //Event Data ======================================================================================== + unsigned int GetNumberOfEvents( int state ); + EventData GetEventData( int state , int eventindex ); + + //Callback Data ====================================================================================== + unsigned int GetNumberOfCallbacks( int state ); + CallbackData GetCallbackData( int state , int eventindex ); + + tAnimatedObjectFactory* GetAnimatedObjectFactory() { return m_ObjectFactory; } + +private: + + //animated object factory + char m_FactoryName[64]; + tAnimatedObjectFactory* m_ObjectFactory; + + //total number of states + unsigned int m_NumStates; + StateData** m_StateData; +}; + + +//============================================================================= +// Class Declarations +// PropLoader +//============================================================================= +class CStatePropDataLoader : public tSimpleChunkHandler +{ +public: + CStatePropDataLoader(); + tEntity* LoadObject(tChunkFile* file, tEntityStore* store); + +protected: + ~CStatePropDataLoader() {}; +}; + +#endif //_STATEPROPDATA_HPP_ diff --git a/tools/statepropbuilder/inc/stateprop/statepropdatatypes.hpp b/tools/statepropbuilder/inc/stateprop/statepropdatatypes.hpp new file mode 100644 index 0000000..4d035af --- /dev/null +++ b/tools/statepropbuilder/inc/stateprop/statepropdatatypes.hpp @@ -0,0 +1,45 @@ +#ifndef _STATEPROPDATATYPES_HPP_ +#define _STATEPROPDATATYPES_HPP_ + +//Transition data +struct TransitionData +{ + unsigned int autoTransition; + unsigned int toState; + float onFrame; +}; + +//Visibility data +struct VisibilityData +{ + unsigned int isVisible; +}; + +//Frame controller data +struct FrameControllerData +{ + unsigned int isCyclic; + unsigned int numberOfCycles; + unsigned int holdFrame; + float minFrame; + float maxFrame; + float relativeSpeed; +}; + +//Event data +struct EventData +{ + char eventName[64]; + unsigned int eventID; + unsigned int toState; +}; + +//Callback data +struct CallbackData +{ + char callbackName[64]; + unsigned int callbackID; + float onFrame; +}; + +#endif //_STATEPROPDATATYPES_HPP_ |