aboutsummaryrefslogtreecommitdiff
path: root/redist/CNFG3D.h
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2018-03-10 23:57:58 -0500
committercnlohr <lohr85@gmail.com>2018-03-10 23:57:58 -0500
commita2ba45f43ae02b1e39b1816fe9c1c70c54a7f046 (patch)
treeb0a916dad0fb979e997d069a0f6c3184279e479a /redist/CNFG3D.h
parent5ae3acb6d63301ac14beaebe692f5af680e65c26 (diff)
downloadlibsurvive-a2ba45f43ae02b1e39b1816fe9c1c70c54a7f046.tar.gz
libsurvive-a2ba45f43ae02b1e39b1816fe9c1c70c54a7f046.tar.bz2
Switch from pos,quat to pose. Also change initialization order.
Diffstat (limited to 'redist/CNFG3D.h')
-rw-r--r--redist/CNFG3D.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/redist/CNFG3D.h b/redist/CNFG3D.h
new file mode 100644
index 0000000..7f74d96
--- /dev/null
+++ b/redist/CNFG3D.h
@@ -0,0 +1,66 @@
+//Copyright 2012-2017 <>< Charles Lohr
+//You may license this file under the MIT/x11, NewBSD, or any GPL license.
+
+//This is a series of tools useful for software rendering.
+//Use of this file with OpenGL is untested.
+
+#ifndef _3D_H
+#define _3D_H
+
+#include <math.h>
+#define tdCOS cosf
+#define tdSIN sinf
+#define tdTAN tanf
+#define tdSQRT sqrtf
+#define tdMATCOPY(x,y) memcpy( x, y, 16*sizeof(float))
+#define tdQ_PI 3.141592653589
+#define tdDEGRAD (tdQ_PI/180.)
+#define tdRADDEG (180./tdQ_PI)
+
+
+//General Matrix Functions
+void tdIdentity( float * f );
+void tdZero( float * f );
+void tdTranslate( float * f, float x, float y, float z ); //Operates ON f
+void tdScale( float * f, float x, float y, float z ); //Operates ON f
+void tdRotateAA( float * f, float angle, float x, float y, float z ); //Operates ON f
+void tdRotateEA( float * f, float x, float y, float z ); //Operates ON f
+void tdMultiply( float * fin1, float * fin2, float * fout ); //Operates ON f
+void tdPrint( float * f );
+void tdTransposeSelf( float * f );
+
+//Specialty Matrix Functions
+void tdPerspective( float fovy, float aspect, float zNear, float zFar, float * out ); //Sets, NOT OPERATES. (FOVX=degrees)
+void tdLookAt( float * m, float * eye, float * at, float * up ); //Operates ON f
+
+//General point functions
+#define tdPSet( f, x, y, z ) { f[0] = x; f[1] = y; f[2] = z; }
+void tdPTransform( const float * pin, float * f, float * pout );
+void tdVTransform( const float * vin, float * f, float * vout );
+void td4Transform( float * kin, float * f, float * kout );
+void td4RTransform( float * kin, float * f, float * kout );
+void tdNormalizeSelf( float * vin );
+void tdCross( float * va, float * vb, float * vout );
+float tdDistance( float * va, float * vb );
+float tdDot( float * va, float * vb );
+#define tdPSub( x, y, z ) { (z)[0] = (x)[0] - (y)[0]; (z)[1] = (x)[1] - (y)[1]; (z)[2] = (x)[2] - (y)[2]; }
+#define tdPAdd( x, y, z ) { (z)[0] = (x)[0] + (y)[0]; (z)[1] = (x)[1] + (y)[1]; (z)[2] = (x)[2] + (y)[2]; }
+
+//Stack Functionality
+#define tdMATRIXMAXDEPTH 32
+extern float * gSMatrix;
+void tdPush();
+void tdPop();
+void tdMode( int mode );
+#define tdMODELVIEW 0
+#define tdPROJECTION 1
+
+//Final stage tools
+void tdSetViewport( float leftx, float topy, float rightx, float bottomy, float pixx, float pixy );
+void tdFinalPoint( float * pin, float * pout );
+
+
+float tdFLerp( float a, float b, float t );
+float tdPerlin2D( float x, float y );
+
+#endif