1 / 9

CS3451-P5

CS3451-P5. Rolling a disk on a triangle mesh. Show path. Define a data structure for the path (points+normals) pt [] gP = new pt[5000]; // path points vec [] gN = new vec[5000]; // path normaLS vec gD = new vec (1,0,0); // current direction

finnea
Télécharger la présentation

CS3451-P5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS3451-P5 • Rolling a disk on a triangle mesh

  2. Show path • Define a data structure for the path (points+normals) • pt [] gP = new pt[5000]; // path points • vec [] gN = new vec[5000]; // path normaLS • vec gD = new vec (1,0,0); // current direction • int gn = 0; // number of path points • int gm = 0; // number of last undisplayed steps • Visualize it (a bit offset from the surface) • Let the user add points • By clicking void keys() {… if (key=='r') {C.setMark(); M.hitTriangle(); M.gstart();}; if (key=='t') {C.setMark(); M.hitTriangle(); M.gextend();};

  3. Start the path • User click selects corner c and sets mark (green) if (key=='r') {C.setMark(); M.hitTriangle(); M.gstart(); }; void gstart() { gP[0]=g(c); …… }; Compute exit point S1 on opposite edge Compute edge-normal at S1 Compute new (reflected) D Show them all

  4. Extend the path if (key=='t') {M.gextend(); if (jumps) M.gjump(C);}; void gextend(){vec N = cross(triNormal(t(c)),gD); if (dot(N,V(gP[gn-1],g(c)))>0) c=n(c); else c=p(c); gmove(); } void gmove() {… Similar to gstart

  5. Smooth normals if (key=='s') {M.gsmoothNormals();}; void gsmoothNormals () {vec[] L = new vec[gn];… // one line

  6. Display a subset of the path int gn = 0; // number of path points int gm = 0; // number of last not displayed steps void keys() { if (key==',') M.gm++; if (key=='.') M.gm--; Useful to compute the path first, then smooth the normals, then roll

  7. Follow the disk with the camera if (key==’J') jumps=!jumps; if (key=='t') {M.gextend(); if (jumps) M.gjump(C);}; void gjump (cam C) { C.F=P(gP[gn-gm-1]); C.E= S(S(C.F,-200,gD),200,gN[gn-gm-1]); C.U=S(-1,gN[gn-gm-1]); C.sD=200; C.pullE(); C.pose(); };

  8. Display disk void gshow() {stroke(red); gshowPath(); stroke(blue); gshowNormals(); stroke(magenta); fill(blue); gshowPoints(); fill(orange); gdisk(30); } void gdisk(float d) {float L=0; // measure length of displayed path (to gm) show polygonized disk above gP[gn-gm-1] using gN[gn-gm-1] and D as basis vectors. rotate it to reflect distance traveled L I show it missing one slice to check the roll (you should put a texture)

  9. Results • 3 hours • 40 lines of code (total)

More Related