A code-walkthrough Commentary on our ‘model3d.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

Game with US Beginner Tutorial. Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays.
CompSci Today’s topics Java Recursion in Graphics Writing a Class Simple Animation Upcoming Simulation Reading Great Ideas, Chapters 5.
Structures in C.
1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
A code-walkthrough Commentary on our ‘wfmodel.cpp’ demo-program – an initial ‘prototype’ for 3D wire-frame animations.
Civil 114 Civil Engineering Drawing AutoCAD
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 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.
Dynamic visualizations On ‘non-canonical’ keyboard-input and terminal escape-sequences for visualization effects.
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.
Sketchify Tutorial Graphics and Animation in Sketchify sketchify.sf.net Željko Obrenović
Vertical Retrace Interval An introduction to VGA techniques for smooth graphics animation.
Linux game programming An introduction to the use of interval timers and asynchronous input notifications.
Ever wonder how they made STAR WARS or TOY STORY? The development of Computer Graphics is responsible for a revolution in art and media. Starting with.
Linux game programming An introduction to the use of interval timers and asynchronous input notifications.
1 Lab Session-12 CSIT121 Fall 2004 Structures and Their Usage Passing Struct Variables to Functions.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® PowerPoint 2010 © 2011 The McGraw-Hill Companies,
COMPUTER GRAPHICS Prepared by S.MAHALAKSHMI Asst. Prof(Sr) / SCSE VIT University.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
KeyListener and Keyboard Events Just as we can implement listeners to handle mouse events, we can do the same for keyboard events (keypresses) –to implement.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. M I C R O S O F T ® Preparing a Presentation for Delivery Lesson 13.
Lecture 3 OpenGL.
Keyboard and Events. What about the keyboard? Keyboard inputs can be used in many ways---not just for text The boolean variable keyPressed is true if.
KeyListener and Keyboard Events Another type of listener listens for keyboard entry – the KeyListener which generates KeyEvents –to implement KeyListener,
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Graphics CSCI 343, Fall 2015 Lecture 1 Introduction to Graphics Read: Chapter 1 of textbook.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Getting Started With AutoCAD ENGR 2 Week #1 Laboratory.
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.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 11 Fall 2010.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
CGMB214: Introduction to Computer Graphics
Learning Unity. Getting Unity
CIS 3.5 Lecture 2.2 More programming with "Processing"
Arrays. An array is a collection “The Dinner offers an array of choices.” In computer programming, an array is a collection of variables of the same data.
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.
Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.
Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
©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,
Simulation and Modeling: Predator-Prey Processing Lab IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 23, 2014 Carolyn Seaman Susan.
Computer Science I Looping. User input. Classwork/Homework: Incorporate looping & user input into a sketch.
Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization GameFX C# / DirectX 2005 The Rendering Pipeline.
11 Using the Keyboard in XNA Session 9.1. Session Overview  Discover more detail on how the XNA keyboard is implemented  Find out how to use arrays.
Introduction to Input/Interaction Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 19, 2003.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
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 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
3D Viewing and Clipping Ming Ouhyoung 歐陽明 Professor Dept. of CSIE and GINM NTU.
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
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.
Sprite Animation An exercise on filling circles and polygons to create the animated sprite used in ‘Pac Man’
Lecture 13 Clipping & Scan Conversion
Viewing Transformations II
Line Drawing Algorithms
Presentation transcript:

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

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

Graphics acronyms VRP: View Reference Point VPL: View-Plane Normal VUP: 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; float3_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( float3_t p, float3_t q ); void normalize( float3_t &v ); void cross_product( float3_t u, float3_t v, float3_t &w );

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

Using the ‘split-screen’ We can demonstrate the benefit of using a ‘page-flipping’ animation algorithm, taking advantage of the CRT Line-Compare and Start-Address parameters Our demo-program is called ‘flipdemo.cpp’ With a split-screen display, we can show two wire-frame animations on the same screen, one without page-flipping (flickers) and the other with page-flipping (smooth!)

Theory behind our demo split-screen display VRAM Page 0 Page 1 Page 2 We draw (and erase) to page 0 (The viewer can watch this on lower screen) CRT Start-Address offset Here or Here Always shows page 0 Flips between pages 1/2 CRT Line-Compare offset

In-class exercises Try modifying the ‘model3d.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)