1 /*
2
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 */
19 // Here is the bridge routine for maintenance and upkeep of death...
20 // =================================================================
21
22 /*
23 * WARNING
24 * This file is not used by Shockolate anymore and left here for historical purpose.
25 */
26
27 ////#include <conio.h>
28 #include "fixpp.h"
29 #include "edms_int.h"
30
31
32
33 //#ifdef EDMS_SHIPPABLE
34 ////#include <mout.h>
35 //#endif
36
37
38
39 // Here we need include files for each and every model that we'll be using...
40 // ==========================================================================
41 #include "death.h"
42
43
44 // The physics handles definitions...
45 // ==================================
46 #include "physhand.h"
47
48 // Pointers to skeletons (for bipeds, as it were and will be)...
49 // =============================================================
50 extern Q *utility_pointer[MAX_OBJ];
51
52 // Death...
53 // --------
54 typedef struct {
55
56 fix mass,
57 size,
58 gravity,
59 drag;
60
61 } Death;
62
63
64
65
66 // We need to link to c...
67 // =======================
68 extern "C" {
69
70
71
72
73
74 // Here are the bridge routines to the models...
75 // =============================================
76
77
78
79
80
81
82 // Utility routines...
83 // ===================
EDMS_make_death(Death * d,State * s)84 physics_handle EDMS_make_death( Death *d, State *s ) {
85
86
87 Q params[10],
88 init_state[6][3];
89
90 Q mass,
91 size,
92 gravity,
93 drag;
94
95 int on = 0;
96
97 physics_handle ph = 0;
98
99 init_state[0][0].fix_to( s->X ); init_state[0][1].fix_to( s->X_dot );
100 init_state[1][0].fix_to( s->Y ); init_state[1][1].fix_to( s->Y_dot );
101 init_state[2][0].fix_to( s->Z ); init_state[2][1].fix_to( s->Z_dot );
102
103 mass.fix_to( d -> mass );
104 size.fix_to( d -> size );
105 // if ( size > .45/hash_scale ) size = .45/hash_scale;
106 gravity.fix_to( d -> gravity );
107 drag.fix_to (d->drag);
108
109 params[0] = mass;
110 params[1] = 1/mass;
111 params[2] = 0;
112 params[3] = 0;
113 params[4] = 0;
114 params[5] = drag * 2 * size;
115 params[6] = gravity;
116 params[7] = size;
117 params[8] =
118 params[9] = END;
119
120
121 on = make_death( init_state, params );
122 ph = EDMS_bind_object_number( on );
123
124 return ph;
125
126 }
127
128
129
130
131 // Utilities for the weak spirited...
132 // ==================================
EDMS_set_death_parameters(physics_handle ph,Death * d)133 void EDMS_set_death_parameters( physics_handle ph, Death *d )
134 {
135 Q mass,
136 size,
137 gravity,
138 drag;
139
140 mass.fix_to( d -> mass );
141 size.fix_to( d -> size );
142 gravity.fix_to( d -> gravity );
143 drag.fix_to (d->drag);
144
145 int on = physics_handle_to_object_number( ph );
146
147 I[on][20] = mass;
148 I[on][21] = 1/mass;
149 I[on][22] = 0;
150 I[on][23] = 0;
151 I[on][24] = 0;
152 I[on][25] = drag*2*size;
153 I[on][26] = gravity;
154 I[on][27] = size;
155 I[on][28] =
156 I[on][29] = END;
157
158
159 }
160
161
162
163 // And the weak minded...
164 // ======================
EDMS_get_death_parameters(physics_handle ph,Death * d)165 void EDMS_get_death_parameters( physics_handle ph, Death *d )
166 {
167 int on = physics_handle_to_object_number( ph );
168
169 d -> size = (I[on][27]).to_fix();
170 d -> mass = I[on][20].to_fix();
171 d -> gravity = I[on][26].to_fix();
172 d -> drag = (I[on][25] / (I[on][27] * 2)).to_fix();
173 }
174
175
176
177 } //End of extern "C" for the &^%$@% compiler...
178
179