diff options
Diffstat (limited to 'src/jake2/render/fastjogl')
-rw-r--r-- | src/jake2/render/fastjogl/Image.java | 3 | ||||
-rw-r--r-- | src/jake2/render/fastjogl/Light.java | 42 | ||||
-rw-r--r-- | src/jake2/render/fastjogl/Mesh.java | 25 | ||||
-rw-r--r-- | src/jake2/render/fastjogl/Model.java | 11 | ||||
-rw-r--r-- | src/jake2/render/fastjogl/Warp.java | 15 |
5 files changed, 37 insertions, 59 deletions
diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java index b05321b..1f80af0 100644 --- a/src/jake2/render/fastjogl/Image.java +++ b/src/jake2/render/fastjogl/Image.java @@ -2,7 +2,7 @@ * Image.java * Copyright (C) 2003 * - * $Id: Image.java,v 1.2 2004-07-09 10:22:28 hzi Exp $ + * $Id: Image.java,v 1.3 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -750,7 +750,6 @@ public abstract class Image extends Main { } } // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) - // TODO sync with jogl renderer. hoz void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { // byte fillcolor = *skin; // assume this is the pixel to fill int fillcolor = skin[0] & 0xff; diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java index 298a3db..a9e64a5 100644 --- a/src/jake2/render/fastjogl/Light.java +++ b/src/jake2/render/fastjogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.3 2004-07-09 16:44:01 hzi Exp $ + * $Id: Light.java,v 1.4 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -223,44 +223,38 @@ public abstract class Light extends Warp { cplane_t lightplane; // used as shadow plane float[] lightspot = {0, 0, 0}; // vec3_t -// TODO sync with jogl renderer. hoz int RecursiveLightPoint (mnode_t node, float[] start, float[] end) { - float front, back, frac; - boolean side; - int sideIndex; - cplane_t plane; + if (node.contents != -1) + return -1; // didn't hit anything + msurface_t surf; int s, t, ds, dt; int i; mtexinfo_t tex; ByteBuffer lightmap; int maps; - int r; float[] mid = {0, 0, 0}; - - if (node.contents != -1) - return -1; // didn't hit anything // calculate mid point // FIXME: optimize for axial - plane = node.plane; - front = Math3D.DotProduct (start, plane.normal) - plane.dist; - back = Math3D.DotProduct (end, plane.normal) - plane.dist; - side = (front < 0); - sideIndex = (side) ? 1 : 0; + cplane_t plane = node.plane; + float front = Math3D.DotProduct (start, plane.normal) - plane.dist; + float back = Math3D.DotProduct (end, plane.normal) - plane.dist; + boolean side = (front < 0); + int sideIndex = (side) ? 1 : 0; if ( (back < 0) == side) return RecursiveLightPoint (node.children[sideIndex], start, end); - frac = front / (front-back); + float frac = front / (front-back); mid[0] = start[0] + (end[0] - start[0])*frac; mid[1] = start[1] + (end[1] - start[1])*frac; mid[2] = start[2] + (end[2] - start[2])*frac; // go down front side - r = RecursiveLightPoint (node.children[sideIndex], start, mid); + int r = RecursiveLightPoint (node.children[sideIndex], start, mid); if (r >= 0) return r; // hit something @@ -341,11 +335,7 @@ public abstract class Light extends Warp { assert (color.length == 3) : "rgb bug"; float[] end = {0, 0, 0}; - float r; - int lnum; dlight_t dl; - float light; - float[] dist = {0, 0, 0}; float add; if (r_worldmodel.lightdata == null) @@ -358,7 +348,7 @@ public abstract class Light extends Warp { end[1] = p[1]; end[2] = p[2] - 2048; - r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); + float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); if (r == -1) { @@ -372,13 +362,12 @@ public abstract class Light extends Warp { // // add dynamic lights // - light = 0; - for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++) + for (int lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++) { dl = r_newrefdef.dlights[lnum]; - Math3D.VectorSubtract (currententity.origin, dl.origin, dist); - add = dl.intensity - Math3D.VectorLength(dist); + Math3D.VectorSubtract (currententity.origin, dl.origin, end); + add = dl.intensity - Math3D.VectorLength(end); add *= (1.0f/256); if (add > 0) { @@ -389,7 +378,6 @@ public abstract class Light extends Warp { Math3D.VectorScale (color, gl_modulate.value, color); } - // =================================================================== float[] s_blocklights = new float[34 * 34 * 3]; diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java index 572e691..257fc68 100644 --- a/src/jake2/render/fastjogl/Mesh.java +++ b/src/jake2/render/fastjogl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.2 2004-07-09 10:25:29 hzi Exp $ + * $Id: Mesh.java,v 1.3 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -67,20 +67,20 @@ public abstract class Mesh extends Light { float[] shadedots = r_avertexnormal_dots[0]; - void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, FloatBuffer lerp, float[] move, float[] frontv, float[] backv ) + void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv ) { - int i; int lerpIndex = 0; int[] ovv; int[] vv; + FloatBuffer lerp = vertexArrayBuf; //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) { float[] normal; int j = 0; - for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) + for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { normal = r_avertexnormals[verts[i].lightnormalindex]; ovv = ov[i].v; @@ -95,7 +95,7 @@ public abstract class Mesh extends Light { else { int j = 0; - for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) + for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { ovv = ov[i].v; vv = v[i].v; @@ -140,7 +140,6 @@ public abstract class Mesh extends Light { float alpha; float[] move = {0, 0, 0}; // vec3_t - float[] delta = {0, 0, 0}; // vec3_t float[] frontv = {0, 0, 0}; // vec3_t float[] backv = {0, 0, 0}; // vec3_t @@ -168,29 +167,25 @@ public abstract class Mesh extends Light { frontlerp = 1.0f - backlerp; // move should be the delta back to the previous frame * backlerp - Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, delta); + Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv); Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]); - move[0] = Math3D.DotProduct (delta, vectors[0]); // forward - move[1] = -Math3D.DotProduct (delta, vectors[1]); // left - move[2] = Math3D.DotProduct (delta, vectors[2]); // up + move[0] = Math3D.DotProduct (frontv, vectors[0]); // forward + move[1] = -Math3D.DotProduct (frontv, vectors[1]); // left + move[2] = Math3D.DotProduct (frontv, vectors[2]); // up Math3D.VectorAdd (move, oldframe.translate, move); for (i=0 ; i<3 ; i++) { move[i] = backlerp*move[i] + frontlerp*frame.translate[i]; - } - - for (i=0 ; i<3 ; i++) - { frontv[i] = frontlerp*frame.scale[i]; backv[i] = backlerp*oldframe.scale[i]; } // ab hier wird optimiert - GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv ); + GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv ); //gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf ); diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java index 4b781be..c7d83e9 100644 --- a/src/jake2/render/fastjogl/Model.java +++ b/src/jake2/render/fastjogl/Model.java @@ -2,7 +2,7 @@ * Model.java * Copyright (C) 2003 * - * $Id: Model.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Model.java,v 1.2 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -560,18 +560,17 @@ public abstract class Model extends Surf { float[] maxs = {0, 0}; float val; - int i, j, e; + int j, e; mvertex_t v; - mtexinfo_t tex; int[] bmins = {0, 0}; int[] bmaxs = {0, 0}; mins[0] = mins[1] = 999999; maxs[0] = maxs[1] = -99999; - tex = s.texinfo; + mtexinfo_t tex = s.texinfo; - for (i=0 ; i<s.numedges ; i++) + for (int i=0 ; i<s.numedges ; i++) { e = loadmodel.surfedges[s.firstedge+i]; if (e >= 0) @@ -592,7 +591,7 @@ public abstract class Model extends Surf { } } - for (i=0 ; i<2 ; i++) + for (int i=0 ; i<2 ; i++) { bmins[i] = (int)Math.floor(mins[i]/16); bmaxs[i] = (int)Math.ceil(maxs[i]/16); diff --git a/src/jake2/render/fastjogl/Warp.java b/src/jake2/render/fastjogl/Warp.java index f9a5b07..d7645f8 100644 --- a/src/jake2/render/fastjogl/Warp.java +++ b/src/jake2/render/fastjogl/Warp.java @@ -2,7 +2,7 @@ * Warp.java * Copyright (C) 2003 * - * $Id: Warp.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Warp.java,v 1.2 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,15 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.fastjogl; -import java.nio.FloatBuffer; - import jake2.Defines; import jake2.Globals; -import jake2.game.GameBase; -import jake2.render.glpoly_t; -import jake2.render.image_t; -import jake2.render.msurface_t; +import jake2.render.*; import jake2.util.Math3D; + +import java.nio.FloatBuffer; + import net.java.games.jogl.GL; /** @@ -125,7 +123,6 @@ public abstract class Warp extends Model { int f, b; float[] dist = new float[64]; float frac; - glpoly_t poly; float s, t; float[] total = {0, 0, 0}; float total_s, total_t; @@ -194,7 +191,7 @@ public abstract class Warp extends Model { // poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); // init polys - poly = new glpoly_t(numverts + 2); + glpoly_t poly = new glpoly_t(numverts + 2); poly.next = warpface.polys; warpface.polys = poly; |