aboutsummaryrefslogtreecommitdiffstats
path: root/test/jake2/render/TestMap.java
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-09 06:50:52 +0000
committerHolger Zickner <[email protected]>2004-07-09 06:50:52 +0000
commit20a66a892a3f0704ef37f1eebb681edfee6fc165 (patch)
tree118e0e5ea00eecf450e4c63edc88c421d52a7db2 /test/jake2/render/TestMap.java
parent6b36f9e0380b7c80aecdc78ef07a0cf473712416 (diff)
import of Jake2
Diffstat (limited to 'test/jake2/render/TestMap.java')
-rw-r--r--test/jake2/render/TestMap.java58
1 files changed, 37 insertions, 21 deletions
diff --git a/test/jake2/render/TestMap.java b/test/jake2/render/TestMap.java
index 711b159..e6670dc 100644
--- a/test/jake2/render/TestMap.java
+++ b/test/jake2/render/TestMap.java
@@ -2,7 +2,7 @@
* TestMap.java
* Copyright (C) 2003
*
- * $Id: TestMap.java,v 1.2 2004-07-08 20:24:31 hzi Exp $
+ * $Id: TestMap.java,v 1.3 2004-07-09 06:50:51 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -36,6 +36,7 @@ import jake2.sys.KBD;
import jake2.util.*;
import java.awt.Dimension;
+import java.nio.FloatBuffer;
import java.util.*;
/**
@@ -177,7 +178,7 @@ public class TestMap
}
};
- Qcommon.InitForTestMap(new String[] { "TestMap $Id: TestMap.java,v 1.2 2004-07-08 20:24:31 hzi Exp $" });
+ Qcommon.Init(new String[] { "TestMap $Id: TestMap.java,v 1.3 2004-07-09 06:50:51 hzi Exp $" });
// sehr wichtig !!!
VID.Shutdown();
@@ -246,8 +247,8 @@ public class TestMap
break;
case 1 :
// register the map
- re.SetSky("space1", 0, new float[]{ 0, 0, 0 });
re.BeginRegistration("base1");
+ re.SetSky("space1", 0, new float[]{ 0, 0, 0 });
re.EndRegistration();
currentState = 2;
//break;
@@ -431,7 +432,7 @@ public class TestMap
refdef.time = time() * 0.001f;
// particle init
- particles.clear();
+ r_numparticles = 0;
// check the enemy distance
float[] diff = {0, 0, 0};
@@ -451,11 +452,7 @@ public class TestMap
// particles
animateParticles();
- particle_t[] tmp = new particle_t[particles.size()];
- particles.toArray(tmp);
-
- refdef.particles = tmp;
- refdef.num_particles = tmp.length;
+ refdef.num_particles = r_numparticles;
}
else {
ent.frame = 0;
@@ -463,10 +460,11 @@ public class TestMap
}
}
+ refdef.num_dlights = 0;
+
re.RenderFrame(refdef);
}
- private Vector particles = new Vector(1024); // = new particle_t[20];
private LinkedList active_particles = new LinkedList();
private boolean explode = false;
private float[] target;
@@ -480,8 +478,7 @@ public class TestMap
float time, time2;
float[] org = {0, 0, 0};
int color;
- particle_t particle;
-
+
time = 0.0f;
for (Iterator it = active_particles.iterator(); it.hasNext();)
@@ -514,13 +511,8 @@ public class TestMap
org[1] = p.org[1] + p.vel[1]*time + p.accel[1]*time2;
org[2] = p.org[2] + p.vel[2]*time + p.accel[2]*time2;
- particle = new particle_t();
- particle.alpha = alpha;
- Math3D.VectorCopy(org, particle.origin);
- particle.color = color;
-
- particles.add(particle);
-
+ AddParticle(org, color, alpha);
+
// PMM
if (p.alphavel == INSTANT_PARTICLE)
{
@@ -565,7 +557,7 @@ public class TestMap
Math3D.VectorMA (dir, s, up, dir);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1 + Lib.frand() * 0.2f);
+ p.alphavel = -1.0f / (1 + Globals.rnd.nextFloat() * 0.2f);
p.color = 0x74 + (Lib.rand() & 7);
for (j=0 ; j<3 ; j++)
{
@@ -592,7 +584,7 @@ public class TestMap
Math3D.VectorClear (p.accel);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.6f + Lib.frand() * 0.2f);
+ p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0x0 + Lib.rand()&15;
for (j=0 ; j<3 ; j++)
@@ -625,4 +617,28 @@ public class TestMap
IN.toggleMouse();
}
};
+
+ int r_numparticles = 0;
+ /*
+ =====================
+ V_AddParticle
+
+ =====================
+ */
+ void AddParticle(float[] org, int color, float alpha) {
+ if (r_numparticles >= Defines.MAX_PARTICLES)
+ return;
+
+ int i = r_numparticles++;
+
+ int c = particle_t.colorTable[color];
+ c |= (int)(alpha * 255) << 24;
+ particle_t.colorArray.put(i, c);
+
+ i *= 3;
+ FloatBuffer vertexBuf = particle_t.vertexArray;
+ vertexBuf.put(i++, org[0]);
+ vertexBuf.put(i++, org[1]);
+ vertexBuf.put(i++, org[2]);
+ }
}