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