We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Rotation (Read 680 times)
Rotation
Dec 2nd, 2009, 5:31am
 
The sketch I am building rotates in 3D, but currently the central point is way off the center of the drawing..

I have uploaded the sketch here:http://www.samhumphrey.co.uk/applet/test/index.html
(click to rotate).

The ellipse shows where '0, 0, 0' is, I tried removing as many translations etc as I could to make it spin around without traveling around an orbit, but not found it yet! I found an example of a revolving cube which is basically what I'm after, but it might be different in my case as I am using push/popMatrix:

Cedric wrote on Nov 17th, 2009, 8:56am:
something like this

float x = 0;
float y = 0;
void setup(){
 size(400, 400, P3D);


}
void draw(){
 background(150);
 translate(width/2, height/2, 200);
 rotateX(x);
 rotateY(y);

 box(50, 50, 50);
}

void keyPressed(){
 if ( key == CODED){

   if (keyCode == UP ){
     x+=(2*PI/180.0 );
   }

   if (keyCode == RIGHT){
     y+=(2*PI/180.0 );
   }

   if (keyCode == LEFT){
     y-=(2*PI/180.0 );
   }

   if (keyCode == DOWN){
     x-=(2*PI/180.0 );
   }

 }
}


Re: Rotation
Reply #1 - Dec 2nd, 2009, 5:46am
 
I cant run your sketch, not sure why, but you probably solve your problem my moving the rotation somewhere else.
Re: Rotation
Reply #2 - Dec 2nd, 2009, 6:21am
 
It's because the things you draw (except the ellipse) are not drawn around (0, 0, 0). They are around (0, 0, 1200) or something like that. Just bring them back to the origin.
Re: Rotation
Reply #3 - Dec 2nd, 2009, 6:35am
 
I am guessing here, but it may give you a hint.

I think your 3D starts to draw from 0.0 along the Z axis, and like antiplastyik said it may be translated on the Z hundred pixels away at some point, so I will try to draw everything and translate everything to the middle, so the middle of everything is at the point 0.0 in Z

Wait! I jsut said the same as antiplastik Tongue

Hope that makes any sense
rS
Re: Rotation
Reply #4 - Dec 2nd, 2009, 9:22am
 
Yeah sorted:) - just had a few messy translate functions mixed up in my push/pops. Q!
Page Index Toggle Pages: 1