Development of Interactive 3D Virtual World Applications

Slides:



Advertisements
Similar presentations
02/17/05CISC640/440 OpenGL Tutorial1 OpenGL Tutorial CISC 640/440 Computer Graphics TA: Qi Li/Mani Thomas
Advertisements

2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
OpenGL Basics Donghui Han. Assignment Grading Visual Studio Glut Files of four types needed: – Source code:.cpp,.h – Executable file:.exe (build in release.
OpenGL Basics.
Viewing and Transformation
Hidden Surfaces and Shading CS BSP Tree T1T1 T2T2 E if (f 1 (E) < 0) then draw T 1 draw T 2 else draw T 2 draw T 1 f 1 (p) = 0 is the.
OpenGL and Projections
Typical Program Structure: Initialize Window (GLUT) Initialize Event Handlers and Menus Set some initial GL states/values Pass control over to OpenGL.
CSE 494/598 Intro to Applied Computer Graphics Anshuman Razdan DCST AR's Web Page AR's Web Page
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
CS425 OpenGL Materials. What Color Is It? green & blue absorbed white light Looks red.
OpenGL Tutorial Jason Lawrence COS426 Precept Notes 2/16/04.
Lighting & Material. Example 1/5 #include ” glut.h ” void display(); void reshape(int, int); void lighting(); int main(int argc, char** argv) { glutInit(&argc,
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Introduction to OpenGL M. Ramanathan STTP CAD 2011Introduction to OpenGL.
Write a Simple Program with OpenGL & GLUT. Books and Web Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible.
CS 470 Introduction to Computer Graphics Basic 3D in OpenGL.
Introduction to OpenGL Jian Huang This set of slides are extracted from the Interactive OpenGL Programming course given by Dave Shreine, Ed Angel and Vicki.
OpenGL A Brief Overview. What is OpenGL?  It is NOT a programming language.  It is a Graphics Rendering API consisting of a set of function with a well.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 CSE 872 Advanced Computer Graphics Charles B. Owen (Instructor) – 1138 E. B., MW 12:30-1:50pm.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
1 OpenGL Basics A Graphics Standard ©Mel Slater, Anthony Steed
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Computer Graphics, KKU. Lecture 131 Transformation and Viewing in OpenGL.
Geometric transformations The Pipeline
OpenGl Graphics Programming. Introduction OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric.
Computer Graphics I, Fall 2010 Shading in OpenGL.
Programming for Virtual Reality Applications Projection in OpenGL Lighting and Shading Lecture 17.
Write a Simple Program with OpenGL & GLUT. Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
 “OpenGL (Open Graphics Library) is a standard specification defining a cross- language cross-platform API for writing applications that produce 2D and.
Introduction to OpenGL 1. 2 OpenGL A Graphics rendering API introduced in 1992 by Silicon Graphics Inc Provide the low-level functions to access graphics.
CG1 Labs Wei Li. Back Face Culling // enable back-face culling glEnable( GL_CULL_FACE ); // orientation of front-facing polygons glFrontFace( GL_CCW );
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 4 of 41 William H. Hsu Department of Computing.
OpenGL Color and Lighting 2003 Spring Keng Shih-Ling.
OpenGL Lighting Jian-Liang Lin 2002 Hidden-Surface Removal -1 Original Code: while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT);
Intro to OpenGL (Version 2) Geb Thomas. Setting Up GLUT You will need GLUT for opening windows We can use the version made by Nate Robins: –
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
C O M P U T E R G R A P H I C S Jie chen Computer graphic -- Programming with OpenGL 2.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
David Luebke1/5/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Chap 3 Viewing and Transformation
Introduction to OpenGL Programming
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
CS559: Computer Graphics Lecture 12: OpenGL: ModelView Li Zhang Spring 2010.
OpenGL & OpenSceneGraph Graphics Programming Katia Oleinik:
Implement of transformation,projection, viewing Hanyang University Jungsik Park.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
OpenGL LAB III.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
INTRODUCTION TO OPENGL
CSC Graphic Programming Lecture 2 OpenGL Lightning.
Graphics Graphics Korea University kucg.korea.ac.kr 1 Lights & Material 고려대학교 컴퓨터 그래픽스 연구실.
Basic Program with OpenGL and GLUT
CSC Graphics Programming
Jason Lawrence COS426 Precept Notes 2/16/04
Reference1. [OpenGL course slides by Rasmus Stenholt]
“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.
Projection v VP u VPN n.
Computer Graphics, KKU. Lecture 13
Lighting and Materials
Type of View Perspective View COP(Center of Plane) Diminution of size
Computer Graphics 3Practical Lesson
Projection v VP u VPN n.
Presentation transcript:

