Imageburn
YaBB Newbies
Offline
Posts: 9
P3D problem:
Nov 5th , 2006, 5:43am
Getting into Processing, putting together a program to draw and sketch images. I know I will have to begin deliniating some of these operations into separate methods, but for now I have a few syntax/layout problems that if answered could really help me on my way. Looking at the following code, which compiles, why are the squares not drawing? Following are two code samples. It draws if taken alone like this, and please notice that I have removed P3D capabilty: //Let's get this started void setup() { background(255); size(500,500); frameRate(10); } void draw() { if(keyPressed==true) { //a drawing 'method' switch(key) { case 'a' : stroke(30,20,55,30); rect(mouseX,mouseY,30,30); } } println(frameCount); } *********************************************************** But as soon as I introduce a rotation feature, it ceases to draw. What's the deal? I have seen that strokeWeight(),and stroke() is un-available in P3D, so I'm using the beginshape() method. Where's my logical error? *********************************************************** //Let's get this finished float xRot = 0.0; //storage for current rotation values float zRot = 0.0; float bang; //storage for mouse velocity values float buck; float bizz; void setup() { background(255); size(500,500); frameRate(10); } void draw() { bang = mouseX - pmouseX; //calculate mouse velocity buck = mouseY - pmouseY; if(keyPressed==true) { //a drawing 'method' switch(key) { case 'a' ; translate(mouseX,mouseY); beginShape(); vertex(30, 20); vertex(85, 20); vertex(85, 75); vertex(30, 75); endShape(); } } if(mousePressed) { //change rotation value xRot = xRot + buck; //based on mouse velocity zRot = zRot + bang; } rotateX(xRot); //apply current rotations rotateZ(zRot); println(frameCount); println(xRot); println(zRot); }