reflection clipping cleanups
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2076 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+1
-1
@@ -1986,7 +1986,7 @@
|
||||
<variable name="reflectclip">
|
||||
<value token="V" description="" minValue="0" maxValue="100" defaultValue="3" />
|
||||
</variable>
|
||||
<variable name="reflectres">
|
||||
<variable name="reflectsize">
|
||||
<value token="V" description="" minValue="6" maxValue="10" defaultValue="8" />
|
||||
</variable>
|
||||
<variable name="reflectscissor">
|
||||
|
||||
@@ -185,6 +185,8 @@ extern serverinfo *getconnectedserverinfo();
|
||||
extern void pingservers();
|
||||
|
||||
// rendergl
|
||||
extern GLdouble mvmatrix[16], projmatrix[16], mvpmatrix[16], invmvmatrix[16];
|
||||
|
||||
extern void gl_checkextensions();
|
||||
extern void gl_init(int w, int h, int bpp, int depth, int fsaa);
|
||||
extern void cleangl();
|
||||
|
||||
+13
-13
@@ -406,14 +406,14 @@ void transplayer()
|
||||
glTranslatef(-camera1->o.x, -camera1->o.y, -camera1->o.z);
|
||||
}
|
||||
|
||||
void genclipmatrix(float a, float b, float c, float d, GLfloat matrix[16])
|
||||
void genclipmatrix(double a, double b, double c, double d, GLdouble matrix[16])
|
||||
{
|
||||
// transform the clip plane into camera space
|
||||
GLdouble clip[4] = {a, b, c, d};
|
||||
glClipPlane(GL_CLIP_PLANE0, clip);
|
||||
glGetClipPlane(GL_CLIP_PLANE0, clip);
|
||||
double clip[4];
|
||||
loopi(4) clip[i] = a*invmvmatrix[i*4 + 0] + b*invmvmatrix[i*4 + 1] + c*invmvmatrix[i*4 + 2] + d*invmvmatrix[i*4 + 3];
|
||||
|
||||
memcpy(matrix, projmatrix, 16*sizeof(GLdouble));
|
||||
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, matrix);
|
||||
float x = ((clip[0]<0 ? -1 : (clip[0]>0 ? 1 : 0)) + matrix[8]) / matrix[0],
|
||||
y = ((clip[1]<0 ? -1 : (clip[1]>0 ? 1 : 0)) + matrix[9]) / matrix[5],
|
||||
w = (1 + matrix[10]) / matrix[14],
|
||||
@@ -428,7 +428,7 @@ bool reflecting = false, refracting = false;
|
||||
GLuint reflecttex = 0, refracttex = 0;
|
||||
int reflectlastsize = 0;
|
||||
|
||||
VARP(reflectres, 6, 8, 10);
|
||||
VARP(reflectsize, 6, 8, 10);
|
||||
VAR(reflectclip, 0, 3, 100);
|
||||
VARP(waterreflect, 0, 1, 1);
|
||||
VARP(waterrefract, 0, 0, 1);
|
||||
@@ -439,7 +439,7 @@ void drawreflection(float hf, int w, int h, float changelod, bool refract)
|
||||
reflecting = true;
|
||||
refracting = refract;
|
||||
|
||||
int size = 1<<reflectres, sizelimit = min(hwtexsize, min(w, h));
|
||||
int size = 1<<reflectsize, sizelimit = min(hwtexsize, min(w, h));
|
||||
while(size > sizelimit) size /= 2;
|
||||
if(size!=reflectlastsize)
|
||||
{
|
||||
@@ -495,11 +495,11 @@ void drawreflection(float hf, int w, int h, float changelod, bool refract)
|
||||
glScalef(1, 1, -1);
|
||||
}
|
||||
|
||||
GLfloat clipmat[16];
|
||||
genclipmatrix(0, 0, refract ? -1 : 1, refract ? 0.1f*reflectclip+hf : 0.1f*reflectclip-hf, clipmat);
|
||||
GLdouble clipmat[16];
|
||||
genclipmatrix(0, 0, -1, 0.1f*reflectclip+hf, clipmat);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadMatrixf(clipmat);
|
||||
glLoadMatrixd(clipmat);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
renderstripssky();
|
||||
@@ -795,6 +795,9 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
|
||||
gluPerspective(fovy, aspect, 0.15f, farplane);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
transplayer();
|
||||
readmatrices();
|
||||
|
||||
if(!underwater && waterreflect)
|
||||
{
|
||||
extern int wx1;
|
||||
@@ -808,8 +811,6 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
|
||||
|
||||
glClear((outsidemap(camera1) ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
transplayer();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
resetcubes();
|
||||
@@ -844,7 +845,6 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
|
||||
renderentities();
|
||||
endmodelbatches();
|
||||
|
||||
readmatrices();
|
||||
readdepth(w, h, worldpos);
|
||||
|
||||
startmodelbatches();
|
||||
|
||||
@@ -442,7 +442,6 @@ struct vertmodel : model
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, mm);
|
||||
vec eyepos;
|
||||
loopk(3) eyepos[k] = tagpos.x*mm[0+k] + tagpos.y*mm[4+k] + tagpos.z*mm[8+k] + mm[12+k];
|
||||
extern GLdouble invmvmatrix[16];
|
||||
vec worldpos;
|
||||
loopk(3) worldpos[k] = eyepos.x*invmvmatrix[0+k] + eyepos.y*invmvmatrix[4+k] + eyepos.z*invmvmatrix[8+k] + invmvmatrix[12+k];
|
||||
particle_emit(emitters[i].type, emitters[i].args, basetime, emitters[i].seed, worldpos);
|
||||
|
||||
@@ -75,16 +75,13 @@ extern int nquads;
|
||||
|
||||
void setprojtexmatrix()
|
||||
{
|
||||
GLfloat pm[16], mm[16];
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, pm);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, mm);
|
||||
GLdouble matrix[16];
|
||||
|
||||
memcpy(matrix, mvpmatrix, 16*sizeof(GLdouble));
|
||||
loopi(2) loopj(4) matrix[i + j*4] = 0.5f*(matrix[i + j*4] + matrix[3 + j*4]);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.5f, 0.5f, 0.5f);
|
||||
glScalef(0.5f, 0.5f, 0.5f);
|
||||
glMultMatrixf(pm);
|
||||
glMultMatrixf(mm);
|
||||
glLoadMatrixd(matrix);
|
||||
}
|
||||
|
||||
void setupmultitexrefract(GLuint reflecttex, GLuint refracttex)
|
||||
@@ -237,7 +234,6 @@ void addwaterquad(int x, int y, int size) // update bounding rect that con
|
||||
|
||||
void calcwaterscissor()
|
||||
{
|
||||
extern GLdouble mvpmatrix[16];
|
||||
vec4 v[4];
|
||||
float sx1 = 1, sy1 = 1, sx2 = -1, sy2 = -1;
|
||||
loopi(4)
|
||||
|
||||
Reference in New Issue
Block a user