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

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

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

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

Hierarchical Modeling and Scene Graphs

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

OpenGL Transformations

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

CS451Real-time Rendering Pipeline

Programming using OpenGL: A first Introduction

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

Computer Graphics 7: Viewing in 3-D

Computer graphics MN1

OpenGL: Setup 3D World

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

Hierarchical Modeling and Scene Graphs

OpenGL refresher. Advanced Computer Graphics 2012

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

Modeling the Virtual World

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

Animation & Rendering

CS452/552; EE465/505. Transformations

Speeding up your game

High Level Graphics Programming & VR System Architecture

Game Architecture. 2/19/16: Rasterization

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

Graphics Programming

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

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

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

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

Foundations of 3D Graphics Programming

Graphical Objects and Scene Graphs

Viewport 2.0 API Porting Guide for Locators

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Programming with OpenGL Part 1: Background

Open Scene Graph Lecture Note #1

Graphics for VEs. Ruth Aylett

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

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

NVSG NVIDIA Scene Graph

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

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

Order of Transformations

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

Graphics for VEs. Ruth Aylett

Basic Graphics Programming

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

CS 380 Introduction to Computer Graphics. LAB (1) : OpenGL Tutorial Reference : Foundations of 3D Computer Graphics, Steven J.

Computer Graphics. Bing-Yu Chen National Taiwan University

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

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

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

Advanced Shading and Texturing

Hierarchical Modeling and scene graphs

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

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

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

Shaders. Slide credit to Prof. Zwicker

CSE4030 Introduction to Computer Graphics

CS D Transformation. Junqiao Zhao 赵君峤

WorldToolKit Release 9

Introduction to Computer Graphics with OpenGL/GLUT

Graphics Hardware and OpenGL

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

CHAPTER 1 Graphics Systems and Models 3

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

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

Mobile Application Programming. OpenGL ES 3D

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

VR-programming tools (procedural) More VRML later in this course! (declarative)

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Worksheet 4 Basic Input functions and Mathematical Operators

Mobile Application Programming: Android. OpenGL ES 3D

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

OpenGL/GLUT Intro. Week 1, Fri Jan 12

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

Computer Graphics CS 543 Lecture 5 (Part 2) Implementing Transformations

Renderize Live Overview

Precept 2 Aleksey Boyko February 18, 2011

Projection Matrix Tricks. Eric Lengyel

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

CS GAME PROGRAMMING Question bank

Introduction to 3D Graphics

CSC 470 Computer Graphics

3D GRAPHICS. design. animate. render

Level of Details in Computer Rendering

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

Introduction. What s New in This Edition

lecture 18 - ray tracing - environment mapping - refraction

Programming of Graphics

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

Transcription:

Libraries for Computer Graphics Introduction to VRT HT2004 Mikael Erlandsson mikael.erlandsson@hci.uu.se Application CG-Library OpenGL Hardware What functionality should be provided? Which data structures should be used? Informationsteknologi 2004-09-01 #2 Libraries for computer graphics Example: OpenGL, DirectX Functions for drawing graphics, e g triangles and lines, immediate mode. What kind of functionality do we want? Easier to understand than OpenGL More abstract interface Specialized for Easy object loaders Scene-graph libraries 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 Why is a graph or tree useful? Informationsteknologi 2004-09-01 #3 Informationsteknologi 2004-09-01 #4 Scene-graph libraries (cont.) Models often hierarchical Animals Planet systems Vehicles Each node has orientation relative to parent geometry material color etc... upper arm lower arm body upper leg lower leg head Scene-graph design issues Cameras, lights and animation do not cleanly fit in animation light animation camera camera light (OpenGL & VRT) Informationsteknologi 2004-09-01 #5 Informationsteknologi 2004-09-01 #6 1

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 Scene-graph pros & cons + Provides better abstraction Enables more rapid application development - Less flexible and lower performance Slower propagation of new hardware inventions Informationsteknologi 2004-09-01 #7 Informationsteknologi 2004-09-01 #8 Other scene-graph libraries Virtual Reality Toolkit (VRT) 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 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 2004-09-01 #9 Informationsteknologi 2004-09-01 #10 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 Time to get to know VRT!!! A quick walkthrough of: 8 data structures 70 functions implementation of a simple robot Informationsteknologi 2004-09-01 #11 Informationsteknologi 2004-09-01 #12 2

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. 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 2004-09-01 #13 Informationsteknologi 2004-09-01 #14 VRT General functions VRT General functions (cont.) VRT initialization / close functions: void VRT_Init (&argc, argv) void VRT_Close () int VRT_SetDisplay (int displaymode) void VRT_SetCallback (VRT_HookPtr hook) Some other useful functions: void VRT_PrintSceneGraph () float VRT_GetFrameRate () float VRT_GetSimulationTime () VRT_Node *vrt_createworldreferenceframe() Start / exit simulation loop: void VRT_SimulationLoop () void VRT_ExitSimulationLoop () Informationsteknologi 2004-09-01 #15 Informationsteknologi 2004-09-01 #16 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) 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 2004-09-01 #17 Informationsteknologi 2004-09-01 #18 3

VRT Geometry functions VRT Geometry functions (cont.) 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) 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 2004-09-01 #19 Informationsteknologi 2004-09-01 #20 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) VRT Geometry functions (cont.) Load geometry from object file: VRT_Geometry *VRT_LoadPLG (char *file_name) VRT_Geometry *VRT_LoadOBJ (char *file_name) Informationsteknologi 2004-09-01 #21 Informationsteknologi 2004-09-01 #22 VRT Polygon functions VRT Camera 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) 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 2004-09-01 #23 Informationsteknologi 2004-09-01 #24 4

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) 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 2004-09-01 #25 Informationsteknologi 2004-09-01 #26 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) Hierarchical modeling Example: (extremely) simple robot Simply 3 objects connected to each other hierarchically Nodes connected Hierarchically in a scenegraph Robot Arm1 Arm2 Geometry (shared by all nodes) Informationsteknologi 2004-09-01 #27 Informationsteknologi 2004-09-01 #28 Creating the Model Hierarchy Z Y X 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); 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 2004-09-01 #29 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 2004-09-01 #30 5

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 2004-09-01 #31 6