SlideShare a Scribd company logo
1 of 44
Download to read offline
The Glass Class:
Lecture 5: Prototyping with Processing
Feb 17th – 21st 2014
Mark Billinghurst, Gun Lee
HIT Lab NZ
University of Canterbury
THE GLASS CLASS
Overview
  Intro to Processing
  Processing and Glass
  Setting up, launching apps
  Demos
  Touch Input
  Ketai library and other libraries
  Demos
  Resources
THE GLASS CLASS
Processing
  Programming tool for Artists/Designers
  http://processing.org
  Easy to code, Free, Open source, Java based
  2D, 3D, audio/video support
  Processing For Android
  http://wiki.processing.org/w/Android
  Generates Glass Ready .apk file
THE GLASS CLASS
Processing - Motivation
  Language of Interaction
  Physical Manipulation
  Input using code
  Mouse Manipulation
  Presence, location, image
  Haptic interfaces and multi-touch
  Gesture
  Voice and Speech
THE GLASS CLASS
THE GLASS CLASS
THE GLASS CLASS
Development Environment
THE GLASS CLASS
THE GLASS CLASS
Processing Basics
THE GLASS CLASS
Basic Parts of a Sketch
/* Notes comment */!
//set up global variables!
float moveX = 50;!
!
//Initialize the Sketch!
void setup (){!
}!
!
//draw every frame!
void draw(){!
}!
THE GLASS CLASS
Sample Drawing
int m = 0;!
float s = 0;!
!
void setup(){!
size(512,512);!
background(255);!
}!
!
void draw (){!
fill(255,0,0);!
ellipse(mouseX,mouseY,s,s);!
}!
!
void mouseMoved(){!
s = 40 + 20*sin(++m/10.0f);!
}!
THE GLASS CLASS
THE GLASS CLASS
Drawing
  draw() gets called as fast as possible, unless a
frameRate is specified
  stroke() sets color of drawing outline
  fill() sets inside color of drawing
  mousePressed is true if mouse is down
  mouseX, mouseY - mouse position
!void draw() { !
!stroke(255); !
!if(mousePressed) {!
! !line(mouseX, mouseY, pmouseX, pmouseY);!
! !}!
!}!
THE GLASS CLASS
Processing and Drawing
  Basic Shapes
rect(x, y, width, height)!
ellipse(x, y, width, height)!
line(x1, y1, x2, y2), line(x1, y1, x2, y2, z1, z2)!
  Filling shapes - fill( )
fill(int gray), fill(color color), fill(color color, int alpha)!
  Curve
  Draws curved lines
  Vertex
  Creates shapes (beginShape, endShape)
THE GLASS CLASS
Importing Libraries
  Can add functionality by Importing Libraries
  java archives - .jar files
  Include import code
import processing.opengl.*;!
  Popular Libraries
  Minim - audio library
  OCD - 3D camera views
  Physics - physics engine
  bluetoothDesktop - bluetooth networking
THE GLASS CLASShttp://toxiclibs.org/
THE GLASS CLASS
Classes and Objects
THE GLASS CLASS
Classes and Objects
  see http://processing.org/learning/objects/
  Object
  grouping of multiple related properties and functions
  Objects are defined by Object classes
  Eg Car object
  Data
-  colour, location, speed
  Functions
-  drive(), draw()
THE GLASS CLASS
Classes
  four elements: name, data, constructor, and methods.
  Name
class myName { }!
  Data
  collection of class variables
  Constructor
  run when object created
  Methods
  class functions
THE GLASS CLASS
Car Class
THE GLASS CLASS
THE GLASS CLASS
Class Usage
// Step 1. Declare an object.!
Car myCar;!
!
void setup() { !
// Step 2. Initialize object.!
myCar = new Car(); !
} !
!
void draw() { !
background(255); !
// Step 3. Call methods on the object. !
myCar.drive(); !
myCar.display(); !
}!
THE GLASS CLASS
THE GLASS CLASS
Constructing Objects
  One Car
Car myCar= new Car(); !
  Two Cars
!// Creating two car objects !
!Car myCar1 = new Car(); !
!Car myCar2 = new Car(); !
  One car with initial values
