A code-walkthrough Commentary on our ‘wfmodel.cpp’ demo-program – an initial ‘prototype’ for 3D wire-frame animations.

Slides:



Advertisements
Similar presentations
Linear Interpolation Applying “weighted averages” to some graphics problems: animations and curve-drawing.
Advertisements

Three Dimensional Viewing
I/O Multiplexing The role of the ‘poll()’ method in Linux device-driver operations.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
A question about polygons Devising a computational method for determining if a point lies in a plane convex polygon.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
HCI 530 : Seminar (HCI) Damian Schofield.
True or false A variable of type char can hold the value 301. ( F )
Hidden Line Removal Applying vector algebra to the problem of removing hidden lines from wire-frame models.
1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.
CS 325 Introduction to Computer Graphics 02 / 24 / 2010 Instructor: Michael Eckmann.
The CRT Controller How to modify CRTC registers to achieve a non-standard horizontal and vertical screen resolution.
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Hidden Line Removal Applying vector algebra to the problem of removing hidden lines from wire-frame models.
Michener’s Algorithm An efficient scheme for drawing circles (and filling circular disks) on a raster graphics display.
A code-walkthrough Commentary on our ‘model3d.cpp’ demo-program – an initial ‘prototype’ for 3D wire-frame animations.
Wire-frame Modeling An application of Bresenham’s line-drawing algorithm.
Vertical Retrace Interval An introduction to VGA techniques for smooth graphics animation.
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
How to do ‘page-flipping’ The steps needed when revising our ‘wfmodel1.cpp’ prototype to achieve ‘smooth’ animation.
1 An introduction to programming concepts with Scratch.
Vertical Retrace Interval An introduction to VGA techniques for smooth graphics animation.
3D Concepts UNIT 3. 3-D Coordinate Spaces Remember what we mean by a 3-D coordinate space x axis y axis z axis P y z x Right-Hand Reference System.
Ch 1 Intro to Graphics page 1CS 367 First Day Agenda Best course you have ever had (survey) Info Cards Name, , Nickname C / C++ experience, EOS experience.
Visualization- Determining Depth From Stereo Saurav Basu BITS Pilani 2002.
Linux game programming An introduction to the use of interval timers and asynchronous input notifications.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
Advanced Computer Graphics Three Dimensional Viewing
Week 2 - Wednesday CS361.
Triangulation Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
Lecture 3 Transformations.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Flash! Macromedia Flash is the key to designing and delivering low-bandwidth animations, presentations, and Web sites. It offers scripting capabilities.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Geometric Objects and Transformation
Learning Unity. Getting Unity
1 Computer Graphics Week9 -3D Geometric Transformation.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Graphics Matrices. Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together.
OpenGL Selection. Three Selection Methods Color coding (OpenGL) Selection mode (OpenGL) Selection ray (generic)
CS 376 Introduction to Computer Graphics 02 / 23 / 2007 Instructor: Michael Eckmann.
CS 325 Introduction to Computer Graphics 02 / 26 / 2010 Instructor: Michael Eckmann.
Introduction to Raytracing Raytracing Introduction (from Wikipedia) In computer graphics, ray tracing is a technique for generating an image by tracing.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control.
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
Lecture 3 Transformations. 2D Object Transformations The functions used for modifying the size, location, and orientation of objects or of the camera.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Implementing ‘noecho’ Programming details regarding the Linux implementation for ‘struct termios’ objects.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming.
Higher Dimensions. x Let's say we use a pencil to mark a point on paper. x is this point. We pick a direction and move the pencil along this direction.
Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization GameFX C# / DirectX 2005 The Rendering Pipeline.
Today’s Objectives:. Warm Up 3.4 Solving Systems w/ Three Variables You are familiar with a normal coordinate plane. It is has an x-axis and a y-axis.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Train Body The next series of slides will guide you through the construction of the train body. Start a new drawing and save it as Train Body.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
OpenGL LAB III.
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Assignment 8 Chess Game.
Sprite Animation An exercise on filling circles and polygons to create the animated sprite used in ‘Pac Man’
Lecture 13 Clipping & Scan Conversion
Presentation transcript:

A code-walkthrough Commentary on our ‘wfmodel.cpp’ demo-program – an initial ‘prototype’ for 3D wire-frame animations

The ‘cube.dat’ file This is a textfile (created with an editor) It is organized into two sections: –Coordinates of points in 3-dimensional space –Number-pairs indicating endpoints of lines Each section begins with a integer, telling how many data-elements will follow First section holds floating-point triples Second section holds integer pairs

