modeling 01
play

Modeling (01) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk - PowerPoint PPT Presentation

Principles of Computer Graphics and Image Processing Modeling (01) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk Computer Graphics Image processing Representing and manipulation of 2D images Modeling Representing and


  1. Fast Forward to Practical Assignment Drawing a Line 76

  2. Drawing a Line 77

  3. Drawing a Line 78

  4. Drawing a Line  Some things to consider  Which pixels are to be drawn?  How thick the lines are?  How to join lines? 79

  5. Drawing a Line 80

  6. Drawing a Line  We need some basic math: 81

  7. Drawing a Line  We need some basic math: x=x1 y=y1 while(x<x2) plot(x,y) x++ y+=Dy 82

  8. Drawing a Line  After rounding 83

  9. Drawing a Line  Great, but what about accumulated error? 84

  10. Drawing a Line  What about steep lines? |m| ≤ 𝟐 |m| > 𝟐 85

  11. Drawing a Line  First code void drawLine(int x1, int x2, int y1, int y2) { float m = (y2-y1)/(x2-x1); int x = x1; float y = y1; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; y += m; } } 86

  12. Drawing a Line  It has some issues void drawLine(int x1, int x2, int y1, int y2) { float m = (y2-y1)/(x2-x1); not exact! int x = x1; float y = y1; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; y += m; accumulates error! } } 87

  13. Drawing a Line  First changes, use error threshold void drawLine(int x1, int x2, int y1, int y2) { float m = (y2-y1)/(x2-x1); int x = x1; int y = y1; float e = 0.0f; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; e += m; if(e>0.5f) { y += 1; e -= 1.0f; } } } 88

  14. Drawing a Line  More changes, error condition to 0 void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; float e = -0.5f; while(x<=x2) { setPixel(x, round(y), PIXEL_ON); x += 1; e += (y2-y1)/(x2-x1); if(e>0.0f) { y += 1; e -= 1.0f; } } } 89

  15. Drawing a Line  More changes, splitting up the fraction void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; float e = -0.5f*(x2-x1); while(x<=x2) { setPixel(x, y, PIXEL_ON); x += 1; e += y2-y1; if(e>0.0f) { y += 1; e -= x2-x1; } } } 90

  16. Drawing a Line  More changes, get rid of floats void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; int e = -(x2-x1); while(x<=x2) { setPixel(x, y, PIXEL_ON); x += 1; e += 2*(y2-y1); if(e>0) { y += 1; e -= 2*(x2-x1); } } } 91

  17. Drawing a Line  Jack E. Bresenham, 1962  Fast, no floating points, only for |𝑛| < 1 and 𝑦1 < 𝑦2 void drawLine(int x1, int x2, int y1, int y2) { int x = x1; int y = y1; int e = -(x2-x1); while(x<=x2) { setPixel(x, y, PIXEL_ON); x += 1; e += 2*(y2-y1); if(e>0) { y += 1; e -= 2*(x2-x1); } } } 92

  18. PPGSO Project OpenGL Project (simple demo / scene / game ) 93

  19. OpenGL Project - No engines allowed (NO Unity, Unreal engine etc.) - You can cooperate, help each other - Libraries for resource loading are allowed - Evaluated is graphical output, interaction and animation - Gameplay is secondary (is not scope of this lecture) 94

  20. OpenGL Project  Specification [6p]  Data structures (1p)  Class diagrams (1p)  Pseudocodes (1p)  User interaction diagrams (1p)  Structure rendering algorithms (1p)  Modul connection diagrams (1p)  Use of texture mapping on 3D geometry [4p]  Unique 3D meshes (2p)  Unique texturing using uv coordinates (2p)  Camera transformations [6p]  Camera with perspective projection (1p)  Animated camera (2p)  Interactive camera (2p)  Use of multiple camera view positions (1p) 95

  21. OpenGL Project  Scene logic [5p]  Implementation of a scene with logically relative objects (1p)  Changing scenes and multiple areas/scenes (2p)  At least 2 different scenes  Scene has a logical ground and background (sky, ceiling, walls…) (1p)  Presented demo must have a beginning and a logical ending (1p)  Objects and interactions [6b]  Dynamic scene with objects being created and destroyed during demo simulation (1p)  At least 2 different types of objects  Procedurally generated scene (2b) Constraints and deterministic definitions for object localization   Effective object to object collisions and interactions (3p)  Dynamic response to collisions 96

  22. OpenGL Project  Transformations and animation [9b]  Procedurally driven animation (2p)  Encapsulated method with parameters  Logical branching  Basic simulated animation with at least 2 forces using matrix algebra (2p) Eg. gravity + wind   Hierarchical object transformation (2p)  At least 2 levels with 3 objects  Using the aggregation and transformation matrices  Data driven animations, recommended using key-frames (3p)  Key-frame sequence represented by code structure of transformation matrix and time information  Interpolation using curves or quaternions and spherical linear interpolation 97

  23. OpenGL Project  Lighting with multiple light sources [7b]  Diffuse scene lighting with materials (2p)  Changeable color of light (1b)  Correct Phong lighting with multiple light sources (2p)  Correct depth-based attenuation  At least 3 material and light components  Correctly combine material and light components  Correct shadows or reflections using any approach you can think of (2p)  Project report (pdf) [7b]  1xA4 description of the project manual + runnable package (1b)  2xA4 screens from the projects + game video (2b)  Critical evaluation and update of the specification (4b) 98

  24. OpenGL Project  Get a project!  https://tinyurl.com/y3jdfms4  Subject information:  https://tinyurl.com/y6244wyn 99

  25. Next Week 2D Transformations 3D Transformations Projections 100

Recommend


More recommend