aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/render/fastjogl
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2005-05-07 23:44:38 +0000
committerCarsten Weisse <[email protected]>2005-05-07 23:44:38 +0000
commit645763d5c333568d44a05456f1ace37bd6341f1c (patch)
treeb7cb1116d884e7266068df8eba885f723a10ec90 /src/jake2/render/fastjogl
parent7b85a1449e8ab61c0aac8069d3e7c9c2cd64218e (diff)
model frame animation is now stored in an int[];
an int value contains the x, y, z, lightnormal (8bit for each element) this reduces the memory footprint massive and performs better
Diffstat (limited to 'src/jake2/render/fastjogl')
-rw-r--r--src/jake2/render/fastjogl/Mesh.java60
-rw-r--r--src/jake2/render/fastjogl/Model.java6
2 files changed, 29 insertions, 37 deletions
diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java
index 9635052..e15e698 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.9 2005-05-07 22:15:05 cawe Exp $
+ * $Id: Mesh.java,v 1.10 2005-05-07 23:44:38 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -71,10 +71,9 @@ public abstract class Mesh extends Light {
float[] shadedots = r_avertexnormal_dots[0];
- void GL_LerpVerts(int nverts, qfiles.dtrivertx_t[] ov,
- qfiles.dtrivertx_t[] verts, float[] move, float[] frontv,
+ void GL_LerpVerts(int nverts, int[] ov, int[] v, float[] move, float[] frontv,
float[] backv) {
- qfiles.dtrivertx_t ovv, vv;
+ int ovv, vv;
FloatBuffer lerp = vertexArrayBuf;
//PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM
@@ -82,31 +81,27 @@ public abstract class Mesh extends Light {
| Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE
| Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) {
float[] normal;
- int j = 0;
- for (int i = 0; i < nverts; i++ /* , v++, ov++, lerp+=4 */
- ) {
- normal = r_avertexnormals[verts[i].lightnormalindex()];
- ovv = ov[i];
- vv = verts[i];
-
- lerp.put(j++, move[0] + ovv.v0() * backv[0] + vv.v0() * frontv[0]
- + normal[0] * Defines.POWERSUIT_SCALE);
- lerp.put(j++, move[1] + ovv.v1() * backv[1] + vv.v1() * frontv[1]
- + normal[1] * Defines.POWERSUIT_SCALE);
- lerp.put(j++, move[2] + ovv.v2() * backv[2] + vv.v2() * frontv[2]
- + normal[2] * Defines.POWERSUIT_SCALE);
- }
+ int j = -1;
+ for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */)
+ {
+ vv = v[i];
+ normal = r_avertexnormals[(vv >>> 24 ) & 0xFF];
+ ovv = ov[i];
+ lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
+ lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
+ lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
+ }
} else {
- int j = 0;
- for (int i = 0; i < nverts; i++ /* , v++, ov++, lerp+=4 */
- ) {
- ovv = ov[i];
- vv = verts[i];
-
- lerp.put(j++, move[0] + ovv.v0() * backv[0] + vv.v0() * frontv[0]);
- lerp.put(j++, move[1] + ovv.v1() * backv[1] + vv.v1() * frontv[1]);
- lerp.put(j++, move[2] + ovv.v2() * backv[2] + vv.v2() * frontv[2]);
- }
+ int j = -1;
+ for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
+ {
+ ovv = ov[i];
+ vv = v[i];
+
+ lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]);
+ lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]);
+ lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]);
+ }
}
}
@@ -140,11 +135,11 @@ public abstract class Mesh extends Light {
qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame];
- qfiles.dtrivertx_t[] verts = frame.verts;
+ int[] verts = frame.verts;
qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe];
- qfiles.dtrivertx_t[] ov = oldframe.verts;
+ int[] ov = oldframe.verts;
if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0)
alpha = currententity.alpha;
@@ -205,7 +200,7 @@ public abstract class Mesh extends Light {
int j = 0;
float l;
for (int i = 0; i < paliashdr.num_xyz; i++) {
- l = shadedots[verts[i].lightnormalindex()];
+ l = shadedots[(verts[i] >>> 24 ) & 0xFF];
color.put(j++, l * shadelight[0]);
color.put(j++, l * shadelight[1]);
color.put(j++, l * shadelight[2]);
@@ -270,7 +265,6 @@ public abstract class Mesh extends Light {
* ============= GL_DrawAliasShadow =============
*/
void GL_DrawAliasShadow(qfiles.dmdl_t paliashdr, int posenum) {
- qfiles.dtrivertx_t[] verts;
int[] order;
float height, lheight;
int count;
@@ -280,8 +274,6 @@ public abstract class Mesh extends Light {
frame = paliashdr.aliasFrames[currententity.frame];
- verts = frame.verts;
-
height = 0;
order = paliashdr.glCmds;
diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java
index 02eaddf..1feadbf 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.10 2005-05-07 18:00:03 cawe Exp $
+ * $Id: Model.java,v 1.11 2005-05-07 23:44:38 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -994,9 +994,9 @@ public abstract class Model extends Surf {
for (i = 0; i < pheader.num_frames; i++) {
poutframe[i] = new qfiles.daliasframe_t(buffer);
// verts are all 8 bit, so no swapping needed
- poutframe[i].verts = new qfiles.dtrivertx_t[pheader.num_xyz];
+ poutframe[i].verts = new int[pheader.num_xyz];
for (int k = 0; k < pheader.num_xyz; k++) {
- poutframe[i].verts[k] = new qfiles.dtrivertx_t(buffer);
+ poutframe[i].verts[k] = buffer.getInt();
}
}