Welcome to the Dive Crew of The Dive Academy Welcome to the Dive Crew of The Dive Academy.
Duke University DiVE Virtual Reality Lab Introduction to...
Transcript of Duke University DiVE Virtual Reality Lab Introduction to...
![Page 1: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/1.jpg)
Introduction to Unityand MiddleVR
David J. Zielinski
DiVE Virtual Reality LabDuke University
![Page 2: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/2.jpg)
Overview
● Unity Overview● Editor Interface ● Scripting ● MiddleVR
![Page 3: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/3.jpg)
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
![Page 4: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/4.jpg)
Unity - What is it?
● Commercial game engine (Free and Pro)● Cross platform● Popular
![Page 5: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/5.jpg)
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!
![Page 6: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/6.jpg)
Unity - Cross Platform
Multiple Build Targets (Input/Output Abstraction)● Windows● Linux● iOS● Android● Web● … and more!
![Page 7: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/7.jpg)
Unity - Popular
● 2 million registered users● Large asset store (models, scripts)● Utilized in other Duke classes
![Page 8: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/8.jpg)
Unity - Competitors
![Page 9: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/9.jpg)
Unity - Understanding Projects
A Unity project...● is actually the directory● will contain all the assets for your game● can contain multiple scenes
![Page 10: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/10.jpg)
Unity Editor - Windows
SceneHierarchyInspectorProjectConsole
![Page 11: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/11.jpg)
Unity Editor - Scene WindowOrbit:
alt+left mouseright mouse button
Pan:middle mouse
Zoom:scroll wheelalt+ right mouse
![Page 12: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/12.jpg)
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 object in scene view
![Page 13: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/13.jpg)
Unity Editor - Inspector
● Shows currently selected game object.
● Lists all components of that game object.
● Scripts will show up here as well.
![Page 14: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/14.jpg)
Unity Editor - Project
● Lists all assets in your project
![Page 15: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/15.jpg)
Unity Editor - Console
If there are errors in your script, they will show up here when you press play.
![Page 16: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/16.jpg)
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.
![Page 17: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/17.jpg)
Example - Adding a Cube
GameObjectCreate Other
Cube
![Page 18: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/18.jpg)
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
![Page 19: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/19.jpg)
Example - add material to cube
Assets Create
Material
![Page 20: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/20.jpg)
Example - add material to cube part2
Drag material from project window onto Cube in Hierarchy window.
![Page 21: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/21.jpg)
Example - Material added to cube
● We can change the shader used
● We can change the color by bringing up the color picker
![Page 22: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/22.jpg)
Example - Color picker
![Page 23: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/23.jpg)
Building
FileBuild & Run
![Page 24: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/24.jpg)
Building - Platform Chooser
● This lets you generate a standalone exe
● Tip: make sure scene is in build.
● Look at “Scenes In Build” window.
![Page 25: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/25.jpg)
Scripting
● UnityScript (similiar to JavaScript)● Boo (similiar to python)● C#
![Page 26: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/26.jpg)
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
![Page 27: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/27.jpg)
Comments
// for single line comments
/* for multi line comments */
![Page 28: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/28.jpg)
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;
![Page 29: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/29.jpg)
Functions (called methods in C#)
● allows us to compartmentalize and reuse code effeciently
public int SquareANumber(int number){ return number * number;}
![Page 30: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/30.jpg)
If Statementsif (m > 10){ //do something}else{ //do something}
![Page 31: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/31.jpg)
Basic Functionsvoid Start(){ //called once. do any initialization here}void Update(){ //called every frame. move objects here}
![Page 32: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/32.jpg)
For Loop
for (int i = 1; i <= 5; i++){ Debug.Log(“hello”);}
![Page 33: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/33.jpg)
Example - Rotating Cube
void Update(){ transform.Rotate(0,speed,0);}
![Page 34: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/34.jpg)
Example - Rotate Cube Properly
void Update(){ transform.Rotate(0,speed*Time.deltaTime,0);}
![Page 35: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/35.jpg)
MiddleVR● Commercial Plugin● Support for 3D interaction devices ● Stereoscopy (active, passive)● Multi-screens / multi-computers
○ (needed for CAVE-type systems)
![Page 36: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/36.jpg)
MiddleVR LicensingFree Version:● export for oculus● simulator for desktop developmentAcademic (licensed) Version:● Build/Export to zSpace● Build/Export to DiVE ● Can be node locked or floating license.
![Page 37: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/37.jpg)
Add MiddleVR to Unity ProjectAssets
Import PackageCustom Package
![Page 38: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/38.jpg)
Find the MiddleVR Package
![Page 39: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/39.jpg)
Adding to Scene
Need to drag “VRManager” from project to Hierarchy window
![Page 40: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/40.jpg)
Pick Config File● Select VRManager.● Many options in
inspector window.● Pick configuration
file.
![Page 41: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/41.jpg)
Pick Config File - Part 2
● I’ve been working (in progress) on some config files.
● Located on the DiVE fileserver.
![Page 42: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/42.jpg)
Now Click PlayWe can see that VRRootNode is created dynmically.
![Page 43: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/43.jpg)
Virtual Hand Technique
● MiddleVR has easy ways to enable Virtual Hand technique.
● Add VRActor script to object we want to pickup
![Page 44: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/44.jpg)
Virtual Hand Demo● touch an object
and click, the object is moved underneath the handnode
![Page 45: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/45.jpg)
Learn More
Unityhttp://docs.unity3d.com/Documentation/Manual/index.html
Walker Boys Studio - Video tutorialhttp://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 VRhttp://www.imin-vr.com/doc/current/
![Page 46: Duke University DiVE Virtual Reality Lab Introduction to Unitypeople.duke.edu/~djzielin/slides/Unity_MiddleVR_talk.pdf · Introduction to Unity and MiddleVR David J. Zielinski DiVE](https://reader033.fdocuments.in/reader033/viewer/2022041418/5e1cd48d7839692ad05fdfac/html5/thumbnails/46.jpg)
Thank You!
Questions?