Scientific Visualization Basics

Similar documents
Visualizing Molecular Dynamics

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Graphics and Computation Introduction to OpenGL

Precept 2 Aleksey Boyko February 18, 2011

Order of Transformations

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

Lectures OpenGL Introduction

Introduction to OpenGL

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

1 (Practice 1) Introduction to OpenGL

20 GLuint objects; 36 Scale += 0.1; 37 break; 38 case GLUT_KEY_DOWN:

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

1 /* 4 C:\opencv\build\include. 6 C:\opencv\build\x86\vc10\lib

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

Interaction. CSCI 480 Computer Graphics Lecture 3

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Computer graphics MN1

Rendering Pipeline/ OpenGL

Introduction to OpenGL

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

2 Transformations and Homogeneous Coordinates

Using OpenGL with CUDA

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

Computer graphics MN1

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

Advanced Computer Graphics (CS & SE )

1.2 Basic Graphics Programming

DONALD HOUSE: CPSC 8170, FALL 2018 DESIGN OF A REAL-TIME ANIMATION PROGRAM

Lecture 3. Understanding of OPenGL programming

Graphics Pipeline & APIs

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

BOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Interaction. CSCI 420 Computer Graphics Lecture 3

Graphics Programming

CSC 470 Computer Graphics

yahoo.com

Transformation, Input and Interaction. Hanyang University

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

OpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3

QUESTION 1 [10] 2 COS340-A October/November 2009

Graphics Pipeline & APIs

OpenGL refresher. Advanced Computer Graphics 2012

C OMPUTER G RAPHICS Thursday

Lecture 4 of 41. Lab 1a: OpenGL Basics

Computer Graphics Course 2005

OpenGL and X, Column 1: An OpenGL Toolkit

OPENGL TM AND X, COLUMN 1: AN OPENGL TOOLKIT

Basic Graphics Programming

Pearce Outline. OpenGL Background and History. Other Graphics Technology. Platform Specifics. The Drawing Process

Interaction Computer Graphics I Lecture 3

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Introduction to Computer Graphics with OpenGL/GLUT

Lecture 2 2D transformations Introduction to OpenGL

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Computer graphics MN1

Computer Graphics. Transformations. CSC 470 Computer Graphics 1

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Lecture 4 Advanced Computer Graphics (CS & SE )

GLUT Tutorial. John Tsiombikas (Nuclear / The Lab Demos) May 6, Introduction to GLUT (OpenGL Utility Toolkit)

Graphics Hardware and OpenGL

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

Basic Graphics Programming

RECITATION - 1. Ceng477 Fall

Display Lists in OpenGL

OpenGL Introduction Computer Graphics and Visualization

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Transformation Pipeline

Understand how real-world lighting conditions are approximated by OpenGL

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

Exercise 1 Introduction to OpenGL

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin

CS 4204 Computer Graphics

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Introduction to OpenGL: Part 2

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

Computer Graphics. Bing-Yu Chen National Taiwan University


Lighting. Chapter 5. Chapter Objectives. After reading this chapter, you'll be able to do the following:

Input and Interaction. 1. Interaction. Chapter 3. Introduction: - We now turn to the development of interactive graphics programs.

Chapter 13 Selection and Feedback

Transformations (Rotations with Quaternions) October 24, 2005

Image Rendering. Rendering can be divided into three sub-problems. Image Formation The hidden surface problem visibility determination steps

Fundamental Types of Viewing

compatibility mode core mode

OpenGL. Toolkits.

Transcription:

Scientific Visualization Basics Aiichiro Nakano Collaboratory for Advanced Computing & Simulations Dept. of Computer Science, Dept. of Physics & Astronomy, Dept. of Chemical Engineering & Materials Science, Department of Biological Sciences University of Southern California Email: anakano@usc.edu Goal: Experience simple OpenGL visualization of real simulation

Massive Scientific Data Visualization Graph-based data mining! Interactive visualization of billion atoms

OpenGL: Getting Started Installing OpenGL & GLUT libraries: OpenGL: Standard, hardware-independent interface to graphics hardware. GLUT (OpenGL Utility Toolkit): Windowsystem-independent toolkit for window APIs. http://www.opengl.org Do it on your laptop! http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto

OpenGL Programming Basics #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <GLUT/glut.h> // Header File For The OpenGL32 Library! // Header File For The GLu32 Library! // Header File For The GLut Library! glutinit(&argc, argv);! /* Set up an window */! glutinitdisplaymode(glut_double GLUT_RGBA GLUT_DEPTH); /*Initialize display mode*/! glutinitwindowsize(winx, winy); /* Specify window size */! glutcreatewindow("lennard-jones Atoms"); /* Open window */! glenable(gl_depth_test); /* Enable z-buffer for hidden surface removal */! glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); /* Clear the window */! Frame buffer: A collection of buffers in memory, which store data for screen pixels (e.g., 1280 pixels wide & 1024 pixels high) such as color, depth information for hidden surface removal, etc. http://cacs.usc.edu/education/cs653.html atomv.c!

