summaryrefslogtreecommitdiffstats
path: root/tools/statepropbuilder/apps/spbuilder/code/sp/engine/stateprop.hpp
blob: c72b76b108d739cee3f825ba68ebcb978e65bf8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef _STATEPROP_HPP_
#define _STATEPROP_HPP_

#include "radmath/radmath.hpp"

//=============================================================================
// Forward Class/Struct Declarations
//=============================================================================

class tFrameController;
class tAnimatedObject;
class CStatePropData;
class CStateProp;
class tCompositeDrawable;


//=============================================================================
// Class Declarations
// PropListener
//=============================================================================

class CStatePropListener : public tRefCounted
{
public:
	virtual void RecieveEvent( int event , CStateProp* stateProp ) = 0;
};

//=============================================================================
// Definitions
//=============================================================================


//=============================================================================
// Class Declarations
// CStateProp
//=============================================================================
class CStateProp : public tEntity
{
public:
    
    static CStateProp* CreateCStateProp( CStatePropData* statePropData , unsigned int state );

    CStateProp( tAnimatedObject* animatedObject , CStatePropData* statePropData , unsigned int state = 0 );
    ~CStateProp();

    //Per frame update
    void Update( float dt );

    //Render
    void Render();

    //call before render
    void UpdateFrameControllersForRender();

    unsigned int GetState();
    void SetState( unsigned int state );
    void NextState();
    void PrevState();

	void OnEvent( unsigned int eventID );

    void SetTransformationMatrix( const rmt::Matrix &tm);
    const rmt::Matrix& GetTransformationMatrix() const;
    
    void SetPosition( const rmt::Vector& pos );
    const rmt::Vector& GetPosition() const;

    //Get State Prop Data
	CStatePropData* GetCStatePropData();

    // Update for new data
	void UpdateOnDataEdit();

    //accessors
	float GetBaseFrameControllerFrame();
    unsigned int GetNumberOfFrameControllers();
    tFrameController* GetFrameControllerByIndex( unsigned int i );
    unsigned int GetNumberOfDrawableElements();
    tCompositeDrawable::DrawableElement* GetDrawableElement( unsigned int i );
    const char* GetDrawableName( unsigned int i );
    const char* GetPropName();

    //Export the SmartPropData
    void ExportChunk( const char* filename );


private:
   
	// Orientation and location
	rmt::Matrix     m_Transform;
	
	//Private members
    CStatePropData* m_StatePropData;
	tAnimatedObject* m_AnimatedObject;
	tFrameController* m_BaseFrameController;    
    unsigned int m_CurrentState;
    
    CStatePropListener* m_StatePropListener;
};


inline void CStateProp::SetPosition( const rmt::Vector& pos )
{
    m_Transform.FillTranslate( pos );
}
inline const rmt::Vector& CStateProp::GetPosition() const 
{
    return const_cast< RadicalMathLibrary::Matrix & >( m_Transform ).Row(3);
}

inline void CStateProp::SetTransformationMatrix(const rmt::Matrix& tmx)
{
    m_Transform = tmx;
}
inline const rmt::Matrix& CStateProp::GetTransformationMatrix() const
{
    return m_Transform;
}

#endif //_STATEPROP_HPP_