Chapter 12 Interactive Graphics ChihKuo Yeh Interactive Graphics
- Slides: 43
Chapter 12 Interactive Graphics Chih-Kuo Yeh
Interactive Graphics
Picking Direct Manipulation Demo
Object Picking by Ray Tracing Object 1 p 1 COP Center of Projection Window Coordinates Object 2 p 2
Open. GL Geometric Pipline Vertex Coordinates x, y, z, w Object Coordinates Modelview Matrix Modelview Transformation Eye Coordinates Projection Matrix Projection Transformation Clip Coordinates Perspective Division Device Coordinates Viewport Transformation Part of Open. GL State Viewport Transformation Window Coordinates x, y
Open. GL solution Selection Feedback Application Model API Output Devices Application Program Graphics System Function Calls or Protocol Data Input Devices
Selection
planets. cpp
The Basic Steps Process. Selection gl. Select. Buffer(…) gl. Matrix. Mode(GL_PROJECTION) gl. Push. Matrix() Change render mode gl. Matrix. Mode(GL_PROJECTION) gl. Pop. Matrix()
The Basic Steps Change render mode gl. Render. Mode(GL_SELECT ) glu. Pick. Matrix(…) Render. Scene() gl. Render. Mode(GL_RENDER )
The Basic Steps Render. Scene gl. Init. Names() gl. Push. Name() gl. Load. Name(…) Draw your object 1 gl. Load. Name(…) Draw your object 2
Selection Mode GLint gl. Render. Mode(GLenum mode); Mode = 1. GL_RENDER (the default) 2. GL_SELECT GL_RENDER 3. GL_FEEDBAC 1 zmin gl. Render. Mode() GL_SELECT zmax Yellow Cube gl. Render. Mode(GL_RENDER) returns the number of hits while in SELECT mode
Picking void glu. Pick. Matrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4]); gl. Get. Integerv(GL_VIEWPORT, viewport); glu. Pick. Matrix(x. Pos, viewport[3] – y. Pos + viewport[1], 2, 2, viewport);
Picking in Open. GL Perspective View Volume Canonical View Volume Projection Transform Screen Coordinates Pick Matrix Transform
The Hit Record Each hit record consists of four items, in order. The number of names on the name stack when the hit occurred. 2. Both the minimum and maximum window-coordinate z values 3. The contents of the name stack at the time of the hit, with the bottommost element first. 1.
Selection Buffer
planets. cpp void Render. Scene(void) { // Clear the window with current clearing color gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT // Save the matrix state and do the rotations gl. Matrix. Mode(GL_MODELVIEW); gl. Push. Matrix(); // Translate the whole scene out and into view gl. Translatef(0. 0 f, -300. 0 f); // Initialize the names stack gl. Init. Names();
void Mouse. Callback(int button, int state, int x, int y) { if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN Process. Selection(x, y); }
Process. Selection(int x. Pos, int y. Pos) void Process. Selection(int x. Pos, int y. Pos) { GLfloat f. Aspect; // Space for selection buffer static GLuint select. Buff[BUFFER_LENGTH]; // Hit counter and viewport storage GLint hits, viewport[4]; // Setup selection buffer gl. Select. Buffer(BUFFER_LENGTH, select. Buff);
// Get the viewport gl. Get. Integerv(GL_VIEWPORT, viewport); // Switch to projection and save the matrix gl. Matrix. Mode(GL_PROJECTION); gl. Push. Matrix(); // Change render mode gl. Render. Mode(GL_SELECT);
gl. Load. Identity(); glu. Pick. Matrix(x. Pos, viewport[3] - y. Pos + viewport[1], 2, 2, viewport); // Apply perspective matrix f. Aspect = (float)viewport[2] / (float)viewport[3]; glu. Perspective(45. 0 f, f. Aspect, 1. 0, 425. 0); // Draw the scene Render. Scene(); // Collect the hits = gl. Render. Mode(GL_RENDER);
GLuint n. Err = gl. Get. Error(); // If a single hit occurred, display the info. if(hits == 1) Process. Planet(select. Buff[3]); else glut. Set. Window. Title("Nothing was clicked on!"); // Restore the projection matrix gl. Matrix. Mode(GL_PROJECTION); gl. Pop. Matrix(); // Go back to modelview for normal rendering gl. Matrix. Mode(GL_MODELVIEW);
Hierarchical Picking
Hierarchical Picking
Moons. cpp
Selection Buffer Set up Pick Buffer Selection Buffer: user specified intege gl. Select. Buffer( int size, int *p. Buffer );
Name Stack Set up Pick Buffer Initialize Name Stack stack pointer gl. Render. Mode( GL_SELECT ); gl. Init. Names();
Pick Volume Set up Pick Buffer Initialize Name Stack Specify a Pick Volume glu. Pick. Matrix( x, y, 5. 0, viewport );
Fill Selection Buffer Set up Pick Buffer Initialize Name Stack Specify a Pick Volume Draw Object with IDs gl. Push. Name(100 ); gl. Draw. Red. Rect(); 1 0 0 100
Fill Selection Buffer Set up Pick Buffer Initialize Name Stack Specify a Pick Volume Draw Object with IDs gl. Push. Name(200 ); gl. Draw. Green. Rec t(); 1 0 0 100 200
Fill Selection Buffer Set up Pick Buffer Initialize Name Stack Specify a Pick Volume Draw Object with IDs gl. Push. Name(300 ); gl. Draw. Blue. Rect() ; 1 0 0 100 200
Post Processing Set up Pick Buffer Initialize Name Stack Specify a Pick Volume Draw Object with IDs Post Processing g. Render. Mode( GL_RENDER ); Do anything you want !!!
Feedback
select. cpp
The Basic Steps Process. Selection gl. Select. Buffer(…) gl. Matrix. Mode(GL_PROJECTION) gl. Push. Matrix() Change render mode gl. Matrix. Mode(GL_PROJECTION) gl. Pop. Matrix()
The Basic Steps Change render mode gl. Render. Mode(GL_SELECT ) glu. Pick. Matrix(…) Render. Scene() gl. Render. Mode(GL_RENDER )
The Basic Steps Render. Scene gl. Init. Names() gl. Push. Name() gl. Load. Name(…) gl. Pass. Through(…) Draw your object 1 gl. Load. Name(…)
The Basic Steps Make. Selection gl. Feedback. Buffer(…) gl. Render. Mode(GL_FEEDBACK ) Render. Scene() gl. Render. Mode(GL_RENDER ) Parse the feedback buffer
The Feedback Buffer void gl. Feedback. Buffer(GLsizei size, GLenum type, GLfloat *buffer);
Feedback Buffer Tokens
Feedback Buffer Memory GL_3 D type
Feedback Buffer Memory [0] GL_PASS_THROUGH_TOKEN [1] User defined name [2] GL_POLYGON_TOKEN [3] Number of vertices [4] x [5] y See Make. Selection(int n. Choice) for detail
- Ntu fcfs form
- Jason yeh md
- Peter yeh md
- Dr alex yeh
- Bibi zehra ye dua hai lyrics in urdu written
- Beauty poem class 6 drawing
- Jason yeh cuhk
- Tse-yu yeh
- Forrest voight
- Albert yeh
- Cs 418
- Glcreatebuffer
- What are the interactive input methods? explain in detail.
- Interactive graphics software and hardware
- Calligraphic refresh graphics display
- Interactive graphics sapienza
- Uiuc cs 418
- Enable nui in process gpu
- Interactive computer graphics examples
- Cs 418 interactive computer graphics
- Cs 418 interactive computer graphics
- Interactive computer graphics examples
- Interactive graphics utah
- Graphics monitors and workstations and input devices
- Dot matrix display ppt
- Computer graphics chapter 1 ppt
- Chapter 8 graphics
- Application of computer graphics ppt
- Chapter 3 graphics
- Perspectives on appeasement interactive notebook
- Multimedia becomes interactive multimedia when
- The tyler model
- Interactive voice response system randomization
- Cogat
- Uninterruptible power supply
- Understanding experience in interactive systems
- Linear communication
- "team cohesion"
- Clasificarea strategiilor didactice
- Nitrogen cycle interactive
- Interactive machine translation
- Interactive ultrasound simulator
- Berlos model of communication
- Metode interactive de predare