DI-Guy SDK Documentation  13.2
diguyViewPainter.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2016 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 
8 #ifndef __diguyViewPainter_H
9 #define __diguyViewPainter_H
10 
11 #ifdef SWIG
12 %module diguyViewPainter
13 #else
14 #define CPLUSPLUS_ONLY
15 #endif
16 
17 #include <declspec_diguy.h>
18 
19 class diguyCharacter;
21 
22 /*********************************************************************
23 **
24 *t diguyViewPainter
25 **
26 *b Link against: libdiguy
27 **
28 *b Summary:
29 **
30 ** The diguyViewPainter class acts as a helper for drawing various
31 ** graphics primitives in DI-Guy Scenario 3D views.
32 **
33 ** Currently this class is only supported in DI-Guy Scenario, and should
34 ** be utilized only inside of a diguyScenario::CALLBACK_ID_POST_DRAW
35 ** callback, or inside of a mind draw function.
36 **
37 ** There is only one diguyViewPainter. Retrieve a pointer to it by
38 ** calling diguyApp::get_view_painter().
39 */
40 class BDI_DECLSPEC_diguy diguyViewPainter
41 {
42 
43 public:
44 
45 /*****************************************************************************/
56  /*l
57  *b Description:
58  **
59  ** Sets the current width of lines drawn by the painter.
60  */
61  virtual void set_line_width(float width);
62 
63  /*l
64  *b Description:
65  **
66  ** Sets the color of the default pen. Pens typically draw lines and
67  ** borders around shapes. Color values should be between 0.0 and
68  ** 1.0.
69  */
70  virtual void set_pen_color(float red, float green, float blue, float alpha = 1.0f);
71 
72  /*l
73  *b Description:
74  **
75  ** Sets the color of the secondary pen. Color values should be
76  ** between 0.0 and 1.0.
77  */
78  virtual void set_pen2_color(float red, float green, float blue, float alpha = 1.0f);
79 
80  /*l
81  *b Description:
82  **
83  ** Sets the color of the brush. Brushes are typically used for
84  ** filling shapes. Color values should be between 0.0 and 1.0.
85  */
86  virtual void set_brush_color(float red, float green, float blue, float alpha = 1.0f);
87 
88 
89 /*****************************************************************************/
95  /*l
96  *b Description:
97  **
98  ** Fills out the width and height arguments with the dimensions of
99  ** the primary 3D view.
100  */
101  virtual void get_viewport_size(float* width, float* height);
102 
103  /*l
104  *b Description:
105  **
106  ** This function converts a world (x, y, z) coordinate into a view
107  ** (x, y, z) coordinate.
108  **
109  ** Note: this function must be called *before* 2d text mode is
110  ** entered with the begin_2d_text_mode() function.
111  **
112  ** If the returned view z value is greater then 1, the returned
113  ** coordinate is behind the camera.
114  */
115  virtual void world_to_screen(float world_x, float world_y, float world_z,
116  float* view_x, float* view_y, float* view_z);
117 
118 
119 /*****************************************************************************/
135  /*l
136  *b Description:
137  **
138  ** Draws a line from (x1, y1, z1) to (x2, y2, z2) using the pen color.
139  */
140  virtual void draw_line(float x1, float y1, float z1,
141  float x2, float y2, float z2);
142 
143  /*l
144  *b Description:
145  **
146  ** Draws a line from (x1, y1, z1) to (x2, y2, z2) using both of the
147  ** pen colors. The color of the line is interpolated from point 1 to
148  ** point 2.
149  */
150  virtual void draw_line_2c(float x1, float y1, float z1,
151  float x2, float y2, float z2);
152 
153  /*l
154  *b Description:
155  **
156  ** Draws a sphere with its center at (x, y, z), with radius radius.
157  */
158  virtual void draw_sphere(float x, float y, float z,
159  float radius,
160  int draw_edges = 1,
161  int draw_fill = 1);
162 
163  /*l
164  *b Description:
165  **
166  ** Draws an axis aligned bounding box with one corner at (x1, y1, z1),
167  ** the other at (x2, y2, z2).
168  */
169  virtual void draw_box(float x1, float y1, float z1,
170  float x2, float y2, float z2,
171  int draw_edges = 1,
172  int draw_fill = 1);
173 
174  /*l
175  *b Description:
176  **
177  ** Draws a rotated bounding box with one corner at unrotated (x1,
178  ** y1, z1), and another at unrotated (x2, y2, z2), applying the
179  ** rotation Euler angles (given in BDI_EULER_ANGLE_ORDER_ZXY order in
180  ** degrees). The box is drawn at center point (xc, yc, zc) in global
181  ** space, and then rotated.
182  */
183  virtual void draw_rotated_box(float x1, float y1, float z1,
184  float x2, float y2, float z2,
185  float yaw, float roll, float pitch,
186  float xc, float yc, float zc,
187  int edges = 1,
188  int fill = 1);
189 
190  /*l
191  *b Description:
192  **
193  ** Draws an arrow from (x1, y1, z1) to (x2, y2, z2).
194  */
195  virtual void draw_arrow(float x1, float y1, float z1,
196  float x2, float y2, float z2,
197  float shaft_width = 0.02,
198  float arrow_width = 0.05,
199  int draw_edges = 1,
200  int draw_fill = 1);
201 
202  /*l
203  *b Description:
204  **
205  ** Draws a disc with its center at (x, y, z), and the given radius.
206  */
207  virtual void draw_disc(float x, float y, float z,
208  float radius,
209  int draw_edges = 1,
210  int draw_fill = 1,
211  int num_sides = 12);
212 
213  /*l
214  *b Description:
215  **
216  ** Draws a circle at (x, y, z), with normal (normal_x, normal_y,
217  ** normal_z), and the given radius.
218  */
219  virtual void draw_circle(float x, float y, float z,
220  float normal_x, float normal_y, float normal_z,
221  float radius,
222  int draw_edges = 1,
223  int draw_fill = 1,
224  int num_sides = 12);
225 
226  /*l
227  *b Description:
228  **
229  ** Draws a torus at (x, y, z), with normal (normal_x, normal_y,
230  ** normal_z), and the given radius.
231  */
232  virtual void draw_torus(float x, float y, float z,
233  float inner_radius,
234  float outer_radius,
235  int draw_edges = 1,
236  int draw_fill = 1,
237  int num_sides = 12);
238 
239  /*l
240  *b Description:
241  **
242  ** Draws a Z-axis-up cylinder, with its bottom cap centered at
243  ** (x1, y1, z). The cylinder will have the given radius and height.
244  */
245  virtual void draw_cylinder(float x, float y, float z,
246  float radius,
247  float height,
248  int draw_edges = 1,
249  int draw_fill = 1);
250 
251 
252  /*l
253  *b Description:
254  **
255  ** Draws wedge.
256  */
257  virtual void draw_wedge(float x, float y, float z,
258  float target_x, float target_y, float target_z,
259  float inner_radius,
260  float width,
261  int draw_edges = 1,
262  int draw_fill = 1);
263 
264  virtual void draw_wedge_with_normal(float x, float y, float z,
265  float target_x, float target_y, float target_z,
266  float nx, float ny, float nz,
267  float inner_radius,
268  float width,
269  int draw_edges = 1,
270  int draw_fill = 1);
271 
272 
273 /*****************************************************************************/
287  /*l
288  *b Description:
289  **
290  ** Puts the OpenGL view matrix into a 2D orthogonal state so that
291  ** 2D primitives will be drawn in 2D view coordinates rather than in
292  ** 3D world coordinates.
293  ** This call *must* be balanced by a call to end_2d_text_mode(), or
294  ** overall drawing will be broken.
295  */
296  virtual void begin_2d_mode();
297 
298  /*l
299  *b Description:
300  **
301  ** same as begin_2d_mode() but also binds font texture
302  */
303  virtual void begin_2d_text_mode();
304 
305 
306  /*l
307  *b Description:
308  **
309  ** Returns the OpenGL view matrix back into a 3D perspective state.
310  **
311  ** This call *must* be balanced by a call to begin_2d_text_mode(), or
312  ** overall drawing will be broken.
313  */
314  virtual void end_2d_text_mode();
315 
316  /*l
317  *b Description:
318  **
319  ** Draws the passed text string at view coordinates (x, y).
320  **
321  ** Should only be called inside of a begin_2d_text_mode() and
322  ** end_2d_text_mode() block.
323  **
324  ** The text is drawn with the current pen color.
325  */
326  virtual void draw_text(float screen_x, float screen_y, const char* text);
327 
328  /*l
329  *b Description:
330  **
331  ** Draws a 2D rectangle with the given points as the corners.
332  **
333  ** Should only be called inside of a begin_2d_text_mode() and
334  ** end_2d_text_mode() block.
335  **
336  ** The edges are drawn with the current pen color, the fill is
337  ** drawn with the current brush color.
338  */
339  virtual void draw_2d_rect(float x0,
340  float y0,
341  float x1,
342  float y1,
343  float z0 = 0.0f,
344  int draw_edges = 1,
345  int draw_fill = 1);
346 
348  virtual void draw_private_path_shape(diguyCharacter* diguy_character,
349  int include_waypoints = 0);
350 
351  /*
352  * Point Array Documentation Pending, Experimental
353  */
354  virtual void debug_pa_add_2d_point(const char * name, float x, float y);
355  virtual void debug_pa_add_3d_point(const char * name, float x, float y, float z);
356  virtual void debug_pa_set_param_color(const char * name, float r, float g, float b, float a = 1.0f);
357  // params can be "line_loop"
358  virtual void debug_pa_set_param_style(const char * name, const char * param, int value);
359  virtual void debug_pa_reset(const char * name);
360 
361  virtual void draw_point_arrays();
362 
363 #ifdef CPLUSPLUS_ONLY
364  virtual void draw_opengl_primitive(diguyGraphicsShaderProgram * shader, int primitive_type, int vertex_count, float * verts,
366  float * colors = NULL, float * normals = NULL, float * uvs = NULL);
368  virtual void draw_opengl_primitive(int primative_type, int vertex_count, float * verts, float * colors = NULL, float * normals = NULL, float * uvs = NULL);
369 
376 protected:
377 
378  /*l
379  ** A protected constructor. Use the DI-Guy function
380  ** diguyApp:get_view_painter() to obtain a diguyViewPainter object
381  ** pointer.
382  */
384 
385 private:
386 
387 
388  friend class bdiScenarioApp;
389 
390 #endif
391 
392 };
393 
394 #endif /* __diguyViewPainter_H */
395 
Definition: diguyViewPainter.h:38
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:81
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:96