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
physics.h
Go to the documentation of this file.
1 /*
2  * Vega Strike
3  * Copyright (C) 2001-2002 Daniel Horn
4  *
5  * http://vegastrike.sourceforge.net/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef PHYSICS_H
23 #define PHYSICS_H
24 
25 #include "gfx/vec.h"
26 
27 static const float oocc = (float) 0.0000000000000000111265005605; //1/c^2
28 static const float c = (float) 299792458.0;
29 static const float co10 = (float) 29979245.8;
30 float copysign( float x, float y );
31 
32 struct Force
33 {
35  float t;
36 };
37 const int forcemax = 64;
39 {
40  float mass, MomentOfInertia;
41  Vector NetForce;
42  Vector NetTorque;
43  Vector AngularVelocity;
44  Vector Velocity;
45  QVector *pos;
46  Vector *p, *q, *r;
47  int NumActiveForces;
48  Force ActiveForces[forcemax];
49  int NumActiveTorques;
50  Force ActiveTorques[forcemax];
51 public: PhysicsSystem( float M, float I, QVector *pos, Vector *p, Vector *q, Vector *r );
52 //~PhysicsSystem();
53  virtual void Rotate( const Vector &axis );
54  virtual void JettisonReactionMass( const Vector &Direction, float speed, float mass );
55  virtual void JettisonMass( const Vector &Direction, float speed, float mass );
56  virtual void ResistiveLiquidTorque( float ResistiveForceCoef );
57  virtual void ResistiveTorque( float ResistiveForceCoef );
58  virtual void ResistiveLiquidForce( float ResistiveForceCoef );
59  virtual void ResistiveForce( float ResistiveForceCoef );
60  virtual void ResistiveThrust( float strength );
61  virtual void ResistiveTorqueThrust( float strength, const Vector &Position );
62  virtual void ApplyForce( const Vector &Vforce, float time );
63  virtual void ApplyTorque( const Vector &Vforce, const Vector &Location, float time );
64  virtual void ApplyLocalTorque( const Vector &Vforce, const Vector &Location, float time );
65  virtual void ApplyBalancedLocalTorque( const Vector &Vforce, const Vector &Location, float time );
66  void ApplyImpulses( float Time );
68  {
69  Velocity = v;
70  }
72  {
73  AngularVelocity = w;
74  }
75  const Vector& GetVelocity() const
76  {
77  return Velocity;
78  }
79  const Vector& GetAngularVelocity() const
80  {
81  return AngularVelocity;
82  }
83 
84  virtual void Update();
85 };
86 
87 #endif
88