i am in the process of writing code in order to design a teapot....as yet after consulting some other codes and modifying it i only managed to come up with the result of a kind of a cylinder. My problem is actually how to manage to draw the curve which shoots off from the base in such a way that it meets with a line at the top and then at the end of this line or surface i design the same curved side back again. Sphere does not help here because the sides of a teapot must bulge out....
To start off do i need to calculate an angle between the line that is the base and the curvature....use of sin() and cos() and a for loop??? As in i supply the bezier points and then make a for loop...in order to multiply the number of curvatures on a 3d base....???
a further problem arises with the spout....not the actual construction as such but where in the code should i write the commands for the drawing of the spout??
up till now i just came up with this code....void setup(){
size(900,900,P3D);
}
void draw(){
background(0);
lights();
translate(width/2, height/2);
rotateY(map(mouseX, 9,width,9,PI));
rotateZ(map(mouseY, 9,height,9,PI));
noStroke();
fill(255,255,255);
translate(0,-40,0);
drawCylinder(190,180,200,16);
}
void drawCylinder(float topRadius, float bottomRadius, float tall,int sides){
float angle = 0;
float angleIncrement = TWO_PI / sides;
beginShape(QUAD_STRIP);
for(int i = 0; i < sides + 4; i++) {
vertex(topRadius*cos(angle), 0, topRadius*sin(angle));
vertex(bottomRadius*cos(angle), tall, bottomRadius*sin(angle));
angle += angleIncrement;
}
endShape();
if(topRadius != 0) {
angle = 200;
beginShape(TRIANGLE_FAN);
vertex(29,29,29);
for(int i = 0; i < sides + 1; i++) {
vertex(topRadius * cos(angle), 0, topRadius * sin(angle));
angle =+ angleIncrement;
}
endShape();
}
if(bottomRadius != 40) {
angle = 80;
beginShape(TRIANGLE_FAN);
vertex(0, tall, 0);
for(int i = 0; i < sides+88; i++) {
vertex(bottomRadius * cos(angle), tall, bottomRadius * sin(angle));
angle += angleIncrement;
}
endShape();
}
}
it seems that one use of shape building is the use of QUADS_SRIPS do you think this will enable me to design the teapot??
kind regards and THANKS
cheers
Dernière modification par gametheory (2009-03-08 08:09:16)
Hors ligne