level 3
sos2457
楼主
下面写的程序是以Y轴旋转的,怎么改才能以中心轴旋转?
跪求大神指点
![[委屈]](/static/emoticons/u59d4u5c48.png)
int wl = 500, bl = wl /20, bn = 9;
int degy = 0;
void setup(){
size(wl, wl, P3D);
}
void draw(){
background(0);
translate(wl /3, wl /3, 0);
rotateY(radians(degy++));
for(int y = 0; y < bn; y++){
pushMatrix();
for(int x = 0; x < bn; x++){
change_color(x, y);
box(bl, bl, bl);
translate(bl, 0, 0);
}
popMatrix();
translate(0, bl, 0);
}
}
void change_color(int x, int y){
int[][] col = { {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255} };
int n = (x + y * bn) %7;
fill(col[n][0], col[n][1], col[n][2]); }
2015年10月27日 04点10分
1
跪求大神指点
int wl = 500, bl = wl /20, bn = 9;
int degy = 0;
void setup(){
size(wl, wl, P3D);
}
void draw(){
background(0);
translate(wl /3, wl /3, 0);
rotateY(radians(degy++));
for(int y = 0; y < bn; y++){
pushMatrix();
for(int x = 0; x < bn; x++){
change_color(x, y);
box(bl, bl, bl);
translate(bl, 0, 0);
}
popMatrix();
translate(0, bl, 0);
}
}
void change_color(int x, int y){
int[][] col = { {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255} };
int n = (x + y * bn) %7;
fill(col[n][0], col[n][1], col[n][2]); }