forked from nillerusr/source-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScratchPadUtils.h
163 lines (120 loc) · 3.37 KB
/
ScratchPadUtils.h
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: This module contains helper functions for use with scratch pads.
//
// $NoKeywords: $
//=============================================================================//
#ifndef SCRATCHPADUTILS_H
#define SCRATCHPADUTILS_H
#ifdef _WIN32
#pragma once
#endif
#include "iscratchpad3d.h"
// Use this to make a graph.
class CScratchPadGraph
{
public:
typedef int LineID;
CScratchPadGraph();
// Initialze the orientation and scales of the two axes.
// Axis indices are 0, 1, or 2 for x, y, and z.
void Init(
IScratchPad3D *pPad,
Vector vTimeAxis = Vector(0,-1,0),
float flInchesPerSecond=1,
Vector vTimeLineColor=Vector(0,0,1),
float flTimeOrigin=0, // Where the origin of the graph is.
float flTimeLabelEveryNSeconds=1,
Vector vValueAxis = Vector(0,0,1),
float flInchesPerValue=1,
Vector vValueLineColor=Vector(1,0,0),
float flValueOrigin=0 // Where the origin of the graph is.
);
bool IsInitted() const;
// Add another line into the graph.
LineID AddLine( Vector vColor );
void AddSample( LineID iLine, float flTime, float flValue );
void AddVerticalLine( float flTime, float flMinValue, float flMaxValue, const CSPColor &vColor );
// Get the 3D position of a sample on the graph (so you can draw other things there).
Vector GetSamplePosition( float flTime, float flValue );
private:
void UpdateTicksAndStuff( float flTime, float flValue );
private:
class CLineInfo
{
public:
bool m_bFirst;
float m_flLastTime;
float m_flLastValue;
Vector m_vColor;
};
IScratchPad3D *m_pPad;
CUtlVector<CLineInfo> m_LineInfos;
Vector m_vTimeAxis;
float m_flInchesPerSecond;
Vector m_vValueAxis;
float m_flInchesPerValue;
// How often to make a time label.
float m_flTimeLabelEveryNSeconds;
int m_nTimeLabelsDrawn;
Vector m_vTimeLineColor;
Vector m_vValueLineColor;
float m_flTimeOrigin;
float m_flValueOrigin;
// Used to extend the value border.
float m_flHighestValue;
float m_flHighestTime;
};
// Draw a cone.
void ScratchPad_DrawLitCone(
IScratchPad3D *pPad,
const Vector &vBaseCenter,
const Vector &vTip,
const Vector &vBrightColor,
const Vector &vDarkColor,
const Vector &vLightDir,
float baseWidth,
int nSegments );
// Draw a cylinder.
void ScratchPad_DrawLitCylinder(
IScratchPad3D *pPad,
const Vector &v1,
const Vector &v2,
const Vector &vBrightColor,
const Vector &vDarkColor,
const Vector &vLightDir,
float width,
int nSegments );
// Draw an arrow.
void ScratchPad_DrawArrow(
IScratchPad3D *pPad,
const Vector &vPos,
const Vector &vDirection,
const Vector &vColor,
float flLength=20,
float flLineWidth=3,
float flHeadWidth=8,
int nCylinderSegments=5,
int nHeadSegments=8,
float flArrowHeadPercentage = 0.3f // How much of the line is the arrow head.
);
// Draw an arrow with less parameters.. it generates parameters based on length
// automatically to make the arrow look good.
void ScratchPad_DrawArrowSimple(
IScratchPad3D *pPad,
const Vector &vPos,
const Vector &vDirection,
const Vector &vColor,
float flLength );
void ScratchPad_DrawSphere(
IScratchPad3D *pPad,
const Vector &vCenter,
float flRadius,
const Vector &vColor,
int nSubDivs=7 );
void ScratchPad_DrawAABB(
IScratchPad3D *pPad,
const Vector &vMins,
const Vector &vMaxs,
const Vector &vColor = Vector( 1,1,1 ) );
#endif // SCRATCHPADUTILS_H