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

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

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

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

Speeding up your game

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

Computer Graphics 7: Viewing in 3-D

CS451Real-time Rendering Pipeline

Modeling the Virtual World

Computer graphics MN1

Hierarchical Modeling and Scene Graphs

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

OpenGL Transformations

Culling. Computer Graphics CSE 167 Lecture 12

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

Programming using OpenGL: A first Introduction

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

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

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

CS452/552; EE465/505. Transformations

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

Advanced Shading and Texturing

Programming with OpenGL Part 1: Background

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

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller 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)

Basic Graphics Programming

OpenGL: Setup 3D World

NVIDIA nfinitefx Engine: Programmable Pixel Shaders

CSE4030 Introduction to Computer Graphics

CIS 581 Interactive Computer Graphics (slides based on Dr. Han-Wei Shen s slides) Requirements. Reference Books. Textbook

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

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

Animation & Rendering

Computer Science 175. Introduction to Computer Graphics lib175 time: m/w 2:30-4:00 pm place:md g125 section times: tba

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

Game Architecture. 2/19/16: Rasterization

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

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

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

Hierarchical Modeling and Scene Graphs

Graphics Programming

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

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

I expect to interact in class with the students, so I expect students to be engaged. (no laptops, smartphones,...) (fig)

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

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

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

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

Foundations of 3D Graphics Programming

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

Projection Matrix Tricks. Eric Lengyel

Open Scene Graph Lecture Note #1

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

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

High Level Graphics Programming & VR System Architecture

NVSG NVIDIA Scene Graph

Hardware-Assisted Relief Texture Mapping

Dynamic Ambient Occlusion and Indirect Lighting. Michael Bunnell NVIDIA Corporation

Level of Details in Computer Rendering

Computer Graphics: Introduction to the Visualisation Toolkit

CS GAME PROGRAMMING Question bank

lecture 18 - ray tracing - environment mapping - refraction

Real Time Rendering of Complex Height Maps Walking an infinite realistic landscape By: Jeffrey Riaboy Written 9/7/03

Mattan Erez. The University of Texas at Austin

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Shaders. Slide credit to Prof. Zwicker

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

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

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

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

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

Exercise 1 Introduction to OpenGL

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

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

Graphics for VEs. Ruth Aylett

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

Computer Graphics. Bing-Yu Chen National Taiwan University

Graphical Objects and Scene Graphs

EDAF80 Introduction to Computer Graphics. Seminar 3. Shaders. Michael Doggett. Slides by Carl Johan Gribel,

Viewport 2.0 API Porting Guide for Locators

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

Chapter 5 - The Scene Graph

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

OpenGL refresher. Advanced Computer Graphics 2012

Classic Rendering Pipeline

CSC 470 Computer Graphics

The Shadow Rendering Technique Based on Local Cubemaps

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

Graphics for VEs. Ruth Aylett

CS D Transformation. Junqiao Zhao 赵君峤

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

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

Spring 2009 Prof. Hyesoon Kim

CS 354R: Computer Game Technology

Transcription:

Introduction to VRT HT2005 This lecture My research (not in your slides) Theory VRT Basic structures Useful functions Simple demo Mikael Erlandsson mikael.erlandsson@it.uu.se Informationsteknologi 2006-09-01 #2 Implementation levels Hardware Application E.g. ATI, nvidia, Matrox A driver is used to communicate with the graphic card Scene Graph lib. Computer Graphics lib. Hardware Informationsteknologi 2006-09-01 #3 Informationsteknologi 2006-09-01 #4 Computer Graphic libraries Scene-Graph libraries 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 Easy object loaders Also known as 3D engines Provides functions for loading, rendering, manipulating geometry material, texture and light source management collision detection, level of detail (LOD) rendering Scene is represented using a graph, usually a directed a-cyclic graph or a tree Informationsteknologi 2006-09-01 #5 Informationsteknologi 2006-09-01 #6 1

Application programming Application programming Games, Simulations, Visualizations Counter Strike: Source Valve Source Engine DirectX 9 ATI, nvidia, Informationsteknologi 2006-09-01 #7 Informationsteknologi 2006-09-01 #8 Application programming Scene-graph libraries (cont.) SAS flight academy CAE Tropos Models often hierarchical Animals Planet systems Vehicles Each node has orientation relative to parent geometry material body ATI Tech. color etc... upper arm lower arm upper leg lower leg head Informationsteknologi 2006-09-01 #9 Informationsteknologi 2006-09-01 #10 Scene-graph design issues Cameras, lights and animation do not cleanly fit in animation light animation camera camera light (OpenGL & VRT) 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 2006-09-01 #11 Informationsteknologi 2006-09-01 #12 2

Scene-graph pros & cons + Provides better abstraction Enables more rapid application development - Less flexible and lower performance Slower propagation of new hardware inventions 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 2006-09-01 #13 Informationsteknologi 2006-09-01 #14 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 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 Works with Windows, Linux, Solaris, Mac Informationsteknologi 2006-09-01 #15 Informationsteknologi 2006-09-01 #16 Time to get to know VRT!!! A quick walkthrough of: 8 data structures 70 functions implementation of a simple robot 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 2006-09-01 #17 Informationsteknologi 2006-09-01 #18 3

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. 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 2006-09-01 #19 Informationsteknologi 2006-09-01 #20 VRT General functions (cont.) Some other useful functions: void VRT_PrintSceneGraph () float VRT_GetFrameRate () float VRT_GetSimulationTime () VRT_Node *vrt_createworldreferenceframe() 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 2006-09-01 #21 Informationsteknologi 2006-09-01 #22 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) 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 2006-09-01 #23 Informationsteknologi 2006-09-01 #24 4

VRT Geometry functions (cont.) 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) 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 2006-09-01 #25 Informationsteknologi 2006-09-01 #26 VRT Geometry functions (cont.) VRT Polygon functions Load geometry from object file: VRT_Geometry *VRT_LoadPLG (char *file_name) VRT_Geometry *VRT_LoadOBJ (char *file_name) 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 2006-09-01 #27 Informationsteknologi 2006-09-01 #28 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. 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 2006-09-01 #29 Informationsteknologi 2006-09-01 #30 5

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) 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 2006-09-01 #31 Informationsteknologi 2006-09-01 #32 Hierarchical modeling Creating the Model Hierarchy Example: (extremely) simple robot Simply 3 objects connected to each other hierarchically Robot robot = VRT_NodeNew(VRT_RootNode(), "Robot"); arm1 = VRT_NodeNew(robot, "Lower arm"); arm2 = VRT_NodeNew(arm1, "Upper arm"); Nodes connected hierarchically in the scene-graph Robot Arm1 Geometry (shared by all nodes) Arm1 Arm2 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); Arm2 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 2006-09-01 #33 Informationsteknologi 2006-09-01 #34 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; 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 2006-09-01 #35 Informationsteknologi 2006-09-01 #36 6