Presentation is loading. Please wait.

Presentation is loading. Please wait.

3451-S2008: Project 4 (revised) Ray = line through eye and mark (picked surface point) Cylinder = all points of distanceradius to ray Stabbed vertex =

Similar presentations


Presentation on theme: "3451-S2008: Project 4 (revised) Ray = line through eye and mark (picked surface point) Cylinder = all points of distanceradius to ray Stabbed vertex ="— Presentation transcript:

1 3451-S2008: Project 4 (revised) Ray = line through eye and mark (picked surface point) Cylinder = all points of distanceradius to ray Stabbed vertex = vertex inside the cylinder Stabbed triangle = triangle intersecting the cylinder (or for simplicity, intersected by ray or having at least one vertex in cylinder) Cap = edge-connected component of stabbed triangles. Loop = cycle of border edges around a hole in the mesh

2 Simplified version of P4
‘x’ will identify the stabbed and make them temporarily invisible. When ‘i’ is kept pressed and the mouse clicked and dragged horizontally, the radius of the cylinder will change and the holes will update, so that the user can control the size of the hole. The user may use ‘y’ to toggle the visibility of the triangles and ‘u’ to make all triangles visible. This way we can inspect the caps by themselves or together with the rest of the mesh. And we can also close the holes (press ‘u’ and make holes elsewhere). ‘H’ (already implemented) deletes all invisible triangles and compacts the corner table. ‘k’ will assume that there are exactly 2 loops and will construct a triangle strip that stitches them.

