1 / 27

EEC-492/592 Kinect Application Development

EEC-492/592 Kinect Application Development. Lecture 13 Wenbing Zhao wenbing@ieee.org. Outline. Introduction to Unity3D Based on Book: Beginning 3D Game Development with Unity 4. Creating a New Unity Project. Open Unity

mdorothy
Download Presentation

EEC-492/592 Kinect Application Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EEC-492/592Kinect Application Development Lecture 13 Wenbing Zhao wenbing@ieee.org

  2. Outline Introduction to Unity3D Based on Book: Beginning 3D Game Development with Unity 4

  3. Creating a New Unity Project Open Unity Select the Create New Project tab, change location folder to KinectUnity Select packages for import, then click Create

  4. Unity 3DLayout

  5. Scene View Where you plan and execute your ideas To show the grid, toggle off the game overlay button

  6. Hierarchy View Shows what’s in the currently active scene. GameObjects that are dynamically added and removed from the scene during runtime will appear here when they are active in the scene By default, the maincamera is added

  7. Project View Contains all the assets available to the current project, as well as all scenes or levels available for the finished game or application

  8. Inspector Inspector is used to access various properties and components for objects you’ve selected in either the Hierarchy or Project views

  9. Toolbar Transform tools: provide functionality for navigating the scene and transforming objects Left most button: pan, orbit, zoom tools for navigating and adjusting scene view Pan tool: default, left click and drag to move the view around Orbit tool: hold the Alt key while clicking left click and dragging Zoom tool: Alt + right mouse click Other three buttons: move, rotate, and scale

  10. Toolbar Privot point and coordinate system tools: Objects can be transformed in different coordinate systems and from different pivot points Play mode controls Layers control: Layers are used in Unity for controlling which objects are rendered by which cameras or lit by which lights Layout control

  11. Elements to Build a Scene Assets: non-mesh special effects, physics materials, and scripts GameObject: base container for objects, scripts, and other components in Unity Contains its transforms (location and orientation) and a few other properties Component: items associated with objects, such as meshes, rendering types, sound, scripts, and colliders, as well as those that create or extend functionality with predefined behaviors

  12. Creating Simple Game Objects: Cube

  13. Creating Simple Game Objects To zoom, use middle mouse roller or Alt-right mouse click To set the camera to match the scene view Select the main camera in the hierarchy view From the GameObject menu, choose Align with View

  14. Creating Simple Game Objects Toggle the built-in lighting off and the scene lighting on, by clicking the light button The cube is now lit only with the scene ambient light, as in the Game window Try out zoom, orbit and pan

  15. Selecting and Focusing To focus the viewport back to the cube, or to “find” the cube, do the following Make sure the cube is selected in the Hierarchy view. Put the cursor over the Scene window. Press the F key on your keyboard You can view scene objects in several other modes Wireframe, textured wire, textured (default)

  16. Transforming Objects In 3D space, the Cartesian coordinate system is used X, Y, Z are color-coded with red, green, blue Objects can be transformed (moved, rotated, scaled) around the scene Select the cube, select the move button, click and drag on any of the three axis; Rotate is similar Can also do these in inspector

  17. Lights Because there are no lights in the viewport yet, it went dark, just as in the Game window, when you toggle off the lighting button Adding light Focus the Scene view on the cube again and zoom out a bit From the GameObject menu, choose Create Other ➤ Create a Directional Light. Directional lights emit parallel rays, no matter where they are in the scene. Move the light up and out of the way of the cube. Rotate it in the Scene window until the cube is lit nicely in the Game window Use alt-left mouse click, drag/orbit the viewport so you are facing the unlit side of the cube

  18. Lights Changing light color: in inspector for light Click and drag in the Color’s image/color swatch and watch the light’s color on the cube change Choose something subtle. Close the dialog

  19. Material In the Inspector, select the Cube 2. In the Mesh Renderer section, click to open the Materials array list

  20. Material From the Assets menu, choose Create ➤ Folder, Rename the folder My Materials

  21. Material Right-click the new My Materials folder and, from the same Create submenu, choose Material

  22. Material A New Material entry appears in the Inspector, Name the new material TestBark Drag and drop the material from the folder onto the cube in the Scene window. In the Texture thumbnail window (not the Preview window), pick the Select button and, with the preview slider all the way to the left in the Asset Selector, choose Palm Bark Diffuse.

  23. Material In the Texture thumbnail window (not the Preview window), pick the Select button and, with the preview slider all the way to the left in the Asset Selector, choose Palm Bark Diffuse.

  24. Scripting A script is a program that controls the game objects in the scene dynamically, Unity support a number of programming languages We will be using C# To create a new script Create a New Folder in the Project view using the right-click menu or Assets menu in the menu bar Name the new folder My Scripts With the new folder selected, right-click it to bring up the contents of the right-click menu. Select C# Script from the Create submenu

  25. Scripting To edit the script, click the open button. The MonoDevelop editor will open using UnityEngine; using System.Collections; public class NewBehaviourScript : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } }

  26. Scripting The Start function is only called once as the scene is started and is a good place to initialize values that don’t exist until the game has been loaded The Update function is checked at least every frame during runtime to see if anything needs to be executed It can make a transform such as a rotation continuously loop, check to see if a particular condition is met, and many other things To attach the script to the game object, drag the script file to the game object Add the following line in the Update function, save the script, click play If you want to animate the object on a per-second basis, use Time.deltaTime transform.Rotate(0,5,0); (0,5,0) refers to the X, Y, and Z rotations parameters that are needed by the Rotate function transform.Rotate(0,5 * Time.deltaTime,0);

  27. Scripting We can also move the game object using the Translate function You can also add private or public variables into script Public variables are listed in the inspector and their values can be set their Challenge Task: Animate the cube such that it drops to the ground and then bounce back like a ball transform.Translate(2 * Time.deltaTime,0,0);

More Related