Introduction to Unity and MiddleVR David J. Zielinski DiVE Virtual - - PowerPoint PPT Presentation

introduction to unity and middlevr
SMART_READER_LITE
LIVE PREVIEW

Introduction to Unity and MiddleVR David J. Zielinski DiVE Virtual - - PowerPoint PPT Presentation

Introduction to Unity and MiddleVR David J. Zielinski DiVE Virtual Reality Lab Duke University Overview Unity Overview Editor Interface Scripting MiddleVR Unity - Why even use a game engine? Simplify development of games.


slide-1
SLIDE 1

Introduction to Unity and MiddleVR

David J. Zielinski DiVE Virtual Reality Lab Duke University

slide-2
SLIDE 2

Overview

  • Unity Overview
  • Editor Interface
  • Scripting
  • MiddleVR
slide-3
SLIDE 3

Unity - Why even use a game engine?

Simplify development of games.

  • Game Mechanics

○ physics, AI

  • Rendering Effects

○ shadows, lighting

  • I/O Abstraction

○ input devices ○ output devices

slide-4
SLIDE 4

Unity - What is it?

  • Commercial game engine (Free and Pro)
  • Cross platform
  • Popular
slide-5
SLIDE 5

Unity - Commercial Game Engine

Pro Version offers:

  • LOD
  • Occulsion culling
  • Profiler
  • Full screen post processing effects (Oculus)
  • Quad Buffered Stereo (for zSpace and

DiVE)

  • … and more!
slide-6
SLIDE 6

Unity - Cross Platform

Multiple Build Targets (Input/Output Abstraction)

  • Windows
  • Linux
  • iOS
  • Android
  • Web
  • … and more!
slide-7
SLIDE 7

Unity - Popular

  • 2 million registered users
  • Large asset store (models, scripts)
  • Utilized in other Duke classes
slide-8
SLIDE 8

Unity - Competitors

slide-9
SLIDE 9

Unity - Understanding Projects

A Unity project...

  • is actually the directory
  • will contain all the assets for your game
  • can contain multiple scenes
slide-10
SLIDE 10

Unity Editor - Windows

Scene Hierarchy Inspector Project Console

slide-11
SLIDE 11

Unity Editor - Scene Window

Orbit: alt+left mouse right mouse button Pan: middle mouse Zoom: scroll wheel alt+ right mouse

slide-12
SLIDE 12

Unity Editor - Hierarchy

  • Show objects in current scene
  • Can drag objects underneath

another object.

  • Selecting an object will change

the view in the inspector window (next slide)

  • Tip: can use ‘f’ key to center on
  • bject in scene view
slide-13
SLIDE 13

Unity Editor - Inspector

  • Shows currently selected game
  • bject.
  • Lists all components of that

game object.

  • Scripts will show up here as

well.

slide-14
SLIDE 14

Unity Editor - Project

  • Lists all assets in your project
slide-15
SLIDE 15

Unity Editor - Console

If there are errors in your script, they will show up here when you press play.

slide-16
SLIDE 16

Unity Editor - Game Window

  • When you press play

the scene window will switch to the game view window.

  • IMPORTANT: values

adjusted while in play mode will revert when play ends.

slide-17
SLIDE 17

Example - Adding a Cube

GameObject Create Other Cube

slide-18
SLIDE 18

Example - Moving a cube

  • can use handles in

scene view to move

  • can adjust values in

inspector view

  • Tip: click value and

use mouse to quickly adjust

slide-19
SLIDE 19

Example - add material to cube

Assets Create Material

slide-20
SLIDE 20

Example - add material to cube part2

Drag material from project window onto Cube in Hierarchy window.

slide-21
SLIDE 21

Example - Material added to cube

  • We can change the shader

used

  • We can change the color by

bringing up the color picker

slide-22
SLIDE 22

Example - Color picker

slide-23
SLIDE 23

Building

File Build & Run

slide-24
SLIDE 24

Building - Platform Chooser

  • This lets you

generate a standalone exe

  • Tip: make sure scene

is in build.

  • Look at “Scenes In

Build” window.

slide-25
SLIDE 25

Scripting

  • UnityScript (similiar to JavaScript)
  • Boo (similiar to python)
  • C#
slide-26
SLIDE 26

Which language to use?

Answer: C#

  • interoperability with libraries written in C#

○ MiddleVR is written in C#

  • less errors

○ JS Implicit variable declaration can cause problems

  • advanced features available if needed

○ Properties, delegates, lambdas, generics

slide-27
SLIDE 27

Comments

// for single line comments /* for multi line comments */

slide-28
SLIDE 28

Variables

  • Various Data Types

○ bool, char, byte, float, double, int, string, …

  • Public vs Private keyword
  • Pass by reference: use ref instead of &

Example: public int playerHealth=5;

slide-29
SLIDE 29

Functions (called methods in C#)

  • allows us to compartmentalize and reuse

code effeciently

public int SquareANumber(int number) { return number * number; }

slide-30
SLIDE 30

If Statements

if (m > 10) { //do something } else { //do something }

slide-31
SLIDE 31

Basic Functions

void Start() { //called once. do any initialization here } void Update() { //called every frame. move objects here }

slide-32
SLIDE 32

For Loop

for (int i = 1; i <= 5; i++) { Debug.Log(“hello”); }

slide-33
SLIDE 33

Example - Rotating Cube

void Update() { transform.Rotate(0,speed,0); }

slide-34
SLIDE 34

Example - Rotate Cube Properly

void Update() { transform.Rotate(0,speed*Time.deltaTime,0); }

slide-35
SLIDE 35

MiddleVR

  • Commercial Plugin
  • Support for 3D interaction devices
  • Stereoscopy (active, passive)
  • Multi-screens / multi-computers

○ (needed for CAVE-type systems)

slide-36
SLIDE 36

MiddleVR Licensing

Free Version:

  • export for oculus
  • simulator for desktop development

Academic (licensed) Version:

  • Build/Export to zSpace
  • Build/Export to DiVE
  • Can be node locked or floating license.
slide-37
SLIDE 37

Add MiddleVR to Unity Project

Assets Import Package Custom Package

slide-38
SLIDE 38

Find the MiddleVR Package

slide-39
SLIDE 39

Adding to Scene

Need to drag “VRManager” from project to Hierarchy window

slide-40
SLIDE 40

Pick Config File

  • Select VRManager.
  • Many options in

inspector window.

  • Pick configuration

file.

slide-41
SLIDE 41

Pick Config File - Part 2

  • I’ve been working

(in progress) on some config files.

  • Located on the

DiVE fileserver.

slide-42
SLIDE 42

Now Click Play

We can see that VRRootNode is created dynmically.

slide-43
SLIDE 43

Virtual Hand Technique

  • MiddleVR has easy ways to

enable Virtual Hand technique.

  • Add VRActor script to object

we want to pickup

slide-44
SLIDE 44

Virtual Hand Demo

  • touch an object

and click, the

  • bject is moved

underneath the handnode

slide-45
SLIDE 45

Learn More

Unity

http://docs.unity3d.com/Documentation/Manual/index.html

Walker Boys Studio - Video tutorial

http://www.walkerboystudio.com/html/unity_training___free__.html

Lynda

http://www.lynda.com/Unity-3D-tutorials/Unity-3D-35-Essential-Training/96677-2.html

Middle VR

http://www.imin-vr.com/doc/current/

slide-46
SLIDE 46

Thank You! Questions?