Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Project P3: CSG Lecture 08, File P3.ppt Due Feb 14 Individual.

Similar presentations


Presentation on theme: "1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Project P3: CSG Lecture 08, File P3.ppt Due Feb 14 Individual."— Presentation transcript:

1 1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Project P3: CSG Lecture 08, File P3.ppt Due Feb 14 Individual (Code and PPP) Jarek Rossignac CS1050: Understanding and Constructing Proofs Spring 2006

2 2 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Objectives Implement a 2D design system supporting –Disk primitives –CSG trees with Boolean operators –Interactive placement of primitives –Rendering of the resulting image Extensions for extra credit –Interactive editing of CSG tree

3 3 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Disk class and point-in-disk test class Disk { // class for disk primitive int x, y, r; Disk (int px, int py, int pr) {x=px; y=py; r=pr;}; void move (int px, int py) {x=px; y=py;}; boolean in (int pi, int pj) { boolean isIn=false; if (sq(pi-x)+sq(pj-y)

4 4 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Setting up 3 primitives Disk[] P = new Disk[np]; // array of primitives void setup() { … 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);

5 5 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Editing the primitives int pp=0; // currently selected primitive for moving it void keyPressed() { switch(key) { case 'p': for(int k=0; k': 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

6 6 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Draw calls pmc void draw() { // paints pixel (i,j) based on its classification for(int j=0; j

7 7 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Point-in-CSG test boolean pmc (int n, int pi, int pj) { // returns true if pixel (pi,pj) is in region of node n boolean res=false; switch(o[n]) { case 'p': res=P[L[n]].in(pi,pj); break; // if n is a primitive, call its "in" method // *** edit to improve performance by avoiding redundant recursive calls case '-': res= pmc(L[n],pi,pj) && !pmc(R[n],pi,pj); break; // if difference, combine result of recursive call // *** add here the lines for union, intersection, xor }; return(res); };

8 8 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Assigned implementation Add the code for the other operations Modify these statements to avoid redundant recursions –if P in A, then P in A–B, hence, no need to test against B Manually edit the code defining the CSG tree and primitive lists to produce a Mikey Mouse face –Ears, slit eyes, smiley mouth. Front or profile Add 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 the currently selected leaf node to be the ID of the currently selected primitive

9 9 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Extra credit 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% Add code and key-actions to save and load the CSG and Primitives: +10%

10 10 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Deliverables The usual on PPP with applet, code with COMMENTS, Include the definition and image of your Mikey Mouse Clearly indicate which extra credit parts you have implemented


Download ppt "1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Project P3: CSG Lecture 08, File P3.ppt Due Feb 14 Individual."

Similar presentations


Ads by Google