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