Car myCar = new
Car(color(255,0,0),0,100,2); !
THE GLASS CLASS
Graphics
THE GLASS CLASS
Programming Graphics
  Transformations
  Creating motion and animation
  Bitmaps and pixels
  Textures
THE GLASS CLASS
Drawing Canvas
  OpenGL-y
  Mutate the canvas rendering (move the
canvas):
  translate(), scale(), rotate()
  Save and Restore the state of the canvas:
  pushMatrix(), popMatrix()
  http://ejohn.org/apps/processing.js/examples/
basic/arm.html
THE GLASS CLASS
3D Graphics
  Two options
  P3D Library
  OpenGL Library
  P3D
  Simple, integrated directly into processing
  Lightweight 3D
  OpenGL
  Full graphics support
  Complex
THE GLASS CLASS
P3D Scene
size(640, 360, P3D); !
background(0);!
lights();!
!
noStroke();!
pushMatrix();!
!translate(130, height/2, 0);!
!rotateY(1.25);!
!rotateX(-0.4);!
!box(100);!
popMatrix();!
!
noFill();!
stroke(255);!
pushMatrix();!
!translate(500, height*0.35, -200);!
!sphere(280);!
popMatrix();!
THE GLASS CLASS
Shapes
  beginShape(SHAPE);
  Define Vertices
  SHAPES: QUADS, QUAD_STRIP,
TRIANGLE_FAN
  endShape();
  Eg: Quads
!beginShape(QUADS);!
!fill(0, 1, 1); vertex(-1, 1, 1);!
!fill(1, 1, 1); vertex( 1, 1, 1);!
!fill(1, 0, 1); vertex( 1, -1, 1);!
!fill(0, 0, 1); vertex(-1, -1, 1);!
!endShape();!
THE GLASS CLASS
Vertices Demo
  RGB Cube
  Vetices and vertex fills
  VertexDemo
  Different types of quad strips
  User defined drawing function
THE GLASS CLASS
Transformations
  Rotation
! !rotateX(a), rotateY(a * 2.0), rotateZ(a)!
  Translation
! !translate(X,Y); translate(X,Y,Z);!
  Scale
  Push and Pop functions
  Push - Saving current coordinate system
  Pop – Restores previous coordinate system
  Eg: PushPopCubes
Processing and Glass
THE GLASS CLASS
Setting Up
  Have Android SDK installed
  Install Android Mode
  Need to have And
THE GLASS CLASS
Hello World
//called initially at the start of the Processing sketch!
void setup() {!
size(640, 360);!
background(0);!
} !
!
//called every frame to draw output!
void draw() {!
background(0);!
//draw a white text string showing Hello World!
fill(255);!
text("Hello World", 50, 50);!
}!
THE GLASS CLASS
Demo
THE GLASS CLASS
Hello World Image
PImage img; // Create an image variable!
!
void setup() {!
size(640, 360);!
//load the ok glass home screen image!
img = loadImage("okGlass.jpg"); // Load the image into
the program !
}!
!
void draw() {!
// Displays the image at its actual size at point (0,0)!
image(img, 0, 0);!
}!
THE GLASS CLASS
Demo
THE GLASS CLASS
Touch Pad Input
  Tap recognized as DPAD input
