DI-Guy SDK Documentation  13.6
diguySceneObject.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 /*********************************************************************
8  **
9  *t diguySceneObject
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguySceneObject_H
15 #define __diguySceneObject_H
16 
17 #ifdef SWIG
18 %module diguySceneObject
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 class bdiScenarioSceneObject;
25 #endif
26 
27 #include <declspec_diguy.h>
28 #include <diguy_constants.h>
29 #include <stdio.h> // for NULL
30 
34 
44 /****************************************************************************/
45 class BDI_DECLSPEC_diguy diguySceneObject
46 {
47 
48 /*****************************************************************************/
57 public:
58 
59  /*l
60  *b Description:
61  **
62  ** Returns the name of the scene object. This pointer will
63  ** never be NULL.
64  **
65  *b Returns:
66  **
67  ** name of the scene object
68  */
69  const char* get_name();
70 
71  /*l
72  *b Description:
73  **
74  ** This function sets the name of this object.
75  **
76  *b Returns:
77  **
78  ** 0 on success, -1 on failure
79  */
80  int set_name(const char* name);
81 
82  /*l
83  *b Description:
84  **
85  ** All scene objects are assigned a unique identifier, or uid. This
86  ** function returns this scene object's uid.
87  **
88  ** *Note*: unique identifiers will change between DI-Guy runs!
89  **
90  *b Returns:
91  **
92  ** unique identifier of object
93  */
94  long get_uid();
95 
96  /*l
97  *b Description:
98  **
99  ** Returns the filename of the scene object. This pointer will
100  ** never be NULL.
101  **
102  ** The returned filename may be relative to another directory,
103  ** such as $DIGUY/geometry/sets. Call get_fully_resolved_filename()
104  ** to have DI-Guy search for the fully resolved filename.
105  **
106  *b Returns:
107  **
108  ** filename of the scene object
109  */
110  const char* get_filename();
111 
112  /*l
113  *b Returns:
114  **
115  ** node within the scene object file; returned string is 0 length if
116  ** contents of entire file should be used
117  */
118  const char* get_nodename();
119 
120  /*l
121  *b Returns:
122  **
123  ** alternate filename of the scene object
124  */
125  const char* get_alternate_filename();
126 
127  /*l
128  *b Description:
129  **
130  ** Returns the fully resolved filename of the scene object. Returns
131  ** NULL if the file cannot be found.
132  **
133  *b Returns:
134  **
135  ** fully resolved filename of the scene object; NULL if not found
136  */
137  const char* get_fully_resolved_filename();
138 
139  /*l
140  *b Description:
141  **
142  ** Attempts to load the file returned by get_filename() and
143  ** construct an object that can be rendered in the current
144  ** graphics environment by the call draw_visual().
145  **
146  *b Returns:
147  **
148  ** 0 on success, -1 on failure
149  **
150  */
151  int show();
152 
153  /*l
154  *b Description:
155  **
156  ** Hides the scene object.
157  **
158  *b Returns:
159  **
160  ** 0 on success, -1 on failure
161  */
162  int hide();
163 
164  /*l
165  *b Description:
166  **
167  ** Adds a vertex to a user defined scene object.
168  **
169  *b Returns:
170  **
171  ** 0 on success, -1 on failure
172  */
173  int add_vertex_to_user_defined(float x, float y, float z);
174 
175  /*l
176  *b Description:
177  **
178  ** Adds a triangle to a user defined scene object.
179  ** Indices refer to vertices added with a add_vertex_* call.
180  **
181  *b Returns:
182  **
183  ** 0 on success, -1 on failure
184  */
185  int add_triangle_to_user_defined(int index0, int index1, int index2);
186 
187 #ifdef CPLUSPLUS_ONLY
188  /*l
189  *b Description:
190  **
191  ** Adds an array of vertices to a user defined scene object.
192  **
193  *b Arguments:
194  **
195  *a skipBytes - bytes between vertex position information
196  **
197  *b Returns:
198  **
199  ** 0 on success, -1 on failure
200  */
201  int add_vertex_array_to_user_defined(const float* const vertices,
202  int num_vertices, int skipBytes = 12);
203 
204  /*l
205  *b Description:
206  **
207  ** Adds an array of triangles to a user defined scene object.
208  ** The array should contain indices to vertices added with add_vertex_* calls.
209  **
210  *b Arguments:
211  **
212  *a num_indices - Number of indices (3 indices per triangle).
213  **
214  *b Returns:
215  **
216  ** 0 on success, -1 on failure
217  */
218  int add_triangle_array_to_user_defined(const int* const indices, int num_indices);
219 
220  /*l
221  *b Description:
222  **
223  ** Adds a triangle to a user defined object.
224  ** Positions are expected to be float[3].
225  **
226  *b Returns:
227  **
228  ** 0 on success, -1 on failure
229  */
230  int add_triangle_to_user_defined(const float* const pos0,
231  const float* const pos1, const float* const pos2);
232 #endif
233 
234  /*l
235  *b Description:
236  **
237  ** Builds the geometry of the user defined scene object
238  ** from data passed via add_vertex_* and add_triangle_* calls.
239  **
240  *b Returns:
241  **
242  ** 0 on success, -1 on failure
243  */
244  int build_user_defined();
245 
246 
247 /*****************************************************************************/
253  /*l
254  *b Description:
255  **
256  ** This function is essentially the same as the function
257  ** diguyCharacter::set_render_mode_shader(), but applies to this
258  ** scene object.
259  **
260  *b Returns:
261  **
262  ** 0 on success, -1 on failure
263  */
264  int set_render_mode_shader(const char* shader_name,
265  const char* render_mode = NULL);
266 
267  /*l
268  *b Description:
269  **
270  ** This function is essentially the same as the function
271  ** diguyCharacter::reset_render_mode_shader_to_default(), but
272  ** applies to this scene object.
273  */
274  void reset_render_mode_shader_to_default(const char* render_mode = NULL);
275 
276  /*l
277  *b Description:
278  **
279  ** This function is essentially the same as the function
280  ** diguyCharacter::get_render_mode_shader(), but applies to this to
281  ** this scene object.
282  **
283  *b Returns:
284  **
285  ** name of shader program; NULL if none
286  */
287  const char* get_render_mode_shader(const char* render_mode = NULL);
288 
289  /*l
290  *b Description:
291  **
292  ** This function is essentially the same as the function
293  ** diguyCharacter::get_shader_program(), but applies to this to
294  ** this scene object. It's here for backwards compatibility DI-Guy 12
295  ** now uses shader techniques as wrappers for shader programs.
296  **
297  *b Returns:
298  **
299  ** object of type diguyGraphicsShaderProgram; NULL if none
300  */
301  diguyGraphicsShaderProgram* get_shader_program();
302 
303  /*l
304  *b Description:
305  **
306  ** This function is essentially the same as the function
307  ** diguyCharacter::get_shader_technique(), but applies to this to
308  ** this scene object.
309  **
310  *b Returns:
311  **
312  ** object of type diguyGraphicsShaderTechnique; NULL if none
313  */
314  diguyGraphicsShaderTechnique* get_shader_technique();
315 
316  /*l
317  *b Description:
318  **
319  ** This function is essentially the same as the function
320  ** diguyCharacter::set_temporary_current_shader_program(), but
321  ** applies to this to this scene object.
322  **
323  *b Returns:
324  **
325  ** 0 on success, -1 on failure
326  */
327  int set_temporary_current_shader(const char* shader_name);
328 
329  /*l
330  *b Description:
331  **
332  ** This function is essentially the same as the function
333  ** diguyCharacter::reset_current_shader_to_default(), but
334  ** applies to this to this scene object.
335  */
336  void reset_current_shader_to_default();
337 
338  /*l
339  *b Description:
340  **
341  ** This function is essentially the same as the function
342  ** diguyCharacter::get_shader_instance(), but applies to this to
343  ** this scene object.
344  **
345  ** Note that the shader instance of a scene object can change over
346  ** the lifetime of the scene object. Therefore the returned pointer
347  ** should not be stored, but should be re-read each time it is
348  ** needed.
349  **
350  *b Returns:
351  **
352  ** object of type diguyGraphicsShaderInstance; NULL if none
353  */
354  diguyGraphicsShaderInstance* get_shader_instance();
355 
356  /*l
357  *b Description:
358  **
359  ** This function is essentially the same as the function
360  ** diguyCharacter::reset_shader_instance_variables_to_initial_values(),
361  ** but applies to this scene object.
362  */
363  void reset_shader_instance_variables_to_initial_values();
364 
365  /*l
366  *b Description:
367  **
368  ** This function is essentially the same as the function
369  ** diguyCharacter::reset_shader_instance_variables_to_program_defaults(),
370  ** but applies to this scene object.
371  */
372  void reset_shader_instance_variables_to_program_defaults();
373 
374 
375  /*l
376  ** Deprecated as of 10.5.2. Use set_shader_program_name() instead.
377  */
378  int set_shader_program(const char* shader_name);
379 
380 
381 /****************************************************************************/
382 /****************************************************************************/
383 /****************************************************************************/
390 /****************************************************************************/
391 /****************************************************************************/
392 /****************************************************************************/
393 
395  int set_position(float x, float y, float z);
396  int get_position(float* x, float* y, float* z);
397 
399  int set_orientation(float rz, float rx, float ry);
400  int get_orientation(float* rz, float* rx, float* ry);
401 
403  int set_scale(float sx, float sy, float sz);
404  int get_scale(float* sx, float* sy, float* sz);
405 
406  int set_filename(const char* file_name);
407  int get_is_sky_box();
408  int set_is_sky_box(int skybox);
409 
410  /*l
411  * should be a member of diguyGraphicsTextureLoadingBehavior
412  * DIGUY_LOAD_INSTANTLY, DIGUY_LOAD_PRIORITY_ASYNC, DIGUY_LOAD_ASYNC
413  */
414  static int set_texture_load_behavior(diguyGraphicsTextureLoadingBehavior mode);
415  static diguyGraphicsTextureLoadingBehavior get_texture_load_behavior();
416 
417 
418 #ifdef CPLUSPLUS_ONLY
419 
420  /*l
421  *b Description:
422  **
423  ** Draws the scene object.
424  **
425  *i Currently OpenGL only.
426  **
427  *b Returns:
428  **
429  ** 0 on success, -1 on failure
430  **
431  *b Callable From:
432  **
433  *- - C++
434  */
435  int draw_visual();
436 
437 #endif
438 
439  int get_include_in_octtree();
440  int set_include_in_octtree(int val);
441 
442  int set_include_in_physics_sim_scene(int include_in_simulation_terrain);
443  int get_include_in_physics_sim_scene();
444 
445  int set_physics_collision_group(diguyPhysicsCollisionGroup collision_group);
446  diguyPhysicsCollisionGroup get_physics_collision_group();
447 
448  int get_min(float* x, float* y, float* z);
449  int get_max(float* x, float* y, float* z);
450 
451  /*
452  * DI-Guy doesn't use these masks internally, but they can be useful
453  * for some DI-Guy Graphics API scene graph implementations.
454  */
455  void set_scene_graph_mask(unsigned int mask);
456  unsigned int get_scene_graph_mask();
457 
458  int get_enabled();
459  int set_enabled(int enabled);
460 
461  int get_visible();
462  int set_visible(int visible);
463 
468 #ifdef CPLUSPLUS_ONLY
469 
470 public:
471 
472  bdiScenarioSceneObject* get_scripted_object() {return m_scripted_object;}
473 
474 
475 
476 private:
477 
478  /*l
479  ** A private constructor.
480  */
481  diguySceneObject(bdiScenarioSceneObject* scene_object);
482 
483  /*l
484  ** A private destructor.
485  */
486  ~diguySceneObject();
487 
488  /*l
489  ** A pointer to internal data.
490  */
491  bdiScenarioSceneObject* m_scripted_object;
492 
493  friend class bdiScenarioSceneObject;
494 
495 #endif
496 
497 };
498 
499 #endif /* __diguySceneObject_H */
500 
A class that represents the unique per-character shader object.
Definition: diguyGraphicsShaderInstance.h:55
diguyGraphicsTextureLoadingBehavior
Definition: diguy_constants.h:432
A scene object is a static (that is, non-moving) object in the scenario. Scene objects are the basic ...
Definition: diguySceneObject.h:43
diguyPhysicsCollisionGroup
This enumeration lists the collision groups that a DI-Guy physics sim object can be in...
Definition: diguy_constants.h:1769
This class implements shader lod system for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderTechnique.h:154
This class implements shader programs for use with DI-Guy character graphics.
Definition: diguyGraphicsShaderProgram.h:94