new math func
This commit is contained in:
parent
bf96da0108
commit
68e1228193
4 changed files with 38 additions and 0 deletions
|
|
@ -56,6 +56,7 @@ GSDECL void GSGLBegin2D(GSGL gl);
|
||||||
GSDECL void GSGLEnd2D(GSGL gl);
|
GSDECL void GSGLEnd2D(GSGL gl);
|
||||||
GSDECL void GSGLSetPosition(GSGL gl, GSVector3 pos);
|
GSDECL void GSGLSetPosition(GSGL gl, GSVector3 pos);
|
||||||
GSDECL void GSGLSetRotation(GSGL gl, GSVector3 rot);
|
GSDECL void GSGLSetRotation(GSGL gl, GSVector3 rot);
|
||||||
|
GSDECL void GSGLSetRotation3x3(GSGL gl, GSMatrix3x3 rot);
|
||||||
GSDECL void GSGLPushMatrix(GSGL gl);
|
GSDECL void GSGLPushMatrix(GSGL gl);
|
||||||
GSDECL void GSGLPopMatrix(GSGL gl);
|
GSDECL void GSGLPopMatrix(GSGL gl);
|
||||||
GSDECL GLuint GSGLBeginList(GSGL gl);
|
GSDECL GLuint GSGLBeginList(GSGL gl);
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,13 @@ GSDECL void GSMathNormalTriangle(GSVector3 r, GSVector3 v0, GSVector3 v1, GSVect
|
||||||
GSDECL void GSMathNormalQuad(GSVector3 r, GSVector3 v0, GSVector3 v1, GSVector3 v2, GSVector3 v3);
|
GSDECL void GSMathNormalQuad(GSVector3 r, GSVector3 v0, GSVector3 v1, GSVector3 v2, GSVector3 v3);
|
||||||
GSDECL void GSMathInvert4x4(GSMatrix4x4 out, GSMatrix4x4 in);
|
GSDECL void GSMathInvert4x4(GSMatrix4x4 out, GSMatrix4x4 in);
|
||||||
GSDECL void GSMathRowToColumn4x4(GSMatrix4x4 out, GSMatrix4x4 in);
|
GSDECL void GSMathRowToColumn4x4(GSMatrix4x4 out, GSMatrix4x4 in);
|
||||||
|
GSDECL void GSMathRowToColumn3x3(GSMatrix3x3 out, GSMatrix3x3 in);
|
||||||
|
GSDECL void GSMath3x3To4x4(GSMatrix4x4 out, GSMatrix3x3 in);
|
||||||
GSDECL GSNumber GSMathCot(GSNumber x);
|
GSDECL GSNumber GSMathCot(GSNumber x);
|
||||||
GSDECL GSNumber GSMathClosestPOT(GSNumber x);
|
GSDECL GSNumber GSMathClosestPOT(GSNumber x);
|
||||||
|
|
||||||
#define GSMathColumnToRow4x4 GSMathRowToColumn4x4
|
#define GSMathColumnToRow4x4 GSMathRowToColumn4x4
|
||||||
|
#define GSMathColumnToRow3x3 GSMathRowToColumn3x3
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include <GearSrc/GL.h>
|
#include <GearSrc/GL.h>
|
||||||
|
|
||||||
|
#include <GearSrc/Math.h>
|
||||||
|
|
||||||
GSGL GSGLCreate(GSClient client) {
|
GSGL GSGLCreate(GSClient client) {
|
||||||
GLfloat lightamb[] = {0.5, 0.5, 0.5, 1.0};
|
GLfloat lightamb[] = {0.5, 0.5, 0.5, 1.0};
|
||||||
GLfloat lightcol[] = {1.0, 1.0, 1.0, 1.0};
|
GLfloat lightcol[] = {1.0, 1.0, 1.0, 1.0};
|
||||||
|
|
@ -125,6 +127,17 @@ void GSGLSetRotation(GSGL gl, GSVector3 rot) {
|
||||||
glRotatef(rot[2], 0, 0, 1);
|
glRotatef(rot[2], 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSGLSetRotation3x3(GSGL gl, GSMatrix3x3 rot) {
|
||||||
|
GSMatrix4x4 out, out2;
|
||||||
|
GLdouble mat[16];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
GSMath3x3To4x4(out, rot);
|
||||||
|
GSMathRowToColumn4x4(out2, out);
|
||||||
|
for(i = 0; i < 16; i++) mat[i] = out2[i];
|
||||||
|
glMultMatrixd(mat);
|
||||||
|
}
|
||||||
|
|
||||||
void GSGLPushMatrix(GSGL gl) {
|
void GSGLPushMatrix(GSGL gl) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,27 @@ void GSMathRowToColumn4x4(GSMatrix4x4 out, GSMatrix4x4 in) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSMathRowToColumn3x3(GSMatrix3x3 out, GSMatrix3x3 in) {
|
||||||
|
int y, x;
|
||||||
|
for(y = 0; y < 3; y++) {
|
||||||
|
for(x = 0; x < 3; x++) {
|
||||||
|
out[3 * x + y] = in[3 * y + x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSMath3x3To4x4(GSMatrix4x4 out, GSMatrix3x3 in) {
|
||||||
|
int y, x, i;
|
||||||
|
for(i = 0; i < 16; i++) out[i] = 0;
|
||||||
|
for(y = 0; y < 3; y++) {
|
||||||
|
for(x = 0; x < 3; x++) {
|
||||||
|
out[4 * y + x] = in[3 * y + x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out[15] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void GSMathInvert4x4(GSMatrix4x4 out, GSMatrix4x4 in) {
|
void GSMathInvert4x4(GSMatrix4x4 out, GSMatrix4x4 in) {
|
||||||
GSNumber inv[16], det;
|
GSNumber inv[16], det;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue