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