6 Images, Vector Graphics, and Scenes

Similar documents
3 Multimedia Programming with C++ and Multimedia Frameworks

3 Multimedia Programming with C++ and Multimedia Frameworks

Outline. 1.! Development Platforms for Multimedia Programming!

Lecture Notes, CEng 477

Lesson 4. Temporal Management of Layers

Overview of the Adobe Flash Professional CS6 workspace

Working With Animation: Introduction to Flash

Microsoft Windows Overview Desktop Parts

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

Introduction to Computer Graphics

Sharing Software. Chapter 14

Adobe Illustrator CS5 Part 1: Introduction to Illustrator

B2.53-R3: COMPUTER GRAPHICS. NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions.

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Adobe Illustrator CS5

Adding Animation With Cinema 4D XL

Test Driven Development in Python

JavaFX Session Agenda

Comp 410/510. Computer Graphics Spring Introduction to Graphics Systems

Tutorial: Biped Character in 3D Studio Max 7, Easy Animation

Creating Animated Apps

Game Programming with DXFramework

Canterbury Maps Quick Start - Drawing and Printing Tools

Visualizing Data: Scalable Interactivity

Examples. Pac-Man, Frogger, Tempest, Joust,

Outline. 1.! Development Platforms for Multimedia Programming!

Flash Tutorial Part I

Scripting in Unity3D (vers. 4.2)

How To Watch An Exchange Ediscovery Video On A Computer Or Phone Or Ipad Or Ipa Or Ipo Or Ipom Or Ipor Or Ipro Or Ipode Or Ipod Or Ipore Or Ipob Or Ipoo Or Ipos

Visualization of 2D Domains

Copyright 2006 TechSmith Corporation. All Rights Reserved.

CREATE A 3D MOVIE IN DIRECTOR

Perfect PDF 8 Premium

Tutorial for Tracker and Supporting Software By David Chandler

Petrel TIPS&TRICKS from SCM

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Index. 2D arrays, 210

ClarisWorks 5.0. Graphics

3D-GIS in the Cloud USER MANUAL. August, 2014

Center for Teaching, Learning & Technology

The main imovie window is divided into six major parts.

SnagIt Add-Ins User Guide

Develop Computer Animation

Graphic Design Studio Guide

The following is an overview of lessons included in the tutorial.

MMGD0203 Multimedia Design MMGD0203 MULTIMEDIA DESIGN. Chapter 3 Graphics and Animations

App Inventor Tutorial 4 Cat & Mouse Game

ScanPro 3000 High Definition Microfilm Scanner. Help Guide

Advanced Rendering for Engineering & Styling

Using the Game Boy Advance to Teach Computer Systems and Architecture

Quick Reference Guide for Mimio Teach Hardware:

Doña Ana County, NM Interactive Zoning Map

Practical Data Visualization and Virtual Reality. Virtual Reality VR Software and Programming. Karljohan Lundin Palmerius

Smartboard and Notebook 10 What s New

Maya 2014 Basic Animation & The Graph Editor

Smart Board Notebook Software A guide for new Smart Board users

ANIMATION a system for animation scene and contents creation, retrieval and display

2! Multimedia Programming with! Python and SDL

2012 Ward s Natural Science

Printing Guide. MapInfo Pro Version Contents:

Tips & Tricks for ArcGIS. Presented by: Jim Mallard, Crime Analysis Supervisor Arlington, Texas IACA Conference Pasadena, Ca

ZoomText 10.1 for Windows 8 Quick Reference Guide Addendum

Pro/ENGINEER Wildfire 4.0 Basic Design

The Keyboard One of the first peripherals to be used with a computer and is still the primary input device for text and numbers.

FLASH. Mac versus PC. Pixels versus Vectors Two kinds of images are in the digital world: bitmaps and vectors:

Lesson Plan. Preparation

Lesson Plan. Course Title: Principles of Information Technology Session Title: Understanding Types & Uses of Software

Flash MX 2004 Animation Lesson

Hygame: Teaching Haskell Using Games. Zachi Baharav and David S. Gladstein

MapInfo Professional Version Printing Guide

Sharing Presentations, Documents, and Whiteboards

Welcome to CorelDRAW, a comprehensive vector-based drawing and graphic-design program for the graphics professional.

Using Kid Pix Deluxe 3 (Windows)

