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

#ifndef MAPKEYFRAME_H
#define MAPKEYFRAME_H
#pragma once


#include "MapHelper.h"
#include "hammer_mathlib.h"
#include "keyframe/keyframe.h"


class CMapAnimator;
class CHelperInfo;


class CMapKeyFrame : public CMapHelper
{
public:

	DECLARE_MAPCLASS(CMapKeyFrame,CMapHelper);

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

	//
	// Construction/destruction.
	//
	CMapKeyFrame(void);
	~CMapKeyFrame(void);

	void CalcBounds(BOOL bFullUpdate = FALSE);

	virtual size_t GetSize( void ) { return sizeof(*this); }
	void Render3D(CRender3D *pRender);
	virtual CMapClass *Copy(bool bUpdateDependencies);
	virtual CMapClass *CopyFrom(CMapClass *pFrom, bool bUpdateDependencies);
	virtual void SetOrigin( Vector& pfOrigin );
	virtual void GetQuatAngles( Quaternion &outQuat );

	virtual void OnClone( CMapClass *pClone, CMapWorld *pWorld, const CMapObjectList &OriginalList, CMapObjectList &NewList );
	virtual void OnNotifyDependent(CMapClass *pObject, Notify_Dependent_t eNotifyType);
	virtual void OnParentKeyChanged( const char* key, const char* value );
	virtual void OnRemoveFromWorld( CMapWorld *pWorld, bool bNotifyChildren );

	virtual void UpdateDependencies(CMapWorld *pWorld, CMapClass *pObject);

	bool IsAnyKeyInSequenceSelected( void );

	CMapKeyFrame *NextKeyFrame( void );

	void SetAnimator(CMapAnimator *pAnimator);
	virtual CMapAnimator *GetAnimator(void) { return m_pAnimator; }

	CMapEntity *GetParentEntity( void );

	float GetRemainingTime( CMapObjectList *pVisited = NULL );
	float MoveTime( void ) { return m_flMoveTime; }

	IPositionInterpolator*	SetupPositionInterpolator( int iInterpolator );

protected:

	void SetNextKeyFrame( CMapKeyFrame *pNext );
	void RecalculateTimeFromSpeed( void );
	void CheckForKeyFrameNextKeyLoops( void );
	void BuildPathSegment( CMapKeyFrame *pPrev );

	IPositionInterpolator		*m_pPositionInterpolator;
	int							m_iPositionInterpolator;
	int							m_iChangeFrame;

	Quaternion m_qAngles;
	QAngle m_Angles;
	float m_flMoveTime;				// time it takes to travel to next key frame
	float m_flSpeed;				// average speed travelling to next time; if this is non-zero, m_flMoveTime is calculated from it
	CMapAnimator *m_pAnimator;		// The animator that is at the head of our path.
	CMapKeyFrame *m_pNextKeyFrame;	// The next keyframe in our path.

	enum
	{
		MAX_LINE_POINTS = 10,
	};

	Vector m_LinePoints[MAX_LINE_POINTS];
	bool m_bRebuildPath;
	friend CMapAnimator;
};


#endif // MAPKEYFRAME_H