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(alt, 1, 0, 0);
63 glRotatef(az, 0, 1, 0);
64 glColor4f(wireColor[0], wireColor[1], wireColor[2], wireColor[3]);
65 glLineWidth(framewidth);
69 glEnable(GL_DEPTH_TEST);
70 glDepthMask(GL_FALSE);
73 glScalef(zoom, zoom, zoom);
74 glRotatef(alt, 1, 0, 0);
75 glRotatef(az, 0, 1, 0);
82 void culooks::cube::drawAll()
84 glMatrixMode(GL_MODELVIEW);
87 glTranslatef(-1,-1,-1);
89 for (int iz=0; iz<l; iz++) {
90 for (int iy=0; iy<l; iy++) {
91 for (int ix=0; ix<l; ix++) {
93 glTranslatef(2.0*ix/l,2.0*iy/l,2.0*iz/l);
94 glScalef(2.0/l,2.0/l,2.0/l);
96 glLineWidth(linkwidth);
101 glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 0],
102 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 1],
103 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 2],
104 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 3]);
105 glVertex3f(0,0,0); glVertex3f(1,0,0);
106 glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 0],
107 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 1],
108 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 2],
109 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 3]);
110 glVertex3f(0,0,0); glVertex3f(0,1,0);
111 glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 0],
112 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 1],
113 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 2],
114 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 3]);
115 glVertex3f(0,0,0); glVertex3f(0,0,1);
121 /* draw plaquettes */
122 if (!hideplaquettes) {
124 glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 0],
125 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 1],
126 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 2],
127 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 3]);
128 glVertex3f(0, 0, 0); glVertex3f(1, 0, 0); glVertex3f(1, 1, 0); glVertex3f(0, 1, 0);
129 glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 0],
130 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 1],
131 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 2],
132 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 3]);
133 glVertex3f(0, 0, 0); glVertex3f(1, 0, 0); glVertex3f(1, 0, 1); glVertex3f(0, 0, 1);
134 glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 0],
135 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 1],
136 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 2],
137 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 3]);
138 glVertex3f(0, 0, 0); glVertex3f(0, 1, 0); glVertex3f(0, 1, 1); glVertex3f(0, 0, 1);
150 culooks::cube::cube(int _l)
155 plaqbuf[0] = new float[l*l*l*3 * 4];
156 plaqbuf[1] = new float[l*l*l*3 * 4];
157 linkbuf[0] = new float[l*l*l*3 * 4];
158 linkbuf[1] = new float[l*l*l*3 * 4];
171 for (int ibuf=0; ibuf<2; ibuf++)
172 for (int i=0; i<l*l*l*3; i++) {
173 linkbuf[ibuf][i*4+0]=1; linkbuf[ibuf][i*4+3]=0.6;
174 plaqbuf[ibuf][i*4+1]=1; plaqbuf[ibuf][i*4+3]=0.2;
181 void culooks::cube::setWireColor(const float& r, const float& g, const float& b, const float& a)
189 void culooks::cube::setFrameWidth(float width) {
193 void culooks::cube::setLinkWidth(float width) {