OpenGL Event-Handling Loop main() {! /* Set a glut callback functions */! glutdisplayfunc(display);! glutreshapefunc(reshape);! events /* Start main display loop */! glutmainloop();! /* Definition of callback functions */! display() {!...! event handlers reshape() {!...!

Polygonal Surfaces float normal_vector[max_vertices][3],vertex_position[max_vertices][3];! glbegin(gl_quad_strip);! for (i=0; i<number_of_vertices; i++) {! glnormal3f(normal_vector[i]);! glvertex3f(vertex_position[i]);! glend();!

Polygonal Sphere int nlon=3, nlat=2;! loninc = 2*M_PI/nlon; /* Δφ */! /* North-pole triangular fan */! glbegin(gl_triangle_fan);! latinc = M_PI/nlat; /* Δθ */! glnormal3f(0,1,0);! /* South-pole triangular fan */! glbegin(gl_triangle_fan);! glnormal3f(0,-1,0);! glvertex3f(0,-radius,0);! lon = 0;! lat = -M_PI/2 + latinc;! y = sin(lat);! for (i=0; i<=nlon; i++) {! x = cos(lon)*cos(lat);! z = -sin(lon)*cos(lat);! glnormal3f(x,y,z);! glvertex3f(0,radius,0);! y = sin(lat);! lon = 0;! for (i=0; i<=nlon; i++) {! x = cos(lon)*cos(lat);! z = -sin(lon)*cos(lat);! glnormal3f(x,y,z);! glvertex3f(x*radius,y*radius,z*radius);! lon += loninc;! glend();! glvertex3f(x*radius,y*radius,z*radius);! lon += loninc; glend();! /* Quadrilateral strips to cover the sphere */! for (j=1; j<nlat-1; j++) {! lon = 0;! glbegin(gl_quad_strip);! for (i=0; i<=nlon; i++) {! x = cos(lon)*cos(lat);! y = sin(lat);! z = -sin(lon)*cos(lat);! glnormal3f(x,y,z);! glvertex3f(x*radius,y*radius,z*radius);! x = cos(lon)*cos(lat+latinc);! y = sin(lat+latinc);! z = -sin(lon)*cos(lat+latinc);! glnormal3f(x,y,z);! glvertex3f(x*radius,y*radius,z*radius);! lon += loninc; glend();! lat += latinc;

Display Lists Display list: A group of OpenGL commands that have been stored for later execution. /* Generates one new display-list ID */! GLuint sphereid = glgenlists(1);! /* Define a routine to draw a sphere*/! glnewlist(sphereid, GL_COMPILE);!...code to draw a sphere...! glendlist();! /* Execute sphere drawing */! glcalllist(sphereid);!

Transformation Matrix Transformation matrix: Specifies the amount by which the object s coordinate system is to be rotated, scaled, or translated, i.e., affine transformation. Matrix stack: A stack of transformation matrices at the top of the stack is the current transformation matrix. Initially the transformation matrix is the identity matrix.! ʹ " r = A r! + b! x ʹ a 11 a 12 a 13 b 1 x y ʹ a 21 a 22 a 23 b 2 = y z ʹ a 31 a 32 a 33 b 3 z 1 0 0 0 1 1 Matrix Identity! = {1, 0, 0, 0,! 0, 1, 0, 0,! 0, 0, 1, 0,! 0, 0, 0, 1};! glpushmatrix(); gltranslatef(atoms[i].crd[0],atoms[i].crd[1],atoms[i].crd[2]); glcalllist(sphereid); glpopmatrix();

Color Display RGB(A) mode: Specifying color by providing red, green & blue intensities (& alpha component). Alpha component: Specifies the opacity of a material; default value is 1.0 (nontransparent), if not specified. float r=1.0; g=0.0; b=0.0;! glcolor3f(r,g,b);! OpenGL as a state machine: Color change stays.

Lighting & Materials OpenGL color = light material-reflectance OpenGL Color Types Diffuse component: Gives the appearance of a matter or flat reflection from an object s surface. Ambient illumination: Simulates light reflected from other objects. Specular light: Creates highlights. Emission: Simulates the appearance of lights in the scene. Materials Definition Refelectance: Material is characterized by ambient, diffuse & specular reflectance, i.e., how the object reflects light. glenable(gl_color_material)! In this mode, the current color specified by glcolor*() will change the ambient & diffuse reflectance.

Lighting Source float light_diffuse[4] = {1.0,1.0,1.0,1.0};! float light_position[4] = {0.5,0.5,1.0,0.0};! /* Define a lighting source */! gllightfv(gl_light0,gl_diffuse,light_diffuse);! gllightfv(gl_light0,gl_position,light_position);! /* Enable a single OpenGL light */! glenable(gl_lighting);! glenable(gl_light0);!

Viewing Transformation Viewing transformation: Transforms object coordinates to eye coordinates. glulookat(eyx, eyey, eyz, centerx, centery, centerz, upx, upy, upz);! Eye coordinate system Camera specification

Clipping void reshape (int w, int h) {!...! /* set the GL viewport to match the full size of the window */! glviewport(0, 0, (GLsizei)w, (GLsizei)h);! aspect = w/(float)h;! glmatrixmode(gl_projection);! glloadidentity();! gluperspective(fovy,aspect,near_clip,far_clip);! glmatrixmode(gl_modelview);! View Frustum fovy = 2tan 1 L y /2 dis L z /2 dis = L x 2 + Ly 2 + Lz 2

Animation main() {! glutidlefunc(animate);!...! void animate() { /* Callback function for idle events */! /* Keep updating the scene until the last MD step is reached */! if (stepcount <= StepLimit) {! SingleStep(); /* One MD-step integration */! if (stepcount%stepavg == 0) EvalProps();! makecurframegeom(); /* Redraw the scene */! glutpostredisplay();! ++stepcount;! void display() {!...! drawscene();! glutswapbuffers();!

Immersive & Interactive Visualization ImmersaDesk! at CACS! CAVE! Stereographics Tracking system Wand: 3D (6 degrees-of-freedom) mouse

Origin: Sutherland (1968)

Now: Consumer VR Year 1 Interactive Leap Motion Immersive Oculus head mount display

CAVE Library Programming #include <cave_ogl.h>! #include <GL/glu.h>! GLUquadricObj *sphereobj;! void init_gl(void) {! float redmaterial[] = { 1, 0, 0, 1 };! glenable(gl_light0);! glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, redmaterial);! sphereobj = glunewquadric();! void draw_ball(void) {! glclearcolor(0., 0., 0., 0.);! glclear(gl_depth_buffer_bit GL_COLOR_BUFFER_BIT);! glenable(gl_lighting);! glpushmatrix();! gltranslatef(0.0, 4.0, -4.0);! glusphere(sphereobj, 1.0, 8, 8);! glpopmatrix();! gldisable(gl_lighting);! main(int argc,char **argv) {! CAVEConfigure(&argc,argv,NULL); /* Initialize the CAVE */! CAVEInit();! CAVEInitApplication(init_gl,0); /* Pointer to the GL initialization function */! CAVEDisplay(draw_ball,0); /* Pointer to the drawing function */! while (!CAVEgetbutton(CAVE_ESCKEY)) /* Wait for the escape key to be hit */!!sginap(10); /* Nap so that this busy loop doesn't waste CPU time */! CAVEExit(); /* Clean up & exit */! http://cacs.usc.edu/education/cs653.html ball.c