DI-Guy SDK Documentation  13.7
diguyGraphicsLink.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2023 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 /*********************************************************************/
13 #pragma once
14 
15 #ifdef SWIG
16 %module diguyGraphicsLink
17 #else
18 #define CPLUSPLUS_ONLY
19 #endif
20 
21 #ifdef CPLUSPLUS_ONLY
22 #include <diguy_constants.h>
23 
24 class bdiLink;
25 class diguyCharacter;
26 class diguyGraphicsLink;
27 class diguyGraphicsShape;
29 
30 
31 #endif
32 
33 #include <declspec_diguy.h>
34 
35 //------------------------------------------------------------------------------
47 class BDI_DECLSPEC_diguy diguyGraphicsLink
48 {
49 
50 public:
51 
52 /*****************************************************************************/
65  /*l
66  *b Description:
67  **
68  ** Returns the name of the link. This pointer will never be NULL.
69  **
70  *b Returns:
71  **
72  ** name of the link
73  */
74  const char* get_name();
75 
76  /*l
77  *b Description:
78  **
79  ** All links are assigned a unique identifier, or uid. This
80  ** function returns this links's uid.
81  **
82  ** *Note*: unique identifiers will change between DI-Guy runs!
83  **
84  *b Returns:
85  **
86  ** unique identifier of object
87  */
88  long get_uid();
89 
90  /*l
91  *b Returns:
92  **
93  ** index of the link
94  */
95  int get_index();
96 
97  /*l
98  *b Description:
99  **
100  ** Returns a pointer to the diguyCharacter to which this link belongs.
101  */
102  diguyCharacter* get_character();
103 
104  /*l
105  *b Returns:
106  **
107  ** number of shapes on this link
108  */
109  int get_num_shapes();
110 
111  /*l
112  *b Returns:
113  **
114  ** pointer of type diguyGraphicsShape; NULL if no shape at the
115  ** specified index
116  **
117  *b Arguments:
118  **
119  *a index - index of the shape; indices start at 0
120  */
121  diguyGraphicsShape* get_shape_at_index(int index);
122 
123  /*l
124  *b Description:
125  **
126  ** This function returns a pointer to the specified shape.
127  **
128  *b Arguments:
129  **
130  *a name - name of link to be found
131  **
132  *b Returns:
133  **
134  ** pointer of type diguyGraphicsShape; NULL if not found
135  */
136  diguyGraphicsShape* find_shape(const char* name);
137 
138  /*l
139  *b Description:
140  **
141  ** This function returns a pointer to the specified shape.
142  **
143  *b Arguments:
144  **
145  *a name - name of shape with class_type to be found,
146  *a currently works with heads
147  **
148  *b Returns:
149  **
150  ** pointer of type diguyGraphicsShape; NULL if not found
151  */
152  diguyGraphicsShape* find_shape_by_class_type(const char* name);
153 
154  /*l
155  *b Description:
156  **
157  ** This function overrides the motion data driving the visibility child shapes
158  **
159  *b Arguments:
160  **
161  *a switch_name - the name of the motion data stream that controls the visibility
162  *a of a child shape, see also get_switch_var_name(), set to -1 to
163  *a allow the underlying motion data to resume control
164  **
165  */
166  void set_shape_switch_override(const char * switch_name, int value);
167 
168  /*l
169  *b Description:
170  **
171  ** Returns the type of joint that attaches this link to its parent.
172  **
173  *b Returns:
174  **
175  ** joint type of the link
176  */
177  diguyGraphicsJointType get_joint_type();
178 
179  /*l
180  *b Description:
181  **
182  ** Returns in the passed variables the translation amount of the
183  ** link's joint.
184  **
185  ** If there is a current render camera set, the position link's
186  ** values will be in the local space of the camera. This is useful
187  ** for rendering far from the origin.
188  **
189  ** The values may or may not stay constant frame to frame; see
190  ** get_translation_is_static().
191  **
192  ** Returned values are in meters, and should be applied after the
193  ** rotational offset (if any).
194  **
195  *b Arguments:
196  **
197  *a tx, ty, tz - pointers to floats into which result should be placed
198  **
199  *b Returns:
200  **
201  ** 0 on success, -1 on failure
202  */
203  int get_translation(float* tx, float* ty, float* tz);
204 
205  /*l
206  *b Description:
207  **
208  ** Returns in the passed variables the translation amount of the
209  ** link's joint.
210  **
211  ** The values may or may not stay constant frame to frame; see
212  ** get_translation_is_static().
213  **
214  ** Returned values are in meters, and should be applied after the
215  ** rotational offset (if any).
216  **
217  *b Arguments:
218  **
219  *a tx, ty, tz - pointers to doubles into which result
220  *a should be placed
221  **
222  *b Returns:
223  **
224  ** 0 on success, -1 on failure
225  */
226  int get_translation_double(double* tx, double* ty, double* tz);
227 
228  /*l
229  *b Description:
230  **
231  ** Returns whether the translation returned by get_translation() is
232  ** static (unchanging) or dynamic (can change frame to frame).
233  **
234  ** If the translation is dynamic the translation values will come
235  ** from one or more DI-Guy motion variables; the names of the
236  ** variables are accessible using the functions get_var_name_tx(),
237  ** etc.
238  **
239  ** If the translation is static it will remain so; the value returned
240  ** by this function should not change frame to frame.
241  **
242  *b Returns:
243  **
244  ** 1 if translation is static, 0 if not, -1 on failure
245  */
246  int get_translation_is_static();
247 
248 
249  /*l
250  *b Description:
251  **
252  ** Returns in the passed variables the initial translation amount of the
253  ** link's joint.
254  **
255  ** This value is static and typically represents the offset to the parent link
256  **
257  ** Returned values are in meters
258  **
259  *b Arguments:
260  **
261  *a tx, ty, tz - pointers to floats into which result should be placed
262  **
263  *b Returns:
264  **
265  ** 0 on success, -1 on failure
266  */
267  int get_initial_translation(float* tx, float* ty, float* tz);
268 
269  /*l
270  *b Description:
271  **
272  ** Returns the name of the DI-Guy motion data variable that controls
273  ** translation along the X axis.
274  **
275  ** The returned pointer will be NULL if there is no associated variable.
276  **
277  *b Returns:
278  **
279  ** name of the variable; NULL if there is no variable
280  */
281  const char* get_var_name_tx();
282 
283  /*l
284  *b Description:
285  **
286  ** Returns the name of the DI-Guy motion data variable that controls
287  ** translation along the Y axis.
288  **
289  ** The returned pointer will be NULL if there is no associated variable.
290  **
291  *b Returns:
292  **
293  ** name of the variable; NULL if there is no variable
294  */
295  const char* get_var_name_ty();
296 
297  /*l
298  *b Description:
299  **
300  ** Returns the name of the DI-Guy motion data variable that controls
301  ** translation along the Z axis.
302  **
303  ** The returned pointer will be NULL if there is no associated variable.
304  **
305  *b Returns:
306  **
307  ** name of the variable; NULL if there is no variable
308  */
309  const char* get_var_name_tz();
310 
311  /*l
312  *b Description:
313  **
314  ** Returns in the passed variables the rotation amount of the link's
315  ** joint.
316  **
317  ** The values may or may not stay constant frame to frame; see
318  ** get_rotation_is_static().
319  **
320  ** Returned values are an Euler triple in degrees, and should be
321  ** applied in RZ -> RX -> RY order, after the translation.
322  **
323  *b Arguments:
324  **
325  *a rz, rx, ry - pointers to floats into which result
326  *a should be placed
327  **
328  *b Returns:
329  **
330  ** 0 on success, -1 on failure
331  */
332  int get_rotation(float* rz, float* rx, float* ry);
333 
334  /*l
335  *b Description:
336  **
337  ** Returns in the passed variables the rotation amount of the link's
338  ** joint.
339  **
340  ** The values may or may not stay constant frame to frame; see
341  ** get_rotation_is_static().
342  **
343  ** Returned values are an Euler triple in degrees, and should be
344  ** applied in RZ -> RX -> RY order, after the translation.
345  **
346  *b Arguments:
347  **
348  *a rz, rx, ry - pointers to floats into which result
349  *a should be placed
350  **
351  *b Returns:
352  **
353  ** 0 on success, -1 on failure
354  */
355  int get_rotation_euler(float* rz, float* rx, float* ry);
356 
357  /*l
358  *b Description:
359  **
360  ** Returns in the passed variables the rotation amount of the link's
361  ** joint.
362  **
363  ** The values may or may not stay constant frame to frame; see
364  ** get_rotation_is_static().
365  **
366  ** Returned values are a quaternion and should be applied after
367  ** the translation.
368  **
369  *b Arguments:
370  **
371  *a qx, qy, qz, qw - pointers to floats into which result
372  *a should be placed
373  **
374  *b Returns:
375  **
376  ** 0 on success, -1 on failure
377  */
378  int get_rotation_quat(float* qx, float* qy, float* qz, float* qw);
379 
380  /*l
381  *b Description:
382  **
383  ** Returns whether the rotation returned by get_rotation() is static
384  ** (unchanging) or dynamic (can change frame to frame).
385  **
386  ** If the rotation is dynamic the rotation values will come from one
387  ** or more DI-Guy motion variables; the names of the variables are
388  ** accessible using the functions get_var_name_rz(), etc.
389  **
390  ** If the rotation is static it will remain so; the value returned by
391  ** this function should not change frame to frame.
392  **
393  *b Returns:
394  **
395  ** 1 if rotation is static, 0 if not, -1 on failure
396  */
397  int get_rotation_is_static();
398 
399  /*l
400  *b Description:
401  **
402  ** Returns the name of the DI-Guy motion data variable that controls
403  ** rotation about the Z axis.
404  **
405  ** The returned pointer will be NULL if there is no associated
406  ** variable.
407  */
408  const char* get_var_name_rz();
409 
410  /*l
411  *b Description:
412  **
413  ** Returns the name of the DI-Guy motion data variable that controls
414  ** rotation about the X axis.
415  **
416  ** The returned pointer will be NULL if there is no associated
417  ** variable.
418  */
419  const char* get_var_name_rx();
420 
421  /*l
422  *b Description:
423  **
424  ** Returns the name of the DI-Guy motion data variable that controls
425  ** rotation about the Y axis.
426  **
427  ** The returned pointer will be NULL if there is no associated
428  ** variable.
429  */
430  const char* get_var_name_ry();
431 
432 
433  /*l
434  *b Description:
435  **
436  ** Returns a pointer to this link's parent link. Parent links are
437  ** always links within the same character. If a link is attached to
438  ** a link in another character (i.e., it is "parented to" another
439  ** link), that link pointer can be obtained by calling
440  ** get_attached_to_link().
441  **
442  ** The returned pointer will be NULL if the link is the position link
443  ** and has no parent.
444  **
445  *b Returns:
446  **
447  ** object of type diguyGraphicsLink
448  */
449  diguyGraphicsLink* get_parent_link();
450 
451  /*l
452  *b Description:
453  **
454  ** Returns a pointer to this character's base position link.
455  */
456  diguyGraphicsLink* get_position_link();
457 
458  diguyGraphicsLink* get_position_link() const;
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, int lod, float * tbo_data) const;
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();
1237 
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  void set_selected(bool value);
1288  bool get_selected();
1289 
1290  // These functions were removed since they are now always zero and their use
1291  // could lead to confusion. Links now only have translations and rotations,
1292  // those completely represent their offset from their parents
1293  //int get_offset_translation(float* tx, float* ty, float* tz);
1294 
1295  //int get_offset_rotation(float* rz, float* rx, float* ry);
1296 
1301 #ifdef CPLUSPLUS_ONLY
1302 
1303  bdiLink* get_scripted_object() {return m_scripted_object;}
1304 
1305 protected:
1306 
1307  /*l
1308  ** A protected constructor. Constructors are called automatically
1309  ** by DI-Guy.
1310  */
1311  diguyGraphicsLink(void* internal_data);
1312 
1313  /*l
1314  ** A protected destructor. Destructors are called automatically
1315  ** by DI-Guy.
1316  */
1317  virtual ~diguyGraphicsLink();
1318 
1319 private:
1320 
1321  /*l
1322  ** A pointer to internal data.
1323  */
1324  bdiLink* m_scripted_object;
1325 
1326  friend class bdiLink;
1327  friend class bdiGraphicsFactory;
1328 
1329 #endif
1330 
1331 };
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:81
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:49