3 Step 1: Keyboard commands
Add action keys in the ‘keys’ tab: void keys() { …. if (key=='u') {M.unhide();}; if (key=='y') {M.toggleVisibility();}; if (key=='x') {C.setMark(); M.hideCaps();}; if (key=='k') {M.stitchBorders(); }; and create dummy placeholder methods in the class Mesh in the meshClass tab for the method names in blue The variables pt eye and pt mark, which is where you clicked on the mesh are set when you call C.setMark(); already provided

4 Step 2: Direct manipulation of radius
In the Mesh class (‘meshClass’ tab) add float r2 = 1000; // square radius of cylinder In the ‘void updateView()’ procedure ( ‘keys’ tab) add if (key=='i') { M.r2+=(mouseX-pmouseX)*abs(mouseX-pmouseX); M.hideCaps(); }; This will update the r2 variable and re-compute the caps as the user keeps ‘i’ and mouse pressed and moves the mouse horizontally You may want to debug it by printing the value of M.r2 each time it is changed. Make sure to remove the print statement once it works, otherwise things will be very slow.

5 Step 3: Visualization ‘e’ ‘y’ ‘u’
Write the toggleVisibility and toggleVisibility methods for the Mesh class. the table visible[nt] contains the visibility status for each triangle nt is the number of triangles Here’s unhide: void unhide() { for(int i=0; i<nt; i++) visible[i]=true; } type it in and also make toggleVisibility Test them on the mesh by using ‘e’ to hide some triangles and then reveal them with ‘y’ or unhide all with ‘u’ ‘e’ ‘y’ ‘u’

6 Step 4a: Geometry Write the hideCaps method that identifies the stabbed triangles and makes them invisible: void hideCaps() { unhide(); classifyVertices(eye,mark); hideStabbedTriangles(); hideHitTriangles(); }

7 Step 4b: classifyVertices(eye,mark);
Use Mv[v] to indicate whether a vertex is in the cylinder. In the Mesh class, add: void classifyVertices(pt A, pt B) { for(int v=0; v<nv; v++) Mv[v]=0; for (int c=0; c<nc; c++) if(ptInCylinder(g(c),A,B,r2)) Mv[v(c)]=1;} and provide the function below at the bottom of the the GEO3D tab. You need to provide the code for computing d2: boolean ptInCylinder(pt P, pt A, pt B,float r2) { vec AP=V(A,P); vec AB=V(A,B); float d2 = … // distance between P and the line through A and B return d2<r2;} Debug this function and the classifyVertices

8 Step 4c: hideStabbedTriangles();
In the Mesh class, provide code that will hide the stabbed triangles void hideStabbedTriangles() {for(int t=0; t<nt; t++) if (triCutCylinder(t)) visible[t]=false;} First, provide a naïve method that will return true if any vertex of triangle t is stabbed (i.e. when Mv[v]==1 for any vertex of t): boolean triCutCylinder(int t) {return … ;} Later, for extra credit, try to provide a better approach that identifies the stabbed triangles even if they have all their vertices outside of the cylinder.

9 Step 4d: hideHitTriangles();
Here you want to identify which triangles are hit by the ray. For example, when the radius of the cylinder is very small, the hideStabbedTriangles(); method would miss these. in the class Mesh, add: void hideHitTriangles() { for (int t=0; t<nt; t++) if (rayHitTri(eye,mark,A,B,C)) visible[t]=false; } You must replace A,B,C in the code above by expressions that return the points where the vertices of triangle t are located. Debug this by temporarily commenting out the hideStabbedTriangles(); call in void hideCaps() {…

10 Step 5a: Stitching Invent a simple and effective solution to the stitching problem where there are only 2 loops and implement it in the Mesh method: void stitchBorders() { clean(); // removes hidden triangles and cleans corner table } No triangle should intersect the ray The resulting mesh should be free from self-intersections Try to minimize the surface area of the stitching triangle strip You do not need to follow the approach suggested below

11 Step 5b: Find a corner on each loop
Write code that will find the first corner c1 that has no opposite. Mark as visited all corners along the corresponding loop. Find a second unmarked corner c2 that has no opposite. Show a line segment between them.

12 Step 5c: Make bridge Write code that will add 2 triangles that form a bridge (quad) connecting the border edge of c1 to a vertex of the border edge of c2.

13 Step 5d: Find best bridge
Compute the area of the two triangles. Try all combinations of corners c1 long loop 1 and c2 along loop 2 and use the one for which the bridge has minimal area.

14 Step 5e: Avoid the ray In the above approach, only use bridges that do not hit the ray.

15 Step 5f: Zip steps Advance c1 along loop 1 and c2 (in the opposite direction) along loop 2. Implement a zipRight step that adds a triangle between the border edge of c1 and the first vertex of c2. This triangle should have one of its edges shared with the previous bridge. The step should advance c1 to the corner facing the next border edge along loop 1. Implement the zipLeft step that does the same thing but for the border edge of loop 2. Hence it advances c2.

16 Step 5g: Zipping Make a loop that zips until no more border edges exist. It should advance either c1 or c2, selecting the move that will add the triangle with the smallest area and checking that the candidate triangle is not intersected by the ray. Make sure that the O table is set properly and that the triangles you have created are properly oriented. You may use clean() to identify in red the border edges (there should be none). You may try to use computeO() at the end, or to compute the opposite corners yourself as you make progress in the stitching.

17 Step 5h: Best next zip Pick zipLeft or zipRight selecting the one that creates a triangle more parallel to the ray.

18 Step 5i: Snap to cylinder
Snap border vertices to the cylinder

19 Deliverables Teams of 2 or solo (your choice, no benefit for solo)
One web page per project ( URL to Justin) Proper title, authors (names, pictures, s, links) Running applet with 3D mesh viewer and clear explanation on how to use your code. Link to source code with clear explanation of where to find the code you wrote (which should be commented). The whole project is only about 50 LoC!!! PDF file with clear and complete explanation (geometric formulae and pieces of code) showing how you: Identify the vertices in the cylinder Identify and make invisible the triangles with at least one vertex in the cylinder Find the c1 and c2 corners on the loops Construct the bridge Compute the triangle area Extra credit suggestions: Correct computation of the stabbed triangle Updating the O table as you add triangles to the zip Optimization of the zipped strip (for example through edge-flips) Handling cases with 4 loops and with general comments on the applications and limitations of this tool.

20 Timeline and grading Steps 1 through 4 should be done and debugged by March 7 before class. They are worth 50% of the grade. By march 7, before class, please to Justin the URL of the project page with the team members… and the code implementing these steps (no documentation needed at this point). If you are not done with some of these steps, please let him know which ones and what is holding you. Steps 5 is due on March 24 before class along with the documentation of the whole project (as discussed above). It is worth 50% of the grade. You do not need to follow the proposed approach. If you implement your own version, please make sure that it is clearly explained Extra credit. Up to a total of 50% of the grade. List the extra credit clearly on your project page It is not limited to the items suggested above Extra credit will be allocated on a competitive basis: The team with the best extra credit package will get up to 50% (TA discretion) and weaker packages will get proportionally less. In class presentations (optional) can bring up to 20% extra credit.

21 Examples


Download ppt "3451-S2008: Project 4 (revised) Ray = line through eye and mark (picked surface point) Cylinder = all points of distanceradius to ray Stabbed vertex ="

Similar presentations


Ads by Google