1 / 17

CS559: Computer Graphics

This project review covers how to change speed, orient a car, and draw trees in a computer graphics program. It also includes code samples and tips on implementing these features.

anordman
Download Presentation

CS559: Computer Graphics

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. CS559: Computer Graphics Lecture 23: Project 2 Review Li Zhang Spring 2008

  2. Today • Project 2 review

  3. Sample Code by Chi Man Liu

  4. Other basic features • How to change speed? • Add a slider with a callback to change timePerFrame • How to orient a car? • How to draw trees? • A triangle + a rectangle • A cone + a cylinder • Using gluQuadrics

  5. Piecewise circles (x2,y2) (x1,y1) R2 R1 t in [0,1] theta1 = t*2*PI-PI; draw train at [ x1 + R1 * cos(theta1), y1 + R1 * sin(theta1) ] t in [1,2] theta2 = (t-1)*2*PI; draw train at [ x2 + R2 * cos(theta2), y2 + R2 * sin(theta2) ]

  6. Arc-Length Parameterization (x2,y2) (x1,y1) R2 R1 t in [0,2*PI*R1] theta1 = t/(2*PI*R1)*2*PI-PI; draw train at [ x1 + R1 * cos(theta1), y1 + R1 * sin(theta1) ] t in [2*PI*R1, 2*PI*R1+2*PI*R2] theta2 = (t-2*PI*R1)/(2*PI*R2)*2*PI; draw train at [ x2 + R2 * cos(theta2), y2 + R2 * sin(theta2) ]

  7. Piecewise Cubics P4 P3 P1 P2

  8. Piecewise Cubics Task1: draw the whole curve DrawCubic(P4,P1,P2,P3); DrawCubic(P1,P2,P3,P4); DrawCubic(P2,P3,P4,P1); DrawCubic(P3,P4,P1,P2); For (t=0; t < 0.1; t+=0.01) { A=computePoint(Q1,Q2,Q3,Q4,t); B=computePoint(Q1,Q2,Q3,Q4,t+0.01); drawLine(A,B); } Fine with Hermite, Catmull-Ron, Cardinal How about Bezier? Task 2: find where the train is at time t: TrainLocation(P1,P2,P3,P4,t) If (0<=t<1) return computePoint(P4,P1,P2,P3,t) If (1<=t<2) return computePoint(P1,P2,P3,P4,t-1); If (2<=t<3) return computePoint(P2,P3,P4,P1,t-2); If (3<=t<4) return computePoint(P3,P4,P1,P2,t-3);

  9. Arc-Length Parameterization • Arbitrary curves? P4 P3 P1 P2

  10. Correct Orientation in 3D • Define and interpolate up vector

  11. Implement simple physics • Energy conservation

  12. Multiple Cars • Each has its own parameter t, assuming arc-length parameterization

  13. Hack Shadow (XL,YL,ZL) (x,y,z)

  14. Train smoke? • Balls moving upward and dissipating

  15. Arc-length parameterization t s 0 1 L 0 Arc-length parameterization y x Freeform

More Related