annotate src/iris/theme_float.c @ 116:a578bf9b2851 trunk

[svn] - iris vis plugin port
author nenolod
date Tue, 24 Oct 2006 21:25:31 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
116
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1 /* Iris - visualization plugin for XMMS
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
2 * Copyright (C) 2000-2002 Cédric DELFOSSE (cdelfosse@free.fr)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
3 *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
7 * (at your option) any later version.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
8 *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
12 * GNU General Public License for more details.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
13 *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
17 */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
18
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
19 /* New Theme created by Ron Lockwood-Childs
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
20 * Looks best when alpha blending is OFF
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
21 */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
22
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
23 /* $Id: theme_float.c,v 1.1 2002/10/27 19:21:06 cedric Exp $ */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
24
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
25 #include <stdlib.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
26 #include <stdio.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
27 #include <string.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
28 #include <math.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
29 #include <time.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
30 #include <GL/gl.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
31 #include <audacious/configdb.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
32 #include "iris.h"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
33
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
34 #define HISTORY_SIZE 16
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
35 #define HALF_BOX 0.15
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
36 #define HALF_BOX_Y (HALF_BOX * 2)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
37 #define FAR_LEFT -3.0
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
38 #define FAR_BACK -3.0
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
39 #define BOTTOM -2.6
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
40
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
41
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
42 typedef struct
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
43 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
44 GLfloat xc;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
45 GLfloat yc;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
46 GLfloat zc;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
47 } triple;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
48
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
49 static struct
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
50 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
51 int wave_speed;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
52 gfloat num_blocks;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
53 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
54 conf_private, conf_private_new;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
55
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
56 static config_theme conf = {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
57 NULL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
58 &conf_private
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
59 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
60
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
61 static config_theme conf_new = {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
62 NULL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
63 &conf_private_new
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
64 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
65
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
66
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
67 static GLfloat get_x_angle (void);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
68 static void draw_one_frame (gboolean);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
69 static gfloat speed_to_phase(int speed);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
70 static void config_read (ConfigDb *, char *);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
71 static void config_write (ConfigDb *, char *);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
72 static void config_default (void);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
73 static void config_create (GtkWidget *);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
74
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
75
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
76 static char float_numblocks[] = "float_numblocks";
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
77 static char float_wavespeed[] = "float_wavespeed";
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
78
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
79
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
80 iris_theme theme_float = {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
81 "Floaters",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
82 "A spectrum of floating blocks (alpha blend off for best effect)",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
83 "Ron Lockwood-Childs",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
84 "float",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
85 &conf,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
86 &conf_new,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
87 sizeof (conf_private),
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
88 config_read,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
89 config_write,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
90 config_default,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
91 config_create,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
92 NULL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
93 NULL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
94 NULL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
95 get_x_angle,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
96 draw_one_frame,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
97 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
98
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
99 static GLfloat data2[NUM_BANDS][HISTORY_SIZE]; // previous freq band data
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
100 static GLfloat phase[HISTORY_SIZE]; // previous angle data
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
101
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
102 static GLfloat
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
103 get_x_angle ()
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
104 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
105 return (10.0 + (int) (80.0 * rand () / (RAND_MAX + 1.0)));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
106 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
107
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
108 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
109 draw_one_frame (gboolean beat)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
110 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
111 int t1, t2; // loop vars
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
112 GLfloat red, green, blue;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
113 GLfloat y_color = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
114 triple ulf, urf, llf, lrf, ulb, urb, llb, lrb;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
115 GLfloat basis[NUM_BANDS];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
116 int box_height;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
117 int i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
118
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
119 /* shift all data when a new datarow arrives */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
120 for (t2 = (HISTORY_SIZE-1); t2 > 0; t2--)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
121 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
122 for (t1 = 0; t1 < NUM_BANDS; t1++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
123 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
124 data2[t1][t2] = data2[t1][t2-1];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
125 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
126 phase[t2] = phase[t2-1];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
127 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
128 for (t1 = 0; t1 < NUM_BANDS; t1++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
129 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
130 data2[t1][0] = datas.data1[t1];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
131 phase[0] = phase[1] + speed_to_phase(conf_private.wave_speed);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
132 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
133
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
134 glBegin (GL_QUADS);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
135
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
136 for (t2 = (HISTORY_SIZE-1); t2 >= 0; t2--)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
137 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
138 for (t1 = 0; t1 < NUM_BANDS; t1++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
139 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
140 basis[t1] = BOTTOM + sin( phase[t2] + (speed_to_phase(conf_private.wave_speed) * t1));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
141 box_height = (int)ceilf( data2[t1][t2] * conf_private.num_blocks );
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
142
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
143 for (i = 0; i < box_height; i++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
144 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
145 if (i < (box_height-1))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
146 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
147 y_color = (GLfloat)i * (1.0 / (GLfloat)conf_private.num_blocks);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
148 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
149 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
150 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
151 y_color = data2[t1][t2];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
152 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
153 get_color (&red, &green, &blue, &y_color); // box color
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
154 glColor4f (red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
155
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
156 ulf.xc = FAR_LEFT + (HALF_BOX * 3 * t1) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
157 ulf.yc = basis[t1] + (HALF_BOX_Y * 3 * i) + HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
158 ulf.zc = (FAR_BACK + t2 * HALF_BOX * 3) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
159
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
160 urf.xc = FAR_LEFT + (HALF_BOX * 3 * t1) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
161 urf.yc = basis[t1] + (HALF_BOX_Y * 3 * i) + HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
162 urf.zc = (FAR_BACK + t2 * HALF_BOX * 3) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
163
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
164 lrf.xc = FAR_LEFT + (HALF_BOX * 3 * t1) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
165 lrf.yc = basis[t1] + (HALF_BOX_Y * 3 * i) - HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
166 lrf.zc = (FAR_BACK + t2 * HALF_BOX * 3) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
167
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
168 llf.xc = FAR_LEFT + (HALF_BOX * 3 * t1) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
169 llf.yc = basis[t1] + (HALF_BOX_Y * 3 * i) - HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
170 llf.zc = (FAR_BACK + t2 * HALF_BOX * 3) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
171
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
172 ulb.xc = FAR_LEFT + (HALF_BOX * 3 * t1) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
173 ulb.yc = basis[t1] + (HALF_BOX_Y * 3 * i) + HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
174 ulb.zc = (FAR_BACK + t2 * HALF_BOX * 3) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
175
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
176 urb.xc = FAR_LEFT + (HALF_BOX * 3 * t1) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
177 urb.yc = basis[t1] + (HALF_BOX_Y * 3 * i) + HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
178 urb.zc = (FAR_BACK + t2 * HALF_BOX * 3) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
179
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
180 lrb.xc = FAR_LEFT + (HALF_BOX * 3 * t1) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
181 lrb.yc = basis[t1] + (HALF_BOX_Y * 3 * i) - HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
182 lrb.zc = (FAR_BACK + t2 * HALF_BOX * 3) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
183
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
184 llb.xc = FAR_LEFT + (HALF_BOX * 3 * t1) - HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
185 llb.yc = basis[t1] + (HALF_BOX_Y * 3 * i) - HALF_BOX_Y;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
186 llb.zc = (FAR_BACK + t2 * HALF_BOX * 3) + HALF_BOX;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
187
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
188 // now start drawin'
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
189 // start with the front, then left, back, right, finally the top
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
190
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
191 // "front"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
192 glVertex3f (ulf.xc, ulf.yc, ulf.zc); // "top-left"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
193
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
194 glVertex3f (urf.xc, urf.yc, urf.zc); // "top-right"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
195
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
196 glVertex3f (lrf.xc, lrf.yc, lrf.zc); // "bottom-right"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
197
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
198 glVertex3f (llf.xc, llf.yc, llf.zc); // "bottom-left"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
199
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
200 // "back"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
201 glVertex3f (ulb.xc, ulb.yc, ulb.zc); // "top-left"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
202
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
203 glVertex3f (urb.xc, urb.yc, urb.zc); // "top-right"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
204
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
205 glVertex3f (lrb.xc, lrb.yc, lrb.zc); // "bottom-right"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
206
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
207 glVertex3f (llb.xc, llb.yc, llb.zc); // "bottom-left"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
208
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
209 // "left"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
210 glVertex3f( llb.xc, llb.yc, llb.zc); // "bottom-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
211
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
212 glVertex3f( llf.xc, llf.yc, llf.zc); // "bottom-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
213
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
214 glVertex3f( ulf.xc, ulf.yc, ulf.zc); // "top-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
215
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
216 glVertex3f( ulb.xc, ulb.yc, ulb.zc); // "top-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
217
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
218 // "top"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
219 glVertex3f( ulb.xc, ulb.yc, ulb.zc); // "left-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
220
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
221 glVertex3f( ulf.xc, ulf.yc, ulf.zc); // "left-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
222
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
223 glVertex3f( urf.xc, urf.yc, urf.zc); // "right-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
224
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
225 glVertex3f( urb.xc, urb.yc, urb.zc); // "right-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
226
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
227 // "right"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
228 glVertex3f( urb.xc, urb.yc, urb.zc); // "top-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
229
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
230 glVertex3f( urf.xc, urf.yc, urf.zc); // "top-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
231
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
232 glVertex3f( lrf.xc, lrf.yc, lrf.zc); // "bottom-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
233
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
234 glVertex3f( lrb.xc, lrb.yc, lrb.zc); // "bottom-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
235
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
236 // "bottom"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
237 glVertex3f( lrb.xc, lrb.yc, lrb.zc); // "right-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
238
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
239 glVertex3f( lrf.xc, lrf.yc, lrf.zc); // "right-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
240
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
241 glVertex3f( llf.xc, llf.yc, llf.zc); // "left-out"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
242
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
243 glVertex3f( llb.xc, llb.yc, llb.zc); // "left-in"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
244 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
245 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
246 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
247
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
248 glEnd ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
249
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
250 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
251
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
252
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
253 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
254 config_read (ConfigDb * db, char *section_name)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
255 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
256 bmp_cfg_db_get_float (db, section_name, float_numblocks, &conf_private.num_blocks);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
257 bmp_cfg_db_get_int (db, section_name, float_wavespeed, &conf_private.wave_speed);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
258 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
259
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
260
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
261 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
262 config_write (ConfigDb * db, char *section_name)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
263 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
264 bmp_cfg_db_set_float (db, section_name, float_numblocks, conf_private.num_blocks);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
265 bmp_cfg_db_set_int (db, section_name, float_wavespeed, conf_private.wave_speed);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
266 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
267
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
268
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
269 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
270 config_default ()
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
271 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
272 conf_private.num_blocks = 8.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
273 conf_private.wave_speed = 4;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
274 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
275
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
276
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
277 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
278 blocks_changed (GtkAdjustment * adj)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
279 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
280 conf_private_new.num_blocks = (int) adj->value;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
281 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
282
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
283
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
284 // speeds: pi/8, pi/12, pi/16, pi/20, pi/24, pi/28, pi/32,0
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
285 static gfloat speed_to_phase(int speed)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
286 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
287 gfloat phase;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
288
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
289 if (speed == 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
290 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
291 phase = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
292 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
293 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
294 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
295 phase = M_PI_4/(9-speed);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
296 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
297
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
298 return phase;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
299 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
300
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
301 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
302 speed_changed (GtkWidget *menuitem, gpointer data)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
303 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
304 conf_private_new.wave_speed = GPOINTER_TO_INT(data);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
305 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
306
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
307
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
308
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
309 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
310 config_create (GtkWidget * vbox)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
311 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
312 GtkWidget *hbox;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
313 GtkWidget *label;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
314 GtkObject *adjustment;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
315 GtkWidget *hscale;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
316 GtkWidget *menu;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
317 GtkWidget *menuitem;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
318 GtkWidget *optionmenu;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
319 gchar *speeds[8] = {"0","1","2","3","4","5","6","7"};
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
320 int i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
321
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
322 memcpy (&conf_private_new, &conf_private, sizeof (conf_private));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
323
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
324 /* number blocks */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
325 hbox = gtk_hbox_new (FALSE, 2);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
326 gtk_widget_show (hbox);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
327 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
328
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
329 label = gtk_label_new ("Max number blocks per stack");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
330 gtk_widget_show (label);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
331 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
332
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
333 adjustment =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
334 gtk_adjustment_new (conf_private_new.num_blocks, 4, 8, 1, 2, 0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
335 hscale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
336 gtk_scale_set_digits (GTK_SCALE (hscale), 0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
337 gtk_widget_set_usize (GTK_WIDGET (hscale), 200, 25);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
338 gtk_box_pack_start (GTK_BOX (hbox), hscale, FALSE, FALSE, 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
339 gtk_widget_show (hscale);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
340 gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
341 GTK_SIGNAL_FUNC (blocks_changed), NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
342
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
343 /* set wave speed */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
344 hbox = gtk_hbox_new (FALSE, 2);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
345 gtk_widget_show (hbox);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
346 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
347
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
348 label = gtk_label_new ("Wave speed");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
349 gtk_widget_show (label);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
350 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
351
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
352 menu = gtk_menu_new ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
353 for (i=0; i<8; i++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
354 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
355 menuitem = gtk_menu_item_new_with_label(speeds[i]);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
356 gtk_menu_append(GTK_MENU(menu), menuitem);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
357 gtk_widget_show (menuitem);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
358 gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
359 GTK_SIGNAL_FUNC (speed_changed), GINT_TO_POINTER(i));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
360 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
361 optionmenu = gtk_option_menu_new();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
362 gtk_menu_set_active(GTK_MENU(menu), conf_private.wave_speed);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
363 gtk_option_menu_set_menu(GTK_OPTION_MENU(optionmenu), menu);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
364 gtk_box_pack_start (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
365 gtk_widget_show (optionmenu);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
366
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
367 }