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