Update of /cvsroot/javaamp/javaamp/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26034/src
Modified Files:
SimpleVisualization.java
Log Message:
SimpleVisualization appearance changed
Index: SimpleVisualization.java
===================================================================
RCS file: /cvsroot/javaamp/javaamp/src/SimpleVisualization.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- SimpleVisualization.java 25 Mar 2006 06:51:45 -0000 1.6
+++ SimpleVisualization.java 10 Apr 2006 14:52:55 -0000 1.7
@@ -10,21 +10,46 @@
public class SimpleVisualization extends Visualization {
Random rnd;
- Spline splinex, spliney, splinez;
Vector<float[]> points;
float[][] old;
float[] sum;
- float camx, camy, camz, pi;
+ float camx, camy, camz, camx2, camy2, camz2, ccamx, ccamy, ccamz;
+ int c1c2;
+ final float[][][] flags = {
+ { // Austria
+ { 1.0f, 0.0f, 0.0f },
+ { 1.0f, 1.0f, 1.0f },
+ { 1.0f, 0.0f, 0.0f }
+ }, { // Germany
+ { 0.2f, 0.2f, 0.2f },
+ { 1.0f, 0.0f, 0.0f },
+ { 1.0f, 1.0f, 0.0f }
+ }, { // Italy
+ { 0.0f, 1.0f, 0.0f },
+ { 1.0f, 1.0f, 1.0f },
+ { 1.0f, 0.0f, 0.0f }
+ },
+ };
+ int flag, flag2, f1f2;
+ float[][] cf;
public void init() {
rnd = new Random();
points = new Vector<float[]>();
old = new float[300][30];
sum = new float[20];
- camx = rnd.nextFloat() * 60f;
- camy = rnd.nextFloat() * 20;
- camz = rnd.nextFloat() * 30f - 10f;
+ camx = rnd.nextFloat() * 80f - 10f;
+ camy = rnd.nextFloat() * 40f + 20f;
+ camz = rnd.nextFloat() * 150f - 10f;
+ camx2 = camx;
+ camy2 = camy;
+ camz2 = camz;
+ c1c2 = 0;
delay = (long)10E6;
+ flag = rnd.nextInt(flags.length);
+ flag2 = flag;
+ f1f2 = 0;
+ cf = new float[3][3];
glClearColor(0, 0, 0, 1);
glColor3f(1, 1, 1);
@@ -41,7 +66,7 @@
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 800f / 600f, 0.1f, 1000f);
- gluLookAt(camx, camy, camz, camx, 0, 200, 0, 1, 0);
+ gluLookAt(ccamx, ccamy, ccamz, 30, 0, 250, 0, 1, 0);
glMatrixMode(GL_MODELVIEW);
glPointSize(2);
@@ -64,11 +89,16 @@
}
for(int i = 0; i < 300; i++) {
- glColor3f(0, 0.5f + (float)i / 598, 0);
glBegin(GL_LINE_STRIP);
+ glColor3f(cf[2][0], cf[2][1], cf[2][2]);
glVertex3f(-2, 0, i);
- for(int j = 0; j < 30; j++)
+ for(int j = 0; j < 30; j++) {
+ if(j == 10)
+ glColor3f(cf[1][0], cf[1][1], cf[1][2]);
+ else if(j == 20)
+ glColor3f(cf[0][0], cf[0][1], cf[0][2]);
glVertex3f(j * 2, old[i][j] * 20, i);
+ }
glVertex3f(60, 0, i);
glEnd();
}
@@ -79,16 +109,16 @@
public void timer() {
for(int i = 1; i < 300; i++)
System.arraycopy(old[i], 0, old[i - 1], 0, 30);
- for(int i = 0; i < 30; i++)
- old[299][29 - i] = spectrum.get(i + 1);
+ for(int i = 1; i <= 30; i++)
+ old[299][30 - i] = spectrum.get(i);
for(int i = 1; i < 20; i++)
sum[i - 1] = sum[i];
sum[19] = 0;
for(int i = 0; i < 30; i++)
sum[19] += old[299][i];
- for(int i = 0; i < sum[19] * 10; i++)
- points.add(new float[] { rnd.nextFloat() * 500 - 250,
- rnd.nextFloat() * 400 - 200, 100 + rnd.nextFloat() * 200,
+ for(int i = 0; i < sum[19] * 5; i++)
+ points.add(new float[] { rnd.nextFloat() * 800 - 400,
+ rnd.nextFloat() * 800 - 400, 400 + rnd.nextFloat() * 200,
100 });
for(int i = 0; i < points.size(); i++) {
float[] t = points.get(i);
@@ -100,50 +130,56 @@
else
points.set(i, t);
}
- if(splinex == null && rnd.nextInt(10) == 0) {
- double[] xx = new double[5];
- double[] ff = new double[5];
- for(int i = 0; i < 5; i++) {
- xx[i] = i;
- if(i == 0)
- ff[i] = camx;
- else
- ff[i] = rnd.nextDouble() * 60d;
- }
- splinex = new Spline(xx, ff);
-
- xx = new double[5];
- ff = new double[5];
- for(int i = 0; i < 5; i++) {
- xx[i] = i;
- if(i == 0)
- ff[i] = camy;
- else
- ff[i] = rnd.nextDouble() * 20d;
+ if(f1f2 == 0 && rnd.nextInt(500) == 0) {
+ flag2 = rnd.nextInt(flags.length);
+ if(flag == flag2)
+ flag2 = rnd.nextInt(flags.length);
+ f1f2 = 1;
+ }
+ if(f1f2 > 0) {
+ f1f2++;
+ if(f1f2 == 100) {
+ flag = flag2;
+ f1f2 = 0;
}
- spliney = new Spline(xx, ff);
-
- xx = new double[5];
- ff = new double[5];
- for(int i = 0; i < 5; i++) {
- xx[i] = i;
- if(i == 0)
- ff[i] = camz;
- else
- ff[i] = rnd.nextDouble() * 50d - 10d;
+ }
+ cf = new float[][] {
+ {
+ (flags[flag][0][0] * (100f - f1f2) + flags[flag2][0][0] *
+ f1f2) / 100f, (flags[flag][0][1] * (100f - f1f2) +
+ flags[flag2][0][1] * f1f2) / 100f, (flags[flag][0][2] * (100f -
+ f1f2) + flags[flag2][0][2] * f1f2) / 100f
+ }, {
+ (flags[flag][1][0] * (100f - f1f2) + flags[flag2][1][0] *
+ f1f2) / 100f, (flags[flag][1][1] * (100f - f1f2) +
+ flags[flag2][1][1] * f1f2) / 100f, (flags[flag][1][2] * (100f -
+ f1f2) + flags[flag2][1][2] * f1f2) / 100f
+ }, {
+ (flags[flag][2][0] * (100f - f1f2) + flags[flag2][2][0] *
+ f1f2) / 100f, (flags[flag][2][1] * (100f - f1f2) +
+ flags[flag2][2][1] * f1f2) / 100f, (flags[flag][2][2] * (100f -
+ f1f2) + flags[flag2][2][2] * f1f2) / 100f
}
- splinez = new Spline(xx, ff);
- pi = 0;
+ };
+ if(c1c2 == 0 && rnd.nextInt(500) == 0) {
+ camx2 = rnd.nextFloat() * 80f - 10f;
+ camy2 = rnd.nextFloat() * 40f + 20f;
+ camz2 = rnd.nextFloat() * 150f - 10f;
+ c1c2 = 1;
}
- if(splinex != null) {
- pi += 0.001f;
- if(pi > 4)
- splinex = null;
- else {
- camx = (float)splinex.spline_value(pi);
- camy = (float)spliney.spline_value(pi);
- camz = (float)splinez.spline_value(pi);
+ if(c1c2 > 0) {
+ c1c2++;
+ if(c1c2 == 300) {
+ camx = camx2;
+ camy = camy2;
+ camz = camz2;
+ c1c2 = 0;
}
}
+ float fac = (float)(Math.pow(c1c2, 3) / 45000f - c1c2 * c1c2 / 100f +
+ 300f);
+ ccamx = (camx * fac + camx2 * (300f - fac)) / 300f;
+ ccamy = (camy * fac + camy2 * (300f - fac)) / 300f;
+ ccamz = (camz * fac + camz2 * (300f - fac)) / 300f;
}
}
\ No newline at end of file
|