oliver schmahl
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Assignment 5 - Interaction techniques (graded) **Date**: 06/03/2022 **Group members participating**: Jakob Overgaard (201706812), Oilver Rask Schmahl (201805260), Tobias Fabrin Gade (201809466) **Activity duration**: 8-10 hours on average per person. ## Goal Our goal for this week was to finilize our concept and redo our 3D assets in respect to simplifing the models, so that material change is less cumbersome. This is because each model before hand consisted of 80+ textures each. Additionally we want to finish our application and follow the guideliness issued in this weeks exercise by ensuring that we have atleast: - 3 different interaction techniques with different actions. - 3 different input techniques, where we use atleast 1 tracked image marker interaction and 1 relation (e.g. distance) between objects - 3 different output techniques, where we use atleast 1 change of appereance and 1 animation on an object. ## Plan For this exercise we plan to fullfill the project requirements by implementing 3 different interaction techniques which each focus on input and output formats required for the exercise. **Shaking Gesture** The first interaction technequie we plan to implement will be gesture based and works by shaking your phone. When the shake is detected, all objects in the scene will simply fall through the plane, wiping all excisting buildings. Additionally an explosion animation is added, to indicate that the building is being "leveled". ![](https://i.imgur.com/zzwyIqb.png) ***Technical Implementation Plan:*** We plan to implement this by looking at when the phones accelerometor data surpases a threshold and then adding a Rigidbody to all our objects in a given scene at run time and enable gravity to "true". For the explosion animation we want to use a particle system animation and create a prefab that can be added as a child to the GameObjects. **Tracked Image Marker** ![](https://i.imgur.com/qlgIjCS.png) The second interaction technique is utilizing Unity's AR Tracked image manager. It detects different materials, in order to change the appearance of the houses. The library includes distinct pictures of roofs and bricks coloured in grey og red. ***Technical Implementation Plan:*** In order to fullfill this feature, it will be beneficial to first implement the image marker feature from assignment two. Afterwards several features must be implemented as well. In order to do this, the manager must be able to recognize more than one picture and to handle the different events occuring based on the pictues, the script must be expanded. There must be a script for handling the image tracking, which would call a method to change either the bricks or roofs to the right material. **Relational Distance** The final interaction technique we want to implement into our application is making objects in the scene react to each other, when they are within a certain distance from each other in "the real world". Specifically we want to dynamically create hedges between houses, when they are within 1 meter from each other. ![](https://i.imgur.com/wfptbJe.png) ***Technical Implementation Plan:*** We plan to implement this by calculating the distance between all houses, and if they are within 1 meter from eachother, a hedge will be created on the midpoint between the two houses. Some of the challanges regarding this is how to find all houses inserted into the scene, making sure that the hedges' position is updated accordingly when houses are moved around, and that hedges are only created for houses on the same plane (i.e. not between a house on the floor and one on the wall). We plan to use unity's tag system to solve this along with different methods for calculating midpoints and faceings. ## Results ### 1. Shaking Gesture Implementation For detecting whether or not a phone has been shaken we collect the phones accelerometer data and handle it through a lowpass filter, for making a more accurate measurement of a shaking gesture. If the data surpasses our predefined *_shakeDetectionThreshold (5.0f)* then we run a method from our *ObjectAdderScript*. Our code can be seen below: ``` void Update() { Vector3 acceleration = Input.acceleration; _lowPassValue = Vector3.Lerp(_lowPassValue, acceleration, _lowPassFilterFactor); Vector3 deltaAcceleration = acceleration - _lowPassValue; if (deltaAcceleration.sqrMagnitude >= _shakeDetectionThreshold) { _objectAdderScript.RemoveOnShake(); } } ``` For making the objects Disapear on shake, we have looped through all objects in a scene and added Rigidbody to it and then afterwards ensuring that gravity is enabled for each of them. Additionally to handle the animation, we created a custom particle system prefab and added this to all GameObject prefabs that can be spawned in the application. We then simple find this particle prefab "Explosion" and use *Play()* to display the animation. We do not use *Stop()* because the animation is not set to be looping. Our code for adding rigidbody and enabling animation can be seen below: ``` public void RemoveOnShake() { foreach (Transform child in objectsHolder.transform) { child.gameObject.AddComponent<Rigidbody>(); // Add the rigidbody. child.GetComponent<Rigidbody>().useGravity = true; child.transform.Find("Explosion").GetComponent<ParticleSystem>().Play() } } ``` The final result turned out pretty cool and a GIF of it can be seen below: ***ADD GIF ABOUT BUILDING FALLING THROUGH GROUND BOOYYAA!*** ### 2. Tracked Image Marker Implementation Unity includes a library for handling the images recognized and the library is used by the tracked image manager, which is coupled to the AR Session origin. To handle the different events, we have included a script for handling the image tracking. It subscribes to the Tracked Image Manager trackedImageChanged event, which notifies whenever an image is added, updated or deleted. Each image has a state, meaning the when it is not recognized in the picture anymore, its tracking state will likely change. This is not a problem in our case, as we only need to detect if an image occurs, as this makes a call to a method, that handles the change of material. That means that we only need to handle an updated event. private void OnImageChanged(ARTrackedImagesChangedEventArgs args) { foreach (var updatedImage in args.updated) { var imgName = updatedImage.referenceImage.name; if (imgName.Equals("grey-bricks")) { objectManipulatorScript.UpdateMaterials(wallTag, greyBricks); } if (imgName.Equals("grey-roof")) { objectManipulatorScript.UpdateMaterials(roofTag, greyRoof); } if (imgName.Equals("red-bricks")) { objectManipulatorScript.UpdateMaterials(wallTag, redBricks); } if (imgName.Equals("red-roof")) { objectManipulatorScript.UpdateMaterials(roofTag, redRoof); } } } In the ObjectManipulatorScript we have added a method called UpdateMaterials(). It takes a tag and material as argument in order to change the right objects to the right material. That implies that the objects that act as roofs and bricks has been tagged in unity. We find all objects with the given tag, iterates through while we change their materiality to the given material. public void UpdateMaterials(string tag, Material material) { // If values are null, exit! if(string.IsNullOrEmpty(tag) || material == null) return; // Find all objects with the tag var gameObjects = GameObject.FindGameObjectsWithTag(tag); // iterate foreach (var go in gameObjects) { // check if there is a mesh renderer component if (go.TryGetComponent<MeshRenderer>(out var mr)) { // grab the materials array var materials = mr.materials; // update all the materials in our array for (int i = 0; i < materials.Length; i++) { materials[i] = material; Debug.Log(tag + materials); } // Update the material array on the mesh renderer. mr.materials = materials; } } } Below is a GIF that illustrates how the indication marker uses an image to change the materials of the roof and the body of the house accordingly: ***ADD GIF ABOUT MATERIAL CHANGE BOOYYAA!*** ### 3. Relational Distance Implementation The first thing we did was creating a simple, low ploygon, house and "hedge" which was used during development. Next we created a new Hedge Script, which we attached to our default behaviour object. This script will be responsible for finding all houses placed in the scene, calcultating their distances to each other, and then place hedges where fit. Secondly, the script will also update the hedges placement, when a house is moved within the scene. Finding all houses is done using Unity's build-in function to find all GameObjects with a specific tag. The house prefab that uses can place in the scene is marked with a "house" tag, as seen below: ![](https://i.imgur.com/VDKFkV7.png) and all houses are then found with the code shown below: ```C# _houses = GameObject.FindGameObjectsWithTag("House"); ``` The script then loops through all the houses returned in the GameObject array _houses, and performs two checks: 1. The two houses we are currently checking should not be one and the same house instance. We make sure that we are dealing with two distinct houses by checking that they have different instance IDs. 2. The two houses should also be on the same plane, meaning a house place on the floor plane should not end up sharing a hedge with a house place on a wall plane. Code for this is shown below: ```C# foreach (GameObject house in _houses) { foreach (GameObject otherHouse in _houses) { if (house.GetInstanceID() != otherHouse.GetInstanceID()) { Transform houseTransform = house.transform; Transform otherHouseTransform = otherHouse.transform; if (houseTransform.rotation.x == otherHouseTransform.rotation.x && houseTransform.rotation.z == otherHouseTransform.rotation.z) { // Placement code omitted but showed later. } } } } ``` When these checks are correct we know that we have a situration where a hedge might need to be created. In these instances we then calculate the distance between the two houses using Unity's build-in distance function, which returns the distance between two vector3s (i.e. the two houses positions in world space). From assignment 2 we found out that the relational size is 1 unity is equal to 1 meter in real life, thus we check that the distance is below 1 unit (1 meter) and above 0.2 units (20 cm). The reason we also check that the distance is above 20 cm, is to avoid hedges spawning inside houses. If the distance falls within these bounds in calculate the midpoint between the two houses using Unity's build-in lerp function, with can return the point located a given procentage of the way between two points (in out case 0.5, i.e. 50%, of the way between the two houses), we then instansiate a new hedge at this location using the hedge prefab, and make it face the first house using unity's lookAt function. The code for this can be seen below: ```C# var distance = Vector3.Distance(houseTransform.position, otherHouseTransform.position); if (distance < 1f && distance > 0.2f) { Vector3 midpoint = Vector3.Lerp(houseTransform.position, otherHouseTransform.position, 0.5f); Instantiate(hedgeObject, midpoint, houseTransform.rotation, hedgeHolder.transform).transform.LookAt(houseTransform); } ``` The next step was to update the hedges position when houses are moved, this was done by moving the above code into the update function that runs every frame, and deleting all hedges with the associated "hedge" tag first. This might be a very inefficient way to do it, but it was how we were able make it work. Lastly we made some visual improvements to the house and hedges to make it look a little nicer. A gif showcasing the hedges being created and remove correctly as a response to the houses placed and manipulated in the scene: ***ADD GIF ABOUT HOUSE DISTANCE BOOYYAA!***

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully