CS3451-P5 - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CS3451-P5

Description:

if (dot(N,V(gP[gn-1],g(c))) 0) c=n(c); else c=p(c); gmove(); } void gmove ... show polygonized disk above gP[gn-gm-1] using gN[gn-gm-1] and D as basis vectors. ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 10
Provided by: georgeb
Category:
Tags: cs3451 | gp

less

Transcript and Presenter's Notes

Title: CS3451-P5


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

2
Show path
  • Define a data structure for the path
    (pointsnormals)
  • pt gP new pt5000 // path points
  • vec gN new vec5000 // 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() gP0g(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(gPgn-1,g(c)))gt0) cn(c) else
    cp(c) gmove()
  • void gmove()
  • Similar to gstart

5
Smooth normals
  • if (key's') M.gsmoothNormals()
  • void gsmoothNormals () vec L new vecgn
  • // 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 (keyJ') jumps!jumps
  • if (key't') M.gextend() if (jumps)
    M.gjump(C)
  • void gjump (cam C)
  • C.FP(gPgn-gm-1)
  • C.E S(S(C.F,-200,gD),200,gNgn-gm-1)
  • C.US(-1,gNgn-gm-1)
  • C.sD200
  • 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 L0 // measure length
    of displayed path (to gm)
  • show polygonized disk above gPgn-gm-1
  • using gNgn-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)
Write a Comment
User Comments (0)
About PowerShow.com