forked from abcdls0905/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi_primitive_3d_drawer.h
394 lines (328 loc) · 11.2 KB
/
i_primitive_3d_drawer.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
/****************************************************************
File name : i_primitive_3d_drawer.h
Author : 叶峰
Version : 1.0a
Create Date : 2013/03/12
Description : 三维简单图形渲染接口
*****************************************************************/
#ifndef __i_primitive_3d_drawer_H_
#define __i_primitive_3d_drawer_H_
// INCLUDES -----------------------------------------------------------------------------
#include "../public/i_interface.h"
#include "../math/fm_vector.h"
#include "../math/fm_matrix.h"
#include "../math/fm_quaternion.h"
// --------------------------------------------------------------------------------------
class ISceneView;
// --------------------------------------------------------------------------------------
// 坐标轴方向
enum YeAxis3DType
{
YE_AXIS_INVALID = 0,
YE_AXIS_3D_POSITIVE = 0,
YE_AXIS_3D_NEGATIVE = 1,
YE_AXIS_3D_X = 2,
YE_AXIS_3D_Y = 4,
YE_AXIS_3D_Z = 8,
YE_AXIS_3D_PLANE_XOY = YE_AXIS_3D_X | YE_AXIS_3D_Y,
YE_AXIS_3D_PLANE_XOZ = YE_AXIS_3D_X | YE_AXIS_3D_Z,
YE_AXIS_3D_PLANE_YOZ = YE_AXIS_3D_Y | YE_AXIS_3D_Z,
YE_AXIS_3D_POSITIVE_X = YE_AXIS_3D_X | YE_AXIS_3D_POSITIVE,
YE_AXIS_3D_NEGATIVE_X = YE_AXIS_3D_X | YE_AXIS_3D_NEGATIVE,
YE_AXIS_3D_POSITIVE_Y = YE_AXIS_3D_Y | YE_AXIS_3D_POSITIVE,
YE_AXIS_3D_NEGATIVE_Y = YE_AXIS_3D_Y | YE_AXIS_3D_NEGATIVE,
YE_AXIS_3D_POSITIVE_Z = YE_AXIS_3D_Z | YE_AXIS_3D_POSITIVE,
YE_AXIS_3D_NEGATIVE_Z = YE_AXIS_3D_Z | YE_AXIS_3D_NEGATIVE,
};
// --------------------------------------------------------------------------------------
class IPrimitive3DDrawer : public IInterface
{
public:
// 设置当前场景视图
virtual void SetSceneView(ISceneView* pSceneView) = 0;
// 获得当前场景视图
virtual ISceneView* GetSceneView() = 0;
virtual bool IsReady() const = 0;
virtual bool SetSlices(unsigned int slices) = 0;
// 世界矩阵
virtual void SetMtxWorld(const FmMat4& mtxWorld) = 0;
virtual void SetMtxWorldIdentity() = 0;
virtual const FmMat4& GetMtxWorld() const = 0;
// 是否画线模式
virtual void SetWireMode(bool value) = 0;
virtual bool GetWireMode() const = 0;
// 是否背面剔除
virtual void SetCullFace(bool value) = 0;
virtual bool GetCullFace() const = 0;
// 是否使用深度测试
virtual void SetZEnable(bool value) = 0;
virtual bool GetZEnable() const = 0;
/*************基本图形*************/
// 点
virtual void DrawVertex(
const FmVec3& vPos,
unsigned int color
) = 0;
// 线
virtual void DrawLine(
const FmVec3& vStart,
const FmVec3& vEnd,
unsigned int color
) = 0;
virtual void DrawLine(
const FmVec3& vStart,
const FmVec3& vEnd,
unsigned int colStart,
unsigned int colEnd
) = 0;
// 线集
virtual void DrawLineList(
const FmVec3* pVertices,
const unsigned int* pColors,
unsigned int numPoints,
float depth = 0.0f
) = 0;
virtual void DrawLineList(
const FmVec3* pVertices,
unsigned int color,
unsigned int numPoints,
float depth = 0.0f
) = 0;
// 线带
virtual void DrawLineStrip(
const FmVec3* pVertices,
const unsigned int* pColors,
unsigned int numPoints,
float depth = 0.0f
) = 0;
virtual void DrawLineStrip(
const FmVec3* pVertices,
unsigned int color,
unsigned int numPoints,
float depth = 0.0f
) = 0;
//线圈
virtual void DrawLineLoop(
const FmVec3* pVertices,
const unsigned int* pColors,
unsigned int numPoints,
float depth = 0.0f
) = 0;
virtual void DrawLineLoop(
const FmVec3* pVertices,
unsigned int color,
unsigned int numPoints,
float depth = 0.0f
) = 0;
// 三角面
virtual void DrawTriangle(
const FmVec3& v1,
const FmVec3& v2,
const FmVec3& v3,
unsigned int color
) = 0;
virtual void DrawTriangle(
const FmVec3& v1,
const FmVec3& v2,
const FmVec3& v3,
unsigned int color1,
unsigned int color2,
unsigned int color3
) = 0;
// 四角面
virtual void DrawQuadrangle(
const FmVec3& v1,
const FmVec3& v2,
const FmVec3& v3,
const FmVec3& v4,
unsigned int color
) = 0;
virtual void DrawQuadrangle(
const FmVec3& v1,
const FmVec3& v2,
const FmVec3& v3,
const FmVec3& v4,
unsigned int color1,
unsigned int color2,
unsigned int color3,
unsigned int color4
) = 0;
/*************面图形*************/
// 平面
virtual void DrawPlane(
const FmVec3& vCenter,
float fWidth,
float fLength,
unsigned int color,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 平面
virtual void DrawPlane(
const FmPlane& plane,
const FmVec3& vMin,
const FmVec3& vMax,
unsigned int color
) = 0;
// 圆面
virtual void DrawCircleRound(
const FmVec3& vCenter,
float fHeight,
float fRadius,
unsigned int colCenter,
unsigned int colOuter,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 椭圆面
virtual void DrawEllipseRound(
const FmVec3& vCenter,
float fHeight,
float fRadiusW,
float fRadiusH,
unsigned int colCenter,
unsigned int colOuter,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 锥体
virtual void DrawCone(
const FmVec3& vCenter,
float fHeight,
float fRadius,
unsigned int colTop,
unsigned int colBottom,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 金字塔
virtual void DrawPyramid(
const FmVec3& vCenter,
float fWidth,
float fLength,
float fHeight,
unsigned int colTop,
unsigned int colBottom,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 环
virtual void DrawLoop(
const FmVec3& vPosition,
float fHeight,
float fInRadius,
float fOutRadius,
unsigned int colIn,
unsigned int colOut,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 柱
virtual void DrawCylinder(
const FmVec3& vPosition,
float fHeight,
float fTopRadius,
float fBottomRadius,
unsigned int colTop,
unsigned int colBottom,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 长方形
virtual void DrawBox(
const FmVec3& vMin,
const FmVec3& vMax,
unsigned int color
) = 0;
// 包围墙面
virtual void DrawBindingWall(
const FmVec3& vMin,
const FmVec3& vMax,
float fWallHeight,
unsigned int colTop,
unsigned int colBottom
) = 0;
// 球
virtual void DrawSphere(
const FmVec3& vCenter,
float fRadius,
unsigned int color
) = 0;
// 半球
virtual void DrawHemisphere(
const FmVec3& vCenter,
float fRadius,
unsigned int color,
YeAxis3DType axisDir = YE_AXIS_3D_POSITIVE_Y
) = 0;
// 胶囊体
virtual void DrawCapsule(
const FmVec3& vCenter,
float fRadius,
float fHeight,
unsigned int color,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
/*************线图形*************/
// 四边形
virtual void DrawQuadWire(
const FmVec3& vCenter,
float fSize,
unsigned int color,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 圆圈
virtual void DrawCircleWire(
const FmVec3& vCenter,
float fRadius,
unsigned int color,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 椭圆圈
virtual void DrawEllipseWire(
const FmVec3& vCenter,
float fRadiusW,
float fRadiusH,
unsigned int color,
YeAxis3DType axisPlane = YE_AXIS_3D_PLANE_XOZ
) = 0;
// 包围盒
virtual void DrawBindingBox(
const FmVec3& vMin,
const FmVec3& vMax,
unsigned int color
) = 0;
// 每个角上有三角边的包围盒
virtual void DrawSurroundBox(
const FmVec3& vMin,
const FmVec3& vMax,
unsigned int color1,
unsigned int color2
) = 0;
// 包围线圈(圆)
virtual void DrawSurroundCircle(
const FmVec3& vCenter,
float fRadius,
unsigned int colorXOZ,
unsigned int colorYOZ,
unsigned int colorXOY
) = 0;
// 包围线圈(椭圆)
virtual void DrawSurroundEllipse(
const FmVec3& vMin,
const FmVec3& vMax,
unsigned int colorXOZ,
unsigned int colorYOZ,
unsigned int colorXOY
) = 0;
/*************面线图形*************/
// 四面体
virtual void DrawTetrahedron(
const FmVec3* pVertices,
unsigned int faceColor,
unsigned int wireColor
) = 0;
// 六面体
virtual void DrawHexahedron(
const FmVec3* pVertices,
unsigned int faceColor,
unsigned int wireColor
) = 0;
// 提交渲染
virtual void Flush() = 0;
};
// --------------------------------------------------------------------------------------
#endif