FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Discrepancy in 2d/3d transform
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Discrepancy in 2d/3d transform  (Read 348 times)
pitaru

WWW Email
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

WWW
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
Pages: 1 

« Previous topic | Next topic »