U.Rahamathunnisa 1, S. Pragadeeswaran 2 *Assistant Professor, SITE, VIT University, Vellore. **MS(SE) Student, SITE, VIT University, Vellore.

SuperViz: An Interactive Visualization of Super-Peer P2P Network

Advanced Programming with LEGO NXT MindStorms

The Waves Dorrough Meter Collection. User Guide

Test Specification. Introduction

2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION

HANDS-FREE PC CONTROL CONTROLLING OF MOUSE CURSOR USING EYE MOVEMENT

Sticky Password User Manual Sticky Password

Geomagic Design. Release Notes. Get to Market Faster with Better Products at a Lower Cost V17

Introduction... Learn to insert event sounds and streaming sounds and to change the effects for a sound... 69

Experiences with 2-D and 3-D Mathematical Plots on the Java Platform

Getting more out of Matplotlib with GR

Quickstart for Desktop Version

How to Create a Fun Circus Tent Icon. Final Image Preview. Tutorial Details. Step 1. By: Andrei Marius

HTML5 Data Visualization and Manipulation Tool Colorado School of Mines Field Session Summer 2013

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Easy Photo Editing with Windows Vista s Photo Gallery

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Certificate Courses in Animation

Transcription:

6 Images, Vector Graphics, and Scenes 6.1 Image Buffers 6.2 Structured Graphics: Scene Graphs 6.3 Sprites Literature: R. Nystrom: Game Programming Patterns, genever banning 2014, Chapter 8, see also http://gameprogrammingpatterns.com/double-buffer.html LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 1

Tearing and Flickering Using one single graphics buffer Video renderer reads pixel information sequentially and displays it Drawing commands modify same buffer Incomplete drawings are rendered to the screen! LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 2

Double Buffering: Back Buffer Drawing Buffer 1 Buffer 2 READ Display content Video renderer pointer WRITE Drawing pointer LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 3

Double Buffering: Buffer Flipping Buffer 1 Buffer 2 READ Drawing pointer Display content Video WRITE renderer pointer LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 4

Implementation of Double Buffering Basic properties of double buffering Improves user experience Slight cost in speed Hardware realization In graphics cards Software access Clearly visible in low-level frameworks Mostly hidden in high-level frameworks LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 5

Blitting BLIT = Block Image Transfer Bit blit = Name for a hardware technology for speeding up image transfer into frame buffer Speedup fro drawing: Combine small local changes into a larger buffer Display large image at once faster than individual updates Application for copying whole window contents (moving a window) Realized in graphics cards and working together with Double Buffering LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 6

Code Examples Pygame: slide = pygame.image.load('pics/tiger.jpg').convert() screen.blit(slide, (50, 50)) pygame.display.update() SFML: window.clear(bg); sprite.settexture(loadfromfile("pics/tiger.jpg")); window.draw(sprite); window.display(); Cocos2d-x: Create nodes in scene graph Put scene onto primary stage LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 7

Screen/Surface Locking Locking reserves a part of the screen (surface in Pygame) No other process can interfere ( one change at a time, please ) Low-level technique: Manual locking/unlocking may improve performance Lock/unlock pair of commands around logically contingent group of graphics commands Locking is applied automatically in most graphics frameworks Example (Pygame): screen.lock() pygame.draw.rect(screen, red, Rect((10, 10), (230, 80))) pygame.draw.circle(screen, white, (50, 50), 40) pygame.draw.circle(screen, white, (200, 50), 40) screen.unlock() LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 8

6 Images, Vector Graphics, and Scenes 6.1 Image Buffers 6.2 Structured Graphics: Scene Graphs 6.3 Sprites Literature: B. B. Bederson, J, Grosjean, J. Meyer: Toolkit Design for Interactive Structured Graphics, IEEE TSE vol. 30 no. 8, pp. 535-546, 2004 LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 9

Scenes, Objects and Groups Scene graph Logical program objects Scene: Collection of all relevant (view-oriented) objects Abstract representation of the world (in a certain state) Often several objects are grouped into one (view-oriented) representation Operations shall be applied to whole group (movement, copy, ) Two-level view mechanism: Model Scene graph (abstract view) Concrete view LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 10

