DI-Guy C++ SDK Reference  13.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyGraphicsInstanceGroup.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2014 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  ** This function returns the name of the shape. The returned pointer
86  ** will never be NULL.
87  **
88  *b Returns:
89  **
90  ** name of the shape as C string
91  */
92  int get_start_link_offset() const;
93 
94  /*l
95  *b Description:
96  **
97  ** Returns the number of links for instances with skinned geometry.
98  **
99  ** *Note*: will return 0 if the geometry is not skinned
100  **
101  *b Returns:
102  **
103  ** number of links
104  */
105  int get_num_links() const;
106 
107 
108  /*l
109  *b Description:
110  **
111  ** This function returns a pointer to the shader program designated
112  ** for this instance group. if any. Shader programs are shared objects
113  ** usable meshes and instance groups.
114  ** by many meshes.
115  **
116  *b Returns:
117  **
118  ** pointer to diguyGraphicsShaderProgram, or NULL if this instance
119  ** group does not have a shader specified
120  */
121  diguyGraphicsShaderProgram* get_shader_program() const;
122 
123  /*l
124  *b Description:
125  **
126  ** Returns a pointer to the low level geometry mesh object that comprises
127  ** the renderable for the instances in the group.
128  **
129  *b Returns:
130  **
131  ** pointer of type diguyGraphicsMesh
132  */
133  diguyGraphicsMesh* get_diguy_mesh();
134 
135  /*l
136  *b Description:
137  **
138  ** Returns a pointer to the raw instance data for the instance group.
139  **
140  *b Returns:
141  **
142  ** pointer to the instance data
143  */
144  const float* get_instance_data();
145 
146  /*l
147  *b Description:
148  **
149  ** Return the size of the data for the instance group in bytes.
150  **
151  *b Returns:
152  **
153  ** size, in bytes, of the instance buffer data
154  */
155  int get_instance_data_size();
156 
157  /*l
158  *b Description:
159  **
160  ** Return the size of the data for all instance groups in bytes.
161  **
162  *b Returns:
163  **
164  ** size, in bytes of instance buffer data of all groups
165  */
166  int get_instance_data_all_groups_size();
167 
168 #ifdef CPLUSPLUS_ONLY
169 
170  /*l
171  *b Description:
172  **
173  ** This function will be called by DI-Guy when it is time for a
174  ** renderer specific instance group to be created. All information
175  ** to construct the instance group for consumption by either an
176  ** immediate mode or scene graph renderer is avaiable via the
177  ** Accessor Functions above when this function is called.
178  **
179  *i Immediate Mode:
180  **
181  ** Immediate mode renderers do not usually override this function.
182  **
183  *i Scene Graph:
184  **
185  ** Scene graph renderers override this function to create scene graph
186  ** specific objects to handle mangement and rendering of the instance
187  ** group.
188  **
189  *b Callable From:
190  **
191  *- - N/A (automatically called by DI-Guy Graphics API during
192  *- the Build Stage)
193  */
194  virtual void build();
195 
196  /*l
197  *b Description:
198  **
199  ** This function will be called by DI-Guy when it is time for a
200  ** instance group to be destroyed.
201  **
202  *i Immediate Mode:
203  **
204  ** Immediate mode renderers may override this function, to
205  ** destroy any object that may have been created by build().
206  **
207  *i Scene Graph:
208  **
209  ** Scene graph renderers usually do override this function, to
210  ** destroy any object that may have been created by build().
211  **
212  *b Callable From:
213  **
214  *- - N/A (automatically called by DI-Guy Graphics API during
215  *- the Unbuild Stage)
216  */
217  virtual void unbuild();
218 
219  /*l
220  *b Description:
221  **
222  ** This function will be called by DI-Guy when it is time for
223  ** the instance group to be updated with new data.
224  **
225  *i Immediate Mode:
226  **
227  ** Immediate mode renderers usually do not override this function.
228  **
229  *i Scene Graph:
230  **
231  ** Scene graph renderers should override this function if they are
232  ** supporting instancing.
233  **
234  *b Callable From:
235  **
236  *- - N/A (automatically called by DI-Guy Graphics API during
237  *- Update Stage)
238  */
239  virtual void update();
240 
241  /*l
242  *b Description:
243  **
244  ** This function will be called by DI-Guy when variables for
245  ** using the instance data needs to be sent to the graphics card.
246  **
247  ** For GLSL-based shaders, these values are typically passed into
248  ** the vertex shader via uniform variables.
249  **
250  *i Immediate Mode:
251  **
252  ** Immediate mode renderers usually do override this function.
253  **
254  *i Scene Graph:
255  **
256  ** Scene graph renderers usually do not override this function,
257  ** but instead use diguyGraphicsShape::get_shader_matrix_data() during the Update Stage.
258  **
259  *b Callable From:
260  **
261  *- - N/A (automatically called by DI-Guy Graphics API during
262  *- the Draw Stage)
263  */
264  virtual int bind_instance_group_data(int start, int count);
265 
266  /*l
267  *b Description:
268  **
269  ** This function will be called by DI-Guy when data for instance
270  ** groups needs to be sent to the graphics card.
271  **
272  *i Immediate Mode:
273  **
274  ** Immediate mode renderers usually do override this function.
275  **
276  *i Scene Graph:
277  **
278  ** Scene graph renderers usually do not override this function,
279  ** but instead update the instance data in diguyGraphicsInstanceGroup::update()
280  **
281  *b Callable From:
282  **
283  *- - N/A (automatically called by DI-Guy Graphics API during
284  *- the Draw Stage)
285  */
286  virtual int bind_instance_buffer_data(int num_floats, const float* instance_data);
287 
288 #endif
289 
290 /****************************************************************************/
291 /****************************************************************************/
292 
297 #ifdef CPLUSPLUS_ONLY
298  bdiInstanceGroup* get_scripted_object() { return m_scripted_object; }
299 
300 protected:
301 
302  /*l
303  ** A protected constructor. Constructors are called automatically
304  ** by DI-Guy.
305  */
306  diguyGraphicsInstanceGroup(void* internal_data);
307 
308  /*l
309  ** A protected destructor. Destructors are called automatically
310  ** by DI-Guy.
311  */
313 
314 private:
315 
316  /*l
317  ** A pointer to internal data.
318  */
319  bdiInstanceGroup* m_scripted_object;
320 
321  friend class bdiInstanceGroup;
322  friend class bdiGraphicsFactory;
323 #endif
324 
325 };
326 
327 #endif __diguyGraphicsInstanceGroup_H