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