求大神教下,这样的图形怎么编程,是3D效果的,可以旋转。
processing吧
全部回复
仅看楼主
level 7
最好来个编程参考。中间一个球体,东西南北各一个小球,带旋转的,3D效果。谢谢!
2015年03月26日 12点03分 1
level 7
朋友,帮个忙,谢谢了。
2015年03月27日 10点03分 2
level 9
大概这样丑
void setup(){
size(600, 600, P3D);
noSmooth();
}
void draw(){
background(255);
translate(width/2, height/2);
rotateX(map(mouseY, 0, height, -PI, PI));
rotateY(map(mouseX, 0, width, -PI, PI));
noStroke();
spotLight(0,255, 255, 80, 20, 40, -1, 0, 0, PI/2, 2);
sphere(40);
pushMatrix();
translate(0, 100, 0);
sphere(30);
popMatrix();
pushMatrix();
translate(0, -100, 0);
sphere(20);
popMatrix();
pushMatrix();
translate(100, 0, 0);
sphere(10);
popMatrix();
pushMatrix();
translate(-100, 0, 0);
sphere(40);
popMatrix();
}
2015年03月27日 14点03分 3
谢谢你,但是我要的不是这样的效果,要的是,他们在同一水平面上,只能顺时针或逆时针旋转的。
2015年03月28日 04点03分
回复
smile�滭����
:哦,你可以用translate(x, y, z);来控制球的位置
2015年03月28日 05点03分
回复
__����
:我要的是这种形式的,但是我只弄出一个,其他3个弄不出来,你可以帮我修改下么,谢谢!
2015年03月28日 05点03分
回复
smile�滭����
:我再请教你一个问题,就是在3D中怎么画一个圆柱。
2015年03月31日 05点03分
level 7
void draw() {
background(0);
translate(width/2,height/2,0);
rotateY(PI*frameCount/300);
colorMode(HSB,360,100,100);
fill(150,80,60);
stroke(255);
sphere(50);
translate(width/10,height/200,60);
rotateY(PI*frameCount/300);
sphere(25);
}
就是这个
2015年03月28日 05点03分 4
level 9
void setup(){
size(600, 600, P3D);
noSmooth();
}
void draw(){
background(255);
translate(width/2, height/2);
rotateX(-PI/12);
rotateY(map(mouseX, 0, width, -PI, PI));
noStroke();
spotLight(0,255, 255, 80, 20, 40, -1, 0, 0, PI/2, 2);
translate(0, 20, 0);
sphere(40);
pushMatrix();
translate(0, 0, 200);
sphere(30);
popMatrix();
pushMatrix();
translate(0, 0, -200);
sphere(20);
popMatrix();
pushMatrix();
translate(200, 0, 0);
sphere(10);
popMatrix();
pushMatrix();
translate(-200, 0, 0);
sphere(40);
popMatrix();
}
2015年03月28日 07点03分 5
这样?
2015年03月28日 07点03分
回复
__����
:差不多了。非常感谢你。[酷]
2015年03月28日 07点03分
回复
smile�滭����
:对了,你为什么用到矩形方阵呢?
2015年03月28日 07点03分
回复
smile�滭����
:把坐标推进堆栈,方便计算下一个球的位置
2015年03月28日 07点03分
level 7
void setup() {
size(900, 900, P3D);
smooth();
}
void draw() {
background(0);
translate(width/2,height/2,0);
rotateY(PI*frameCount/300);
colorMode(HSB,360,100,100);
fill(150,80,60);
stroke(255);
sphere(50);
translate(width/10,height/200,60);
rotateY(PI*frameCount/300);
sphere(25);
}
这个才是,上面那个复制时少复制了。
2015年03月28日 07点03分 6
level 3
这个怎么变颜色啊
2017年06月22日 15点06分 7
1