Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
building.cpp
Go to the documentation of this file.
1 #include "building.h"
2 #include "cont_terrain.h"
3 
5  bool vehicle,
6  const char *filename,
7  bool SubUnit,
8  int faction,
9  const string &modifications,
10  Flightgroup *fg ) : GameUnit< Building > ( filename, SubUnit, faction, modifications, fg )
11 {
12  this->vehicle = vehicle;
13  continuous = true;
14  this->parent.plane = parent;
15 }
16 
18  bool vehicle,
19  const char *filename,
20  bool SubUnit,
21  int faction,
22  const string &modifications,
23  Flightgroup *fg ) : GameUnit< Building > ( filename, SubUnit, faction, modifications, fg )
24 {
25  this->vehicle = vehicle;
26  continuous = false;
27  this->parent.terrain = parent;
28 }
29 
31  const Transformation &old_physical_state,
32  const Vector &accel,
33  float difficulty,
34  const Matrix &transmat,
35  const Vector &CumulativeVelocity,
36  bool ResolveLast,
37  UnitCollection *uc )
38 {
40  old_physical_state,
41  accel,
42  difficulty,
43  transmat,
44  CumulativeVelocity,
45  ResolveLast,
46  uc );
47  QVector tmp( LocalPosition() );
48  Vector p, q, r;
49  GetOrientation( p, q, r );
50  if (continuous) {
51  tmp = parent.plane->GetGroundPos( tmp, p );
52  } else {
53  parent.terrain->GetGroundPos( tmp, p, (float) 0, (float) 0 );
54  }
55  if (vehicle) {
56  Normalize( p );
57  Vector tmp1;
58 #if 0
59  if (k <= 0) {
60  tmp1 = Vector( 0, 0, 1 );
61  if ( k = tmp1.Magnitude() )
62  tmp1 *= 800./k;
63  } else
64 #endif
65  {
66  tmp1 = 200*q.Cross( p );
67  }
68  NetLocalTorque += ( ( tmp1-tmp1*( tmp1.Dot( GetAngularVelocity() )/tmp1.Dot( tmp1 ) ) ) )*1./GetMass();
69  }
70  SetCurPosition( tmp );
71 }
72