// Project 3 for CS1050 // by Jarek Rossignac /*Student should: - add the code for the other operations - modify these statements to avoid redundant recursions - manually edit the CSG tree and primitive lists to produce a Mikey Mouse face - Key action to change selected CSG node (initially 0, root) * P means go to parent (or stay if root) * L means go toleft child (or stay if leaf) * R means go to righ child (or stay if leaf) - Key actions to edit the operator at the selected CSG node - Key action to change the ID of the primitive at a leaf node Extra credit if develop data-structure and code to support: - Keys to expand primitive nodes to boolean nodes (press key for desired operator): +5% - Keys to collapse boolean nodes to primitive: +5% */ int nn=10; // number of nodes int np=3; // number of primitivces color red = color(155,0,0), green = color(50,255,50); color blue = color(0,0,155), yellow = color(255,55,50); Disk[] P = new Disk[np]; // array of primitives char o[] = new char[nn]; // operator union '+'. intersection '*', difference '-', xor '#' int L[]=new int[nn]; // integer index to left child int R[]=new int[nn]; // integer index to right child int pp=0; // currently selected primitive for moving it void setup() { size(400, 400); background(255); noFill(); P[0]=new Disk(150,150,100); // make primitives with Cx, Cy, radius P[1]=new Disk(250,150,100); P[2]=new Disk(200,250,100); // make tree specifying the operator or primitive and the opernds o[0]='-'; L[0]=1; R[0]=2; // node 0 is a difference of node 1 and node 2 o[1]='p'; L[1]=0; // node 1 is the primitive with ID=0 o[2]='-'; L[2]=3; R[2]=4; // node 2 is a difference of node 3 and 4 o[3]='p'; L[3]=1; // node 3 is theprimitive with ID=1 o[4]='p'; L[4]=2; // node 4 is theprimitive with ID=2 } void draw() { // paints pixel (i,j) based on its classification if (!keyPressed) { // render CSG for(int j=0; j': P[pp].r += 10; break; // incrase the radius of selected primitive case '<': P[pp].r -= 10; break; }; }; void mousePressed() {P[pp].move(mouseX,mouseY);}; // move center of selected primitive