anandmu
YaBB Newbies
Offline
Posts: 2
Broken lines in 3d graphics with P3D
Sep 21st , 2005, 11:16pm
Hi, I am a newbie to processing and am having trouble with 3d graphics on it. I might be making some mistake with my code here but I have tried several things and nothing works. I have comfortably decided to put the blame on processing and so here is my post. If any of you can comment it will be great. OS: windows xp sp2 Version of processing: 0.91 beta Comments: I am using P3D. I realized OPENGL had several issues so I am not using it. The Problem: Below is a simple code which is supposed to draw a box and when a user presses any key it should rotate about the X axis by 5 degrees. The trouble is that the box which rotates is all cropped and broken. When I first saw this I felt it is because ortho by default is ortho(0,width,0,height,-10,+10). I suspected that the -10 and +10 is causing this, so I added ortho(0,width,0,height,-100,+100) but that simply broke the whole thing - the box simply does not appear. Is this a problem with my code? or is this a problem with processing? If it is the former please let me know what is wrong here. If it is the latter is there a work around? This sounds fairly fundamental to me so somebody must have hit this. I searched the database and previous posts but found nothing pertaining to ortho and P3D. Please help. Thanks in advance. --- here is my code --- color black = color(0,0,0); color white = color(255,255,255); int X=0; void setup() { size(200, 200, P3D); background(255,255,255); lights(); } void drawAtom(color clr) { pushMatrix(); // Uncomment stuff below or just ortho line // and nothing will showup //resetMatrix(); //ortho(0,200,0,200,-100,100); stroke(clr); translate(50,50,0); rotateX(radians(X)); translate(25,25,0); box(15); popMatrix(); } void draw() { } void keyPressed() { drawAtom(white); X = X+5; drawAtom(black); }