DI-Guy SDK Documentation  13.5
diguyGraphicsLink.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2020 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  /*l
461  *b Description:
462  **
463  ** Returns a pointer to this link's attached to link. The attached
464  ** to link is different than the parent link in that a parent link is
465  ** always a link in the same character, while an attached to link is
466  ** always a link in a different character.
467  **
468  ** Only position links can be attached to links of another character.
469  **
470  ** The returned pointer will be NULL if the link is not attached to
471  ** the link of another character.
472  */
473  diguyGraphicsLink* get_attached_to_link();
474 
475  /*l
476  *b Description:
477  **
478  ** Returns 1 if this link is the position link, or 0 if not. The
479  ** position link is the root link of the DI-Guy character's link and
480  ** shape hierarchy, and has no parent link.
481  **
482  *b Returns:
483  **
484  ** 1 if this link is the position link, 0 if not, -1 on error
485  */
486  int get_is_position_link();
487 
488  /*l
489  *b Description:
490  **
491  ** Returns how many child links this link has. Child links can be
492  ** accessed using the get_child_link_at_index() function.
493  **
494  *b Returns:
495  **
496  ** number of child links
497  */
498  int get_num_child_links();
499 
500  /*l
501  *b Description:
502  **
503  ** Returns a pointer to this link's child link at the specified
504  ** index.
505  **
506  ** The returned pointer will be NULL if there is no link at that
507  ** index.
508  **
509  *b Arguments:
510  **
511  *a index - index of the child link; indices start at 0
512  */
513  diguyGraphicsLink* get_child_link_at_index(int index);
514 
515 /*****************************************************************************/
522 #ifdef CPLUSPLUS_ONLY
523 
524  /*l
525  *b Description:
526  **
527  ** This function fills out the passed float array with the
528  ** world-coordinate system transformation matrix of this link.
529  ** ie -> character->get_position_transformation_matrix() * link->get_cached_matrix();
530  **
531  *b Arguments:
532  **
533  *a matrix_array - two-dimensional array of floats into
534  *a which the matrix should be copied
535  *a transpose - defaults to zero, sets if the matrix should be
536  *a treated as row-major or column-major
537  **
538  *b Returns:
539  **
540  ** 0 on success, -1 on failure
541  */
542  int get_transformation_matrix(float matrix_array[4][4], int transpose = 0);
543 
544  /*l
545  *b Description:
546  **
547  ** Pointer version of get_transformation_matrix(), see for docs.
548  ** Some end users might prefer this version to avoid copying data from
549  ** an explicit float[4][4].
550  **/
551  int get_transformation_matrix_4x4_ptr(float* matrix, int transpose = 0);
552 
553  /*l
554  *b Description:
555  **
556  ** This function fills out the passed float array with the
557  ** character-local-coordinate system transformation matrix of this
558  ** link. Also known as the cached matrix.
559  **
560  *b Arguments:
561  **
562  *a matrix_array - two-dimensional array of floats into
563  *a which the matrix should be copied
564  *a transpose - defaults to 0, sets if the matrix should be treated
565  *a as row-major or column-major
566  **
567  *b Returns:
568  **
569  ** 0 on success, -1 on failure
570  */
571  int get_local_transformation_matrix(float matrix_array[4][4], int transpose = 0);
572 
573  /*l
574  *b Description:
575  **
576  ** Pointer version of get_local_transformation_matrix(), see for docs.
577  * Some end users might prefer this version to avoid copying data from
578  * an explicit float[4][4].
579  **/
580  int get_local_transformation_matrix_4x4_ptr(float* matrix, int transpose = 0);
581 
582  int get_local_translation(float * x, float *y, float *z);
583 
584  /*l
585  *b Description:
586  **
587  ** This function fills out the passed float array with the
588  ** link-local-coordinate system transformation matrix of this
589  ** link. This is the same value as the matrix built from
590  ** get_rotation() and get_translation()
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 0, sets if the matrix should be treated
597  *a as row-major or column-major
598  **
599  *b Returns:
600  **
601  ** 0 on success, -1 on failure
602  */
603  int get_link_transformation_matrix(float matrix_array[4][4], int transpose = 0);
604 
605  /*l
606  *b Description:
607  **
608  ** Pointer version of get_link_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_link_transformation_matrix_4x4_ptr(float* matrix, int transpose = 0);
613 
614 #endif
615 
616 
617 
618 #ifdef CPLUSPLUS_ONLY
619 
620  /*l
621  *b Description:
622  **
623  ** Returns a pointer to the current motion data array. Along with
624  ** data indices returned below, motion data can be directly read from
625  ** this state vector instead of making multiple calls for getting
626  ** transform data.
627  **
628  ** The rotations in this array will be in Euler angles. If
629  ** quaternions are being used, get_quat_data_ptr() should be called
630  ** instead.
631  **
632  ** This function may return NULL, in which case the functions
633  ** get_translation(), get_rotation(), and get_scale() must be used.
634  **
635  ** The pointer returned by this function may change from frame to
636  ** frame, and therefore should not be saved.
637  **
638  ** This function should not be used for the position link (when
639  ** get_is_position_link() returns 1).
640  **
641  ** This function should not be called in a derived class's
642  ** constructor; the pointer will not yet be valid.
643  **
644  *b Returns:
645  **
646  ** pointer to floats; may return NULL if array isn't available
647  **
648  *b Callable From:
649  **
650  *- - C++
651  */
652  const float* get_data_ptr();
653 
654  /*l
655  *b Description:
656  **
657  ** This function is similar to get_data_ptr(), except rotations in
658  ** the returned array will be in quaternions instead of Euler angles.
659  **
660  *b Returns:
661  **
662  ** pointer to floats; may return NULL if array isn't available
663  **
664  *b Callable From:
665  **
666  *- - C++
667  */
668  const float* get_quat_data_ptr();
669 
670 #endif
671 
672  /*l
673  *b Description:
674  **
675  ** Returns the index of this link's translation data in the float
676  ** array returned by get_data_ptr() or get_quat_data_ptr(). The
677  ** translation values are in (tx, ty, tz) order in the array.
678  **
679  ** This function may return -1, in which case this link has no
680  ** translation data.
681  **
682  ** The index returned by this function will not change from frame to
683  ** frame, and can therefore be saved once it has been obtained.
684  **
685  ** This function should not be used for the position link (when
686  ** get_is_position_link() returns 1). Use get_translation() instead.
687  **
688  ** This function should not be called in a derived class's
689  ** constructor; the index will not yet be valid.
690  **
691  *b Returns:
692  **
693  ** index into float array; -1 if no translation data for link
694  */
695  int get_translation_data_index();
696 
697  /*l
698  *b Description:
699  **
700  ** Returns the index of this link's rotation data in the float array
701  ** returned by get_data_ptr(). If quaternion data is being used,
702  ** call get_quat_data_ptr() instead.
703  **
704  ** The rotation values in the data array will be Euler angles in (rz,
705  ** rx, ry) order.
706  **
707  ** This function may return -1, in which case this link has no
708  ** rotation data.
709  **
710  ** This function should not be used for the position link (when
711  ** get_is_position_link() returns 1). Use get_rotation() instead.
712  **
713  ** This function should not be called in a derived class's
714  ** constructor; the index will not yet be valid.
715  **
716  *b Returns:
717  **
718  ** index into float array; -1 if no rotation data for link
719  */
720  int get_rotation_data_index();
721 
722  /*l
723  *b Description:
724  **
725  ** Returns the index of this link's rotation data in the float array
726  ** returned by get_quat_data_ptr(). If Euler angle data is being
727  ** used, call get_data_ptr() instead.
728  **
729  ** The rotation values in the data array will be a quaternion in (qx,
730  ** qy, qz, qw) order.
731  **
732  ** This function may return -1, in which case this link has no
733  ** rotation data.
734  **
735  ** The index returned by this function will not change from frame to
736  ** frame, and can therefore be saved once it has been obtained.
737  **
738  ** This function should not be used for the position link (when
739  ** get_is_position_link() returns 1). Use get_rotation() instead.
740  **
741  ** This function should not be called in a derived class's
742  ** constructor; the index will not yet be valid.
743  **
744  *b Returns:
745  **
746  ** index into float array; -1 if no rotation data for link
747  */
748  int get_quat_data_index();
749 
750 
751  /*l
752  *b Description:
753  **
754  ** Returns in the passed pointers the unique color of this link. All
755  ** links in a DI-Guy appearance are assigned a unique RGB color that
756  ** can be used in pick/selection operations.
757  **
758  ** Also see diguyScenario::map_color_to_impact().
759  **
760  ** See programming_examples/diguy_graphics_api/ogl_examples/intersection_test
761  ** for an example of its usage.
762  **
763  *b Returns:
764  **
765  ** 0 on success, -1 on failure
766  **
767  ** @TODO Test with lua probably non-functional
768  */
769  int get_unique_color(unsigned char* r,
770  unsigned char* g,
771  unsigned char* b);
772 
773 
774 /*****************************************************************************/
786 #ifdef CPLUSPLUS_ONLY
787 
788  /*l
789  *b Description:
790  **
791  ** This function will be called by DI-Guy when it is time for
792  ** renderer-specific link objects to be created. All information
793  ** necessary to build the link should be available via the Accessor
794  ** Functions above when this function is called.
795  **
796  ** Builds happen in depth-first traversal order, so the parent's
797  ** build() function will always be called before this link's build()
798  ** function.
799  **
800  *i Immediate Mode:
801  **
802  ** Immediate mode renderers usually do not override this function.
803  **
804  *i Scene Graph:
805  **
806  ** Scene graph renderers usually do override this function, to create
807  ** scene graph nodes that allow for the various transformations to
808  ** happen.
809  **
810  ** The following nodes are commonly created:
811  **
812  *- - a static transform node to hold the offsets
813  *- - a dynamic transform node (or DOF) to allow motion data
814  *- to be applied
815  *- - either an LOD or switch node to allow graphics LODs to be
816  *- applied
817  **
818  ** LOD nodes, that automatically handle LOD switching, should be
819  ** created if automatic LOD switching is desired.
820  **
821  ** A switch node should be created if manual setting of the graphics
822  ** LOD is desired.
823  **
824  ** If this link is a position link (it has no parent link), the scene
825  ** graph nodes should not yet be attached to the scene graph; that
826  ** should be done during the call to attach().
827  **
828  ** Otherwise the scene graph nodes should start out attached to their
829  ** attach points (a scene graph node of the parent link).
830  **
831  *b Callable From:
832  **
833  *- - N/A (automatically called by DI-Guy Graphics API during
834  *- the Build Stage)
835  */
836  virtual void build();
837 
838  /*l
839  *b Description:
840  **
841  ** This function will be called by DI-Guy when all links and shapes
842  ** of a DI-Guy character have been built, providing an opportunity
843  ** for final touch-ups to be made to the built hierarchy.
844  **
845  ** This function will be called only for the top-level position link.
846  **
847  *i Immediate Mode:
848  **
849  ** Immediate mode renderers usually do not override this function.
850  **
851  *i Scene Graph:
852  **
853  ** Scene graph renderers sometimes override this function. They
854  ** might to so to do renderer-specific optimizations to the created
855  ** hierarchy.
856  **
857  *b Callable From:
858  **
859  *- - N/A (automatically called by DI-Guy Graphics API during
860  *- the Build Stage)
861  */
862  virtual void post_build();
863 
864  /*l
865  *b Description:
866  **
867  ** This function will be called by DI-Guy when it is time for the
868  ** renderer-specific link objects created during the build() call to
869  ** be destroyed.
870  **
871  ** Unbuilds happen in reverse depth-first traversal order, so this
872  ** link's unbuild() function will always be called before the
873  ** parent's unbuild() function.
874  **
875  *i Immediate Mode:
876  **
877  ** Immediate mode renderers usually do not override this function.
878  **
879  *i Scene Graph:
880  **
881  ** Scene graph renderers usually do override this function, to
882  ** destroy the scene graph nodes created by build().
883  **
884  *b Callable From:
885  **
886  *- - N/A (automatically called by DI-Guy Graphics API during
887  *- the Unbuild Stage)
888  */
889  virtual void unbuild();
890 
891  /*l
892  *b Description:
893  **
894  ** This function will be called by DI-Guy when it is time for
895  ** renderer-specific link objects created during the build() call to
896  ** be attached to their attach points.
897  **
898  ** This function will only be called for the position link.
899  **
900  *i Immediate Mode:
901  **
902  ** Immediate mode renderers usually do not override this function.
903  **
904  *i Scene Graph:
905  **
906  ** Scene graph renderers usually do override this function, to attach
907  ** the scene graph nodes created during build() to somewhere on the
908  ** scene graph.
909  **
910  *b Callable From:
911  **
912  *- - N/A (automatically called by DI-Guy Graphics API during
913  *- the Build Stage, and sometimes during the Update Stage)
914  */
915  virtual void attach_to_scene();
916 
917  /*l
918  *b Description:
919  **
920  ** This function will be called by DI-Guy when it is time for
921  ** renderer-specific link objects created during the build() call to
922  ** be detached from their attach points.
923  **
924  *i Immediate Mode:
925  **
926  ** Immediate mode renderers usually do not override this function.
927  **
928  *i Scene Graph:
929  **
930  ** Scene graph renderers usually do override this function, to detach
931  ** the scene graph nodes created during build() from the scene graph.
932  **
933  *b Callable From:
934  **
935  *- - N/A (automatically called by DI-Guy Graphics API during
936  *- the Build Stage, and sometimes during the Update Stage)
937  */
938  virtual void detach_from_scene();
939 
940  /*l
941  *b Description:
942  **
943  ** This function will be called by DI-Guy when it is time for
944  ** renderer-specific link objects created during the build() call to
945  ** be updated with new transformation data.
946  **
947  ** Updates happen in depth-first traversal order, so the parent's
948  ** update() function will always be called before this link's
949  ** update() function.
950  **
951  *i Immediate Mode:
952  **
953  ** Immediate mode renderers usually do not override this function.
954  **
955  *i Scene Graph:
956  **
957  ** Scene graph renderers usually do override this function, to update
958  ** the scene graph nodes created during build() with new values.
959  **
960  ** These values should be obtained by calling get_translation(),
961  ** get_rotation(), and get_scale().
962  **
963  *b Callable From:
964  **
965  *- - N/A (automatically called by DI-Guy Graphics API during Update Stage)
966  */
967  virtual void update();
968 
969 
970  /*l
971  *b Description:
972  **
973  ** This function will be called by DI-Guy when it is time for the
974  ** transformations of this link to be applied.
975  **
976  *i Immediate Mode:
977  **
978  ** Immediate mode renderers usually do override this function, to
979  ** apply transformations to the transformation stack.
980  **
981  *i Scene Graph:
982  **
983  ** Scene graph renderers usually do not override this function;
984  ** transformation states are handled automatically by scene graphs.
985  **
986  *b Callable From:
987  **
988  *- - N/A (automatically called by DI-Guy Graphics API during Draw Stage)
989  **
990  *e
991  *e //linear draw behavior
992  *e {
993  *e // push the base transform of the character in the world
994  *e // the get_transformation_matrix() of the position link
995  *e m_position_link->begin_character_draw();
996  *e int i;
997  *e for each link in link array
998  *e {
999  *e // note the ability to skip links with nothing attached to them
1000  *e if (link->get_num_shapes() > 0 || link->get_is_position_link())
1001  *e {
1002  *e // each link should multiply by the get_local_transformation_matrix
1003  *e // which contains the precalculated concatenated matrix
1004  *e link->draw();
1005  *e }
1006  *e }
1007  *e m_position_link->end_character_draw();
1008  */
1009 
1010  virtual void draw();
1011 
1012  /*l
1013  *b Description:
1014  **
1015  ** This function will be called by DI-Guy when it a shader should be
1016  ** bound to this link. This is important in some scene graph
1017  ** environments, when the scene graph is responsible for binding the
1018  ** shader.
1019  **
1020  *i Immediate Mode:
1021  **
1022  ** Immediate mode renderers usually do not override this function.
1023  **
1024  *i Scene Graph:
1025  **
1026  ** Scene graph renderers can override this function but some don't
1027  ** need to.
1028  **
1029  *b Callable From:
1030  **
1031  *- - N/A (automatically called by DI-Guy Graphics API during Build Stage)
1032  */
1033  virtual void set_shader_instance(diguyGraphicsShaderInstance* shader_instance);
1034 
1035  /*b Description:
1036  **
1037  ** This function will be called by DI-Guy in the update loop when the character
1038  ** changes instancing state. This allows additional work to be done to manage
1039  ** instancing. Note this hasn't been needed, for any of our sample implementations.
1040  */
1041  virtual void instancing_state_changed(int instanced);
1042 
1043  /*l
1044  *b Description:
1045  **
1046  ** This function will be called by DI-Guy while building instance groups (which occurs
1047  ** during diguyScenario::draw() or when manually invoked. It gives the user a chance to set
1048  ** the contents of the tbo on a per shape basis. tbo_data should be a 4x3 matrix.
1049  ** Will only be called if diguyScenario::set_instancing_position_callback_enabled() is set to true.
1050  */
1051  virtual void fill_out_tbo_position_matrix(diguyGraphicsShape * current_shape, float * tbo_data);
1052 
1053  /*l
1054  *b Description:
1055  **
1056  ** This function will be called by DI-Guy while building instance groups (which occurs
1057  ** during diguyScenario::draw() or when manually invoked. Will allow the end user to add additional
1058  ** data to the tbo. This is required to be in blocks of 4 floats. Will only be called if
1059  ** diguyScenario::set_num_extra_per_instance_data_floats(int number); is set to a reasonable number.
1060  */
1061  virtual void fill_out_tbo_additional_data(diguyGraphicsShape * current_shape, float * tbo_data);
1062 
1063 /****************************************************************************/
1068  /*l
1069  *b Description:
1070  **
1071  ** This function will be called by DI-Guy when the drawing of a new
1072  ** character is beginning. This happens when the position link is
1073  ** drawn.
1074  **
1075  *i Immediate Mode:
1076  **
1077  ** Immediate mode renderers can override this function. Typically
1078  ** some type of transformation matrix stack push operation is
1079  ** performed. This is also an appropriate place to do any
1080  ** per-character modifications, such as:
1081  **
1082  *- - applying scale
1083  *- - applying the base translation of the character
1084  *- - picking a current LOD
1085  *- - etc.
1086  **
1087  *i Scene Graph:
1088  **
1089  ** Scene graph renderers usually do not override this function;
1090  ** transformation states are handled automatically by scene graphs.
1091  **
1092  *b Callable From:
1093  **
1094  *- - N/A (automatically called by DI-Guy Graphics API during
1095  *- Draw Stage)
1096  */
1097  virtual void begin_character_draw();
1098 
1099  /*l
1100  *b Description:
1101  **
1102  ** This function will be called by DI-Guy when the drawing traversal
1103  ** of the character's link hierarchy has completed.
1104  **
1105  *i Immediate Mode:
1106  **
1107  ** Immediate mode renderers can override this function. Typically
1108  ** any matrix stack push operation done in begin_character_draw()
1109  ** is undone here by an appropriate pop operation.
1110  **
1111  *i Scene Graph:
1112  **
1113  ** Scene graph renderers usually do not override this function;
1114  ** transformation states are handled automatically by scene graphs.
1115  **
1116  *b Callable From:
1117  **
1118  *- - N/A (automatically called by DI-Guy Graphics API during
1119  *- Draw Stage)
1120  */
1121  virtual void end_character_draw();
1122 
1123 
1124 #endif
1125 
1126 
1127 
1128 /****************************************************************************/
1129 /****************************************************************************/
1136 /****************************************************************************/
1137 /****************************************************************************/
1138 
1140  int get_inverse_rotation_matrix(float matrix_array[4][4], int transpose = 0,
1141  int include_translation = 1);
1142 
1144  int get_inverse_rotation_matrix_4x4_ptr(float* matrix_array, int transpose = 0,
1145  int include_translation = 1);
1146 
1150  int get_approximate_bounding_box(float * bbox_min_x, float * bbox_min_y, float * bbox_min_z,
1151  float * bbox_max_x, float * bbox_max_y, float * bbox_max_z);
1152 
1153 /****************************************************************************/
1154 /****************************************************************************/
1165 /****************************************************************************/
1166 /****************************************************************************/
1167 /****************************************************************************/
1168 
1169  /*l
1170  *b Description:
1171  **
1172  ** Deprecated as of 9.1.4; use diguyGraphicsLink::get_is_position_link()
1173  ** instead.
1174  */
1175  int get_is_base_link();
1176 
1177  /*l
1178  *b Description:
1179  **
1180  ** Deprecated as of 12.0.0 due to architecture change
1181  */
1182  //int get_shader_matrix_index();
1183 
1184  //Deprecated as of 13.2.0 due to architecture change
1185  /*l
1186  *b Deprecated, we don't currently support scaling links
1187  **
1188  ** Returns in the passed variables the scale amount of the link's
1189  ** joint.
1190  **
1191  ** The values may or may not stay constant frame to frame; see
1192  ** get_scale_is_static().
1193  **
1194  ** Returned values unitless scale factors, and should be applied
1195  ** after the rotation.
1196  **
1197  *b Arguments:
1198  **
1199  *a sx, sy, sz - pointers to floats into which result
1200  *a should be placed
1201  **
1202  *b Returns:
1203  **
1204  ** 0 on success, -1 on failure
1205  */
1206  int get_scale(float* sz, float* sx, float* sy);
1207 
1208  /*l
1209  *b Description:
1210  **
1211  ** Returns whether the scale returned by get_scale() is static
1212  ** (unchanging) or dynamic (can change frame to frame).
1213  **
1214  ** If the scale is dynamic the scale values will come from one or
1215  ** more DI-Guy motion variables; the names of the variables are
1216  ** accessible using the functions get_var_name_sx(), etc.
1217  **
1218  ** If the scale is static it will remain so; the value returned by
1219  ** this function should not change frame to frame.
1220  **
1221  *b Returns:
1222  **
1223  ** 1 if scale is static, 0 if not, -1 on failure
1224  */
1225  int get_scale_is_static();
1226 
1227  /*l
1228  *b Description:
1229  **
1230  ** Returns the name of the DI-Guy motion data variable that controls
1231  ** scale in the Z dimension.
1232  **
1233  ** The returned pointer will be NULL if there is no associated
1234  ** variable.
1235  */
1236  const char* get_var_name_sx();
1238  /*l
1239  *b Description:
1240  **
1241  ** Returns the name of the DI-Guy motion data variable that controls
1242  ** scale in the Y dimension.
1243  **
1244  ** The returned pointer will be NULL if there is no associated
1245  ** variable.
1246  */
1247  const char* get_var_name_sy();
1248 
1249  /*l
1250  *b Description:
1251  **
1252  ** Returns the name of the DI-Guy motion data variable that controls
1253  ** scale in the X dimension.
1254  **
1255  ** The returned pointer will be NULL if there is no associated
1256  ** variable.
1257  */
1258  const char* get_var_name_sz();
1259 
1260  /*l
1261  *b Description:
1262  **
1263  ** Returns the index of this link's scale data in the float array
1264  ** returned by get_data_ptr() or get_quat_data_ptr(). The scale
1265  ** values are in (sx, sy, sz) order in the array.
1266  **
1267  ** This function may return -1, in which case this link has no scale
1268  ** data.
1269  **
1270  ** The index returned by this function will not change from frame to
1271  ** frame, and can therefore be saved once it has been obtained.
1272  **
1273  ** This function should not be used for the position link (when
1274  ** get_is_position_link() returns 1). Use get_scale() instead.
1275  **
1276  ** This function should not be called in a derived class's
1277  ** constructor; the index will not yet be valid.
1278  **
1279  *b Returns:
1280  **
1281  ** index into float array; -1 if no scale data for link
1282  */
1283  int get_scale_data_index();
1284 
1285 /****************************************************************************/
1286 /****************************************************************************/
1287 
1288  // These functions were removed since they are now always zero and their use
1289  // could lead to confusion. Links now only have translations and rotations,
1290  // those completely represent their offset from their parents
1291  //int get_offset_translation(float* tx, float* ty, float* tz);
1292 
1293  //int get_offset_rotation(float* rz, float* rx, float* ry);
1294 
1299 #ifdef CPLUSPLUS_ONLY
1300 
1301  bdiLink* get_scripted_object() {return m_scripted_object;}
1302 
1303 protected:
1304 
1305  /*l
1306  ** A protected constructor. Constructors are called automatically
1307  ** by DI-Guy.
1308  */
1309  diguyGraphicsLink(void* internal_data);
1310 
1311  /*l
1312  ** A protected destructor. Destructors are called automatically
1313  ** by DI-Guy.
1314  */
1315  virtual ~diguyGraphicsLink();
1316 
1317 private:
1318 
1319  /*l
1320  ** A pointer to internal data.
1321  */
1322  bdiLink* m_scripted_object;
1323 
1324  friend class bdiLink;
1325  friend class bdiGraphicsFactory;
1326 
1327 #endif
1328 
1329 };
1330 
1331 
1332 #endif /* __diguyGraphicsLink_H */
1333 
A class that represents the unique per-character shader object.
Definition: diguyGraphicsShaderInstance.h:55
diguyGraphicsJointType
DI-Guy graphics joint types.
Definition: diguy_constants.h:448
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:80
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:51