DI-Guy SDK Documentation  13.2
diguyGraphicsInstanceGroup.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2016 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************/
14 #ifndef __diguyGraphicsInstanceGroup_H
15 #define __diguyGraphicsInstanceGroup_H
16 
17 #ifdef SWIG
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 #include <diguy_constants.h>
25 
26 class bdiInstanceGroup;
29 class diguyGraphicsShape;
30 class diguyGraphicsMesh;
31 
32 #endif
33 
34 /****************************************************************************/
35 
36 #include <declspec_diguy.h>
37 
49 class BDI_DECLSPEC_diguy diguyGraphicsInstanceGroup
50 {
51 public:
52 
53 /*****************************************************************************/
66  /*l
67  *b Description:
68  **
69  ** Instance groups are assigned a unique identifier, or uid. This
70  ** function returns the uid of the instance group.
71  **
72  ** *Note*: uid will change between DI Guy runs.
73  **
74  *b Returns:
75  ** uid of the instance group
76  **
77  */
78  long get_uid() const;
79 
80  /*l
81  *b Description:
82  **
83  ** Returns the number of instances in the instance group.
84  */
85  int get_num_instances() const;
86 
87  /*l
88  *b Description:
89  **
90  ** Return the offset, in floats, of the base data for the instance group.
91  **
92  *b Returns:
93  **
94  ** offset, in bytes, of the instance group in the buffer data
95  */
96  int get_start_base_offset() const;
97 
98  /*l
99  *b Description:
100  **
101  ** Return the offset, in floats, of the link data for the instance group.
102  **
103  *b Returns:
104  **
105  ** offset, in bytes, of the instance group in the buffer data
106  */
107  int get_start_link_offset() const;
108 
109  /*l
110  *b Description:
111  **
112  ** Returns the number of links for instances with skinned geometry.
113  **
114  ** *Note*: will return 0 if the geometry is not skinned
115  **
116  *b Returns:
117  **
118  ** number of links
119  */
120  int get_num_links() const;
121 
122  /*l
123  *b Description:
124  **
125  ** Returns the debug color of an instance group.
126  **
127  *b Returns:
128  **
129  ** RGBA color
130  */
131  void get_debug_color(float& r, float& g, float& b, float& a) const;
132 
134  int get_show_debug_colors() const;
135 
136  /*l
137  *b Description:
138  **
139  ** This function returns a pointer to the shader program designated
140  ** for this instance group. if any. Shader programs are shared objects
141  ** usable meshes and instance groups.
142  ** by many meshes.
143  **
144  *b Returns:
145  **
146  ** pointer to diguyGraphicsShaderProgram, or NULL if this instance
147  ** group does not have a shader specified
148  */
149  diguyGraphicsShaderProgram* get_shader_program() const;
150 
151  /*l
152  *b Description:
153  **
154  ** Returns a pointer to the low level geometry mesh object that comprises
155  ** the renderable for the instances in the group.
156  **
157  *b Returns:
158  **
159  ** pointer of type diguyGraphicsMesh
160  */
161  diguyGraphicsMesh* get_diguy_mesh();
162 
163  /*l
164  *b Description:
165  **
166  ** Returns a index to which swapped texture state to use for drawing this instance group. Only
167  ** meaningful if respect texture states is on.
168  */
169  int get_graphics_state_switch_index();
170 
171  /*l
172  *b Description:
173  **
174  ** Returns a pointer to the raw instance data for the instance group.
175  **
176  *b Returns:
177  **
178  ** pointer to the instance data
179  */
180  const float* get_instance_data();
181 
182  /*l
183  *b Description:
184  **
185  ** Return the size of the data for the instance group in bytes.
186  **
187  *b Returns:
188  **
189  ** size, in bytes, of the instance buffer data
190  */
191  int get_instance_data_size();
192 
193  /*l
194  *b Description:
195  **
196  ** Returns a pointer to the raw instance data for the instance group.
197  */
198  const float* get_instance_base_data();
199 
200  /*l
201  *b Description:
202  **
203  ** Return the size of the data for the instance group in bytes.
204  */
205  int get_instance_base_data_size();
206 
207  /*l
208  *b Description:
209  **
210  ** Returns a pointer to the raw instance data for the instance group.
211  */
212  const float* get_instance_link_data();
213 
214  /*l
215  *b Description:
216  **
217  ** Return the size of the data for the instance group in bytes.
218  */
219  int get_instance_link_data_size();
220 
221  /*l
222  *b Description:
223  **
224  ** Return the size of the data for all instance groups in bytes.
225  */
226  int get_instance_data_all_groups_size();
227 
228 
229  /*l
230  *b Description:
231  **
232  ** Return the number of extra floats the user has requested for the tbo, must be multiple of 4.
233  */
234  int get_num_extra_per_instance_data_floats();
235 
236 #ifdef CPLUSPLUS_ONLY
237 
238  /*l
239  *b Description:
240  **
241  ** This function will be called by DI-Guy when it is time for a
242  ** renderer specific instance group to be created. All information
243  ** to construct the instance group for consumption by either an
244  ** immediate mode or scene graph renderer is avaiable via the
245  ** Accessor Functions above when this function is called.
246  **
247  *i Immediate Mode:
248  **
249  ** Immediate mode renderers do not usually override this function.
250  **
251  *i Scene Graph:
252  **
253  ** Scene graph renderers override this function to create scene graph
254  ** specific objects to handle mangement and rendering of the instance
255  ** group.
256  **
257  *b Callable From:
258  **
259  *- - N/A (automatically called by DI-Guy Graphics API during
260  *- the Build Stage)
261  */
262  virtual void build();
263 
264  /*l
265  *b Description:
266  **
267  ** This function will be called by DI-Guy when it is time for a
268  ** instance group to be destroyed.
269  **
270  *i Immediate Mode:
271  **
272  ** Immediate mode renderers may override this function, to
273  ** destroy any object that may have been created by build().
274  **
275  *i Scene Graph:
276  **
277  ** Scene graph renderers usually do override this function, to
278  ** destroy any object that may have been created by build().
279  **
280  *b Callable From:
281  **
282  *- - N/A (automatically called by DI-Guy Graphics API during
283  *- the Unbuild Stage)
284  */
285  virtual void unbuild();
286 
287  /*l
288  *b Description:
289  **
290  ** This function will be called by DI-Guy when it is time for
291  ** the instance group to be updated with new data.
292  **
293  *i Immediate Mode:
294  **
295  ** Immediate mode renderers usually do not override this function.
296  **
297  *i Scene Graph:
298  **
299  ** Scene graph renderers should override this function if they are
300  ** supporting instancing.
301  **
302  *b Callable From:
303  **
304  *- - N/A (automatically called by DI-Guy Graphics API during
305  *- Update Stage)
306  */
307  virtual void update();
308 
309  /*l
310  *b Description:
311  **
312  ** This function will be called by DI-Guy when variables for
313  ** using the instance data needs to be sent to the graphics card.
314  **
315  ** For GLSL-based shaders, these values are typically passed into
316  ** the vertex shader via uniform variables.
317  **
318  *i Immediate Mode:
319  **
320  ** Immediate mode renderers usually do override this function.
321  **
322  *i Scene Graph:
323  **
324  ** Scene graph renderers usually do not override this function,
325  ** but instead use diguyGraphicsShape::get_shader_matrix_data() during the Update Stage.
326  **
327  *b Callable From:
328  **
329  *- - N/A (automatically called by DI-Guy Graphics API during
330  *- the Draw Stage)
331  */
332  virtual int bind_instance_group_data(int base_start, int link_start, int count);
333 
334  /*l
335  *b Description:
336  **
337  ** This function will be called by DI-Guy when data for instance
338  ** groups needs to be sent to the graphics card.
339  **
340  *i Immediate Mode:
341  **
342  ** Immediate mode renderers usually do override this function.
343  **
344  *i Scene Graph:
345  **
346  ** Scene graph renderers usually do not override this function,
347  ** but instead update the instance data in diguyGraphicsInstanceGroup::update()
348  **
349  *b Callable From:
350  **
351  *- - N/A (automatically called by DI-Guy Graphics API during
352  *- the Draw Stage)
353  */
354  virtual int bind_instance_buffer_data(int num_floats, const float* instance_data);
355 
356 #endif
357 
359  diguyGraphicsShape * get_instanced_shape_at_index(int index);
360 
361 /****************************************************************************/
362 /****************************************************************************/
363 
368 #ifdef CPLUSPLUS_ONLY
369  bdiInstanceGroup* get_scripted_object() { return m_scripted_object; }
371 protected:
372 
373  /*l
374  ** A protected constructor. Constructors are called automatically
375  ** by DI-Guy.
376  */
377  diguyGraphicsInstanceGroup(void* internal_data);
378 
379  /*l
380  ** A protected destructor. Destructors are called automatically
381  ** by DI-Guy.
382  */
383  virtual ~diguyGraphicsInstanceGroup();
384 
385 private:
386 
387  /*l
388  ** A pointer to internal data.
389  */
390  bdiInstanceGroup* m_scripted_object;
391 
392  friend class bdiInstanceGroup;
393  friend class bdiGraphicsFactory;
394 #endif
395 
396 };
397 
398 #endif //__diguyGraphicsInstanceGroup_H
A class that represents an instance group. An instance group is a collection of meshes, attached to shapes, that can be drawn with a single draw call using supplemental instance data information. An instance group can contain segmented meshes or skinned mesh.
Definition: diguyGraphicsInstanceGroup.h:48
A class that represents a shared mesh object.
Definition: diguyGraphicsMesh.h:80
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:51
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:96