aboutsummaryrefslogtreecommitdiff
path: root/mp/src/public/tier2/camerautils.h
blob: dcaf423d5a6b5b1acc984ed8c84170336989f1e2 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A set of utilities to deal with camera transforms
//
//===========================================================================//

#ifndef CAMERAUTILS_H
#define CAMERAUTILS_H

#ifdef _WIN32
#pragma once
#endif

#include "tier2/tier2.h"
#include "Color.h"

//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class Vector;
class QAngle;
class IMaterial;
struct matrix3x4_t;
class VMatrix;


//-----------------------------------------------------------------------------
// Camera state
// TODO: Maybe this should be a base class of CViewSetup?
//-----------------------------------------------------------------------------
struct Camera_t
{
	Vector m_origin;
	QAngle m_angles;
	float m_flFOV;
	float m_flZNear;
	float m_flZFar;
};


//-----------------------------------------------------------------------------
// accessors for generated matrices
//-----------------------------------------------------------------------------
void ComputeViewMatrix( VMatrix *pWorldToCamera, const Camera_t& camera );
void ComputeViewMatrix( matrix3x4_t *pWorldToCamera, const Camera_t& camera );
void ComputeProjectionMatrix( VMatrix *pCameraToProjection, const Camera_t& camera, int width, int height );


//-----------------------------------------------------------------------------
// Computes the screen space position given a screen size
//-----------------------------------------------------------------------------
void ComputeScreenSpacePosition( Vector2D *pScreenPosition, const Vector &vecWorldPosition, 
	const Camera_t &camera, int width, int height );


#endif // CAMERAUTILS_H