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.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › rotate screen drawn with line()
Page Index Toggle Pages: 1
rotate screen drawn with line() (Read 410 times)
rotate screen drawn with line()
Dec 30th, 2008, 11:37pm
 
I draw 3d lines using line(x,y,z,x2,y2,z2) creating a sceen over the course of a few minutes and then I would like to rotate the entire sceen to see it from the side.  Is it possible to do this without requiring recording all the possitions and redrawing them on each frame?

One idea: paint line()'s onto an image which is mapped over a vertex and then rotate this.
Problem: I wont be able to see the original 3d shape of the lines.  Meaning: z is lost.

Does anyone have an idea of other solutions.  Here is some example code that explains the problem.  When run it paints onto a layer.  When you press ',' it rotates Y and starts a new layer.  My desire is that when you rotate it rotates the old layer with it, showing the z contours of the lines in accordance with the new rotation angle. (btw, '.' rotates back to the original plane)

Code:

import processing.opengl.*;
float angle = 0;

int x=10;
int y=10;
int z=0;

void setup () {
 size(800,600,OPENGL);
 hint(DISABLE_OPENGL_2X_SMOOTH);// opengl bug
 background(0);
 stroke(255);
}
void draw () {
rotateY(angle);
line(x,y,z, x+10,y,z+10);
x+=10;
y+=10;
if(x >= 800)
  x = 10;
if(y >= 600)
  y = 10;
}

void keyPressed() {
if (key == ',') {
   angle =  PI/3.0;
   stroke(255,0,0);
}
 else if (key == '.')
 {
   angle =  0;
   stroke(255);
 }
}
Re: rotate screen drawn with line()
Reply #1 - Dec 31st, 2008, 12:12pm
 
If it's in 3D you have to save all the lines and re-draw them to rotate around. I really can't see any way around it.
Page Index Toggle Pages: 1