DI-Guy SDK Documentation  13.6
diguyChainSettings.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2022 MAK Technologies, Inc.
4  ** All rights reserved.
5  *********************************************************************/
6 
7 
8 /*********************************************************************
9  **
10  *t diguyChainSettings
11  **
12  */
13 
14 #ifndef __diguyChainSettings_H
15 #define __diguyChainSettings_H
16 
17 
18 #ifdef SWIG
19 %module diguyChainSettings
20 #else
21 #define CPLUSPLUS_ONLY
22 #endif
23 
24 #ifdef CPLUSPLUS_ONLY
25 class bdiScenarioChainSettings;
26 #endif
27 
28 
29 #include <declspec_diguy.h>
30 
36 class BDI_DECLSPEC_diguy diguyChainSettings
37 {
38 
39 public:
40 
41 /*****************************************************************************/
51  /*l
52  *b Returns:
53  **
54  ** name of this object; this value will never be NULL
55  */
56  const char* get_name();
57 
58  /*l
59  *b Description:
60  **
61  ** This function sets the name of this object.
62  **
63  *b Returns:
64  **
65  ** 0 on success, -1 on failure
66  */
67  int set_name(const char* name);
68 
69 
70 /*****************************************************************************/
76  /*l
77  *b Description:
78  **
79  ** This function sets how many masses will in a chain using these
80  ** settings.
81  **
82  ** The default is 80 masses.
83  **
84  *b Arguments:
85  **
86  *a num_masses - number of masses
87  */
88  void set_num_masses(int num_masses);
89 
90  /*l
91  *b Returns:
92  **
93  ** number of masses; see set_num_masses()
94  */
95  int get_num_masses();
96 
97  /*l
98  *b Description:
99  **
100  ** This function sets which chain mass will be connected to the
101  ** chain's associated character when a chain using these settings is
102  ** created or reset.
103  **
104  ** Pass -1 for no mass to be connected.
105  **
106  ** The default is chain mass 0.
107  **
108  *b Arguments:
109  **
110  *a chain_mass_index - index of chain mass
111  */
112  void set_index_of_chain_mass_connected_to_character(int chain_mass_index);
113 
114  /*l
115  *b Returns:
116  **
117  ** which mass to connect on reset; see
118  ** set_index_of_chain_mass_connected_to_character()
119  */
120  int get_index_of_chain_mass_connected_to_character();
121 
122  /*l
123  *b Description:
124  **
125  ** This function sets the dt of the chain simulation using these
126  ** settings.
127  **
128  ** Higher dt values will provide faster simulations at the risk of
129  ** instabilities. Conversely, lower dt values result in more
130  ** simulation computational overhead, but the simulation will be more
131  ** stable.
132  **
133  ** The default is 0.002 seconds.
134  **
135  *b Arguments:
136  **
137  *a simulation_dt - dt of each simulation time step, in seconds
138  */
139  void set_simulation_dt(float simulation_dt);
140 
141  /*l
142  *b Returns:
143  **
144  ** dt of chain simulation; see set_simulation_dt()
145  */
146  float get_simulation_dt();
147 
148  /*l
149  *b Description:
150  **
151  ** This function sets the mass of each chain mass of the chain
152  ** simulation using these settings.
153  **
154  ** Heavier mass will result in chain masses that have more momentum
155  ** when moving.
156  **
157  ** The default is 0.5 kg.
158  **
159  *b Arguments:
160  **
161  *a mass - mass of each chain mass, in kg
162  */
163  void set_mass(float mass);
164 
165  /*l
166  *b Returns:
167  **
168  ** mass of each chain mass; see set_mass()
169  */
170  float get_mass();
171 
172  /*l
173  *b Description:
174  **
175  ** This function sets the nominal length of the springs connecting
176  ** adjacent chain masses of the chain simulation using these
177  ** settings.
178  **
179  ** Adjacent chain masses will try to keep this distance between them.
180  ** A longer spring length will result in a longer chain.
181  **
182  ** The default is 0.2 meters
183  **
184  *b Arguments:
185  **
186  *a spring_length - nominal length between adjacent chain masses,
187  *a in meters
188  */
189  void set_spring_length(float spring_length);
190 
191  /*l
192  *b Returns:
193  **
194  ** nominal length between adjacent chain masses;
195  ** see set_spring_length()
196  */
197  float get_spring_length();
198 
199  /*l
200  *b Description:
201  **
202  ** This function sets the spring constant of the springs connecting
203  ** adjacent chain masses of the chain simulation using these
204  ** settings.
205  **
206  ** A higher spring constant will result in a more rigid chain, as
207  ** adjacent masses will try to maintain their nominal spring length
208  ** between them, as set by set_spring_length().
209  **
210  ** A hose would have a high spring constant, while a "slinky" would
211  ** have a low spring constant.
212  **
213  ** This spring constant only applies between adjacent masses.
214  **
215  ** The default is 10000.
216  **
217  *b Arguments:
218  **
219  *a spring_k - spring constant of springs between adjacent masses
220  */
221  void set_spring_k(float spring_k);
222 
223  /*l
224  *b Returns:
225  **
226  ** spring constant of springs between adjacent masses; see
227  ** set_spring_k()
228  */
229  float get_spring_k();
230 
231  /*l
232  *b Description:
233  **
234  ** This function sets the damping constant of the springs connecting
235  ** adjacent chain masses of the chain simulation using these
236  ** settings.
237  **
238  ** A higher damping constant will result in a chain that doesn't
239  ** oscillate as much; movement between masses will quickly die down.
240  **
241  ** A hose would have a high damping constant, while a "slinky" would
242  ** have a low damping constant.
243  **
244  ** The default is 15.
245  **
246  *b Arguments:
247  **
248  *a damping constant of springs between adjacent masses
249  */
250  void set_spring_b(float spring_b);
251 
252  /*l
253  *b Returns:
254  **
255  ** damping constant of springs between adjacent masses; see
256  ** set_spring_b()
257  */
258  float get_spring_b();
259 
260  /*l
261  *b Description:
262  **
263  ** This function sets the nominal length of the springs connecting
264  ** '2nd neighbor' chain masses of the chain simulation using these
265  ** settings.
266  **
267  ** 2nd neighbor chain masses are two masses apart instead of one.
268  ** (Adjacent masses are one mass apart.)
269  **
270  ** A longer 2nd neighbor spring length will result in a chain that is
271  ** stiffer and doesn't droop. A lower value will result in a chain
272  ** that can droop a lot from mass to mass.
273  **
274  ** A garden hose would have a high 2nd neighbor spring length, while
275  ** a metal chain made of linked chain links would have a low 2nd
276  ** neighbor spring length.
277  **
278  ** The default is 0.8 meters
279  **
280  *b Arguments:
281  **
282  *a spring_length - nominal length between adjacent chain masses,
283  *a in meters
284  */
285  void set_neighbor2_spring_length(float neighbor2_spring_length);
286 
287  /*l
288  *b Returns:
289  **
290  ** nominal distance between each mass and its '2nd neighbor'; see
291  ** set_neighbor2_spring_length()
292  */
293  float get_neighbor2_spring_length();
294 
295  /*l
296  *b Description:
297  **
298  ** This function sets the spring constant of springs connecting 2nd
299  ** neighbor chain masses of the chain simulation using these
300  ** settings.
301  **
302  ** See set_spring_k() for a discussion of what this value means.
303  **
304  ** The default is 600.
305  **
306  *b Arguments:
307  **
308  *a neighbor2_spring_k - spring constant of springs between
309  ** 2nd neighbor masses
310  */
311  void set_neighbor2_spring_k(float neighbor2_spring_k);
312 
313  /*l
314  *b Returns:
315  **
316  ** spring constant of springs between 2nd neighbor masses; see
317  ** set_neighbor2_spring_k()
318  */
319  float get_neighbor2_spring_k();
320 
321  /*l
322  *b Description:
323  **
324  ** This function sets the damping constant of springs connecting 2nd
325  ** neighbor chain masses of the chain simulation using these
326  ** settings.
327  **
328  ** See set_spring_b() for a discussion of what this value means.
329  **
330  ** The default is 5.
331  **
332  *b Arguments:
333  **
334  *a neighbor2_spring_b - damping constant of springs between
335  ** 2nd neighbor masses
336  */
337  void set_neighbor2_spring_b(float neighbor2_spring_b);
338 
339  /*l
340  *b Returns:
341  **
342  ** damping constant of springs between 2nd neighbor masses; see
343  ** set_neighbor2_spring_b()
344  */
345  float get_neighbor2_spring_b();
346 
347  /*l
348  *b Description:
349  **
350  ** This function sets the spring constant of the ground model.
351  **
352  ** A higher spring constant will result in a harder ground that
353  ** bounces chain masses higher when they come in contact with the
354  ** ground. Also, chain masses will not sink as far into the ground
355  ** when they come to rest.
356  **
357  ** A tile floor would have a high spring constant, while a mattress
358  ** would have a low spring constant.
359  **
360  ** The default is 5000.
361  **
362  *b Arguments:
363  **
364  *a ground_k - spring constant of ground model
365  */
366  void set_ground_k(float ground_k);
367 
368  /*l
369  *b Returns:
370  **
371  ** spring constant of ground model; see set_ground_k()
372  */
373  float get_ground_k();
374 
375  /*l
376  *b Description:
377  **
378  ** This function sets the damping constant of the ground model.
379  **
380  ** A higher damping constant will result in a ground that absorbs
381  ** impacts and doesn't bounce masses as much when they hit the
382  ** ground.
383  **
384  ** A tile floor would have a low damping constant, while an exercise
385  ** mat would have a high damping constant.
386  **
387  ** The default is 100.
388  **
389  *b Arguments:
390  **
391  *a ground_b - vertical damping constant of ground model
392  */
393  void set_ground_b(float ground_b);
394 
395  /*l
396  *b Returns:
397  **
398  ** vertical damping constant of ground model; see set_ground_b()
399  */
400  float get_ground_b();
401 
402  /*l
403  *b Description:
404  **
405  ** This function sets how much the ground model slows down masses
406  ** that are sliding on it.
407  **
408  ** A higher lateral damping constant will quickly slow down masses
409  ** sliding along the ground.
410  **
411  ** Dirt or grass ground would have a high lateral damping constant.
412  ** Ice would have a very low damping constant.
413  **
414  ** The default is 0.5.
415  **
416  *b Arguments:
417  **
418  *a ground_lateral_b - lateral damping constant of ground model
419  */
420  void set_ground_lateral_b(float ground_lateral_b);
421 
422  /*l
423  *b Returns:
424  **
425  ** lateral damping constant of ground model; see
426  ** set_ground_lateral_b()
427  */
428  float get_ground_lateral_b();
429 
430  /*l
431  *b Description:
432  **
433  ** This function sets how slow a mass in contact with the ground must
434  ** go in order for the mass to stop moving and "stick" to the ground.
435  ** This is a simple form of "stiction".
436  **
437  ** A mass will unstick if the force being applied to it exceeds the
438  ** stiction release force as set by
439  ** set_ground_stiction_release_force().
440  **
441  ** The default is 0.05 m/s.
442  **
443  *b Arguments:
444  **
445  *a ground_stiction_engage_vel - velocity at stiction will engage
446  */
447  void set_ground_stiction_engage_vel(float ground_stiction_engage_vel);
448 
449  /*l
450  *b Returns:
451  **
452  ** velocity at stiction will engage; see
453  ** set_ground_stiction_engage_vel()
454  */
455  float get_ground_stiction_engage_vel();
456 
457  /*l
458  *b Description:
459  **
460  ** This function sets how much force is required to cause a mass that
461  ** has stuck to the ground because of stiction to be released.
462  **
463  ** The default is 10 newtons.
464  **
465  *b Arguments:
466  **
467  *a ground_stiction_release_force - force at which masses will
468  *a release from stiction
469  */
470  void set_ground_stiction_release_force(float ground_stiction_release_force);
471 
472  /*l
473  *b Returns:
474  **
475  ** force at which masses will release from stiction; see
476  ** set_ground_stiction_release_force()
477  */
478  float get_ground_stiction_release_force();
479 
480  /*l
481  *b Description:
482  **
483  ** This function sets the height of the ground model. Chain masses
484  ** below this height will be repelled upward based on their mass and
485  ** the ground spring and damping constants.
486  **
487  ** Currently the ground is a level plane.
488  **
489  ** The default is 0 meters.
490  **
491  *b Arguments:
492  **
493  *a ground_height - height of the ground model, in meters
494  */
495  void set_ground_height(float ground_height);
496 
497  /*l
498  *b Returns:
499  **
500  ** height of the ground model; see set_ground_height()
501  */
502  float get_ground_height();
503 
504  /*l
505  *b Description:
506  **
507  ** This function sets the damping constant caused by air resistance.
508  **
509  ** A higher air damping constant will result in chains that don't
510  ** swing as much. A low air damping constant will result in chains
511  ** that swing freely for a long time.
512  **
513  ** Water would have a very high "air" damping constant. A clock
514  ** pendulum would have a very low air damping constant.
515  **
516  ** The default is 0.1.
517  **
518  *b Arguments:
519  **
520  *a air_b - damping constant of air, or air resistance
521  */
522  void set_air_b(float air_b);
523 
524  /*l
525  *b Returns:
526  **
527  ** damping constant of air; see set_air_b()
528  */
529  float get_air_b();
530 
531  /*l
532  *b Description:
533  **
534  ** This function sets how strongly link masses will be accelerated in
535  ** the gravity direction, typically downward.
536  **
537  ** The default is (0, 0, -9.8), in meters per second squared.
538  **
539  *b Arguments:
540  **
541  *a x, y, z - accelerations due to gravity
542  */
543  void set_gravity(float x, float y, float z);
544 
545  /*l
546  *b Returns:
547  **
548  ** x, y, and z components of gravity; see set_gravity()
549  */
550  void get_gravity(float* x, float* y, float* z);
551 
552 
553 /*****************************************************************************/
559  /*l
560  *b Description:
561  **
562  ** This function sets the radius of the chain visual.
563  **
564  ** The default is 0.05 meters.
565  **
566  *b Arguments:
567  **
568  *a radius - radius of chain visual, in meters
569  */
570  void set_radius(float radius);
571 
572  /*l
573  *b Returns:
574  **
575  ** radius of chain visual; see set_radius()
576  */
577  float get_radius();
578 
579  /*l
580  *b Description:
581  **
582  ** This function sets the ambient color of the chain visual. Passed
583  ** values should be between 0 and 1.
584  **
585  ** The default values are (0.4, 0.4, 0.4, 1).
586  **
587  *b Arguments:
588  **
589  *a r, g, b, a - red, green, blue, and alpha components
590  */
591  void set_ambient_color(float r, float g, float b, float a);
592 
593  /*l
594  *b Description:
595  **
596  ** This function gets the ambient color of the chain visual. Values
597  ** are returned via the passed pointers.
598  **
599  *b Arguments:
600  **
601  *a r, g, b, a - red, green, blue, and alpha components
602  */
603  void get_ambient_color(float* r, float* g, float* b, float* a);
604 
605  /*l
606  *b Description:
607  **
608  ** This function sets the diffuse color of the chain visual. Passed
609  ** values should be between 0 and 1.
610  **
611  ** The default values are (1, 1, 1, 1).
612  **
613  *b Arguments:
614  **
615  *a r, g, b, a - red, green, blue, and alpha components
616  */
617  void set_diffuse_color(float r, float g, float b, float a);
618 
619  /*l
620  *b Description:
621  **
622  ** This function gets the diffuse color of the chain visual. Values
623  ** are returned via the passed pointers.
624  **
625  *b Arguments:
626  **
627  *a r, g, b, a - red, green, blue, and alpha components
628  */
629  void get_diffuse_color(float* r, float* g, float* b, float* a);
630 
631  /*l
632  *b Description:
633  **
634  ** This function sets the specular color of the chain visual. Passed
635  ** values should be between 0 and 1.
636  **
637  ** The default values are (1, 1, 1, 1).
638  **
639  *b Arguments:
640  **
641  *a r, g, b, a - red, green, blue, and alpha components
642  */
643  void set_specular_color(float r, float g, float b, float a);
644 
645  /*l
646  *b Description:
647  **
648  ** This function gets the specular color of the chain visual. Values
649  ** are returned via the passed pointers.
650  **
651  *b Arguments:
652  **
653  *a r, g, b, a - red, green, blue, and alpha components
654  */
655  void get_specular_color(float* r, float* g, float* b, float* a);
656 
657  /*l
658  *b Description:
659  **
660  ** This function sets the shininess of the chain visual.
661  **
662  ** The default is 20.
663  **
664  *b Arguments:
665  **
666  *a shininess - the shininess of the chain visual
667  */
668  void set_shininess(float shininess);
669 
670  /*l
671  *b Returns:
672  **
673  ** the shininess of the chain visual; see set_shininess()
674  */
675  float get_shininess();
676 
677  /*l
678  *b Description:
679  **
680  ** This function sets the filename of the texture that will be used
681  ** for the chain visual.
682  **
683  ** Common textures are:
684  **
685  *- - "chain_link.rgba"
686  *- - "firefighter_hose2.rgb"
687  **
688  ** The default is "" (no texture).
689  **
690  *b Arguments:
691  **
692  *a texture_filename - filename of texture of chain visual
693  */
694  void set_texture_filename(const char* texture_filename);
695 
696  /*l
697  *b Returns:
698  **
699  ** filename of texture of chain visual; see set_texture_filename()
700  */
701  const char* get_texture_filename();
702 
703  /*l
704  *b Description:
705  **
706  ** This function sets how many times the texture will be repeated
707  ** along the length of the chain.
708  **
709  ** The default is 1 rep.
710  **
711  *b Arguments:
712  **
713  *a num_texture_repetitions - how many times texture will be
714  *a repeated on chain visual
715  */
716  void set_num_texture_repetitions(int num_texture_repetitions);
717 
718  /*l
719  *b Returns:
720  **
721  ** how many times texture will be repeated on chain visual; see
722  ** set_num_texture_repetitions()
723  */
724  int get_num_texture_repetitions();
725 
726  /*l
727  *b Description:
728  **
729  ** This function sets what the "cross section" of the chain visual
730  ** will be.
731  **
732  ** See the documentation for diguyChainCrossSection for information
733  ** on what the different cross sections mean.
734  **
735  ** The default is DIGUY_CHAIN_CROSS_SECTION_SQUARE.
736  **
737  *b Arguments:
738  **
739  *a cs - cross section of the chain visual
740  */
741  void set_cross_section(diguyChainCrossSection cs);
742 
743  /*l
744  *b Returns:
745  **
746  ** cross section type of chain visual; see set_cross_section()
747  */
748  diguyChainCrossSection get_cross_section();
749 
750  /*l
751  *b Description:
752  **
753  ** Set the shape that will be attached to the beginning end of the
754  ** chain. Options are:
755  **
756  *- - "chain_cap_firehose_nozzle"
757  *- - "chain_cap_fuel_hose_nozzle"
758  *- - "chain_cap_taser_probe"
759  *- - "chain_cap_chain_hook"
760  **
761  ** The default is "" (no begin cap).
762  **
763  *b Arguments:
764  **
765  *a appearance_begin_cap - name of begin cap
766  */
767  void set_appearance_begin_cap(const char* appearance_begin_cap);
768 
769  /*l
770  *b Returns:
771  **
772  ** name of cap appearance at beginning of chain; see
773  ** set_appearance_begin_cap()
774  */
775  const char* get_appearance_begin_cap();
776 
777  /*l
778  *b Description:
779  **
780  ** Sets the shape that will be attached to the end of the chain. See
781  ** set_appearance_begin_cap().
782  **
783  ** The default is "" (no end cap).
784  **
785  *b Arguments:
786  **
787  *a appearance_end_cap - name of end cap
788  */
789  void set_appearance_end_cap(const char* appearance_end_cap);
790 
791  /*l
792  *b Returns:
793  **
794  ** name of cap appearance at end of chain; see
795  ** set_appearance_end_cap()
796  */
797  const char* get_appearance_end_cap();
798 
799 
800 /*****************************************************************************/
806  /*l
807  *b Description:
808  **
809  ** For chains with the DIGUY_CHAIN_CROSS_SECTION_COIL cross section,
810  ** sets the number of coil windings of the chain.
811  **
812  ** The default is 4 coils.
813  **
814  *b Arguments:
815  **
816  *a num_coils - number of coil windings
817  */
818  void set_num_coils(int num_coils);
819 
820  /*l
821  *b Returns:
822  **
823  ** number of coils for chain visual of type
824  ** DIGUY_CHAIN_CROSS_SECTION_COIL; see set_num_coils()
825  */
826  int get_num_coils();
827 
828  /*l
829  *b Description:
830  **
831  ** Sets how thick the coil will be.
832  **
833  ** The default is 0.02 meters.
834  **
835  *b Arguments:
836  **
837  *a coil_thickness - thickness of coil
838  */
839  void set_coil_thickness(float coil_thickness);
840 
841  /*l
842  *b Returns:
843  **
844  ** thickness of coils for chain visual of type
845  ** DIGUY_CHAIN_CROSS_SECTION_COIL; see set_coil_thickness()
846  */
847  float get_coil_thickness();
848 
849  /*l
850  *b Description:
851  **
852  ** Sets at which mass in the coil the thickness of the coil will
853  ** reach its full radius.
854  **
855  ** The default is 6.
856  **
857  *b Arguments:
858  **
859  *a coil_taper_begin_mass_count - chain mass at which to begin taper
860  */
861  void set_coil_taper_begin_mass_count(int coil_taper_begin_mass_count);
862 
863  /*l
864  *b Returns:
865  **
866  ** mass at which the coil will reach its full radius at the beginning
867  ** of chain; see set_coil_taper_begin_mass_count()
868  */
869  int get_coil_taper_begin_mass_count();
870 
871  /*l
872  *b Description:
873  **
874  ** Similar to set_coil_taper_begin_mass_count(), but for the end of
875  ** the chain.
876  **
877  ** The default is 0.
878  **
879  *b Arguments:
880  **
881  *a coil_taper_end_mass_count - chain mass at which to end taper
882  */
883  void set_coil_taper_end_mass_count(int coil_taper_end_mass_count);
884 
885  /*l
886  *b Returns:
887  **
888  ** mass at which the coil will reach its full radius at end of chain;
889  ** see set_coil_taper_end_mass_count()
890  */
891  int get_coil_taper_end_mass_count();
892 
897 #ifdef CPLUSPLUS_ONLY
898 
899  bdiScenarioChainSettings* get_scripted_object() {return m_scripted_object;}
900 
901 private:
902 
903  /*l
904  ** A private constructor.
905  */
906  diguyChainSettings(bdiScenarioChainSettings* scripted_object);
907 
908  /*l
909  ** A private destructor.
910  */
912 
913  /*l
914  ** A pointer to internal data.
915  */
916  bdiScenarioChainSettings* m_scripted_object;
917 
918  friend class bdiScenarioChainSettings;
919 
920 #endif
921 
922 };
923 
924 
925 #endif /* __diguyChainSettings_H */
926 
927 
928 /*********************************************************************
929  ** Copyright (c) 1992-2022 MAK Technologies, Inc.
930  ** All rights reserved.
931  *********************************************************************/
932 
chain settings.. Rarely used
Definition: diguyChainSettings.h:32
diguyChainCrossSection
This enumeration lists which cross-sections are available for DI-Guy chain simulation visuals...
Definition: diguy_constants.h:821