Development of Interactive 3D Virtual World Applications Lab exercises by Assoc. Prof. Dr. Emiliyan Petkov

Accents Virtual world – a computer simulation of a real environment which contains real objects Practical exercises on how to create 3D worlds, import them in a OpenGL application and manipulate cameras and 3D models Low-level graphics programming lessons (OpenGL) 3D world creation – Blender Development of an interactive application – Code::Blocks (C++ IDE) Using a graphics system – OpenGL Free, cross platform and open source products

Lessons Part I – Basics OpenGL GS OpenGL libraries Main functions Structure of an OpenGL app Interactivity OpenGL and Blender: Lights Materials Cameras Part II – Advanced Virtual World Development – Blender X3DLoader library Creating interactive OpenGL application using X3DLoader library

Basics of OpenGL OpenGL (Open Graphics Library) – cross-platform, high performance graphics, by Khronos Group GLU and GLUT Under MS Windows we need: gl.h, libopengl32.a, opengl32.dll glu.h, libglu32.a, glu32.dll glut.h, libglut32.a, glut32.dll Creating models 10 graphics primitives glBegin( GL_POLYGON ); glVertex3f( 0.0, 0.5, 0.0 ); glVertex3f( 0.75, -0.5, 0.0 ); glVertex3f( -0.75, -0.5, 0.0 ); glEnd();

GLUT main functions void glutInit(int *argcp, char **argv); - used to initialize the GLUT library void glutInitWindowPosition(int x, int y); - sets the initial window position void glutInitWindowSize(int width, int height); - sets the initial window size void glutInitDisplayMode(unsigned int mode); - sets the initial display mode int glutCreateWindow(char *name); - creates a top-level window void glutDisplayFunc(void (*func)(void)); -  sets the display callback for the current window void glutMainLoop(void); - enters the GLUT event processing loop

GLUT 3D Models void glutWireCube(GLdouble size) void glutSolidCube(GLdouble size) void glutWireSphere(GLdouble radius, GLint slices, GLint stacks) void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks) and more

GLUT management of events void glutReshapeFunc(void (*func)(int width, int height)); - sets the reshape callback for the current window void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y)); -  sets the keyboard callback for the current window void glutMouseFunc(void (*func)(int button, int state, int x, int y)); - sets the mouse callback for the current window void glutMotionFunc(void (*func)(int x, int y)); - sets the motion callback for the current window void glutPassiveMotionFunc(void (*func)(int x, int y)); - set the passive motion callback for the current window

Lights in OpenGL Point light Sun light Spot light Sun: Point: Spot: glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); GLfloat light0Position[] = {4.0, 4.0, 0.0, 0.0 }; glLightfv(GL_LIGHT0, GL_POSITION, light0Position ); Point: glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); GLfloat light0Position[] = {4.0, 4.0, 0.0, 1.0 }; glLightfv(GL_LIGHT0, GL_POSITION, light0Position ); Spot: glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 45.0 ); glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 4.0 ); GLfloat direction[] = {-1.0, -2.0, 2.0}; glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, direction );

Materials in OpenGL Ambient – factor of reflection (depends on the ambient environment) GL_AMBIENT Diffuse – factor of diffuse reflection GL_DIFFUSE Specular – factor of specular reflection GL_SPECULAR Shininess – factor of concentration of reflected light in a small area around the ideal reflector GL_SHININESS Emission – factor of emissive color of the material GL_EMISSION These factors are applied over the faces in three modes: GL_FRONT, GL_BACK and GL_FRONT_AND_BACK

Materials in OpenGL Example: GLfloat ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f }; GLfloat diffuse[] = { 1.0f, 0.0f, 0.0f, 1.0f }; GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat shininess[] = { 50.0f }; glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialfv(GL_FRONT, GL_SHININESS, shininess);

Defining a Camera

Defining a Camera void gluLookAt(GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); - creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector eyeX, eyeY, eyeZ specifies the position of the eye point. centerX, centerY, centerZ specifies the position of the reference point. upX, upY, upZ specifies the direction of the up vector.

Defining a Camera void gluPerspective(GLdouble  fovy, GLdouble  aspect, GLdouble  zNear, GLdouble  zFar); - specifies a viewing frustum into the world coordinate system fovy specifies the field of view angle, in degrees, in the y direction. aspect specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height). zNear specifies the distance from the viewer to the near clipping plane (always positive). zFar specifies the distance from the viewer to the far clipping plane (always positive).

Defining a Camera Example: glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 70.0, 640.0/480.0, 0.1, 100.0 ); gluLookAt( eyex, eyey, eyez, //eye 0.0, 0.0, 0.0, //center 0.0, 1.0, 0.0 );//up vector