DI-Guy SDK Documentation  13.6
diguyGraphicsLink.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 __diguyGraphicsLink_H
15 #define __diguyGraphicsLink_H
16 
17 #ifdef SWIG
18 %module diguyGraphicsLink
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 #include <diguy_constants.h>
25 
26 class bdiLink;
27 class diguyCharacter;
28 class diguyGraphicsLink;
29 class diguyGraphicsShape;
31 
32 
33 #endif
34 
35 #include <declspec_diguy.h>
36 
37 //------------------------------------------------------------------------------
49 class BDI_DECLSPEC_diguy diguyGraphicsLink
50 {
51 
52 public:
53 
54 /*****************************************************************************/
67  /*l
68  *b Description:
69  **
70  ** Returns the name of the link. This pointer will never be NULL.
71  **
72  *b Returns:
73  **
74  ** name of the link
75  */
76  const char* get_name();
77 
78  /*l
79  *b Description:
80  **
81  ** All links are assigned a unique identifier, or uid. This
82  ** function returns this links's uid.
83  **
84  ** *Note*: unique identifiers will change between DI-Guy runs!
85  **
86  *b Returns:
87  **
88  ** unique identifier of object
89  */
90  long get_uid();
91 
92  /*l
93  *b Returns:
94  **
95  ** index of the link
96  */
97  int get_index();
98 
99  /*l
100  *b Description:
101  **
102  ** Returns a pointer to the diguyCharacter to which this link belongs.
103  */
104  diguyCharacter* get_character();
105 
106  /*l
107  *b Returns:
108  **
109  ** number of shapes on this link
110  */
111  int get_num_shapes();
112 
113  /*l
114  *b Returns:
115  **
116  ** pointer of type diguyGraphicsShape; NULL if no shape at the
117  ** specified index
118  **
119  *b Arguments:
120  **
121  *a index - index of the shape; indices start at 0
122  */
123  diguyGraphicsShape* get_shape_at_index(int index);
124 
125  /*l
126  *b Description:
127  **
128  ** This function returns a pointer to the specified shape.
129  **
130  *b Arguments:
131  **
132  *a name - name of link to be found
133  **
134  *b Returns:
135  **
136  ** pointer of type diguyGraphicsShape; NULL if not found
137  */
138  diguyGraphicsShape* find_shape(const char* name);
139 
140  /*l
141  *b Description:
142  **
143  ** This function returns a pointer to the specified shape.
144  **
145  *b Arguments:
146  **
147  *a name - name of shape with class_type to be found,
148  *a currently works with heads
149  **
150  *b Returns:
151  **
152  ** pointer of type diguyGraphicsShape; NULL if not found
153  */
154  diguyGraphicsShape* find_shape_by_class_type(const char* name);
155 
156  /*l
157  *b Description:
158  **
159  ** This function overrides the motion data driving the visibility child shapes
160  **
161  *b Arguments:
162  **
163  *a switch_name - the name of the motion data stream that controls the visibility
164  *a of a child shape, see also get_switch_var_name(), set to -1 to
165  *a allow the underlying motion data to resume control
166  **
167  */
168  void set_shape_switch_override(const char * switch_name, int value);
169 
170  /*l
171  *b Description:
172  **
173  ** Returns the type of joint that attaches this link to its parent.
174  **
175  *b Returns:
176  **
177  ** joint type of the link
178  */
179  diguyGraphicsJointType get_joint_type();
180 
181  /*l
182  *b Description:
183  **
184  ** Returns in the passed variables the translation amount of the
185  ** link's joint.
186  **
187  ** If there is a current render camera set, the position link's
188  ** values will be in the local space of the camera. This is useful
189  ** for rendering far from the origin.
190  **
191  ** The values may or may not stay constant frame to frame; see
192  ** get_translation_is_static().
193  **
194  ** Returned values are in meters, and should be applied after the
195  ** rotational offset (if any).
196  **
197  *b Arguments:
198  **
199  *a tx, ty, tz - pointers to floats into which result should be placed
200  **
201  *b Returns:
202  **
203  ** 0 on success, -1 on failure
204  */
205  int get_translation(float* tx, float* ty, float* tz);
206 
207  /*l
208  *b Description:
209  **
210  ** Returns in the passed variables the translation amount of the
211  ** link's joint.
212  **
213  ** The values may or may not stay constant frame to frame; see
214  ** get_translation_is_static().
215  **
216  ** Returned values are in meters, and should be applied after the
217  ** rotational offset (if any).
218  **
219  *b Arguments:
220  **
221  *a tx, ty, tz - pointers to doubles into which result
222  *a should be placed
223  **
224  *b Returns:
225  **
226  ** 0 on success, -1 on failure
227  */
228  int get_translation_double(double* tx, double* ty, double* tz);
229 
230  /*l
231  *b Description:
232  **
233  ** Returns whether the translation returned by get_translation() is
234  ** static (unchanging) or dynamic (can change frame to frame).
235  **
236  ** If the translation is dynamic the translation values will come
237  ** from one or more DI-Guy motion variables; the names of the
238  ** variables are accessible using the functions get_var_name_tx(),
239  ** etc.
240  **
241  ** If the translation is static it will remain so; the value returned
242  ** by this function should not change frame to frame.
243  **
244  *b Returns:
245  **
246  ** 1 if translation is static, 0 if not, -1 on failure
247  */
248  int get_translation_is_static();
249 
250 
251  /*l
252  *b Description:
253  **
254  ** Returns in the passed variables the initial translation amount of the
255  ** link's joint.
256  **
257  ** This value is static and typically represents the offset to the parent link
258  **
259  ** Returned values are in meters
260  **
261  *b Arguments:
262  **
263  *a tx, ty, tz - pointers to floats into which result should be placed
264  **
265  *b Returns:
266  **
267  ** 0 on success, -1 on failure
268  */
269  int get_initial_translation(float* tx, float* ty, float* tz);
270 
271  /*l
272  *b Description:
273  **
274  ** Returns the name of the DI-Guy motion data variable that controls
275  ** translation along the X axis.
276  **
277  ** The returned pointer will be NULL if there is no associated variable.
278  **
279  *b Returns:
280  **
281  ** name of the variable; NULL if there is no variable
282  */
283  const char* get_var_name_tx();
284 
285  /*l
286  *b Description:
287  **
288  ** Returns the name of the DI-Guy motion data variable that controls
289  ** translation along the Y axis.
290  **
291  ** The returned pointer will be NULL if there is no associated variable.
292  **
293  *b Returns:
294  **
295  ** name of the variable; NULL if there is no variable
296  */
297  const char* get_var_name_ty();
298 
299  /*l
300  *b Description:
301  **
302  ** Returns the name of the DI-Guy motion data variable that controls
303  ** translation along the Z axis.
304  **
305  ** The returned pointer will be NULL if there is no associated variable.
306  **
307  *b Returns:
308  **
309  ** name of the variable; NULL if there is no variable
310  */
311  const char* get_var_name_tz();
312 
313  /*l
314  *b Description:
315  **
316  ** Returns in the passed variables the rotation amount of the link's
317  ** joint.
318  **
319  ** The values may or may not stay constant frame to frame; see
320  ** get_rotation_is_static().
321  **
322  ** Returned values are an Euler triple in degrees, and should be
323  ** applied in RZ -> RX -> RY order, after the translation.
324  **
325  *b Arguments:
326  **
327  *a rz, rx, ry - pointers to floats into which result
328  *a should be placed
329  **
330  *b Returns:
331  **
332  ** 0 on success, -1 on failure
333  */
334  int get_rotation(float* rz, float* rx, float* ry);
335 
336  /*l
337  *b Description:
338  **
339  ** Returns in the passed variables the rotation amount of the link's
340  ** joint.
341  **
342  ** The values may or may not stay constant frame to frame; see
343  ** get_rotation_is_static().
344  **
345  ** Returned values are an Euler triple in degrees, and should be
346  ** applied in RZ -> RX -> RY order, after the translation.
347  **
348  *b Arguments:
349  **
350  *a rz, rx, ry - pointers to floats into which result
351  *a should be placed
352  **
353  *b Returns:
354  **
355  ** 0 on success, -1 on failure
356  */
357  int get_rotation_euler(float* rz, float* rx, float* ry);
358 
359  /*l
360  *b Description:
361  **
362  ** Returns in the passed variables the rotation amount of the link's
363  ** joint.
364  **
365  ** The values may or may not stay constant frame to frame; see
366  ** get_rotation_is_static().
367  **
368  ** Returned values are a quaternion and should be applied after
369  ** the translation.
370  **
371  *b Arguments:
372  **
373  *a qx, qy, qz, qw - pointers to floats into which result
374  *a should be placed
375  **
376  *b Returns:
377  **
378  ** 0 on success, -1 on failure
379  */
380  int get_rotation_quat(float* qx, float* qy, float* qz, float* qw);
381 
382  /*l
383  *b Description:
384  **
385  ** Returns whether the rotation returned by get_rotation() is static
386  ** (unchanging) or dynamic (can change frame to frame).
387  **
388  ** If the rotation is dynamic the rotation values will come from one
389  ** or more DI-Guy motion variables; the names of the variables are
390  ** accessible using the functions get_var_name_rz(), etc.
391  **
392  ** If the rotation is static it will remain so; the value returned by
393  ** this function should not change frame to frame.
394  **
395  *b Returns:
396  **
397  ** 1 if rotation is static, 0 if not, -1 on failure
398  */
399  int get_rotation_is_static();
400 
401  /*l
402  *b Description:
403  **
404  ** Returns the name of the DI-Guy motion data variable that controls
405  ** rotation about the Z axis.
406  **
407  ** The returned pointer will be NULL if there is no associated
408  ** variable.
409  */
410  const char* get_var_name_rz();
411 
412  /*l
413  *b Description:
414  **
415  ** Returns the name of the DI-Guy motion data variable that controls
416  ** rotation about the X axis.
417  **
418  ** The returned pointer will be NULL if there is no associated
419  ** variable.
420  */
421  const char* get_var_name_rx();
422 
423  /*l
424  *b Description:
425  **
426  ** Returns the name of the DI-Guy motion data variable that controls
427  ** rotation about the Y axis.
428  **
429  ** The returned pointer will be NULL if there is no associated
430  ** variable.
431  */
432  const char* get_var_name_ry();
433 
434 
435  /*l
436  *b Description:
437  **
438  ** Returns a pointer to this link's parent link. Parent links are
439  ** always links within the same character. If a link is attached to
440  ** a link in another character (i.e., it is "parented to" another
441  ** link), that link pointer can be obtained by calling
442  ** get_attached_to_link().
443  **
444  ** The returned pointer will be NULL if the link is the position link
445  ** and has no parent.
446  **
447  *b Returns:
448  **
449  ** object of type diguyGraphicsLink
450  */
451  diguyGraphicsLink* get_parent_link();
452 
453  /*l
454  *b Description:
455  **
456  ** Returns a pointer to this character's base position link.
457  */
458  diguyGraphicsLink* get_position_link();
459 
460  diguyGraphicsLink* get_position_link() const;
461 
462  /*l
463  *b Description:
464  **
465  ** Returns a pointer to this link's attached to link. The attached
466  ** to link is different than the parent link in that a parent link is
467  ** always a link in the same character, while an attached to link is
468  ** always a link in a different character.
469  **
470  ** Only position links can be attached to links of another character.
471  **
472  ** The returned pointer will be NULL if the link is not attached to
473  ** the link of another character.
474  */
475  diguyGraphicsLink* get_attached_to_link();
476 
477  /*l
478  *b Description:
479  **
480  ** Returns 1 if this link is the position link, or 0 if not. The
481  ** position link is the root link of the DI-Guy character's link and
482  ** shape hierarchy, and has no parent link.
483  **
484  *b Returns:
485  **
486  ** 1 if this link is the position link, 0 if not, -1 on error
487  */
488  int get_is_position_link();
489 
490  /*l
491  *b Description:
492  **
493  ** Returns how many child links this link has. Child links can be
494  ** accessed using the get_child_link_at_index() function.
495  **
496  *b Returns:
497  **
498  ** number of child links
499  */
500  int get_num_child_links();
501 
502  /*l
503  *b Description:
504  **
505  ** Returns a pointer to this link's child link at the specified
506  ** index.
507  **
508  ** The returned pointer will be NULL if there is no link at that
509  ** index.
510  **
511  *b Arguments:
512  **
513  *a index - index of the child link; indices start at 0
514  */
515  diguyGraphicsLink* get_child_link_at_index(int index);
516 
517 /*****************************************************************************/
524 #ifdef CPLUSPLUS_ONLY
525 
526  /*l
527  *b Description:
528  **
529  ** This function fills out the passed float array with the
530  ** world-coordinate system transformation matrix of this link.
531  ** ie -> character->get_position_transformation_matrix() * link->get_cached_matrix();
532  **
533  *b Arguments:
534  **
535  *a matrix_array - two-dimensional array of floats into
536  *a which the matrix should be copied
537  *a transpose - defaults to zero, sets if the matrix should be
538  *a treated as row-major or column-major
539  **
540  *b Returns:
541  **
542  ** 0 on success, -1 on failure
543  */
544  int get_transformation_matrix(float matrix_array[4][4], int transpose = 0);
545 
546  /*l
547  *b Description:
548  **
549  ** Pointer version of get_transformation_matrix(), see for docs.
550  ** Some end users might prefer this version to avoid copying data from
551  ** an explicit float[4][4].
552  **/
553  int get_transformation_matrix_4x4_ptr(float* matrix, int transpose = 0);
554 
555  /*l
556  *b Description:
557  **
558  ** This function fills out the passed float array with the
559  ** character-local-coordinate system transformation matrix of this
560  ** link. Also known as the cached matrix.
561  **
562  *b Arguments:
563  **
564  *a matrix_array - two-dimensional array of floats into
565  *a which the matrix should be copied
566  *a transpose - defaults to 0, sets if the matrix should be treated
567  *a as row-major or column-major
568  **
569  *b Returns:
570  **
571  ** 0 on success, -1 on failure
572  */
573  int get_local_transformation_matrix(float matrix_array[4][4], int transpose = 0);
574 
575  /*l
576  *b Description:
577  **
578  ** Pointer version of get_local_transformation_matrix(), see for docs.
579  * Some end users might prefer this version to avoid copying data from
580  * an explicit float[4][4].
581  **/
582  int get_local_transformation_matrix_4x4_ptr(float* matrix, int transpose = 0);
583 
584  int get_local_translation(float * x, float *y, float *z);
585 
586  /*l
587  *b Description:
588  **
589  ** This function fills out the passed float array with the
590  ** link-local-coordinate system transformation matrix of this
591  ** link. This is the same value as the matrix built from
592  ** get_rotation() and get_translation()
593  **
594  *b Arguments:
595  **
596  *a matrix_array - two-dimensional array of floats into
597  *a which the matrix should be copied
598  *a transpose - defaults to 0, sets if the matrix should be treated
599  *a as row-major or column-major
600  **
601  *b Returns:
602  **
603  ** 0 on success, -1 on failure
604  */
605  int get_link_transformation_matrix(float matrix_array[4][4], int transpose = 0);
606 
607  /*l
608  *b Description:
609  **
610  ** Pointer version of get_link_transformation_matrix(), see for docs.
611  ** Some end users might prefer this version to avoid copying data from
612  ** an explicit float[4][4].
613  **/
614  int get_link_transformation_matrix_4x4_ptr(float* matrix, int transpose = 0);
615 
616 #endif
617 
618 
619 
620 #ifdef CPLUSPLUS_ONLY
621 
622  /*l
623  *b Description:
624  **
625  ** Returns a pointer to the current motion data array. Along with
626  ** data indices returned below, motion data can be directly read from
627  ** this state vector instead of making multiple calls for getting
628  ** transform data.
629  **
630  ** The rotations in this array will be in Euler angles. If
631  ** quaternions are being used, get_quat_data_ptr() should be called
632  ** instead.
633  **
634  ** This function may return NULL, in which case the functions
635  ** get_translation(), get_rotation(), and get_scale() must be used.
636  **
637  ** The pointer returned by this function may change from frame to
638  ** frame, and therefore should not be saved.
639  **
640  ** This function should not be used for the position link (when
641  ** get_is_position_link() returns 1).
642  **
643  ** This function should not be called in a derived class's
644  ** constructor; the pointer will not yet be valid.
645  **
646  *b Returns:
647  **
648  ** pointer to floats; may return NULL if array isn't available
649  **
650  *b Callable From:
651  **
652  *- - C++
653  */
654  const float* get_data_ptr();
655 
656  /*l
657  *b Description:
658  **
659  ** This function is similar to get_data_ptr(), except rotations in
660  ** the returned array will be in quaternions instead of Euler angles.
661  **
662  *b Returns:
663  **
664  ** pointer to floats; may return NULL if array isn't available
665  **
666  *b Callable From:
667  **
668  *- - C++
669  */
670  const float* get_quat_data_ptr();
671 
672 #endif
673 
674  /*l
675  *b Description:
676  **
677  ** Returns the index of this link's translation data in the float
678  ** array returned by get_data_ptr() or get_quat_data_ptr(). The
679  ** translation values are in (tx, ty, tz) order in the array.
680  **
681  ** This function may return -1, in which case this link has no
682  ** translation data.
683  **
684  ** The index returned by this function will not change from frame to
685  ** frame, and can therefore be saved once it has been obtained.
686  **
687  ** This function should not be used for the position link (when
688  ** get_is_position_link() returns 1). Use get_translation() instead.
689  **
690  ** This function should not be called in a derived class's
691  ** constructor; the index will not yet be valid.
692  **
693  *b Returns:
694  **
695  ** index into float array; -1 if no translation data for link
696  */
697  int get_translation_data_index();
698 
699  /*l
700  *b Description:
701  **
702  ** Returns the index of this link's rotation data in the float array
703  ** returned by get_data_ptr(). If quaternion data is being used,
704  ** call get_quat_data_ptr() instead.
705  **
706  ** The rotation values in the data array will be Euler angles in (rz,
707  ** rx, ry) order.
708  **
709  ** This function may return -1, in which case this link has no
710  ** rotation data.
711  **
712  ** This function should not be used for the position link (when
713  ** get_is_position_link() returns 1). Use get_rotation() instead.
714  **
715  ** This function should not be called in a derived class's
716  ** constructor; the index will not yet be valid.
717  **
718  *b Returns:
719  **
720  ** index into float array; -1 if no rotation data for link
721  */
722  int get_rotation_data_index();
723 
724  /*l
725  *b Description:
726  **
727  ** Returns the index of this link's rotation data in the float array
728  ** returned by get_quat_data_ptr(). If Euler angle data is being
729  ** used, call get_data_ptr() instead.
730  **
731  ** The rotation values in the data array will be a quaternion in (qx,
732  ** qy, qz, qw) order.
733  **
734  ** This function may return -1, in which case this link has no
735  ** rotation data.
736  **
737  ** The index returned by this function will not change from frame to
738  ** frame, and can therefore be saved once it has been obtained.
739  **
740  ** This function should not be used for the position link (when
741  ** get_is_position_link() returns 1). Use get_rotation() instead.
742  **
743  ** This function should not be called in a derived class's
744  ** constructor; the index will not yet be valid.
745  **
746  *b Returns:
747  **
748  ** index into float array; -1 if no rotation data for link
749  */
750  int get_quat_data_index();
751 
752 
753  /*l
754  *b Description:
755  **
756  ** Returns in the passed pointers the unique color of this link. All
757  ** links in a DI-Guy appearance are assigned a unique RGB color that
758  ** can be used in pick/selection operations.
759  **
760  ** Also see diguyScenario::map_color_to_impact().
761  **
762  ** See programming_examples/diguy_graphics_api/ogl_examples/intersection_test
763  ** for an example of its usage.
764  **
765  *b Returns:
766  **
767  ** 0 on success, -1 on failure
768  **
769  ** @TODO Test with lua probably non-functional
770  */
771  int get_unique_color(unsigned char* r,
772  unsigned char* g,
773  unsigned char* b);
774 
775 
776 /*****************************************************************************/
788 #ifdef CPLUSPLUS_ONLY
789 
790  /*l
791  *b Description:
792  **
793  ** This function will be called by DI-Guy when it is time for
794  ** renderer-specific link objects to be created. All information
795  ** necessary to build the link should be available via the Accessor
796  ** Functions above when this function is called.
797  **
798  ** Builds happen in depth-first traversal order, so the parent's
799  ** build() function will always be called before this link's build()
800  ** function.
801  **
802  *i Immediate Mode:
803  **
804  ** Immediate mode renderers usually do not override this function.
805  **
806  *i Scene Graph:
807  **
808  ** Scene graph renderers usually do override this function, to create
809  ** scene graph nodes that allow for the various transformations to
810  ** happen.
811  **
812  ** The following nodes are commonly created:
813  **
814  *- - a static transform node to hold the offsets
815  *- - a dynamic transform node (or DOF) to allow motion data
816  *- to be applied
817  *- - either an LOD or switch node to allow graphics LODs to be
818  *- applied
819  **
820  ** LOD nodes, that automatically handle LOD switching, should be
821  ** created if automatic LOD switching is desired.
822  **
823  ** A switch node should be created if manual setting of the graphics
824  ** LOD is desired.
825  **
826  ** If this link is a position link (it has no parent link), the scene
827  ** graph nodes should not yet be attached to the scene graph; that
828  ** should be done during the call to attach().
829  **
830  ** Otherwise the scene graph nodes should start out attached to their
831  ** attach points (a scene graph node of the parent link).
832  **
833  *b Callable From:
834  **
835  *- - N/A (automatically called by DI-Guy Graphics API during
836  *- the Build Stage)
837  */
838  virtual void build();
839 
840  /*l
841  *b Description:
842  **
843  ** This function will be called by DI-Guy when all links and shapes
844  ** of a DI-Guy character have been built, providing an opportunity
845  ** for final touch-ups to be made to the built hierarchy.
846  **
847  ** This function will be called only for the top-level position link.
848  **
849  *i Immediate Mode:
850  **
851  ** Immediate mode renderers usually do not override this function.
852  **
853  *i Scene Graph:
854  **
855  ** Scene graph renderers sometimes override this function. They
856  ** might to so to do renderer-specific optimizations to the created
857  ** hierarchy.
858  **
859  *b Callable From:
860  **
861  *- - N/A (automatically called by DI-Guy Graphics API during
862  *- the Build Stage)
863  */
864  virtual void post_build();
865 
866  /*l
867  *b Description:
868  **
869  ** This function will be called by DI-Guy when it is time for the
870  ** renderer-specific link objects created during the build() call to
871  ** be destroyed.
872  **
873  ** Unbuilds happen in reverse depth-first traversal order, so this
874  ** link's unbuild() function will always be called before the
875  ** parent's unbuild() function.
876  **
877  *i Immediate Mode:
878  **
879  ** Immediate mode renderers usually do not override this function.
880  **
881  *i Scene Graph:
882  **
883  ** Scene graph renderers usually do override this function, to
884  ** destroy the scene graph nodes created by build().
885  **
886  *b Callable From:
887  **
888  *- - N/A (automatically called by DI-Guy Graphics API during
889  *- the Unbuild Stage)
890  */
891  virtual void unbuild();
892 
893  /*l
894  *b Description:
895  **
896  ** This function will be called by DI-Guy when it is time for
897  ** renderer-specific link objects created during the build() call to
898  ** be attached to their attach points.
899  **
900  ** This function will only be called for the position link.
901  **
902  *i Immediate Mode:
903  **
904  ** Immediate mode renderers usually do not override this function.
905  **
906  *i Scene Graph:
907  **
908  ** Scene graph renderers usually do override this function, to attach
909  ** the scene graph nodes created during build() to somewhere on the
910  ** scene graph.
911  **
912  *b Callable From:
913  **
914  *- - N/A (automatically called by DI-Guy Graphics API during
915  *- the Build Stage, and sometimes during the Update Stage)
916  */
917  virtual void attach_to_scene();
918 
919  /*l
920  *b Description:
921  **
922  ** This function will be called by DI-Guy when it is time for
923  ** renderer-specific link objects created during the build() call to
924  ** be detached from their attach points.
925  **
926  *i Immediate Mode:
927  **
928  ** Immediate mode renderers usually do not override this function.
929  **
930  *i Scene Graph:
931  **
932  ** Scene graph renderers usually do override this function, to detach
933  ** the scene graph nodes created during build() from the scene graph.
934  **
935  *b Callable From:
936  **
937  *- - N/A (automatically called by DI-Guy Graphics API during
938  *- the Build Stage, and sometimes during the Update Stage)
939  */
940  virtual void detach_from_scene();
941 
942  /*l
943  *b Description:
944  **
945  ** This function will be called by DI-Guy when it is time for
946  ** renderer-specific link objects created during the build() call to
947  ** be updated with new transformation data.
948  **
949  ** Updates happen in depth-first traversal order, so the parent's
950  ** update() function will always be called before this link's
951  ** update() function.
952  **
953  *i Immediate Mode:
954  **
955  ** Immediate mode renderers usually do not override this function.
956  **
957  *i Scene Graph:
958  **
959  ** Scene graph renderers usually do override this function, to update
960  ** the scene graph nodes created during build() with new values.
961  **
962  ** These values should be obtained by calling get_translation(),
963  ** get_rotation(), and get_scale().
964  **
965  *b Callable From:
966  **
967  *- - N/A (automatically called by DI-Guy Graphics API during Update Stage)
968  */
969  virtual void update();
970 
971 
972  /*l
973  *b Description:
974  **
975  ** This function will be called by DI-Guy when it is time for the
976  ** transformations of this link to be applied.
977  **
978  *i Immediate Mode:
979  **
980  ** Immediate mode renderers usually do override this function, to
981  ** apply transformations to the transformation stack.
982  **
983  *i Scene Graph:
984  **
985  ** Scene graph renderers usually do not override this function;
986  ** transformation states are handled automatically by scene graphs.
987  **
988  *b Callable From:
989  **
990  *- - N/A (automatically called by DI-Guy Graphics API during Draw Stage)
991  **
992  *e
993  *e //linear draw behavior
994  *e {
995  *e // push the base transform of the character in the world
996  *e // the get_transformation_matrix() of the position link
997  *e m_position_link->begin_character_draw();
998  *e int i;
999  *e for each link in link array
1000  *e {
1001  *e // note the ability to skip links with nothing attached to them
1002  *e if (link->get_num_shapes() > 0 || link->get_is_position_link())
1003  *e {
1004  *e // each link should multiply by the get_local_transformation_matrix
1005  *e // which contains the precalculated concatenated matrix
1006  *e link->draw();
1007  *e }
1008  *e }
1009  *e m_position_link->end_character_draw();
1010  */
1011 
1012  virtual void draw();
1013 
1014  /*l
1015  *b Description:
1016  **
1017  ** This function will be called by DI-Guy when it a shader should be
1018  ** bound to this link. This is important in some scene graph
1019  ** environments, when the scene graph is responsible for binding the
1020  ** shader.
1021  **
1022  *i Immediate Mode:
1023  **
1024  ** Immediate mode renderers usually do not override this function.
1025  **
1026  *i Scene Graph:
1027  **
1028  ** Scene graph renderers can override this function but some don't
1029  ** need to.
1030  **
1031  *b Callable From:
1032  **
1033  *- - N/A (automatically called by DI-Guy Graphics API during Build Stage)
1034  */
1035  virtual void set_shader_instance(diguyGraphicsShaderInstance* shader_instance);
1036 
1037  /*b Description:
1038  **
1039  ** This function will be called by DI-Guy in the update loop when the character
1040  ** changes instancing state. This allows additional work to be done to manage
1041  ** instancing. Note this hasn't been needed, for any of our sample implementations.
1042  */
1043  virtual void instancing_state_changed(int instanced);
1044 
1045  /*l
1046  *b Description:
1047  **
1048  ** This function will be called by DI-Guy while building instance groups (which occurs
1049  ** during diguyScenario::draw() or when manually invoked. It gives the user a chance to set
1050  ** the contents of the tbo on a per shape basis. tbo_data should be a 4x3 matrix.
1051  ** Will only be called if diguyScenario::set_instancing_position_callback_enabled() is set to true.
1052  */
1053  virtual void fill_out_tbo_position_matrix(diguyGraphicsShape * current_shape, int lod, float * tbo_data) const;
1054 
1055  /*l
1056  *b Description:
1057  **
1058  ** This function will be called by DI-Guy while building instance groups (which occurs
1059  ** during diguyScenario::draw() or when manually invoked. Will allow the end user to add additional
1060  ** data to the tbo. This is required to be in blocks of 4 floats. Will only be called if
1061  ** diguyScenario::set_num_extra_per_instance_data_floats(int number); is set to a reasonable number.
1062  */
1063  virtual void fill_out_tbo_additional_data(diguyGraphicsShape * current_shape, float * tbo_data);
1064 
1065 /****************************************************************************/
1070  /*l
1071  *b Description:
1072  **
1073  ** This function will be called by DI-Guy when the drawing of a new
1074  ** character is beginning. This happens when the position link is
1075  ** drawn.
1076  **
1077  *i Immediate Mode:
1078  **
1079  ** Immediate mode renderers can override this function. Typically
1080  ** some type of transformation matrix stack push operation is
1081  ** performed. This is also an appropriate place to do any
1082  ** per-character modifications, such as:
1083  **
1084  *- - applying scale
1085  *- - applying the base translation of the character
1086  *- - picking a current LOD
1087  *- - etc.
1088  **
1089  *i Scene Graph:
1090  **
1091  ** Scene graph renderers usually do not override this function;
1092  ** transformation states are handled automatically by scene graphs.
1093  **
1094  *b Callable From:
1095  **
1096  *- - N/A (automatically called by DI-Guy Graphics API during
1097  *- Draw Stage)
1098  */
1099  virtual void begin_character_draw();
1100 
1101  /*l
1102  *b Description:
1103  **
1104  ** This function will be called by DI-Guy when the drawing traversal
1105  ** of the character's link hierarchy has completed.
1106  **
1107  *i Immediate Mode:
1108  **
1109  ** Immediate mode renderers can override this function. Typically
1110  ** any matrix stack push operation done in begin_character_draw()
1111  ** is undone here by an appropriate pop operation.
1112  **
1113  *i Scene Graph:
1114  **
1115  ** Scene graph renderers usually do not override this function;
1116  ** transformation states are handled automatically by scene graphs.
1117  **
1118  *b Callable From:
1119  **
1120  *- - N/A (automatically called by DI-Guy Graphics API during
1121  *- Draw Stage)
1122  */
1123  virtual void end_character_draw();
1124 
1125 
1126 #endif
1127 
1128 
1129 
1130 /****************************************************************************/
1131 /****************************************************************************/
1138 /****************************************************************************/
1139 /****************************************************************************/
1140 
1142  int get_inverse_rotation_matrix(float matrix_array[4][4], int transpose = 0,
1143  int include_translation = 1);
1144 
1146  int get_inverse_rotation_matrix_4x4_ptr(float* matrix_array, int transpose = 0,
1147  int include_translation = 1);
1148 
1152  int get_approximate_bounding_box(float * bbox_min_x, float * bbox_min_y, float * bbox_min_z,
1153  float * bbox_max_x, float * bbox_max_y, float * bbox_max_z);
1154 
1155 /****************************************************************************/
1156 /****************************************************************************/
1167 /****************************************************************************/
1168 /****************************************************************************/
1169 /****************************************************************************/
1170 
1171  /*l
1172  *b Description:
1173  **
1174  ** Deprecated as of 9.1.4; use diguyGraphicsLink::get_is_position_link()
1175  ** instead.
1176  */
1177  int get_is_base_link();
1178 
1179  /*l
1180  *b Description:
1181  **
1182  ** Deprecated as of 12.0.0 due to architecture change
1183  */
1184  //int get_shader_matrix_index();
1185 
1186  //Deprecated as of 13.2.0 due to architecture change
1187  /*l
1188  *b Deprecated, we don't currently support scaling links
1189  **
1190  ** Returns in the passed variables the scale amount of the link's
1191  ** joint.
1192  **
1193  ** The values may or may not stay constant frame to frame; see
1194  ** get_scale_is_static().
1195  **
1196  ** Returned values unitless scale factors, and should be applied
1197  ** after the rotation.
1198  **
1199  *b Arguments:
1200  **
1201  *a sx, sy, sz - pointers to floats into which result
1202  *a should be placed
1203  **
1204  *b Returns:
1205  **
1206  ** 0 on success, -1 on failure
1207  */
1208  int get_scale(float* sz, float* sx, float* sy);
1209 
1210  /*l
1211  *b Description:
1212  **
1213  ** Returns whether the scale returned by get_scale() is static
1214  ** (unchanging) or dynamic (can change frame to frame).
1215  **
1216  ** If the scale is dynamic the scale values will come from one or
1217  ** more DI-Guy motion variables; the names of the variables are
1218  ** accessible using the functions get_var_name_sx(), etc.
1219  **
1220  ** If the scale is static it will remain so; the value returned by
1221  ** this function should not change frame to frame.
1222  **
1223  *b Returns:
1224  **
1225  ** 1 if scale is static, 0 if not, -1 on failure
1226  */
1227  int get_scale_is_static();
1228 
1229  /*l
1230  *b Description:
1231  **
1232  ** Returns the name of the DI-Guy motion data variable that controls
1233  ** scale in the Z dimension.
1234  **
1235  ** The returned pointer will be NULL if there is no associated
1236  ** variable.
1237  */
1238  const char* get_var_name_sx();
1239 
1240  /*l
1241  *b Description:
1242  **
1243  ** Returns the name of the DI-Guy motion data variable that controls
1244  ** scale in the Y dimension.
1245  **
1246  ** The returned pointer will be NULL if there is no associated
1247  ** variable.
1248  */
1249  const char* get_var_name_sy();
1250 
1251  /*l
1252  *b Description:
1253  **
1254  ** Returns the name of the DI-Guy motion data variable that controls
1255  ** scale in the X dimension.
1256  **
1257  ** The returned pointer will be NULL if there is no associated
1258  ** variable.
1259  */
1260  const char* get_var_name_sz();
1261 
1262  /*l
1263  *b Description:
1264  **
1265  ** Returns the index of this link's scale data in the float array
1266  ** returned by get_data_ptr() or get_quat_data_ptr(). The scale
1267  ** values are in (sx, sy, sz) order in the array.
1268  **
1269  ** This function may return -1, in which case this link has no scale
1270  ** data.
1271  **
1272  ** The index returned by this function will not change from frame to
1273  ** frame, and can therefore be saved once it has been obtained.
1274  **
1275  ** This function should not be used for the position link (when
1276  ** get_is_position_link() returns 1). Use get_scale() instead.
1277  **
1278  ** This function should not be called in a derived class's
1279  ** constructor; the index will not yet be valid.
1280  **
1281  *b Returns:
1282  **
1283  ** index into float array; -1 if no scale data for link
1284  */
1285  int get_scale_data_index();
1286 
1287 /****************************************************************************/
1288 /****************************************************************************/
1289  void set_selected(bool value);
1290  bool get_selected();
1291 
1292  // These functions were removed since they are now always zero and their use
1293  // could lead to confusion. Links now only have translations and rotations,
1294  // those completely represent their offset from their parents
1295  //int get_offset_translation(float* tx, float* ty, float* tz);
1296 
1297  //int get_offset_rotation(float* rz, float* rx, float* ry);
1298 
1303 #ifdef CPLUSPLUS_ONLY
1304 
1305  bdiLink* get_scripted_object() {return m_scripted_object;}
1306 
1307 protected:
1308 
1309  /*l
1310  ** A protected constructor. Constructors are called automatically
1311  ** by DI-Guy.
1312  */
1313  diguyGraphicsLink(void* internal_data);
1314 
1315  /*l
1316  ** A protected destructor. Destructors are called automatically
1317  ** by DI-Guy.
1318  */
1319  virtual ~diguyGraphicsLink();
1320 
1321 private:
1322 
1323  /*l
1324  ** A pointer to internal data.
1325  */
1326  bdiLink* m_scripted_object;
1327 
1328  friend class bdiLink;
1329  friend class bdiGraphicsFactory;
1330 
1331 #endif
1332 
1333 };
1334 
1335 
1336 #endif /* __diguyGraphicsLink_H */
1337 
A class that represents the unique per-character shader object.
Definition: diguyGraphicsShaderInstance.h:55
diguyGraphicsJointType
DI-Guy graphics joint types.
Definition: diguy_constants.h:498
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:82
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:49