The ‘world’ model ( 1, 1, 1) ( 1,-1, 1)(-1,-1, 1) (-1, 1, 1) ( 1, 1,-1)(-1, 1,-1) (-1,-1,-1) ( 1,-1,-1) 8 vertices and 12 edges X-axis Y-axis

Data structures typedef struct { float x, y, z; } vector_t; -Used for locating points in 3-space -Also used for representing vectors typedef struct { vector_t vrp, vpn, vup; } camera_t; - Used to specify crucial viewing directions

Graphics acronyms VRP: View Reference Point VPN: View-Plane Normal VUP: Vector Upward Pointing

VUP VPN The ‘view’ model X-axis Y-axis Z-axis Eye Viewplane View Reference Point View Plane Normal Vector Upward Pointing

More structures… typedef int edge_t [ 2 ]; -Used to specify a line-segment (by means of its two end-points) -We will be using an array of such ‘edges’

Our ‘model’ type #define MAXVERT 50 #define MAXEDGE 50 typedef struct { intnumverts; vector_t vert[ MAXVERT ]; intnumedges; edge_t edge[ MAXEDGE ]; } model_t;

Some ‘helper’ functions int get_model_data( char *filename, model_t model ); double dot_product( vector_t p, vector_t q ); void normalize( vector_t &v ); void cross_product( vector_t u, vector_t v, vector_t &w );

Perspective projection P P’ E World point P is projected into viewplane point P’ along ray toward eye E X-axis Y-axis Z-axis

Similar triangles y P(x,y,z) E(0,0,e) -z e y’ P’(x’,y’,0) y’ : e = y : e-z

The ‘draw_model()’ function void draw_model( model_t model, camera_t camera, float3_t eye ); - It uses these ‘helper’ functions: void draw_pixel( int x, int y, int color ), draw_line( int x1, int y1, int x2, int y2, int color ), fill_rectangle( int x, int y, int h, int v, int color );

Algorithm for ‘main()’ Preliminary steps (to set up for the demo): 1) setup filename (for the wire-frame data) 2) read the data into our ‘model’ structure 3) setup i/o permissions, vram mapping, noncanonical input, and graphics mode 4) draw a screen border (as confirmation) 5) setup variables for ‘camera’ and ‘eye’

The demo’s main loop 6) Adjust the location of the viewer’s eye 7) Setup the camera and view parameters 8) Compute the 3D perspective projection 9) Erase old image and draw the new one 10) Then wait for the user to press a key Unless done (i.e., -key was hit), go back and repeat steps 6 through 10; Otherwise, restore text mode and then quit

The ‘draw_model()’ function 1) setup axes for a new coordinate-system based on camera-angles and viewer’s eye 2) transform the model’s vertices into their coordinates relative to these new axes 3) perform a perspective projection of the points in 3-space onto the 2D view-plane 4) for each edge, draw the line-segment that joins the images of its two end-points

The ‘flicker’ problem When you hold down the key while running our ‘wfmodel’ demo, you see annoying image-flicker as the cube rotates The visible image is erased and redrawn, but the redrawing takes considerable time For smooth flicker-free animation, we need to avoid doing the lengthy redrawing while the partially-drawn image remains visible

‘page-flipping’ We can utilize off-screen video memory to eliminate the problem of image flickering The technique is called ‘page-flipping’ We have created a demo-program (named ‘vramscan.cpp’) that lets you take a look at the entire contents of video display ram It works by changing one of the Radeon’s CRT Controller registers: CRT_START (So it won’t run on other vendors’ SVGAs)

How page-flipping works VRAM The ‘Visual’ Page The ‘Active’ Page CRTC START-ADDRESS The user sees this part of video memory Your program draws to this part of video memory When the ‘Active’ page is ready to be viewed, your program changes the CRTC START-ADDRESS and thus the roles of these two pages are ‘flipped’

In-class exercises Try modifying the ‘wfmodel.cpp’ program (so as to allow for a greater degree of ‘user control’) Specifically, let the user move the viewer’s eye higher or lower, by pressing up-arrow or down- arrow on the keyboard Apply the ideas from our ‘animate2.cpp’ demo to add animation (by removing the keyboard input delay from the main loop), but let the user still be able to exert control (via asynchronous keyboard input notification and a signal-handler function)