aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/fx_interpvalue.h
blob: a274ffe1eed1d89a0b5094683c03ff2beab23f16 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

#ifndef FX_INTERPVALUE_H
#define FX_INTERPVALUE_H
#ifdef _WIN32
#pragma once
#endif

// Types of supported interpolation
enum InterpType_t
{
	INTERP_LINEAR = 0,
	INTERP_SPLINE,
};

class CInterpolatedValue 
{
public:
			CInterpolatedValue( void );
			CInterpolatedValue( float startTime, float endTime, float startValue, float endValue, InterpType_t type );

	void	SetTime( float start, float end );
	void	SetRange( float start, float end );
	void	SetType( InterpType_t type );
	
	// Set the value with no range
	void SetAbsolute( float value );

	// Set the value with range and time supplied
	void Init( float startValue, float endValue, float dt, InterpType_t type = INTERP_LINEAR );

	// Start from the current value and move towards the end value
	void InitFromCurrent( float endValue, float dt, InterpType_t type = INTERP_LINEAR );

	// Find our interpolated value at the given point in time
	float Interp( float curTime );

private:

	float	m_flStartTime;
	float	m_flEndTime;
	float	m_flStartValue;
	float	m_flEndValue;

	int		m_nInterpType;
};

#endif // FX_INTERPVALUE_H