1 /* StonerView: An eccentric visual toy.
2 Copyright 1998-2001 by Andrew Plotkin (erkyrath@eblong.com)
4 Permission to use, copy, modify, distribute, and sell this software and its
5 documentation for any purpose is hereby granted without fee, provided that
6 the above copyright notice appear in all copies and that both that
7 copyright notice and this permission notice appear in supporting
8 documentation. No representations are made about the suitability of this
9 software for any purpose. It is provided "as is" without express or
23 # include <OpenGL/gl.h>
29 #include "stonerview.h"
33 init_move(stonerview_state *st)
35 /*st->theta = new_osc_linear(
36 new_osc_wrap(0, 36000, 25),
37 new_osc_constant(2000));*/
39 st->theta = new_osc_linear(st,
40 new_osc_velowrap(st, 0, 36000, new_osc_multiplex(st,
41 new_osc_randphaser(st, 300, 600),
42 new_osc_constant(st, 25),
43 new_osc_constant(st, 75),
44 new_osc_constant(st, 50),
45 new_osc_constant(st, 100))
49 new_osc_buffer(st, new_osc_randphaser(st, 300, 600)),
50 new_osc_buffer(st, new_osc_wrap(st, 0, 36000, 10)),
51 new_osc_buffer(st, new_osc_wrap(st, 0, 36000, -8)),
52 new_osc_wrap(st, 0, 36000, 4),
53 new_osc_buffer(st, new_osc_bounce(st, -2000, 2000, 20))
57 st->rad = new_osc_buffer(st, new_osc_multiplex(st,
58 new_osc_randphaser(st, 250, 500),
59 new_osc_bounce(st, -1000, 1000, 10),
60 new_osc_bounce(st, 200, 1000, -15),
61 new_osc_bounce(st, 400, 1000, 10),
62 new_osc_bounce(st, -1000, 1000, -20)));
63 /*st->rad = new_osc_constant(st, 1000);*/
65 st->alti = new_osc_linear(st,
66 new_osc_constant(st, -1000),
67 new_osc_constant(st, 2000 / st->num_els));
69 /*st->alti = new_osc_multiplex(
70 new_osc_buffer(st, new_osc_randphaser(60, 270)),
71 new_osc_buffer(st, new_osc_bounce(-1000, 1000, 48)),
73 new_osc_constant(-1000),
74 new_osc_constant(2000 / st->num_els)),
75 new_osc_buffer(st, new_osc_bounce(-1000, 1000, 27)),
77 new_osc_constant(-1000),
78 new_osc_constant(2000 / st->num_els))
81 /*st->color = new_osc_buffer(st, new_osc_randphaser(5, 35));*/
83 /*st->color = new_osc_buffer(st, new_osc_multiplex(
84 new_osc_randphaser(25, 70),
85 new_osc_wrap(0, 3600, 20),
86 new_osc_wrap(0, 3600, 30),
87 new_osc_wrap(0, 3600, -20),
88 new_osc_wrap(0, 3600, 10)));*/
89 st->color = new_osc_multiplex(st,
90 new_osc_buffer(st, new_osc_randphaser(st, 150, 300)),
91 new_osc_buffer(st, new_osc_wrap(st, 0, 3600, 13)),
92 new_osc_buffer(st, new_osc_wrap(st, 0, 3600, 32)),
93 new_osc_buffer(st, new_osc_wrap(st, 0, 3600, 17)),
94 new_osc_buffer(st, new_osc_wrap(st, 0, 3600, 7)));
99 void final_move(stonerview_state *st)
103 /* Set up the list of polygon data for rendering. */
104 void move_increment(stonerview_state *st)
108 /* GLfloat recipels = (1.0 / (GLfloat)st->num_els); */
110 GLfloat ptrad, pttheta;
112 for (ix=0; ix<st->num_els; ix++) {
113 elem_t *el = &st->elist[ix];
115 /* Grab r and theta... */
116 val = osc_get(st, st->theta, ix);
117 pttheta = val * (0.01 * M_PI / 180.0);
118 ptrad = (GLfloat)osc_get(st, st->rad, ix) * 0.001;
119 /* And convert them to x,y coordinates. */
120 pt[0] = ptrad * cos(pttheta);
121 pt[1] = ptrad * sin(pttheta);
126 el->pos[2] = (GLfloat)osc_get(st, st->alti, ix) * 0.001;
128 /* Set which way the square is rotated. This is fixed for now, although
129 it would be trivial to make the squares spin as they revolve. */
130 el->vervec[0] = 0.11;
133 /* Grab the color, and convert it to RGB values. Technically, we're
134 converting an HSV value to RGB, where S and V are always 1. */
135 val = osc_get(st, st->color, ix);
137 el->col[0] = ((GLfloat)val / 1200.0);
139 el->col[2] = (GLfloat)(1200 - val) / 1200.0;
141 else if (val < 2400) {
142 el->col[0] = (GLfloat)(2400 - val) / 1200.0;
143 el->col[1] = ((GLfloat)(val - 1200) / 1200.0);
148 el->col[1] = (GLfloat)(3600 - val) / 1200.0;
149 el->col[2] = ((GLfloat)(val - 2400) / 1200.0);