diff --git a/3d-generation-pipeline/README.md b/3d-generation-pipeline/README.md index 0943979b..2c8563a0 100644 --- a/3d-generation-pipeline/README.md +++ b/3d-generation-pipeline/README.md @@ -15,8 +15,6 @@ * kui kõik configurationid tehtud, siis midagi juhtub: uks avaneb, quest marker läheb ukse juurde, professor ütleb "thank you" * peab mängijale kuidagi selgitama, kuidas scale'ida prinditud objekte * prinditud objekti scale'imisele min ja max size limiit - * shape scanner mitte lihtsalt ontriggerenter ja -exit, sest kui mitu objekti lähevad samal ajal sisse - * shape scanneris prinditud objektid mõnikord ei kao ära kui config success * archery range: * mikrofon peaks lõpetama protsessimise ka siis kui mängija läheb ära mikri juurest * võiks jääda kordama viimast instruktsiooni, kui mängija ei progressi edasi diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset index 75b7ce82..9cf711af 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Anton SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:27b8a0cf09be3037f91a8eee3c18842a3e4b33ca11d7ff64bec223be8fd196f8 -size 2108584 +oid sha256:3d5cfcffff8dff4e78b27660e504f3f3c7e33bc90635f4ecea5fba734cea9076 +size 8426 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset index 13b677bf..703f2486 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Bangers SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b03910b5aa7086327212ee452f1087a63d9d0b2104fa32e3265aaff9beeda11 -size 2176050 +oid sha256:cd9b73f8a66de23601f20f4ee0be0146d3bb10a3ee71549cb5df990d0b58580c +size 76143 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset index 2fd05d9f..d3d2e36b 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Electronic Highway Sign SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88b9b8257f42bdd2594201d098bcbabb58abb8f8578ba535422ae62a8892d6ac -size 2108080 +oid sha256:0b91d586ea5e3b650560f7626572004d37022e69998298493bd3bbbc7458d132 +size 8542 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset index 78cfb5a1..7a4c27ee 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Oswald Bold SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:83c38cb41a2cb6789a843d35f22b6b6901d4f470299332a38cb1066047b57831 -size 2169752 +oid sha256:87cd6656b74c1aeaca65492c12c7f13854f553643782f3c21e7be8922a6bb25e +size 69579 diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset index bd4bbe71..efd99ccb 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:98ba21be5410cb67f08db0df0d02809fd498a59eceb8c11939f51244f37332af -size 2788231 +oid sha256:be30842c9400a3cee8e0a04837a440a13ed3987dfe7414baf3d7cc09906912da +size 688126 diff --git a/Assets/_PROJECT/Fonts/Handlee-Regular SDF.asset b/Assets/_PROJECT/Fonts/Handlee-Regular SDF.asset index 50f0e74e..e3896749 100644 --- a/Assets/_PROJECT/Fonts/Handlee-Regular SDF.asset +++ b/Assets/_PROJECT/Fonts/Handlee-Regular SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2abe1cb5e86fddfd0b4c2d754c85b04398bcf85c63294ca987b9d62d7187bb56 -size 2666407 +oid sha256:e335e65ec81f22cc2ba30d8e923dbaa9fd279b077622e4ff5816f3d4f66b40ea +size 2641660 diff --git a/Assets/_PROJECT/Fonts/Quantico-Bold SDF.asset b/Assets/_PROJECT/Fonts/Quantico-Bold SDF.asset index 1cb3b8d9..b47c185a 100644 --- a/Assets/_PROJECT/Fonts/Quantico-Bold SDF.asset +++ b/Assets/_PROJECT/Fonts/Quantico-Bold SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21bdbfbf7ff9cd5304fb588fa1f3c3ae61fae692247bcc1dc70f372dc11260af -size 2107856 +oid sha256:0b1be4c9a9b40876d4ed284bf3c1ceebbe67a79a2f7fefe68b45ae85b213b9f9 +size 7701 diff --git a/Assets/_PROJECT/Fonts/Quantico-Regular SDF.asset b/Assets/_PROJECT/Fonts/Quantico-Regular SDF.asset index e2d16c45..7f203143 100644 --- a/Assets/_PROJECT/Fonts/Quantico-Regular SDF.asset +++ b/Assets/_PROJECT/Fonts/Quantico-Regular SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d5164ab1d49ccaf08e463a2d0138be724b3d86ae6c0e1623d418b26c6b79f515 -size 2107858 +oid sha256:5e3d6effe83965263a7f57fc4da5b9796c6b2d25b429b0f0a22b409ef7a0d88f +size 2113086 diff --git a/Assets/_PROJECT/Prefabs/ModelGeneration/ShapeScanner.prefab b/Assets/_PROJECT/Prefabs/ModelGeneration/ShapeScanner.prefab index 13a465c1..b395a6bb 100644 --- a/Assets/_PROJECT/Prefabs/ModelGeneration/ShapeScanner.prefab +++ b/Assets/_PROJECT/Prefabs/ModelGeneration/ShapeScanner.prefab @@ -426,7 +426,6 @@ GameObject: - component: {fileID: 5559886958032571103} - component: {fileID: 5954212323650350193} - component: {fileID: 2317701697644582190} - - component: {fileID: 5652247538039532239} m_Layer: 0 m_Name: ShapeScanner m_TagString: Untagged @@ -549,6 +548,7 @@ MonoBehaviour: rayParent: {fileID: 6811284554916002137} currentConfigurationDisplay: {fileID: 2482954631852020050} correctPercentageDisplay: {fileID: 496206569825438079} + interactionManager: {fileID: 0} requiredAndActive: {fileID: 2100000, guid: dccb608b252977047bd5848d6a497bfb, type: 2} requiredAndPassive: {fileID: 2100000, guid: c0707507abffb6149b19e60299403e82, type: 2} notRequiredAndActive: {fileID: 2100000, guid: 991fa2870324ba04aba7bec9e1168afa, @@ -718,27 +718,6 @@ MonoBehaviour: m_StartingSingleGrabTransformers: [] m_StartingMultipleGrabTransformers: [] m_AddDefaultGrabTransformers: 1 ---- !u!65 &5652247538039532239 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4393714733752105576} - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_IsTrigger: 1 - m_ProvidesContacts: 0 - m_Enabled: 1 - serializedVersion: 3 - m_Size: {x: 1.5, y: 1.5, z: 1.5} - m_Center: {x: 0, y: 0, z: 0} --- !u!1 &5905737949616845505 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity b/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity index 30396401..34c78aeb 100644 --- a/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity +++ b/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa4addd609932273253c1fb56ebe9d4bbd8adf81241becbb407d7b2256feef47 -size 68623051 +oid sha256:08a8398cc64b16a9541f514849f81e5e950755772d7d9b96f096351f5cb6520e +size 68632201 diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3D.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3D.cs index 14c068c9..4dbfda02 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3D.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/Printer3D.cs @@ -11,7 +11,6 @@ public class Printer3D : MonoBehaviour private bool isPrinting = false; private EventInstance printingSound; - private GameObject GeneratedModel; // Start is called before the first frame update void Start() @@ -39,12 +38,6 @@ public class Printer3D : MonoBehaviour GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel, printedObjectSize); InitializeSpawnedObject(spawnedObject); - if (GeneratedModel != null) - { - // Destroy previous generated object (first move out of ShapeScanner to trigger OnTriggerExit - GeneratedModel.transform.position = Vector3.zero; - } - GeneratedModel = spawnedObject; printingSound.setParameterByName("3DPrinterPrintingJob", 1); isPrinting = false; diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScanner.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScanner.cs index 9a68df7d..d546534e 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScanner.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScanner.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using TMPro; using UnityEngine; +using UnityEngine.XR.Interaction.Toolkit; [Serializable] @@ -29,26 +30,25 @@ public class ShapeScanner : MonoBehaviour public Transform rayParent; public TextMeshProUGUI currentConfigurationDisplay; public TextMeshProUGUI correctPercentageDisplay; + public XRInteractionManager interactionManager; public Material requiredAndActive; public Material requiredAndPassive; public Material notRequiredAndActive; public Material notRequiredAndPassive; - private List existingRays; + private List existingRays; private float raySpawnDistanceX; private float raySpawnDistanceZ; private int currentConfiguration; private int rayCount; private int correctRayStates; - private GameObject currentlyScannableObject; - // Start is called before the first frame update void Start() { - existingRays = new List(); + existingRays = new List(); raySpawnDistanceX = raySpawnCorner2.localPosition.x - raySpawnCorner1.localPosition.x; raySpawnDistanceZ = raySpawnCorner2.localPosition.z - raySpawnCorner1.localPosition.z; @@ -62,34 +62,15 @@ public class ShapeScanner : MonoBehaviour } - private void OnTriggerEnter(Collider other) - { - if (other.tag == rayPrefab.scannableTag) - { - currentlyScannableObject = other.gameObject; - } - } - - private void OnTriggerExit(Collider other) - { - if (other.tag == rayPrefab.scannableTag) - { - currentlyScannableObject = null; - } - } - private void InitializeConfiguration() { - // Delete all existing rays first - foreach (GameObject ray in existingRays) + // Delete all colliding objects and then all existing rays + DestroyCollidingObjects(); + foreach (ShapeScannerRay ray in existingRays) { - Destroy(ray); - } - if (currentlyScannableObject != null) - { - currentlyScannableObject.transform.position = Vector3.zero; - Destroy(currentlyScannableObject); + Destroy(ray.gameObject); } + existingRays.Clear(); ShapeScannerConfiguration configuration = configurations[currentConfiguration]; int rayRowCount = configuration.rows.Count; @@ -103,7 +84,7 @@ public class ShapeScanner : MonoBehaviour Vector3 rayPos = new Vector3(rayPosX, 0, rayPosZ); ShapeScannerRay ray = Instantiate(rayPrefab, rayParent); ray.transform.localPosition = rayPos; - existingRays.Add(ray.gameObject); + existingRays.Add(ray); bool rayCollisionRequired = configuration.rows[i].cells[j]; if (rayCollisionRequired) @@ -122,6 +103,31 @@ public class ShapeScanner : MonoBehaviour UpdateDisplay(calculateCorrectPercentage()); } + private void DestroyCollidingObjects() + { + HashSet allCollidingObjects = new HashSet(); + foreach (ShapeScannerRay ray in existingRays) + { + allCollidingObjects.UnionWith(ray.GetCollidingObjects()); + } + foreach (GameObject collidingObject in allCollidingObjects) + { + // Release player holding it + var grab = collidingObject.GetComponent(); + if (grab != null && grab.isSelected) + { + var interactor = grab.firstInteractorSelecting; // the hand/controller currently holding it + if (interactor != null) + { + // Transfer ownership: tell the manager to stop the selection + interactionManager.SelectExit(interactor, grab); + } + } + collidingObject.transform.position = Vector3.zero; + Destroy(collidingObject); + } + } + private float calculateCorrectPercentage() { return Mathf.RoundToInt((float)correctRayStates / rayCount * 100); diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScannerRay.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScannerRay.cs index f05a2d81..cc596dd4 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScannerRay.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/ShapeScannerRay.cs @@ -10,11 +10,13 @@ public class ShapeScannerRay : MonoBehaviour private ShapeScanner _scanner; private MeshRenderer[] meshRenderers; + private HashSet collidingObjects; private bool _collisionRequired; void Awake() { meshRenderers = GetComponentsInChildren(); + collidingObjects = new HashSet(); } // Update is called once per frame @@ -40,18 +42,23 @@ public class ShapeScannerRay : MonoBehaviour { if (other.gameObject.tag == scannableTag) { - foreach (MeshRenderer meshRenderer in meshRenderers) + collidingObjects.Add(other.gameObject); + // Only activate when this was the first object that entered collision + if (collidingObjects.Count == 1) { - meshRenderer.material = _activeMaterial; + foreach (MeshRenderer meshRenderer in meshRenderers) + { + meshRenderer.material = _activeMaterial; + } + if (_collisionRequired) + { + _scanner.IncrementCorrectRayCount(); + } + else + { + _scanner.DecrementCorrectRayCount(); + } } - if (_collisionRequired) - { - _scanner.IncrementCorrectRayCount(); - } else - { - _scanner.DecrementCorrectRayCount(); - } - } } @@ -59,17 +66,27 @@ public class ShapeScannerRay : MonoBehaviour { if (other.gameObject.tag == "ShapeScannable") { - foreach (MeshRenderer meshRenderer in meshRenderers) + collidingObjects.Remove(other.gameObject); + if (collidingObjects.Count == 0) { - meshRenderer.material = _passiveMaterial; - } - if (_collisionRequired) - { - _scanner.DecrementCorrectRayCount(); - } else - { - _scanner.IncrementCorrectRayCount(); + foreach (MeshRenderer meshRenderer in meshRenderers) + { + meshRenderer.material = _passiveMaterial; + } + if (_collisionRequired) + { + _scanner.DecrementCorrectRayCount(); + } + else + { + _scanner.IncrementCorrectRayCount(); + } } } } + + public HashSet GetCollidingObjects() + { + return collidingObjects; + } }