|
Author |
Topic: Discrepancy in 2d/3d transform (Read 348 times) |
|
pitaru
|
Discrepancy in 2d/3d transform
« on: Jun 26th, 2003, 2:33pm » |
|
someone pointed out to me that 2D and 3D objects are not affected by transformation in the same manner: to rotate a 2d object on its axis, the shape must be drawn *after* the transformation routine: translate(width/2, height/2,0); rotateY(angleX); rotateX(-angleY); translate(-width/2, -height/2,0); ellipse(100, 150, 50, 50); to rotate a 3d object on its axis, the shape must be drawn *during* the transformation routine: translate(width/2, height/2,0); rotateY(angleX); rotateX(-angleY); box(40); translate(-width/2, -height/2,0);
|
|
|
|
arielm
|
Re: Discrepancy in 2d/3d transform
« Reply #1 on: Jun 29th, 2003, 6:21pm » |
|
in your "box" example, the last translate seems useless to me, because it won't affect the drawing of the box anyway... but concerning the discrepancy you mentioned, the following code for the ellipse is fixing-up things i guess: Code: float angleX; float angleY; void setup() { size(200, 200); angleX = 0.0; angleY = 0.0; } void loop() { ellipseMode(CENTER_DIAMETER); translate(width/2, height/2,0); rotateY(angleX); rotateX(-angleY); ellipse(0, 0, 50, 50); angleX += radians(2.0); angleY += radians(2.0); } |
| the point: i'm an ellipse but i want to feel like a box, so first i set my "ellipseMode", so i'm drawn from the center, and second, i use "zeroed" x and y coordinates! make sense?
|
Ariel Malka | www.chronotext.org
|
|
|
|