summaryrefslogtreecommitdiffstats
path: root/neofx
diff options
context:
space:
mode:
Diffstat (limited to 'neofx')
-rw-r--r--neofx/collision.h11
-rw-r--r--neofx/math.h21
-rw-r--r--neofx/types.h28
3 files changed, 60 insertions, 0 deletions
diff --git a/neofx/collision.h b/neofx/collision.h
new file mode 100644
index 0000000..ce5ff5f
--- /dev/null
+++ b/neofx/collision.h
@@ -0,0 +1,11 @@
+#ifndef NEOFX_COLLISION_H
+#define NEOFX_COLLISION_H
+
+#include "types.h"
+
+int CollisionPointTriangle(VERTEX, TRIANGLE);
+int CollisionRayTriangle(VERTEX, VECTOR, TRIANGLE, float*);
+int CollisionSphereTriangle(VERTEX, float,TRIANGLE);
+int CollisionMovingSphereTriangle(VERTEX, float, VECTOR, float, TRIANGLE);
+
+#endif
diff --git a/neofx/math.h b/neofx/math.h
new file mode 100644
index 0000000..f0f6550
--- /dev/null
+++ b/neofx/math.h
@@ -0,0 +1,21 @@
+#ifndef NEOFX_MATH_H
+#define NEOFX_MATH_H
+
+#include "types.h"
+
+float VectorDot(VECTOR, VECTOR);
+VECTOR VectorCross(VECTOR, VECTOR);
+VECTOR VectorSub(VECTOR, VECTOR);
+VECTOR VectorAdd(VECTOR, VECTOR);
+VECTOR VectorMul(VECTOR, float);
+VECTOR VectorNormalize(VECTOR);
+VECTOR VectorNeg(VECTOR);
+float VectorLength(VECTOR);
+float VectorLengthSq(VECTOR);
+int VectorEqual(VECTOR, VECTOR);
+MATRIX MatrixMul(MATRIX, MATRIX);
+MATRIX MatrixIdentity();
+MATRIX VectorMatrix(VERTEX, VECTOR, VERTEX, VECTOR);
+VECTOR VectorMatrixMul(VECTOR, MATRIX);
+
+#endif
diff --git a/neofx/types.h b/neofx/types.h
new file mode 100644
index 0000000..130f0f1
--- /dev/null
+++ b/neofx/types.h
@@ -0,0 +1,28 @@
+#ifndef NEOFX_TYPES_H
+#define NEOFX_TYPES_H
+
+#pragma pack(push, 2)
+typedef union _MATRIX {
+ float m[4][4];
+ float f[16];
+} MATRIX;
+
+typedef struct _VECTOR_VERTEX {
+ float x, y, z;
+} VECTOR, VERTEX;
+
+typedef struct _TEXCOORDS {
+ float s, t;
+} TEXCOORDS;
+
+typedef struct _TRIANGLE {
+ unsigned char type;
+ unsigned char visible;
+ VERTEX vertices[3];
+ VECTOR normal;
+ int texture;
+ TEXCOORDS texcoords[3];
+} TRIANGLE;
+#pragma pack(pop)
+
+#endif