DI-Guy SDK Documentation  13.2
diguyChainSimulation.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2016 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 
8 /*********************************************************************
9  **
10  *t diguyChainSimulation
11  **
12  */
13 
14 #ifndef __diguyChainSimulation_H
15 #define __diguyChainSimulation_H
16 
17 
18 #ifdef SWIG
20 #else
21 #define CPLUSPLUS_ONLY
22 #endif
23 
24 #ifdef CPLUSPLUS_ONLY
25 class bdiScenarioChain;
26 class bdiScenarioChainSettings;
27 class diguyChainSettings;
28 class diguyPathShape;
29 #endif
30 
31 
32 #include <declspec_diguy.h>
33 
39 class BDI_DECLSPEC_diguy diguyChainSimulation
40 {
41 public:
51  /*l
52  *b Description:
53  **
54  ** This function returns the chain settings this chain simulation is
55  ** using.
56  **
57  *b Returns:
58  **
59  ** object of type diguyChainSettings; will never be NULL
60  */
61  diguyChainSettings* get_settings();
62 
63  /*l
64  *b Description:
65  **
66  ** This function sets the settings this chain simulation will use.
67  **
68  *b Arguments:
69  **
70  *a settings - name of new settings to use
71  **
72  *b Returns:
73  **
74  ** 0 on success, -1 on failure
75  */
76  int update_settings(const char* settings);
77 
78  /*l
79  *b Description:
80  **
81  ** This function runs the simulation forward the specified number of
82  ** seconds, to let the chain settle into a stable configuration.
83  **
84  ** Note that the chain will appear to achieve the new configuration
85  ** instantly.
86  **
87  ** Specifying a large amount of time can result in a frame rate
88  ** hitch.
89  **
90  *b Arguments:
91  **
92  *a time_runoff - how much time to run off, in seconds
93  **
94  *b Returns:
95  **
96  ** 0 on success, -1 on failure
97  */
98  int do_stabilization_time_runoff(float time_runoff);
99 
100  /*l
101  *b Description:
102  **
103  ** This function can 'freeze' or 'unfreeze' a chain.
104  **
105  ** If a chain is frozen, all chain masses will remain in their
106  ** current positions and will not move until the chain is unfrozen.
107  **
108  ** A frozen chain requires no simulation time.
109  **
110  *b Arguments:
111  **
112  *a is_frozen - pass 1 to freeze the chain; 0 to unfreeze
113  */
114  void set_is_frozen(int is_frozen);
115 
116  /*l
117  *b Returns:
118  **
119  ** 1 if chain is frozen, 0 if not
120  */
121  int get_is_frozen();
122 
123  /*l
124  *b Description:
125  **
126  ** This function connects a chain mass to a character, or disconnects
127  ** a chain mass if the passed character_name is NULL.
128  **
129  ** As the character moves the chain mass will move with it, dragging
130  ** adjacent masses along. This allows a firefighter to pick up one
131  ** end of a hose and drag the hose to a new location, for example.
132  **
133  ** In each time-step of the scenario a new position for the specified
134  ** chain mass will be computed based on the position of the
135  ** character.
136  **
137  ** When the chain sim is created, and when the scenario is reset, one
138  ** chain mass will be automatically connected to the chain's
139  ** character. The index of the mass that will be connected is set by
140  ** a call to
141  ** diguyChainSettings::set_index_of_chain_mass_connected_to_character().
142  **
143  ** Chain masses can be connected to a specific link of the connection
144  ** character by passing the link's name. If NULL is passed, the
145  ** connection will be made to the character's "position" link. Note
146  ** that a non-NULL link name must be used for the link offset
147  ** arguments to have an effect.
148  **
149  ** The chain mass can gradually be shifted from its current position
150  ** to the connection position using the connection_smoothing_period
151  ** argument. Passing in 0.5, for example, will cause the link to
152  ** shift to its new connection point within approximately 0.5
153  ** seconds, avoiding an abrupt and potentially ugly impulse to the
154  ** simulation.
155  **
156  *b Arguments:
157  **
158  *a chain_mass_index - index of chain mass
159  *a character_name - name of character to attach to; must not be NULL
160  *a link_name - name of link to attach to; can be NULL; if
161  *a so, will attach to character's base position
162  *a link_offset_x - link attachment offset in X
163  *a link_offset_y - link attachment offset in Y
164  *a link_offset_z - link attachment offset in Z
165  *a connection_smoothing_period - how much time to take, in seconds,
166  *a to gradually shift the chain mass
167  *a to its new connection point
168  **
169  *b Returns:
170  **
171  ** 0 on success, -1 on failure
172  */
173  int set_chain_mass_connection_character(int chain_mass_index,
174  const char* character_name,
175  const char* link_name = NULL,
176  float link_offset_x = 0.0f,
177  float link_offset_y = 0.0f,
178  float link_offset_z = 0.0f,
179  float connection_smoothing_period = 0.1f);
180 
181  /*l
182  *b Description:
183  **
184  ** This function sets the position of one chain mass, and optionally
185  ** fixes it there.
186  **
187  ** The passed position is always relative to the chain character's
188  ** parent, if there is one.
189  **
190  ** If the fix_mass_position argument is 1, the chain mass will remain
191  ** fixed in the new position, as if
192  ** set_chain_mass_position_is_fixed(1) were called.
193  **
194  *b Arguments:
195  **
196  *a chain_mass_index - index of chain mass; pass -1 to
197  *a affect all chain masses
198  *a mass_x - position x
199  *a mass_y - position y
200  *a mass_z - position z
201  *a fix_mass_position - pass 1 to fix chain mass in place;
202  *a 0 to leave it free to move
203  **
204  *b Returns:
205  **
206  ** 0 on success, -1 on failure
207  */
208  int set_chain_mass_position(int chain_mass_index,
209  float mass_x,
210  float mass_y,
211  float mass_z,
212  int fix_mass_position);
213 
214  /*l
215  *b Description:
216  **
217  ** This function sets the positions of all chain masses to lie along
218  ** the passed path shape.
219  **
220  ** If the stretch_to_fit argument is 1, chain masses will be spaced
221  ** along the entire length of the path shape. If the path shape is
222  ** longer than the nominal length of the chain, the chain will be
223  ** stretched out. If the path shape is shorter, the chain will be
224  ** compressed.
225  **
226  *b Arguments:
227  **
228  *a path_shape - path shape for new chain mass positions
229  *a stretch_to_fit - pass 1 to stretch chain to take up entire
230  *a length of path_shape; pass 0 to leave
231  *a chain at its nominal length
232  **
233  *b Returns:
234  **
235  ** 0 on success, -1 on failure
236  */
237  int set_chain_mass_positions_along_path_shape(diguyPathShape* path_shape,
238  int stretch_to_fit = 1);
239 
240  /*l
241  *b Description:
242  **
243  ** This function can fix or unfix a chain mass in place. If it is
244  ** fixed the chain mass will remain in its current position until it
245  ** is unfixed.
246  **
247  ** Fixed chain masses do not require simulation time, so the more
248  ** masses in a chain that are fixed, the lower the computational load
249  ** of the chain simulation.
250  **
251  *b Arguments:
252  **
253  *a chain_mass_index - index of chain mass; pass -1 to
254  *a affect all chain masses
255  *a is_fixed - pass 1 to fix chain mass position;
256  *a 0 to unfix it
257  **
258  *b Returns:
259  **
260  ** 0 on success, -1 on failure
261  */
262  int set_chain_mass_position_is_fixed(int chain_mass_index,
263  int is_fixed);
265  /*l
266  *b Returns:
267  **
268  ** 1 if chain mass is fixed, 0 if not
269  */
270  int get_chain_mass_position_is_fixed(int mass_index);
271 
272  /*l
273  *b Returns:
274  **
275  ** length of the chain
276  */
277  float get_length();
278 
279 
284 #ifdef CPLUSPLUS_ONLY
285 
286  bdiScenarioChain* get_scripted_object() {return m_scripted_object;}
287 
288 private:
289 
290  /*l
291  ** A private constructor.
292  */
293  diguyChainSimulation(bdiScenarioChain* scripted_object);
294 
295  /*l
296  ** A private destructor.
297  */
299 
300  /*l
301  ** A pointer to internal data.
302  */
303  bdiScenarioChain* m_scripted_object;
304 
305  friend class bdiScenarioChain;
306 
307 #endif
308 
309 };
310 
311 
312 #endif /* __diguyChainSimulation_H */
313 
314 
315 /*********************************************************************
316  ** Copyright (c) 1992-2016 VT MAK
317  ** All rights reserved.
318  *********************************************************************/
319 
wrapper around a chain simulation
Definition: diguyChainSimulation.h:35
Definition: diguyPathShape.h:30
chain settings.. Rarely used
Definition: diguyChainSettings.h:32