summaryrefslogtreecommitdiff
path: root/hammer/mapanimator.h
blob: 130f0b6aa708650fb64d98bd22b6ec74afe20f81 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef MAPANIMATOR_H
#define MAPANIMATOR_H
#pragma once


#include "MapClass.h"
#include "MapKeyFrame.h"


class CMapAnimator : public CMapKeyFrame
{
public:

	DECLARE_MAPCLASS( CMapAnimator, CMapKeyFrame );

	//
	// Factories.
	//
	static CMapClass *CreateMapAnimator(CHelperInfo *pHelperInfo, CMapEntity *pParent);

	//
	// Construction/destruction.
	//
	CMapAnimator();
	~CMapAnimator();

	virtual size_t GetSize( void ) { return sizeof(*this); }
	virtual CMapClass *Copy(bool bUpdateDependencies);
	virtual CMapClass *CopyFrom(CMapClass *pFrom, bool bUpdateDependencies);

	virtual void UpdateAnimation( float animTime );
	virtual void OnClone( CMapClass *pClone, CMapWorld *pWorld, const CMapObjectList &OriginalList, CMapObjectList &NewList );
	virtual bool GetTransformMatrix( VMatrix& matrix );
	virtual void OnParentKeyChanged( const char* key, const char* value );
	virtual CMapAnimator *GetAnimator(void) { return this; }
	void RebuildPath( void );

	float GetKeyFramesAtTime( float time, CMapKeyFrame *&pKeyFrame, CMapKeyFrame *&pPrevKeyFrame );
	CMapEntity *CreateNewKeyFrame( float time );
	void GetAnimationAtTime( float animTime, Vector& newOrigin, Quaternion &newAngles );
	static void GetAnimationAtTime( CMapKeyFrame *currentKey, CMapKeyFrame *pPrevKey, float animTime, Vector& newOrigin, Quaternion &newAngles, int posInterpolator, int rotInterpolator );

	int GetNumKeysChanged() {return m_nKeysChanged;}

private:
	// Used by the keys to detect when changes need to be sent to the position interpolators.
	int			m_nKeysChanged;
	
	VMatrix m_CoordFrame;
	bool m_bCurrentlyAnimating;
	CMapKeyFrame *m_pCurrentKeyFrame;	// keyframe it's currently at

	int m_iTimeModifier;
	int m_iPositionInterpolator;
	int m_iRotationInterpolator;

	friend CMapKeyFrame;
};


#endif // MAPANIMATOR_H