From 8898ad9b25fca6afe2374d293a981db02a83d7e9 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 31 May 2012 14:46:27 +0000 Subject: Committing the documentation to svn to have it accessible online --- Doc/doxygen/html/_landing_gear_8cpp_source.html | 396 ++++++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 Doc/doxygen/html/_landing_gear_8cpp_source.html (limited to 'Doc/doxygen/html/_landing_gear_8cpp_source.html') diff --git a/Doc/doxygen/html/_landing_gear_8cpp_source.html b/Doc/doxygen/html/_landing_gear_8cpp_source.html new file mode 100644 index 0000000..c34f2b4 --- /dev/null +++ b/Doc/doxygen/html/_landing_gear_8cpp_source.html @@ -0,0 +1,396 @@ + + + + + +Starshatter_Open: D:/SRC/StarshatterSVN/Stars45/LandingGear.cpp Source File + + + + + + + + + + + + + +
+
+ + + + + + +
+
Starshatter_Open +
+
Open source Starshatter engine
+
+
+ + + + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
LandingGear.cpp
+
+
+Go to the documentation of this file.
1 /* Project Starshatter 4.5
+
2  Destroyer Studios LLC
+
3  Copyright © 1997-2004. All Rights Reserved.
+
4 
+
5  SUBSYSTEM: Stars.exe
+
6  FILE: LandingGear.cpp
+
7  AUTHOR: John DiCamillo
+
8 
+
9 
+
10  OVERVIEW
+
11  ========
+
12  LandingGear System class
+
13 */
+
14 
+
15 #include "MemDebug.h"
+
16 #include "LandingGear.h"
+
17 #include "Ship.h"
+
18 #include "Sim.h"
+
19 #include "AudioConfig.h"
+
20 
+
21 #include "DataLoader.h"
+
22 #include "Physical.h"
+
23 #include "Scene.h"
+
24 #include "Sound.h"
+
25 #include "Game.h"
+
26 
+
27 static Sound* gear_transit_sound = 0;
+
28 
+
29 // +----------------------------------------------------------------------+
+
30 
+ +
32 : System(MISC_SYSTEM, 0, "Landing Gear", 1, 1, 1, 1),
+
33 state(GEAR_UP), transit(0), ngear(0), clearance(0)
+
34 {
+
35  name = Game::GetText("sys.landing-gear");
+
36  abrv = Game::GetText("sys.landing-gear.abrv");
+
37 
+
38  for (int i = 0; i < MAX_GEAR; i++) {
+
39  models[i] = 0;
+
40  gear[i] = 0;
+
41  }
+
42 }
+
43 
+
44 // +----------------------------------------------------------------------+
+
45 
+ +
47 : System(g), state(GEAR_UP), transit(0), ngear(g.ngear), clearance(0)
+
48 {
+
49  Mount(g);
+ +
51  int i;
+
52 
+
53  for (i = 0; i < ngear; i++) {
+
54  models[i] = 0;
+
55  gear[i] = new(__FILE__,__LINE__) Solid;
+
56  start[i] = g.start[i];
+
57  end[i] = g.end[i];
+
58 
+
59  gear[i]->UseModel(g.models[i]);
+
60 
+
61  if (clearance > end[i].y)
+
62  clearance = end[i].y;
+
63  }
+
64 
+
65  while (i < MAX_GEAR) {
+
66  models[i] = 0;
+
67  gear[i] = 0;
+
68  i++;
+
69  }
+
70 
+ +
72 }
+
73 
+
74 // +--------------------------------------------------------------------+
+
75 
+ +
77 {
+
78  for (int i = 0; i < MAX_GEAR; i++) {
+
79  delete models[i];
+
80 
+
81  if (gear[i]) {
+
82  Solid* g = gear[i];
+
83 
+
84  if (g->GetScene())
+
85  g->GetScene()->DelGraphic(g);
+
86  delete g;
+
87  }
+
88  }
+
89 }
+
90 
+
91 // +--------------------------------------------------------------------+
+
92 
+
93 void
+ +
95 {
+
96  if (!gear_transit_sound) {
+ +
98  loader->SetDataPath("Sounds/");
+
99  loader->LoadSound("GearTransit.wav", gear_transit_sound);
+
100  }
+
101 }
+
102 
+
103 // +--------------------------------------------------------------------+
+
104 
+
105 void
+ +
107 {
+
108  delete gear_transit_sound;
+
109  gear_transit_sound = 0;
+
110 }
+
111 
+
112 // +--------------------------------------------------------------------+
+
113 
+
114 int
+
115 LandingGear::AddGear(Model* m, const Point& s, const Point& e)
+
116 {
+
117  if (ngear < MAX_GEAR) {
+
118  models[ngear] = m;
+
119  start[ngear] = s;
+
120  end[ngear] = e;
+
121 
+
122  ngear++;
+
123  }
+
124 
+
125  return ngear;
+
126 }
+
127 
+
128 // +--------------------------------------------------------------------+
+
129 
+
130 void
+ +
132 {
+
133  if (state != s) {
+
134  state = s;
+
135 
+
136  if (ship && ship == Sim::GetSim()->GetPlayerShip()) {
+
137  if (state == GEAR_LOWER || state == GEAR_RAISE) {
+
138  if (gear_transit_sound) {
+
139  Sound* sound = gear_transit_sound->Duplicate();
+ +
141  sound->Play();
+
142  }
+
143  }
+
144  }
+
145  }
+
146 }
+
147 
+
148 // +--------------------------------------------------------------------+
+
149 
+
150 void
+
151 LandingGear::ExecFrame(double seconds)
+
152 {
+
153  System::ExecFrame(seconds);
+
154 
+
155  switch (state) {
+
156  case GEAR_UP:
+
157  transit = 0;
+
158  break;
+
159 
+
160  case GEAR_DOWN:
+
161  transit = 1;
+
162  break;
+
163 
+
164  case GEAR_LOWER:
+
165  if (transit < 1) {
+
166  transit += seconds;
+
167 
+
168  Scene* s = 0;
+
169  if (ship && ship->Rep())
+
170  s = ship->Rep()->GetScene();
+
171 
+
172  if (s) {
+
173  for (int i = 0; i < ngear; i++) {
+
174  if (gear[i] && !gear[i]->GetScene()) {
+
175  s->AddGraphic(gear[i]);
+
176  }
+
177  }
+
178  }
+
179  }
+
180  else {
+
181  transit = 1;
+
182  state = GEAR_DOWN;
+
183  }
+
184  break;
+
185 
+
186  case GEAR_RAISE:
+
187  if (transit > 0) {
+
188  transit -= seconds;
+
189  }
+
190  else {
+
191  transit = 0;
+
192  state = GEAR_UP;
+
193 
+
194  for (int i = 0; i < ngear; i++) {
+
195  if (gear[i]) {
+
196  Scene* s = gear[i]->GetScene();
+
197  if (s) s->DelGraphic(gear[i]);
+
198  }
+
199  }
+
200  }
+
201  break;
+
202  }
+
203 }
+
204 
+
205 // +--------------------------------------------------------------------+
+
206 
+
207 void
+ +
209 {
+
210  System::Orient(rep);
+
211 
+
212  const Matrix& orientation = rep->Cam().Orientation();
+
213  Point ship_loc = rep->Location();
+
214 
+
215  for (int i = 0; i < ngear; i++) {
+
216  Point gloc;
+
217  if (transit < 1) gloc = start[i] + (end[i]-start[i])*transit;
+
218  else gloc = end[i];
+
219 
+
220  Point projector = (gloc * orientation) + ship_loc;
+
221  if (gear[i]) {
+
222  gear[i]->MoveTo(projector);
+
223  gear[i]->SetOrientation(orientation);
+
224  }
+
225  }
+
226 }
+
227 
+
228 // +--------------------------------------------------------------------+
+
229 
+
230 Solid*
+ +
232 {
+
233  if (index >= 0 && index < ngear) {
+
234  Solid* g = gear[index];
+
235  return g;
+
236  }
+
237 
+
238  return 0;
+
239 }
+
240 
+
241 // +--------------------------------------------------------------------+
+
242 
+
243 Point
+ +
245 {
+
246  if (index >= 0 && index < ngear) {
+
247  Solid* g = gear[index];
+
248 
+
249  if (g)
+
250  return g->Location();
+
251  }
+
252 
+
253  return Point();
+
254 }
+
255 
+
256 // +--------------------------------------------------------------------+
+
257 
+
258 double
+ +
260 {
+
261  double down = 0;
+
262 
+
263  if (ship) {
+
264  down = ship->Location().y;
+
265 
+
266  if (state != GEAR_UP) {
+
267  for (int i = 0; i < ngear; i++) {
+
268  if (gear[i]) {
+
269  Point stop = gear[i]->Location();
+
270 
+
271  if (stop.y < down)
+
272  down = stop.y;
+
273  }
+
274  }
+
275  }
+
276  }
+
277 
+
278  return down;
+
279 }
+
+
+ + + + -- cgit v1.1