Introduction to VRT. Interactive Graphical Systems HT2007. Lars Pettersson. Interactive Graphical Systems

Similar documents
This lecture. Introduction to VRT. Hardware. Implementation levels. Scene-Graph libraries. Computer Graphic libraries

Libraries for Computer Graphics. Introduction to VRT. Scene-graph libraries. Libraries for computer graphics. Scene-graph libraries (cont.

VRT 2.0 Stefan Seipel, Hans Molin, Lars Winkler Pettersson, Mikael Erlandsson Version 2.0 9/30/2003 i

Building Interactive Graphical Systems

Lecture 08: Hierarchical Modeling with Scene Graphs

CSCI E-74. Simulation and Gaming

Chapter 3. Texture mapping. Learning Goals: Assignment Lab 3: Implement a single program, which fulfills the requirements:

Interactive Graphical Systems HT2006

3D Rendering. Course Syllabus. Where Are We Now? Rendering. 3D Rendering Example. Overview. Rendering. I. Image processing II. Rendering III.

Speeding up your game

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

CS451Real-time Rendering Pipeline

Hierarchical Modeling and Scene Graphs

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

OpenGL Transformations

Modeling the Virtual World

Game Architecture. 2/19/16: Rasterization

High Level Graphics Programming & VR System Architecture

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Hierarchical Models Josef Pelikán & Alexander Wilkie CGG MFF UK Praha

Computer graphics MN1

to OpenGL Introduction Pipeline Graphics pipeline OpenGL pipeline OpenGL syntax Modeling Arrays Conclusion 1 Introduction Introduction to OpenGL

Computer Graphics 7: Viewing in 3-D

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

OpenGL: Setup 3D World

NVIDIA nfinitefx Engine: Programmable Pixel Shaders

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

Graphics for VEs. Ruth Aylett

CS452/552; EE465/505. Transformations

Computer Graphics. Prof. Feng Liu. Fall /21/2016

Advanced Shading and Texturing

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

OpenGL refresher. Advanced Computer Graphics 2012

Hierarchical Modeling and Scene Graphs

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Rendering. Generate an image from geometric primitives II. Rendering III. Modeling IV. Animation. (Michael Bostock, CS426, Fall99)

Graphics for VEs. Ruth Aylett

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

NVSG NVIDIA Scene Graph

3D GRAPHICS. design. animate. render

CHAPTER 1 Graphics Systems and Models 3

Animation & Rendering

Programming using OpenGL: A first Introduction

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

Networked Virtual Environments and Distributed Rendering IGS HT Background and history. Background and history. Background and history

Animation Essentially a question of flipping between many still images, fast enough

lecture 18 - ray tracing - environment mapping - refraction

Shaders. Slide credit to Prof. Zwicker

Graphics Hardware. Instructor Stephen J. Guy

CSE4030 Introduction to Computer Graphics

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

Dynamic Ambient Occlusion and Indirect Lighting. Michael Bunnell NVIDIA Corporation

Whiz-Bang Graphics and Media Performance for Java Platform, Micro Edition (JavaME)

CS GAME PROGRAMMING Question bank

Graphics Programming

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

Transformations. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

Exercise 1 Introduction to OpenGL

3D computer graphics: geometric modeling of objects in the computer and rendering them

Programming with OpenGL Part 1: Background

CS 354R: Computer Game Technology

Graphical Objects and Scene Graphs

CSE 167: Introduction to Computer Graphics Lecture #8: Scene Graph. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Graphics Hardware and OpenGL

Spring 2009 Prof. Hyesoon Kim

Foundations of 3D Graphics Programming

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Programming Graphics Hardware

Custom Component Development Using RenderMonkey SDK. Natalya Tatarchuk 3D Application Research Group ATI Research, Inc

Lesson 01 Polygon Basics 17. Lesson 02 Modeling a Body 27. Lesson 03 Modeling a Head 63. Lesson 04 Polygon Texturing 87. Lesson 05 NURBS Basics 117

Hardware-Assisted Relief Texture Mapping

Projection Matrix Tricks. Eric Lengyel

3D Computer Games Technology and History. Markus Hadwiger VRVis Research Center

Mobile Application Programming. OpenGL ES 3D

Tetra4D Reviewer. Version 2018 User Guide. Document version: V3.0. Tetra4D Reviewer 2018 Users Guide V3.0 1

Order of Transformations

A Conceptual and Practical Look into Spherical Curvilinear Projection By Danny Oros

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

Computer Graphics: Viewing in 3-D. Course Website:

Basic Graphics Programming

Graphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal

Objectives. transformation. General Transformations. Affine Transformations. Notation. Pipeline Implementation. Introduce standard transformations

Hidden Surface Elimination Raytracing. Pre-lecture business. Outline for today. Review Quiz. Image-Space vs. Object-Space

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

Mobile Application Programming: Android. OpenGL ES 3D

GEOMETRIC OBJECTS AND TRANSFORMATIONS I

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Introduction to Computer Graphics. Knowledge basic concepts 2D and 3D computer graphics

Mattan Erez. The University of Texas at Austin

Advanced Lighting Techniques Due: Monday November 2 at 10pm

Assignment #3: Scalar Field Visualization 3D: Cutting Plane, Wireframe Iso-surfacing, and Direct Volume Rendering

Level of Details in Computer Rendering

CSE 167: Introduction to Computer Graphics Lecture #11: Visibility Culling

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

Classic Rendering Pipeline

Software Engineering. ò Look up Design Patterns. ò Code Refactoring. ò Code Documentation? ò One of the lessons to learn for good design:

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

Transcription:

Introduction to VRT Interactive Graphical Systems HT2007 Lars Pettersson lwp@it.uu.se Interactive Graphical Systems

Implementation levels Application Scene Graph lib. Computer Graphics lib. Hardware Informationsteknologi 2007-08-28 #2

Hardware App. E.g. ATI, nvidia, Matrox A driver is used to communicate with the graphic card SG-lib. CG-lib. Hardw. Informationsteknologi 2007-08-28 #3

Computer Graphic libraries App. SG-lib. CG-lib. Hardw. E.g. OpenGL, DirectX Provides a low-level programming interface Functions for drawing graphics, e g triangles and lines, etc. What kind of functionality do we want? Easier to understand than OpenGL, etc. More abstract programming interface Specialized for Interactive Graphical Systems Easy object loaders Informationsteknologi 2007-08-28 #4

Scene-Graph libraries App. Also known as 3D engines SG-lib. CG-lib. Provides functions for loading, rendering, manipulating geometry material, texture and light source management collision detection, level of detail (LOD) rendering Hardw. Scene is represented using a graph, usually a directed a-cyclic graph or a tree Informationsteknologi 2007-08-28 #5

Application programming App. Games, Simulations, Visualizations SG-lib. CG-lib. Hardw. Informationsteknologi 2007-08-28 #6

Application programming App. SG-lib. CG-lib. Counter Strike: Source Valve Source Engine DirectX 9 Hardw. ATI, nvidia, Informationsteknologi 2007-08-28 #7

Application programming App. SAS flight academy SG-lib. CG-lib. CAE Tropos Hardw. ATI Tech. Informationsteknologi 2007-08-28 #8

Scene-graph libraries (cont.) Models often hierarchical App. Animals Planet systems SG-lib. Vehicles Each node has CG-lib. orientation relative to parent geometry material body Hardw. color upper arm upper leg head etc... lower arm lower leg Informationsteknologi 2007-08-28 #9

Scene-graph design issues Cameras, lights and animation do not cleanly fit in animation light animation camera camera light (OpenGL & VRT) Informationsteknologi 2007-08-28 #10

Scene-graph design issues (cont.) Stored files could represent: Simple geometry Wavefront (.obj) Whole scene VRML 3D studio Standard or native file format? Which programming language to use? Function and data-type naming conventions Informationsteknologi 2007-08-28 #11

Scene-graph pros & cons + - Provides better abstraction Enables more rapid application development Less flexible and lower performance Slower propagation of new hardware inventions Informationsteknologi 2007-08-28 #12

Other scene-graph libraries World Toolkit Developed by Sense8 Different file formats; Wavefront, VRML, etc... Dive Developed by SICS Scene graph distributed transparently over network Java3D Java Developed by Sun Microsystems Informationsteknologi 2007-08-28 #13

Virtual Reality Toolkit (VRT) A scene-graph graphics library Developed by Stefan Seipel in 1997 UU-local toolkit, but similar to other scene graph libs Used for 3D modeling and simulation Callback-based Still being developed Mainly used at the department Informationsteknologi 2007-08-28 #14

Virtual Reality Toolkit (cont.) Built as an interface on top of OpenGL VRT allows use of native OpenGL functions VRT uses OpenGL s hardware assisted graphics acceleration Application programmers interface (API) in C Not object oriented Informationsteknologi 2007-08-28 #15

Hierarchical modeling Interactive Graphical Systems Example: (extremely) simple robot Simply 3 objects connected to each other hierarchically Nodes connected hierarchically in the scene-graph Geometry (shared by all nodes) Robot Arm1 Arm2 Informationsteknologi 2007-08-28 #16

Explicit geometry representations Organization of geometry data: y v2 p1 v1 v7 p4 v6 v3 p2 p3 v5 v4 z x Objects reference frame Vertex List 1 2 3 4 5 6 n Vertex Index x,y,z,...u,v x,y,z,...u,v x,y,z,...u,v x,y,z,...u,v x,y,z,...u,v x,y,z,...u,v x,y,z,...u,v Vertex Data Cartesian Coordinates Normal Vectors Texture Coordinates Color Values Polygon List 1 4 { 1, 2, 3, 4 } 2 3 { 6, 4, 3 } 3 3 { 5, 4, 6 } 4 4 { 3, 2, 7, 6 } k 3 { l, m, n } Polygon Index Number of Vertices List of Vertex Indices {... } {... } {... } {... } {... } Other data e.g. Texture Reference Informationsteknologi 2007-08-28 #17

Implicit geometry representations Organization of geometry data: geom = VRT_Box(1.0f, 1.0f, 1.0f); (float dx, float dy, float dz) v7 v2 y dy v3 v6 v5 z v1 dx v4 x dz Objects reference frame Informationsteknologi 2007-08-28 #18

Creating the Model Hierarchy Interactive Graphical Systems Scene graph Robot Arm1 Arm2 robot = VRT_NodeNew(VRT_RootNode(), "Robot"); arm1 = VRT_NodeNew(robot, "Lower arm"); arm2 = VRT_NodeNew(arm1, "Upper arm"); geom = VRT_Box(0.05f, 0.3f, 0.05f); VRT_GeometrySetColor(geom, 255, 10, 255, 255); VRT_GeometrySetShadingModel(geom, VRT_SM_SHADE); VRT_NodeSetGeometry(robot, geom); VRT_NodeSetGeometry(arm1, geom); VRT_NodeSetGeometry(arm2, geom); Scene Y X Z VRT_NodeScale(arm1, 0.8f, 1.0f, 0.8f); VRT_NodeScale(arm2, 0.8f, 1.0f, 0.8f); VRT_NodeTranslate(arm1, 0.0f, 0.28f, 0.0f); VRT_NodeTranslate(arm2, 0.0f, 0.28f, 0.0f); Informationsteknologi 2007-08-28 #19

int main(int argc, char *argv[]) { VRT_Init(&argc, argv); /* initialize VRT Toolkit */ VRT_SetDisplay(0); /* choose a display type, usually default */ build_scene(); /* build up your own scenery */ /* install a user-define callback function */ VRT_SetCallback((VRT_HookPtr)SimulationLoop); /* decide for background color */ VRT_SetClearColor(0.7f,0.7f,8.0f,0.5f); /* install and set a virtual camera */ VRT_SetDefaultCamera(6.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); VRT_SetCameraFieldOfView(15.0f); } /* start the simulation loop */ VRT_SimulationLoop(); /* shut down simulation server */ VRT_Close(); return 0; Informationsteknologi 2007-08-28 #20

static VRT_HookPtr SimulationLoop(VRT_CB_MSG *msg) /* Create the main (infinite) loop */ { switch (msg->id) /* Handle keyboard events */ { case VRT_MSG_KEYBOARD_DOWN: { // Switch camera settings if (msg->arg1 == 'x') { VRT_SetDefaultCamera(6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); break; } if (msg->arg1 == 'y') { VRT_SetDefaultCamera(0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0); break; } if (msg->arg1 == 'z') { VRT_SetDefaultCamera(0.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); break; } } default: break; } return 0; } Informationsteknologi 2007-08-28 #21

VRT Overview A more detailed overview is available here: http://www.it.uu.se/edu/course/homepage/igs/ht06/ labs/env/vrt_programmers_manual.chm Informationsteknologi 2007-08-28 #22

VRT Basic structures VRT_Context Holds information about the current VRT universe. VRT_Node A placeholder in the scene graph that contains a transformation matrix relative to its parent and can also hold a geometry and links to a number of children nodes. VRT_Geometry A set of polygons that build up an object in the scene. Must be linked to a node to be visible. Can also have color and other attributes. VRT_Polygon A set of vertices and a normal vector, that build up a surface in a geometry. Can also have color on polygon level. Informationsteknologi 2007-08-28 #23

VRT Basic structures (cont.) VRT_Vertex A point in the local coordinate system of a geometry. Can also have a normal vector on vertex level (for smooth shading) and texture coordinates. VRT_Htx Handle to a texture object. VRT_Camera Representing the observers view of the scene. Contains position, direction and field of view (fov). There can be several cameras in VRT, but only one can be active. VRT_Light Represents a light source in the scene. Contains position, direction, colors, intensity and other attributes. Informationsteknologi 2007-08-28 #24

VRT General functions VRT initialization / close functions: void VRT_Init (&argc, argv) void VRT_Close () int VRT_SetDisplay (int displaymode) void VRT_SetCallback (VRT_HookPtr hook) Start / exit simulation loop: void VRT_SimulationLoop () void VRT_ExitSimulationLoop () Informationsteknologi 2007-08-28 #25

VRT General functions (cont.) Some other useful functions: void VRT_PrintSceneGraph () float VRT_GetFrameRate () float VRT_GetSimulationTime () VRT_Node *vrt_createworldreferenceframe() Informationsteknologi 2007-08-28 #26

VRT Node functions Create / delete node: VRT_Node * VRT_NodeNew (VRT_Node *parent, char *name) int VRT_NodeDelete (VRT_Node *anode) Show / hide node: int VRT_NodeSwitchOff (VRT_Node *anode) int VRT_NodeSwitchOn (VRT_Node *anode) Connect geometry to node: int VRT_NodeSetGeometry (VRT_Node *anode, VRT_Geometry *geom) Informationsteknologi 2007-08-28 #27

VRT Node functions (cont.) Transform a node: relative to the parent node int VRT_NodeTranslate (VRT_Node *anode, float tx, float ty, float tz) int VRT_NodeRotate (VRT_Node *anode, float rx, float ry, float rz) int VRT_NodeScale (VRT_Node *anode, float sx, float sy, float sz) absolute transformation int VRT_NodeSetTranslation (VRT_Node *anode, float tx,float ty,float tz) int VRT_NodeSetRotation (VRT_Node *anode, float rx, float ry, float rz) int VRT_NodeSetScale (VRT_Node *anode, float sx, float sy, float sz) Informationsteknologi 2007-08-28 #28

VRT Geometry functions Create / delete geometry: VRT_Geometry * VRT_GeometryNew () int VRT_GeometryDelete (VRT_Geometry *geom) Add vertex / polygons to geometry: int VRT_GeometryAddVertex (VRT_Geometry *geom, float x, float y, float z, float nx, float ny, float nz, float u, float v) VRT_HPlg VRT_GeometryNewTriangle (VRT_Geometry *geom, int v1, int v2, int v3) VRT_HPlg VRT_GeometryNewQuad (VRT_Geometry *geom, int v1, int v2, int v3, int v4) VRT_HPlg VRT_GeometryNewTriangleStrip (VRT_Geometry *geom, int nv, int *vi) Informationsteknologi 2007-08-28 #29

VRT Geometry functions (cont.) Set geometry attributes: int VRT_GeometrySetColor (VRT_Geometry *geom, int r, int g, int b, int alpha) int VRT_GeometrySetMaterial (VRT_Geometry *geom, float *material) int VRT_GeometrySetTexture (VRT_Geometry *geom, VRT_Htx texture) int VRT_GeometrySetShadingModel (VRT_Geometry *geom, int shadingmodel) int VRT_GeometryFlipNormals (VRT_Geometry *geom) int VRT_GeometryCalcVertexNormals (VRT_Geometry *geom) Informationsteknologi 2007-08-28 #30

VRT Geometry functions (cont.) Some predefined VRT_Geometry objects: VRT_Geometry *VRT_Pyramid () VRT_Geometry *VRT_Cube (float size) VRT_Geometry *VRT_Box (float dx, float dy, float dz) VRT_Geometry *VRT_Plate (float size, char *tname) VRT_Geometry *VRT_Cone (float tr, float br, float height, int resolution) VRT_Geometry *VRT_Sphere (float diameter, int resolution) VRT_Geometry *VRT_ConstantPipe (float radius, int resolution, int numsamples, float *controls) VRT_Geometry *VRT_ModulatedPipe (int resolution, int numsamples, float *controls, float *radius) Informationsteknologi 2007-08-28 #31

VRT Geometry functions (cont.) Load geometry from object file: VRT_Geometry *VRT_LoadPLG (char *file_name) VRT_Geometry *VRT_LoadOBJ (char *file_name) Informationsteknologi 2007-08-28 #32

VRT Polygon functions Set attributes for individual polygons: int VRT_PolygonSetShadingModel (VRT_HPlg poly, int rendermode) int VRT_PolygonGetShadingModel (VRT_HPlg poly, int *rendermode) int VRT_PolygonSetColor (VRT_HPlg poly, int r, int g, int b, int a) int VRT_PolygonGetColor (VRT_HPlg poly, int *r,int *g,int *b,int *a) int VRT_PolygonSetTexture (VRT_HPlg poly, VRT_Htx texture) VRT_Htx VRT_PolygonGetTexture (VRT_HPlg poly) Informationsteknologi 2007-08-28 #33

VRT Camera functions Handle the default camera: void VRT_ResetDefaultCamera () void VRT_SetDefaultCamera (float ex, float ey, float ez, float cx, float cy, float cz, float ux, float uy, float uz) void VRT_GetDefaultCamera (float *ex, float *ey, float *ez, float *cx, float *cy, float *cz, float *ux, float *uy, float *uz) int VRT_AttachCameraToNode (VRT_Node *node) void VRT_SetCameraFieldOfView (float fov) There are also functions for handling general, user defined cameras. Informationsteknologi 2007-08-28 #34

VRT Light functions Create / delete lights: VRT_Light *VRT_LightNew (int light_type) int VRT_LightDelete (VRT_Light *light) Switch lights on / off: int VRT_LightSwitchOn (VRT_Light *light) int VRT_LightSwitchOff (VRT_Light *light) Set light attributes: int VRT_LightSetColors (VRT_Light *light, float *colors) int VRT_LightSetAttenuation (VRT_Light *light, float *attenuation) int VRT_LightSetType (VRT_Light *light, int light_type) Informationsteknologi 2007-08-28 #35

VRT Light functions (cont.) Light positioning functions: int VRT_LightSetPosition (VRT_Light *light, float x, float y, float z) int VRT_LightSetDirection (VRT_Light *light, float dx, float dy, float dz) int VRT_LightSetPositionNode (VRT_Light *light, VRT_Node *nposition) int VRT_LightSetTargetNode (VRT_Light *light, VRT_Node *ntarget) Informationsteknologi 2007-08-28 #36

VRT Texture functions Create / load / delete texture: VRT_Htx VRT_LoadTexture (char *filename) VRT_Htx VRT_CreateRGBATexture (int sx, int sy, char *texels) int VRT_DeleteTexture (VRT_Htx *texture) Replace texture: int VRT_ReplaceRGBATexture (VRT_Htx *texture, int sx, int sy, char *texels) Set texture attributes: void VRT_SetTextureModulationMode (int texture_modulation) Informationsteknologi 2007-08-28 #37