Scene Graphs Are High-Level Constructs Pygame, SFML: No built-in scene graph External library or own implementation For Pygame, see for instance: http://pygame.org/project-pygext-103-136.html For SFML, see for instance: J. Haller, H.V. Hansson, A. Moreira: SFML Game Development, Packt 2013, Chapter 3 Cocos2d-x, JavaFX: Built-in scene graph Scene graph as basis for displaying anything LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 11

Example: Scene Graph for SFML Excerpt of the implementation in Haller et al. 2013 Note: Heavy use of modern C++11 class SceneNode { }; public: typedef std::unique_ptr<scenenode> Ptr; public: SceneNode(); private: std::vector<ptr> mchildren; SceneNode* mparent; LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 12

Reminder: Scene Graph with JavaFX Group root = new Group(); Scene scene = new Scene(root, 250, 100); Rectangle r = new Rectangle(10, 10, 230, 80); r.setfill(color.red); root.getchildren().add(r); Group circles = new Group(); circles.settranslatex(10); circles.settranslatey(10); root.getchildren().add(circles); Circle circle1 = new Circle(40, 40, 40); circle1.setfill(color.white); circles.getchildren().add(circle1); Circle circle2 = new Circle(190, 40, 40); circle2.setfill(color.white); circles.getchildren().add(circle2); Rectangle primarystage.settitle("javafx Scene Graph"); primarystage.setscene(scene); Scene Circle Group Circle LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 13

6 Images, Vector Graphics, and Scenes 6.1 Image Buffers 6.2 Structured Graphics: Scene Graphs 6.3 Sprites Literature: Will McGugan: Beginning Game Development with Python and Pygame, Apress 2007 http://cocos2d-x.org/docs/programmers-guide/3/ LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 14

Sprite A sprite (Kobold, Geist) is a movable graphics object which is presented on top of the background image. Mouse pointer images are examples of sprites Hardware sprite: Outdated technique for hardware-supported fast display of moving image Software sprite: Any moving picture displayed over background Game sprites are mostly based on bitmap graphics Reasons: Ease of creation, need for bitmapped end product Pygame sprite: Special class designed to display movable game objects Cocos2d-x sprite: Special class, objects created from bitmap image Many manipulation functions, like setting anchor point, rotation, scale, skew, color, opacity, sprite outline (rectangle vs. polygon) LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 15

Example: Simple Sprite in Pygame class MagSprite(pygame.sprite.Sprite): def init (self): pygame.sprite.sprite. init (self) self.image = pygame.image.load(sprite_imgfile) self.rect = self.image.get_rect() def update(self): self.rect.center = pygame.mouse.get_pos() sprite = MagSprite() allsprites = pygame.sprite.group() allsprites.add(sprite) while True: for event in pygame.event.get():... screen.blit(background,(0,0)) allsprites.update() allsprites.draw(screen) pygame.display.update() LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 16

Example: Magnifying Glass in Pygame class MagSprite(pygame.sprite.Sprite): def init (self): pygame.sprite.sprite. init (self) self.image = pygame.image.load(sprite_imgfile) self.rect = self.image.get_rect() def update(self): (mx,my) = pygame.mouse.get_pos() self.rect.center = (mx,my) if (mx+d/2 < 256) and (my+d/2 < 256) and (mx-d/2 > 0) and (my-d/2 > 0): magview = background.subsurface( (mx-d/2,my-d/2,d,d)).copy() magview = pygame.transform.scale(magview,(256,256)) screen.blit(magview,(256,0)) LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 17

Example: Simple Sprite in Cocos2d-x (1) Creating a sprite: cocos2d::sprite* cursorsprite = Sprite::create(); this->addchild(cursorsprite); Listening to mouse movements and placing the sprite: auto listener = cocos2d::eventlistenermouse::create(); listener->onmousemove = [=](Event* event) { EventMouse* e = (EventMouse*)event; cursorsprite->setposition (Vec2(e->getCursorX(), e->getcursory())); }; Please note: Event listener needs to be registered separately (see next slide)! Lambda declaration is just one way to write the code LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 18

Example: Simple Sprite in Cocos2d-x (2) Listening to mouse clicks and executing an action: listener->onmouseup = [=](Event* event) { EventMouse* e = (EventMouse*)event; // for instance, create a new sprite cocos2d::sprite* imagesprite = Sprite::create(); this->addchild(imagesprite); }; Registering the listeners(!): imageframe->geteventdispatcher() ->addeventlistenerwithscenegraphpriority(listener, imageframe); LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 6, Folie 19