summaryrefslogtreecommitdiffstats
path: root/physics.c
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2006-10-20 14:57:05 +0200
committerneoraider <devnull@localhost>2006-10-20 14:57:05 +0200
commit1021d32f7ccb9f3f10253934fd4e5202b7382b2d (patch)
tree61dd0e93d0171a5fcc8b0fe854a2f50df52652d5 /physics.c
parentf5ef6536cc243acd39bf563c3d9064d1908483b3 (diff)
downloadlibneofx-1021d32f7ccb9f3f10253934fd4e5202b7382b2d.tar
libneofx-1021d32f7ccb9f3f10253934fd4e5202b7382b2d.zip
Physik-Engine angefangen.
Lightmaps implementiert.
Diffstat (limited to 'physics.c')
-rw-r--r--physics.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/physics.c b/physics.c
new file mode 100644
index 0000000..cea066d
--- /dev/null
+++ b/physics.c
@@ -0,0 +1,26 @@
+#include <neofx/physics.h>
+#include <neofx/math.h>
+#include <math.h>
+
+static VECTOR gravitation = {0, -9.8, 0};
+
+
+void SetGravitation(VECTOR v) {
+ gravitation = v;
+}
+
+void ApplyPhysics(OBJECT o, float delta) {
+ VERTEX old_pos = o.pos;
+ VECTOR old_move = o.move;
+ float e;
+
+ e = expf(-o.air_resistance*delta);
+
+ o.move = VectorAdd(VectorMul(gravitation, 1/o.air_resistance),
+ VectorMul(VectorSub(old_move, VectorMul(gravitation, 1/o.air_resistance)),
+ e));
+
+ o.pos = VectorAdd(old_pos, VectorAdd(VectorMul(gravitation, delta/o.air_resistance),
+ VectorMul(VectorSub(old_move, VectorMul(gravitation, 1/o.air_resistance)),
+ (1-e)/o.air_resistance)));
+}