Lecture 18: FLTK and Curves Li Zhang Spring 2008

Slides:



Advertisements
Similar presentations
Computer Graphics (Spring 2008) COMS 4160, Lecture 6: Curves 1
Advertisements

Lecture 10 Curves and Surfaces I
FLUID  The Fast Light User Interface Designer, or FLUID, is a graphical editor that is used to produce FLTK source code  Creates C++ code  Compile.fl.
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
OpenGL and Projections
Drawing Parametric Curves Jean-Paul Mueller. Curves - The parametric form of a curve expresses the value of each spatial variable for points on the curve.
Curve Modeling Bézier Curves
19/4/ :32 Graphics II Syllabus Selection and Picking Session 1.
3.2 – Solving Linear Equations by Graphing. Ex.1 Solve the equation by graphing. x – y = 1.
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
CS 376 Introduction to Computer Graphics 04 / 23 / 2007 Instructor: Michael Eckmann.
Computer Graphics. Requirements Prerequisites Prerequisites CS 255 : Data Structures CS 255 : Data Structures Math 253 Math 253 Experience with C Programming.
FLTK Tutorial.
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
FLTK. Objectives Install and Use FLTK Widgets ◦Callbacks Handling event ◦System events ◦Mouse events ◦Keyboard events.
1 Chapter 12 GUI C/C++ Language Programming Wanxiang Che.
Spring 2010Topics in Computer Graphics FLTK and OpenGL Jyun-Ming Chen.
CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5.
CS559: Computer Graphics Lecture 27: Texture Mapping Li Zhang Spring 2008 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee.
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008.
OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
11/6/ :55 Graphics II Introduction to Parametric Curves and Surfaces Session 2.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring.
Splines I – Curves and Properties based on: Michael Gleicher Curves, chapter 15 in Fundamentals of Computer Graphics, 3 rd ed. (Shirley & Marschner) Slides.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
CS559: Computer Graphics Final Review Li Zhang Spring 2010.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
CS 325 Computer Graphics 04 / 30 / 2010 Instructor: Michael Eckmann.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 12: Curves 1
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
OpenGL LAB III.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
Introduction to Parametric Curve and Surface Modeling.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
School of Computer Science
School of Computer Science
Curve & Surface.
CS 445 / 645 Introduction to Computer Graphics
FLTK The Fast Light Toolkit
Lecture 33: Shape Modeling Li Zhang Spring 2008
Reference1. [OpenGL course slides by Rasmus Stenholt]
OpenGL API 2D Graphic Primitives
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Fall 2004
Which of the equations below is an equation of a cone?
© University of Wisconsin, CS559 Spring 2004
Stack buffer overflow.
Implicit Functions Some surfaces can be represented as the vanishing points of functions (defined over 3D space) Places where a function f(x,y,z)=0 Some.
Basic Assembly.
OpenGL program.
Introduction to Parametric Curve and Surface Modeling
Presentation transcript:

Lecture 18: FLTK and Curves Li Zhang Spring 2008 CS559: Computer Graphics Lecture 18: FLTK and Curves Li Zhang Spring 2008

Today Finish FLTK curves Reading http://pages.cs.wisc.edu/~cs559-1/tutorials.htm Shirley: Ch 15.1, 15.2, 15.3

FLUT vs FLTK

FLTK Demo Demo: Window-> glWindow Window-> double buffer Image for manual –> evaluator Cool -> puzzle Tutorial -> hello Tutorial -> shape Tutorial -> cubeview

FLTK class hierarchy

Hello world and Shape control

The Cube example #include "config.h" #include <FL/Fl.H> #include "CubeViewUI.h" int main(int argc, char **argv) { CubeViewUI *cvui=new CubeViewUI; Fl::visual(FL_DOUBLE|FL_RGB); cvui->show(argc, argv); return Fl::run(); } Defined the widgets alredy You only need to assemble them together If you want to change the behavior, you will create an subclass and inheriate some functions

class CubeViewUI { public: CubeViewUI(); private: Fl_Double_Window *mainWindow; Fl_Roller *vrot; Fl_Slider *ypan; void cb_vrot_i(Fl_Roller*, void*); void cb_ypan_i(Fl_Slider*, void*); Fl_Slider *xpan; Fl_Roller *hrot; void cb_xpan_i(Fl_Slider*, void*); void cb_hrot_i(Fl_Roller*, void*); CubeView *cube; Fl_Value_Slider *zoom; void cb_zoom_i(Fl_Value_Slider*, void*); void show(int argc, char **argv); };