!void keyPressed() {!
!if (key == CODED){!
! !if (keyCode == DPAD) {!
!// Do something ..!
  Java code to capture rich motion events
  import android.view.MotionEvent;!
THE GLASS CLASS
Motion Event
//Glass Touch Events - reads from touch pad!
public boolean dispatchGenericMotionEvent(MotionEvent event) {!
float x = event.getX(); // get x/y coords !
float y = event.getY();!
int action = event.getActionMasked(); // get code for action!
!
switch (action) { // let us know which action code shows up!
!case MotionEvent.ACTION_DOWN:!
! !touchEvent = "DOWN";!
! !fingerTouch = 1;!
!break; !
!case MotionEvent.ACTION_MOVE:!
! !touchEvent = "MOVE";!
! !xpos = myScreenWidth-x*touchPadScaleX;!
! !ypos = y*touchPadScaleY;!
!break;!
THE GLASS CLASS
Demo
THE GLASS CLASS
Sensors
  Ketai Library for Processing
  https://code.google.com/p/ketai/
  Support all phone sensors
  GPS, Compass, Light, Camera, etc
  Include Ketai Library
  import ketai.sensors.*;!
  KetaiSensor sensor;!
THE GLASS CLASS
Using Sensors
  Setup in Setup( ) function
  sensor = new KetaiSensor(this);!
  sensor.start();!
  sensor.list();
  Event based sensor reading
void onAccelerometerEvent(…)!
{!
accelerometer.set(x, y, z);!
}!
THE GLASS CLASS
Sensor Demo

More Related Content

Similar to The Glass Class Lecture 5: Prototyping with Processing

用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化Shengyou Fan
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1Bitla Software
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Patrick Chanezon
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureSimon Willison
 
Creative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling FrameworkCreative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling FrameworkHuijie Wu
 
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...Plain Concepts
 
Creating Flash Content for Multiple Screens
Creating Flash Content for Multiple ScreensCreating Flash Content for Multiple Screens
Creating Flash Content for Multiple Screenspaultrani
 
Processing presentation
Processing presentationProcessing presentation
Processing presentationrngtng
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?Ankara JUG
 
Declarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDKDeclarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDKBéla Varga
 
An introduction to the create js suite
An introduction to the create js suiteAn introduction to the create js suite
An introduction to the create js suiteScott Ackerman
 
Flash for Mobile Devices
Flash for Mobile DevicesFlash for Mobile Devices
Flash for Mobile Devicespaultrani
 
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.jsVisual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.jsFlorian Georg
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webpjcozzi
 

Similar to The Glass Class Lecture 5: Prototyping with Processing (20)

用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
 
Creative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling FrameworkCreative Coders March 2013 - Introducing Starling Framework
Creative Coders March 2013 - Introducing Starling Framework
 
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
 
Creating Flash Content for Multiple Screens
Creating Flash Content for Multiple ScreensCreating Flash Content for Multiple Screens
Creating Flash Content for Multiple Screens
 
Processing presentation
Processing presentationProcessing presentation
Processing presentation
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
 
Declarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDKDeclarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDK
 
An introduction to the create js suite
An introduction to the create js suiteAn introduction to the create js suite
An introduction to the create js suite
 
Flash for Mobile Devices
Flash for Mobile DevicesFlash for Mobile Devices
Flash for Mobile Devices
 
ICS3211 lecture 08
ICS3211 lecture 08ICS3211 lecture 08
ICS3211 lecture 08
 
P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218
 
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.jsVisual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 

More from Mark Billinghurst

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Future Research Directions for Augmented Reality
Future Research Directions for Augmented RealityFuture Research Directions for Augmented Reality
Future Research Directions for Augmented RealityMark Billinghurst
 
Evaluation Methods for Social XR Experiences
Evaluation Methods for Social XR ExperiencesEvaluation Methods for Social XR Experiences
Evaluation Methods for Social XR ExperiencesMark Billinghurst
 
Empathic Computing: Delivering the Potential of the Metaverse
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the MetaverseMark Billinghurst
 
Empathic Computing: Capturing the Potential of the Metaverse
Empathic Computing: Capturing the Potential of the MetaverseEmpathic Computing: Capturing the Potential of the Metaverse
Empathic Computing: Capturing the Potential of the MetaverseMark Billinghurst
 
Talk to Me: Using Virtual Avatars to Improve Remote Collaboration
Talk to Me: Using Virtual Avatars to Improve Remote CollaborationTalk to Me: Using Virtual Avatars to Improve Remote Collaboration
Talk to Me: Using Virtual Avatars to Improve Remote CollaborationMark Billinghurst
 
Empathic Computing: Designing for the Broader Metaverse
Empathic Computing: Designing for the Broader MetaverseEmpathic Computing: Designing for the Broader Metaverse
Empathic Computing: Designing for the Broader MetaverseMark Billinghurst
 
2022 COMP 4010 Lecture 7: Introduction to VR
2022 COMP 4010 Lecture 7: Introduction to VR2022 COMP 4010 Lecture 7: Introduction to VR
2022 COMP 4010 Lecture 7: Introduction to VRMark Billinghurst
 
2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR Systems2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR SystemsMark Billinghurst
 
Novel Interfaces for AR Systems
Novel Interfaces for AR SystemsNovel Interfaces for AR Systems
Novel Interfaces for AR SystemsMark Billinghurst
 
2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR Prototyping2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR PrototypingMark Billinghurst
 
2022 COMP4010 Lecture4: AR Interaction
2022 COMP4010 Lecture4: AR Interaction2022 COMP4010 Lecture4: AR Interaction
2022 COMP4010 Lecture4: AR InteractionMark Billinghurst
 
2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR Technology2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR TechnologyMark Billinghurst
 
2022 COMP4010 Lecture2: Perception
2022 COMP4010 Lecture2: Perception2022 COMP4010 Lecture2: Perception
2022 COMP4010 Lecture2: PerceptionMark Billinghurst
 
2022 COMP4010 Lecture1: Introduction to XR
2022 COMP4010 Lecture1: Introduction to XR2022 COMP4010 Lecture1: Introduction to XR
2022 COMP4010 Lecture1: Introduction to XRMark Billinghurst
 
Empathic Computing and Collaborative Immersive Analytics
Empathic Computing and Collaborative Immersive AnalyticsEmpathic Computing and Collaborative Immersive Analytics
Empathic Computing and Collaborative Immersive AnalyticsMark Billinghurst
 
Empathic Computing: Developing for the Whole Metaverse
Empathic Computing: Developing for the Whole MetaverseEmpathic Computing: Developing for the Whole Metaverse
Empathic Computing: Developing for the Whole MetaverseMark Billinghurst
 

More from Mark Billinghurst (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Future Research Directions for Augmented Reality
Future Research Directions for Augmented RealityFuture Research Directions for Augmented Reality
Future Research Directions for Augmented Reality
 
Evaluation Methods for Social XR Experiences
Evaluation Methods for Social XR ExperiencesEvaluation Methods for Social XR Experiences
Evaluation Methods for Social XR Experiences
 
Empathic Computing: Delivering the Potential of the Metaverse
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
 
Empathic Computing: Capturing the Potential of the Metaverse
Empathic Computing: Capturing the Potential of the MetaverseEmpathic Computing: Capturing the Potential of the Metaverse
Empathic Computing: Capturing the Potential of the Metaverse
 
Talk to Me: Using Virtual Avatars to Improve Remote Collaboration
Talk to Me: Using Virtual Avatars to Improve Remote CollaborationTalk to Me: Using Virtual Avatars to Improve Remote Collaboration
Talk to Me: Using Virtual Avatars to Improve Remote Collaboration
 
Empathic Computing: Designing for the Broader Metaverse
Empathic Computing: Designing for the Broader MetaverseEmpathic Computing: Designing for the Broader Metaverse
Empathic Computing: Designing for the Broader Metaverse
 
2022 COMP 4010 Lecture 7: Introduction to VR
2022 COMP 4010 Lecture 7: Introduction to VR2022 COMP 4010 Lecture 7: Introduction to VR
2022 COMP 4010 Lecture 7: Introduction to VR
 
2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR Systems2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR Systems
 
ISS2022 Keynote
ISS2022 KeynoteISS2022 Keynote
ISS2022 Keynote
 
Novel Interfaces for AR Systems
Novel Interfaces for AR SystemsNovel Interfaces for AR Systems
Novel Interfaces for AR Systems
 
2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR Prototyping2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR Prototyping
 
2022 COMP4010 Lecture4: AR Interaction
2022 COMP4010 Lecture4: AR Interaction2022 COMP4010 Lecture4: AR Interaction
2022 COMP4010 Lecture4: AR Interaction
 
2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR Technology2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR Technology
 
2022 COMP4010 Lecture2: Perception
2022 COMP4010 Lecture2: Perception2022 COMP4010 Lecture2: Perception
2022 COMP4010 Lecture2: Perception
 
2022 COMP4010 Lecture1: Introduction to XR
2022 COMP4010 Lecture1: Introduction to XR2022 COMP4010 Lecture1: Introduction to XR
2022 COMP4010 Lecture1: Introduction to XR
 
Empathic Computing and Collaborative Immersive Analytics
Empathic Computing and Collaborative Immersive AnalyticsEmpathic Computing and Collaborative Immersive Analytics
Empathic Computing and Collaborative Immersive Analytics
 
Metaverse Learning
Metaverse LearningMetaverse Learning
Metaverse Learning
 
Empathic Computing: Developing for the Whole Metaverse
Empathic Computing: Developing for the Whole MetaverseEmpathic Computing: Developing for the Whole Metaverse
Empathic Computing: Developing for the Whole Metaverse
 

Recently uploaded

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

The Glass Class Lecture 5: Prototyping with Processing

  • 1. The Glass Class: Lecture 5: Prototyping with Processing Feb 17th – 21st 2014 Mark Billinghurst, Gun Lee HIT Lab NZ University of Canterbury
  • 2. THE GLASS CLASS Overview   Intro to Processing   Processing and Glass   Setting up, launching apps   Demos   Touch Input   Ketai library and other libraries   Demos   Resources
  • 3. THE GLASS CLASS Processing   Programming tool for Artists/Designers   http://processing.org   Easy to code, Free, Open source, Java based   2D, 3D, audio/video support   Processing For Android   http://wiki.processing.org/w/Android   Generates Glass Ready .apk file
  • 4. THE GLASS CLASS Processing - Motivation   Language of Interaction   Physical Manipulation   Input using code   Mouse Manipulation   Presence, location, image   Haptic interfaces and multi-touch   Gesture   Voice and Speech
  • 10. THE GLASS CLASS Basic Parts of a Sketch /* Notes comment */! //set up global variables! float moveX = 50;! ! //Initialize the Sketch! void setup (){! }! ! //draw every frame! void draw(){! }!
  • 11. THE GLASS CLASS Sample Drawing int m = 0;! float s = 0;! ! void setup(){! size(512,512);! background(255);! }! ! void draw (){! fill(255,0,0);! ellipse(mouseX,mouseY,s,s);! }! ! void mouseMoved(){! s = 40 + 20*sin(++m/10.0f);! }!
  • 13. THE GLASS CLASS Drawing   draw() gets called as fast as possible, unless a frameRate is specified   stroke() sets color of drawing outline   fill() sets inside color of drawing   mousePressed is true if mouse is down   mouseX, mouseY - mouse position !void draw() { ! !stroke(255); ! !if(mousePressed) {! ! !line(mouseX, mouseY, pmouseX, pmouseY);! ! !}! !}!
  • 14. THE GLASS CLASS Processing and Drawing   Basic Shapes rect(x, y, width, height)! ellipse(x, y, width, height)! line(x1, y1, x2, y2), line(x1, y1, x2, y2, z1, z2)!   Filling shapes - fill( ) fill(int gray), fill(color color), fill(color color, int alpha)!   Curve   Draws curved lines   Vertex   Creates shapes (beginShape, endShape)
  • 15. THE GLASS CLASS Importing Libraries   Can add functionality by Importing Libraries   java archives - .jar files   Include import code import processing.opengl.*;!   Popular Libraries   Minim - audio library   OCD - 3D camera views   Physics - physics engine   bluetoothDesktop - bluetooth networking
  • 17. THE GLASS CLASS Classes and Objects
  • 18. THE GLASS CLASS Classes and Objects   see http://processing.org/learning/objects/   Object   grouping of multiple related properties and functions   Objects are defined by Object classes   Eg Car object   Data -  colour, location, speed   Functions -  drive(), draw()
  • 19. THE GLASS CLASS Classes   four elements: name, data, constructor, and methods.   Name class myName { }!   Data   collection of class variables   Constructor   run when object created   Methods   class functions
  • 22. THE GLASS CLASS Class Usage // Step 1. Declare an object.! Car myCar;! ! void setup() { ! // Step 2. Initialize object.! myCar = new Car(); ! } ! ! void draw() { ! background(255); ! // Step 3. Call methods on the object. ! myCar.drive(); ! myCar.display(); ! }!
  • 24. THE GLASS CLASS Constructing Objects   One Car Car myCar= new Car(); !   Two Cars !// Creating two car objects ! !Car myCar1 = new Car(); ! !Car myCar2 = new Car(); !   One car with initial values Car myCar = new Car(color(255,0,0),0,100,2); !
  • 26. THE GLASS CLASS Programming Graphics   Transformations   Creating motion and animation   Bitmaps and pixels   Textures
  • 27. THE GLASS CLASS Drawing Canvas   OpenGL-y   Mutate the canvas rendering (move the canvas):   translate(), scale(), rotate()   Save and Restore the state of the canvas:   pushMatrix(), popMatrix()   http://ejohn.org/apps/processing.js/examples/ basic/arm.html
  • 28. THE GLASS CLASS 3D Graphics   Two options   P3D Library   OpenGL Library   P3D   Simple, integrated directly into processing   Lightweight 3D   OpenGL   Full graphics support   Complex
  • 29. THE GLASS CLASS P3D Scene size(640, 360, P3D); ! background(0);! lights();! ! noStroke();! pushMatrix();! !translate(130, height/2, 0);! !rotateY(1.25);! !rotateX(-0.4);! !box(100);! popMatrix();! ! noFill();! stroke(255);! pushMatrix();! !translate(500, height*0.35, -200);! !sphere(280);! popMatrix();!
  • 30. THE GLASS CLASS Shapes   beginShape(SHAPE);   Define Vertices   SHAPES: QUADS, QUAD_STRIP, TRIANGLE_FAN   endShape();   Eg: Quads !beginShape(QUADS);! !fill(0, 1, 1); vertex(-1, 1, 1);! !fill(1, 1, 1); vertex( 1, 1, 1);! !fill(1, 0, 1); vertex( 1, -1, 1);! !fill(0, 0, 1); vertex(-1, -1, 1);! !endShape();!
  • 31. THE GLASS CLASS Vertices Demo   RGB Cube   Vetices and vertex fills   VertexDemo   Different types of quad strips   User defined drawing function
  • 32. THE GLASS CLASS Transformations   Rotation ! !rotateX(a), rotateY(a * 2.0), rotateZ(a)!   Translation ! !translate(X,Y); translate(X,Y,Z);!   Scale   Push and Pop functions   Push - Saving current coordinate system   Pop – Restores previous coordinate system   Eg: PushPopCubes
  • 34. THE GLASS CLASS Setting Up   Have Android SDK installed   Install Android Mode   Need to have And
  • 35. THE GLASS CLASS Hello World //called initially at the start of the Processing sketch! void setup() {! size(640, 360);! background(0);! } ! ! //called every frame to draw output! void draw() {! background(0);! //draw a white text string showing Hello World! fill(255);! text("Hello World", 50, 50);! }!
  • 37. THE GLASS CLASS Hello World Image PImage img; // Create an image variable! ! void setup() {! size(640, 360);! //load the ok glass home screen image! img = loadImage("okGlass.jpg"); // Load the image into the program ! }! ! void draw() {! // Displays the image at its actual size at point (0,0)! image(img, 0, 0);! }!
  • 39. THE GLASS CLASS Touch Pad Input   Tap recognized as DPAD input !void keyPressed() {! !if (key == CODED){! ! !if (keyCode == DPAD) {! !// Do something ..!   Java code to capture rich motion events   import android.view.MotionEvent;!
  • 40. THE GLASS CLASS Motion Event //Glass Touch Events - reads from touch pad! public boolean dispatchGenericMotionEvent(MotionEvent event) {! float x = event.getX(); // get x/y coords ! float y = event.getY();! int action = event.getActionMasked(); // get code for action! ! switch (action) { // let us know which action code shows up! !case MotionEvent.ACTION_DOWN:! ! !touchEvent = "DOWN";! ! !fingerTouch = 1;! !break; ! !case MotionEvent.ACTION_MOVE:! ! !touchEvent = "MOVE";! ! !xpos = myScreenWidth-x*touchPadScaleX;! ! !ypos = y*touchPadScaleY;! !break;!
  • 42. THE GLASS CLASS Sensors   Ketai Library for Processing   https://code.google.com/p/ketai/   Support all phone sensors   GPS, Compass, Light, Camera, etc   Include Ketai Library   import ketai.sensors.*;!   KetaiSensor sensor;!
  • 43. THE GLASS CLASS Using Sensors   Setup in Setup( ) function   sensor = new KetaiSensor(this);!   sensor.start();!   sensor.list();   Event based sensor reading void onAccelerometerEvent(…)! {! accelerometer.set(x, y, z);! }!