Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started With MRTK (for Beginner)

Getting Started With MRTK (for Beginner)

TakashiYoshinaga

June 20, 2020
Tweet

More Decks by TakashiYoshinaga

Other Decks in Technology

Transcript

  1. Downloading MRTK (2/3) Microsoft Mixed Reality Toolkit v2.4.0 is used

    for this tutorial 少し下にスクロール
  2. Installation of MRTK (1/3) Double click the unitypackage. Click Import

    button of Import Unity Package dialog. Microsoft.MixedReality. Toolkit.Unity.Foundation .2.4.0.unitypackage Import
  3. Run View from camera will be shown. Click to play

    Click it again to stop preview
  4. Inputting Values to Transform Object p Properties of each object

    can be added/edited in Inspector p Position/Rotation/Scale are editable in Transform. Inspector
  5. Inputting Values to Transform Object Set as following Positionを 0

    0 1 Rotation 0 0 0 Scale 0.3 0.3 0.3 p Properties of each object can be added/edited in Inspector p Position/Rotation/Scale are editable in Transform.
  6. Controlling Viewpoint of Scene [←] [→]: Move to Left/RIght [↑][↓]:

    Zoom In/Out [Alt]+Drag: Rotation +Drag: Move to ←→↑↓
  7. Next Step Not only Transform but also appearance and behavior

    and properties can be edited in Inspector
  8. Changing Color of Cube (4/4) Detail of Material is shown

    at the bottom of Inspector. But Default-Material is not editable.
  9. Play (2/4) [A][D] :Move to Left and Right [W][S] :Zoom

    In/Out [Q][E] :Move to Up and Down RightClick + Drag :Rotation
  10. Play (3/4) [Shift] :Show left hand [Space] :Show right hand

    While hand is appearing+ [Click] :Pinch [Scroll] :Forward/Back
  11. Adding Obj File (7/7) ①model Set chair as following nbv

    Position 0.5 -0.3 1 Rotation 0 180 0
  12. In order to enable chair to detect contact with hand,

    Collider should be added to model.obj
  13. Restrict the Direction of the Chair ①model ②Set One Hand

    Rotation Mode Near/Far to Gravity Aligned Maintain Rotation to User
  14. Allow Only Rotation for 2 Hand Operation ①model ②Set Rotate

    for Two Hand Manipulation Type ③ Set Y Axis Only for Constraint On Rotation
  15. Run

  16. Depending on the development environment, the chair may fall off

    before the mesh appears on the scene. Keep the chair in the air at first and allow it to fall when you let go of your hand.
  17. Turn Off Gravity ①Use GravityをOff ②Is KinematicをOn Note︓ Turn Is

    Kinematic On to prevent physical interference. Prevents the chair from hitting the mesh and flying away when the app is launched.
  18. Turn On Gravity After Manipulation model The ManipulationHandler has OnManipulation

    Started/Ended, which makes it easy to get the operation started and finished.
  19. Turn On Gravity After Manipulation ①Clear Search Area ③Set Script

    Name ex)PhysicsScript ②New script ④Create and Add
  20. using System.Collections; using System.Collections.Generic; using UnityEngine; public class PhysicsScript :

    MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } } Editing Script
  21. using System.Collections; using System.Collections.Generic; using UnityEngine; public class PhysicsScript :

    MonoBehaviour { //SetGravityにtrue/falseを渡すことで重⼒および物理⼲渉のOn/Offを切り替える public void SetGravity(bool flag) { //重⼒のOn/Offを設定 gameObject.GetComponent<Rigidbody>().useGravity = flag; //物理的な⼲渉のOn/Offを設定 gameObject.GetComponent<Rigidbody>().isKinematic = !flag; } } Function to Switch On/Off Physics
  22. The object (chair) will rebound and roll when spatial meshes

    are refreshed on the actual HoloLens. Turn off gravity as soon as collision with spatial mesh
  23. using System.Collections; using System.Collections.Generic; using UnityEngine; public class HandScript :

    MonoBehaviour { //SetGravityにtrue/falseを渡すことで重⼒および物理⼲渉のOn/Offを切り替える public void SetGravity(bool flag) { gameObject.GetComponent<Rigidbody>().useGravity = flag; gameObject.GetComponent<Rigidbody>().isKinematic = !flag; } //Called when collision is occured private void OnCollisionEnter(Collision collision) { SetGravity(false); } }
  24. Using Plane Detection ①SeeAR Default Plane (※ Do NOT click)

    ②Drag & Drop into None aligned right of Plane Prefab