12 int culooks::cube::allid = 0;
14 void culooks::cube::setLink (const int& posdir,
15 const float& red, const float& green, const float& blue, const float& alpha) {
16 linkbuf[(linkbuf_active+1)%2][ posdir*4 ] = red;
17 linkbuf[(linkbuf_active+1)%2][ posdir*4 + 1 ] = green;
18 linkbuf[(linkbuf_active+1)%2][ posdir*4 + 2 ] = blue;
19 linkbuf[(linkbuf_active+1)%2][ posdir*4 + 3 ] = alpha;
22 void culooks::cube::setPlaq (const int& posdir,
23 const float& red, const float& green, const float& blue, const float& alpha) {
24 plaqbuf[(plaqbuf_active+1)%2][ posdir*4 ] = red;
25 plaqbuf[(plaqbuf_active+1)%2][ posdir*4 + 1 ] = green;
26 plaqbuf[(plaqbuf_active+1)%2][ posdir*4 + 2 ] = blue;
27 plaqbuf[(plaqbuf_active+1)%2][ posdir*4 + 3 ] = alpha;
30 void culooks::cube::hidePlaqs()
32 hideplaquettes = true;
35 void culooks::cube::hideLinks()
40 void culooks::cube::swapLinkBuffer()
42 linkbuf_active = (linkbuf_active+1)%2;
43 link = linkbuf[linkbuf_active];
46 void culooks::cube::swapPlaqBuffer()
48 plaqbuf_active = (plaqbuf_active+1)%2;
49 plaq = plaqbuf[plaqbuf_active];
52 void culooks::cube::draw()
54 glMatrixMode(GL_MODELVIEW);
57 glEnable(GL_DEPTH_TEST);
61 glScalef(zoom*1.01, zoom*1.01, zoom*1.01);
62 glRotatef(az, 0, 1, 0);
63 glRotatef(alt, 1, 0, 0);
64 glColor4f(wireColor[0], wireColor[1], wireColor[2], wireColor[3]);
68 glEnable(GL_DEPTH_TEST);
69 glDepthMask(GL_FALSE);
72 glScalef(zoom, zoom, zoom);
73 glRotatef(az, 0, 1, 0);
74 glRotatef(alt, 1, 0, 0);
81 void culooks::cube::drawAll()
83 glMatrixMode(GL_MODELVIEW);
86 glTranslatef(-1,-1,-1);
88 for (int iz=0; iz<l; iz++) {
89 for (int iy=0; iy<l; iy++) {
90 for (int ix=0; ix<l; ix++) {
92 glTranslatef(2.0*ix/l,2.0*iy/l,2.0*iz/l);
93 glScalef(2.0/l,2.0/l,2.0/l);
98 glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 0],
99 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 1],
100 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 2],
101 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 3]);
102 glVertex3f(0,0,0); glVertex3f(1,0,0);
103 glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 0],
104 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 1],
105 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 2],
106 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 3]);
107 glVertex3f(0,0,0); glVertex3f(0,1,0);
108 glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 0],
109 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 1],
110 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 2],
111 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 3]);
112 glVertex3f(0,0,0); glVertex3f(0,0,1);
116 /* draw plaquettes */
117 if (!hideplaquettes) {
119 glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 0],
120 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 1],
121 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 2],
122 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 3]);
123 glVertex3f(0, 0, 0); glVertex3f(1, 0, 0); glVertex3f(1, 1, 0); glVertex3f(0, 1, 0);
124 glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 0],
125 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 1],
126 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 2],
127 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 3]);
128 glVertex3f(0, 0, 0); glVertex3f(1, 0, 0); glVertex3f(1, 0, 1); glVertex3f(0, 0, 1);
129 glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 0],
130 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 1],
131 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 2],
132 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 3]);
133 glVertex3f(0, 0, 0); glVertex3f(0, 1, 0); glVertex3f(0, 1, 1); glVertex3f(0, 0, 1);
145 culooks::cube::cube(int _l)
150 plaqbuf[0] = new float[l*l*l*3 * 4];
151 plaqbuf[1] = new float[l*l*l*3 * 4];
152 linkbuf[0] = new float[l*l*l*3 * 4];
153 linkbuf[1] = new float[l*l*l*3 * 4];
166 for (int ibuf=0; ibuf<2; ibuf++)
167 for (int i=0; i<l*l*l*3; i++) {
168 linkbuf[ibuf][i*4+0]=1; linkbuf[ibuf][i*4+3]=0.6;
169 plaqbuf[ibuf][i*4+1]=1; plaqbuf[ibuf][i*4+3]=0.2;
176 void culooks::cube::setWireColor(const float& r, const float& g, const float& b, const float& a)