1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Adrian Buerli |
---|
13 | */ |
---|
14 | |
---|
15 | #include <iostream> |
---|
16 | |
---|
17 | #include "IPhys.h" |
---|
18 | #include "stdincl.h" |
---|
19 | |
---|
20 | using namespace std; |
---|
21 | |
---|
22 | IPhys::IPhys () |
---|
23 | { |
---|
24 | } |
---|
25 | |
---|
26 | IPhys::~IPhys () |
---|
27 | { |
---|
28 | } |
---|
29 | |
---|
30 | // Simulation |
---|
31 | void IPhys::simIterate(Uint32 deltaT){ |
---|
32 | Vector Accel; |
---|
33 | switch (behav) { |
---|
34 | case B_MASS_POINT: |
---|
35 | Accel = resForce / m; |
---|
36 | vel = vel + (Accel * deltaT); |
---|
37 | pos = pos + (vel * deltaT); |
---|
38 | break; |
---|
39 | case B_RIGID_BODY: |
---|
40 | break; |
---|
41 | case B_ELAST_BODY: |
---|
42 | break; |
---|
43 | case I_SPRING_LINEAR: |
---|
44 | |
---|
45 | break; |
---|
46 | case I_DMPSPR_LINEAR: |
---|
47 | break; |
---|
48 | case I_SPRING_MOMENTUM: |
---|
49 | break; |
---|
50 | case I_DMPSPR_MOMENTUM: |
---|
51 | break; |
---|
52 | case F_GRAVITY: |
---|
53 | break; |
---|
54 | case F_HOVER: |
---|
55 | break; |
---|
56 | case F_SHOCKWAVE: |
---|
57 | break; |
---|
58 | case F_BEAM: |
---|
59 | break; |
---|
60 | default:; |
---|
61 | } |
---|
62 | resForce = Vector(0,0,0); |
---|
63 | }; |
---|
64 | |
---|
65 | |
---|
66 | // Exertion of external forces |
---|
67 | void IPhys::exertForce( Vector force ){ |
---|
68 | resForce = resForce + force; |
---|
69 | }; |
---|
70 | |
---|
71 | void IPhys::exertMomentum( Vector Momentum ){ |
---|
72 | resMomentum = resMomentum + Momentum; |
---|
73 | }; |
---|
74 | |
---|
75 | // set attributes |
---|
76 | void IPhys::setBehaviour( IPHYS_BEHAVIOUR desiredBehaviour ){ |
---|
77 | behav = desiredBehaviour; |
---|
78 | }; |
---|
79 | |
---|
80 | void IPhys::setBody( float mass ){ |
---|
81 | m = mass; |
---|
82 | }; |
---|
83 | |
---|
84 | void IPhys::setBody( float mass, float inertMoment[] ){ |
---|
85 | m = mass; |
---|
86 | //inertM = inertMoment; |
---|
87 | }; |
---|
88 | |
---|
89 | void IPhys::setBody( float mass, float inertMoment[], float YoungsModulus ){ |
---|
90 | m = mass; |
---|
91 | //inertM = inertMoment; |
---|
92 | YE = YoungsModulus; |
---|
93 | }; |
---|
94 | |
---|
95 | void IPhys::setMounts( WorldEntity *point1, WorldEntity *point2 ){ |
---|
96 | mounts[0] = point1; |
---|
97 | mounts[1] = point2; |
---|
98 | }; |
---|
99 | |
---|
100 | void IPhys::setSpring( float neutralLength, float springConst ){ |
---|
101 | spNeutralL = neutralLength; |
---|
102 | spConst = springConst; |
---|
103 | }; |
---|
104 | |
---|
105 | void IPhys::setSpring( float neutralLength, float springConst, float damping ){ |
---|
106 | spNeutralL = neutralLength; |
---|
107 | spConst = springConst; |
---|
108 | dmp = damping; |
---|
109 | }; |
---|
110 | |
---|
111 | void IPhys::setSpring( Quaternion neutralOrientation, float springConst ){ |
---|
112 | mspNeutralOri = neutralOrientation; |
---|
113 | spConst = springConst; |
---|
114 | }; |
---|
115 | void IPhys::setSpring( Quaternion neutralOrientation, float springConst, float damping ){ |
---|
116 | mspNeutralOri = neutralOrientation; |
---|
117 | spConst = springConst; |
---|
118 | dmp = damping; |
---|
119 | }; |
---|
120 | |
---|
121 | |
---|