class CubeViewUI { public: CubeViewUI(); private: Fl_Double_Window *mainWindow; Fl_Roller *vrot; Fl_Slider *ypan; void cb_vrot_i(Fl_Roller*, void*); void cb_ypan_i(Fl_Slider*, void*); Fl_Slider *xpan; Fl_Roller *hrot; void cb_xpan_i(Fl_Slider*, void*); void cb_hrot_i(Fl_Roller*, void*); CubeView *cube; Fl_Value_Slider *zoom; void cb_zoom_i(Fl_Value_Slider*, void*); void show(int argc, char **argv); }; class CubeView : public Fl_Gl_Window { public: double size; float vAng,hAng; float xshift,yshift; CubeView(int x,int y,int w,int h,const char *l=0); void v_angle(float angle){vAng=angle;}; void h_angle(float angle){hAng=angle;}; void panx(float x){xshift=x;}; void pany(float y){yshift=y;}; void draw(); void drawCube(); float boxv0[3];float boxv1[3]; float boxv2[3];float boxv3[3]; float boxv4[3];float boxv5[3]; float boxv6[3];float boxv7[3]; };

class CubeViewUI { public: CubeViewUI(); private: Fl_Double_Window *mainWindow; Fl_Roller *vrot; Fl_Slider *ypan; void cb_vrot_i(Fl_Roller*, void*); void cb_ypan_i(Fl_Slider*, void*); Fl_Slider *xpan; Fl_Roller *hrot; void cb_xpan_i(Fl_Slider*, void*); void cb_hrot_i(Fl_Roller*, void*); CubeView *cube; Fl_Value_Slider *zoom; void cb_zoom_i(Fl_Value_Slider*, void*); void show(int argc, char **argv); }; class CubeView : public Fl_Gl_Window { public: double size; float vAng,hAng; float xshift,yshift; CubeView(int x,int y,int w,int h,const char *l=0); void v_angle(float angle){vAng=angle;}; void h_angle(float angle){hAng=angle;}; void panx(float x){xshift=x;}; void pany(float y){yshift=y;}; void draw(); void drawCube(); float boxv0[3];float boxv1[3]; float boxv2[3];float boxv3[3]; float boxv4[3];float boxv5[3]; float boxv6[3];float boxv7[3]; }; void CubeView::draw() { if (!valid()) { glLoadIdentity(); glViewport(0,0,w(),h()); glOrtho(-10,10,-10,10,-20050,10000); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(xshift, yshift, 0); glRotatef(hAng,0,1,0); glRotatef(vAng,1,0,0); glScalef(float(size),float(size),float(size)); drawCube(); glPopMatrix();

class CubeViewUI { public: CubeViewUI(); private: Fl_Double_Window *mainWindow; Fl_Roller *vrot; Fl_Slider *ypan; void cb_vrot_i(Fl_Roller*, void*); void cb_ypan_i(Fl_Slider*, void*); Fl_Slider *xpan; Fl_Roller *hrot; void cb_xpan_i(Fl_Slider*, void*); void cb_hrot_i(Fl_Roller*, void*); CubeView *cube; Fl_Value_Slider *zoom; void cb_zoom_i(Fl_Value_Slider*, void*); void show(int argc, char **argv); }; class CubeView : public Fl_Gl_Window { public: double size; float vAng,hAng; float xshift,yshift; CubeView(int x,int y,int w,int h,const char *l=0); void v_angle(float angle){vAng=angle;}; void h_angle(float angle){hAng=angle;}; void panx(float x){xshift=x;}; void pany(float y){yshift=y;}; void draw(); void drawCube(); float boxv0[3];float boxv1[3]; float boxv2[3];float boxv3[3]; float boxv4[3];float boxv5[3]; float boxv6[3];float boxv7[3]; };

Initialize window layout CubeViewUI::CubeViewUI() { Fl_Double_Window* w; { Fl_Double_Window* o = mainWindow = new Fl_Double_Window(415, 405, "CubeView"); w = o; o->box(FL_UP_BOX); o->labelsize(12); o->user_data((void*)(this)); { Fl_Group* o = new Fl_Group(5, 3, 374, 399); { Fl_Group* o = VChange = new Fl_Group(5, 100, 37, 192); { Fl_Roller* o = vrot = new Fl_Roller(5, 100, 17, 186, "V Rot"); o->labeltype(FL_NO_LABEL); o->minimum(-180); o->maximum(180); o->step(1); o->callback((Fl_Callback*)cb_vrot); o->align(FL_ALIGN_WRAP); } { Fl_Slider* o = ypan = new Fl_Slider(25, 100, 17, 186, "V Pan"); o->type(4); o->selection_color(FL_DARK_BLUE); o->minimum(-25); o->maximum(25); o->step(0.1); o->callback((Fl_Callback*)cb_ypan); o->align(FL_ALIGN_CENTER); o->end(); { Fl_Group* o = HChange = new Fl_Group(120, 362, 190, 40); { Fl_Slider* o = xpan = new Fl_Slider(122, 364, 186, 17, "H Pan"); o->type(5); o->minimum(25); o->maximum(-25); o->callback((Fl_Callback*)cb_xpan); o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); { Fl_Roller* o = hrot = new Fl_Roller(122, 383, 186, 17, "H Rotation"); o->type(1); o->callback((Fl_Callback*)cb_hrot); o->align(FL_ALIGN_RIGHT); { Fl_Group* o = MainView = new Fl_Group(46, 27, 333, 333); { Fl_Box* o = cframe = new Fl_Box(46, 27, 333, 333); o->box(FL_DOWN_FRAME); o->color((Fl_Color)4); o->selection_color((Fl_Color)69); { CubeView* o = cube = new CubeView(48, 29, 329, 329, "This is the cube_view"); o->box(FL_NO_BOX); o->color(FL_BACKGROUND_COLOR); o->selection_color(FL_BACKGROUND_COLOR); o->labeltype(FL_NORMAL_LABEL); o->labelfont(0); o->labelsize(14); o->labelcolor(FL_FOREGROUND_COLOR); o->when(FL_WHEN_RELEASE); { Fl_Value_Slider* o = zoom = new Fl_Value_Slider(106, 3, 227, 19, "Zoom"); o->labelfont(1); o->minimum(1); o->maximum(50); o->value(10); o->textfont(1); o->callback((Fl_Callback*)cb_zoom); o->align(FL_ALIGN_LEFT); o->resizable(o);

FLUID

FLUID Demo

Where are we? We know the math and programming skill to: Using transformation, projection, rasterization, hiddern-surface removal, lighting, material. What we can’t do so far?

Where are we? We know the math and programming skill to: Remain questions: Model 3D shape Where to get shape? How to edit it?

Where are we? We know the math and programming skill to: Remain questions: Model 3D shape Model complex appearance

Where are we? We know the math and programming skill to: Remain questions: Model 3D shape Model complex appearance More Realistic Synthesis

Curves y y x x line circle y x Freeform

Curve Representation y y t t d d c c x x line circle Explicit: Implicit: Parametric:

Curve Representation y y t t d d c c x x line circle Parametric:

Curve Representation y y t t d d c c x x line circle Parametric:

Curve Representation y y t t d d c c x x line circle Parametric: Any invertible function g will result in the same curve

What are Parametric Curves? Define a mapping from parameter space to 2D or 3D points A function that takes parameter values and gives back 3D points The result is a parametric curve Mapping:F:t→(x,y,z) (Fx(t), Fy(t), Fz(t),) 1 1 t

An example of a complex curve Piecing together basic curves

Continuities

Polynomial Pieces Polynomial functions: Polynomial curves:

Polynomial Evaluation Polynomial functions: f = a[0]; for i = 1:n f += a[i]*power(t,i); end f = a[0]; s = 1; for i = 1:n s *= t; f += a[i]*s; end f = a[n]; for i = n-1:-1:0 f = a[i]+t*f; end

A line Segment We have seen the parametric form for a line: Note that x, y and z are each given by an equation that involves: The parameter t Some user specified control points, x0 and x1 This is an example of a parametric curve p1 p0

A line Segment We have seen the parametric form for a line: p1 p0 From control points p, we can solve coefficients a

More control points p1 p2 p0

More control points p1 p2 p0 By solving a matrix equation that satisfies the constraints, we can get polynomial coefficients

Two views on polynomial curves From control points p, we can compute coefficients a Each point on the curve is a linear blending of the control points