diff --git a/Assets/GameObjects/waypoint.prefab b/Assets/GameObjects/waypoint.prefab index 43f0f70f4..b102e3292 100644 --- a/Assets/GameObjects/waypoint.prefab +++ b/Assets/GameObjects/waypoint.prefab @@ -119,7 +119,7 @@ MonoBehaviour: referenceDroneGameObject: {fileID: 0} unpassedWaypoint: {fileID: 2100000, guid: afba4be579bef284c89de7b26b5e7cba, type: 2} passedWaypoint: {fileID: 2100000, guid: a9daeb5b833c0a0488eaad3102105b2d, type: 2} - touchedWaypoint: {fileID: 2100000, guid: a6b8d73a9ec98454fa523b580489b686, type: 2} + grabbedWaypoint: {fileID: 2100000, guid: 43be1c9607da4e5498d0404a743de3d8, type: 2} lockedWaypoint: {fileID: 2100000, guid: a235c9ef53b67974898f2378dd243557, type: 2} uploadedWaypoint: {fileID: 2100000, guid: 9cf45ff77abd26a4da04aa71d8f388e8, type: 2} selectedUnpassedLine: {fileID: 2100000, guid: 4464a80a04b3c7648b7eb56b8ef58f8b, @@ -133,6 +133,7 @@ MonoBehaviour: type: 2} unselectedGroundpointLine: {fileID: 2100000, guid: 265b177cdfd2bff4f87141ff55372302, type: 2} + grabbedLine: {fileID: 2100000, guid: 88142d8c361f30049bae694ac76275bf, type: 2} waypointStatus: 0 prevWaypointStatus: 0 modelGroundpoint: {fileID: 1072266980392874, guid: fe9c4c5a263cc4144a730d848f5fd6ad, diff --git a/Assets/Materials/Waypoints/touchedWaypoint.mat b/Assets/Materials/Waypoints/grabbedLine.mat similarity index 91% rename from Assets/Materials/Waypoints/touchedWaypoint.mat rename to Assets/Materials/Waypoints/grabbedLine.mat index 0099606e5..b0a57c4a0 100644 --- a/Assets/Materials/Waypoints/touchedWaypoint.mat +++ b/Assets/Materials/Waypoints/grabbedLine.mat @@ -6,10 +6,10 @@ Material: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_Name: touchedWaypoint + m_Name: grabbedLine m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: - m_LightmapFlags: 4 + m_ShaderKeywords: _EMISSION + m_LightmapFlags: 1 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 @@ -72,5 +72,5 @@ Material: - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _Color: {r: 0.8206897, g: 0, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Materials/Waypoints/touchedWaypoint.mat.meta b/Assets/Materials/Waypoints/grabbedLine.mat.meta similarity index 78% rename from Assets/Materials/Waypoints/touchedWaypoint.mat.meta rename to Assets/Materials/Waypoints/grabbedLine.mat.meta index c2f0f5dff..8329bd5cf 100644 --- a/Assets/Materials/Waypoints/touchedWaypoint.mat.meta +++ b/Assets/Materials/Waypoints/grabbedLine.mat.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a6b8d73a9ec98454fa523b580489b686 +guid: 88142d8c361f30049bae694ac76275bf NativeFormatImporter: externalObjects: {} mainObjectFileID: 0 diff --git a/Assets/Materials/Waypoints/grabbedWaypoint.mat b/Assets/Materials/Waypoints/grabbedWaypoint.mat new file mode 100644 index 000000000..5ef0e0eb0 --- /dev/null +++ b/Assets/Materials/Waypoints/grabbedWaypoint.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: grabbedWaypoint + m_Shader: {fileID: 4800000, guid: c445713453d55ad4c8193855100fd967, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _ColorMask: 15 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Outline: 0.01 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UVSec: 0 + - _UseUIAlphaClip: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.86764705, g: 0.86764705, b: 0.86764705, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _OutlineColor: {r: 1, g: 1, b: 1, a: 1} + - _Specular: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/Materials/Waypoints/grabbedWaypoint.mat.meta b/Assets/Materials/Waypoints/grabbedWaypoint.mat.meta new file mode 100644 index 000000000..3b2ef2aeb --- /dev/null +++ b/Assets/Materials/Waypoints/grabbedWaypoint.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 43be1c9607da4e5498d0404a743de3d8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index fe9e42bc3..4861b16a7 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -291,92 +291,6 @@ Material: - _DetailColor2: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 0} - _WindowColor: {r: 1, g: 1, b: 1, a: 1} ---- !u!1 &78194253 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 78194254} - - component: {fileID: 78194257} - - component: {fileID: 78194258} - - component: {fileID: 78194255} - m_Layer: 0 - m_Name: Pivot - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &78194254 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 78194253} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 2.600603, y: -0.015563183, z: 2.600604} - m_Children: [] - m_Father: {fileID: 267214439} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &78194255 -MeshRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 78194253} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: f5e394a942fae453583e8e6009ee49a1, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 1 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &78194257 -MeshFilter: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 78194253} - m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!64 &78194258 -MeshCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 78194253} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 3 - m_Convex: 0 - m_CookingOptions: 14 - m_SkinWidth: 0.01 - m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &79141381 GameObject: m_ObjectHideFlags: 0 @@ -678,11 +592,11 @@ MonoBehaviour: waypointBaseObject: {fileID: 1161822125618724, guid: c209b41633a109640bb6a3527c86c801, type: 2} sensorManagerBaseObject: {fileID: 130481553} - MeshLatitude: 0 - MeshLongitude: 0 - MeshAltitude: 0 + MeshLatitude: 37.9152 + MeshLongitude: -122.338 + MeshAltitude: 17.6 MeshRotation: {x: 0, y: 0, z: 0} - MeshScale: {x: 0, y: 0, z: 0} + MeshScale: {x: 30, y: 30, z: 30} MeshEarthPrefab: {fileID: 1460938711} MCLatitude: 37.9152 MCLongitude: -122.338 @@ -978,7 +892,6 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1076179635} - - {fileID: 78194254} m_Father: {fileID: 0} m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -2136,7 +2049,6 @@ GameObject: - component: {fileID: 564073445} - component: {fileID: 564073444} - component: {fileID: 564073443} - - component: {fileID: 564073442} - component: {fileID: 564073441} m_Layer: 0 m_Name: EventSystem @@ -2156,18 +2068,6 @@ MonoBehaviour: m_Script: {fileID: 1327945023, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &564073442 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 564073440} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1997211142, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_ForceModuleActive: 0 --- !u!114 &564073443 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2268,6 +2168,10 @@ Prefab: propertyPath: m_IsActive value: 1 objectReference: {fileID: 0} + - target: {fileID: 1125901207556238, guid: 4d3381740d602f043bb130adb276352f, type: 2} + propertyPath: m_StaticEditorFlags + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 4d3381740d602f043bb130adb276352f, type: 2} m_IsPrefabParent: 0 @@ -4050,7 +3954,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 2100000, guid: 48f79b58f9f4c6f49b5fe7617beff012, type: 2} + - {fileID: 2100000, guid: 43be1c9607da4e5498d0404a743de3d8, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -4900,14 +4804,13 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: controllerInput: {fileID: 1699223320} - Pivot: {fileID: 78194253} World: {fileID: 146794962} minScale: 0.1 maxScale: 10 speed: 1 - direction: 0 + direction: 1 rotationalSpeed: 1 - rotationalDirection: 0 + rotationalDirection: 1 --- !u!114 &1699223320 MonoBehaviour: m_ObjectHideFlags: 0 @@ -5221,7 +5124,7 @@ GameObject: - component: {fileID: 1843436370} m_Layer: 0 m_Name: CitySimParent - m_TagString: Ground + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -5815,9 +5718,6 @@ GameObject: - component: {fileID: 2053542337} - component: {fileID: 2053542340} - component: {fileID: 2053542341} - - component: {fileID: 2053542335} - - component: {fileID: 2053542338} - - component: {fileID: 2053542336} m_Layer: 0 m_Name: LeftController m_TagString: Untagged @@ -5838,36 +5738,6 @@ Transform: m_Father: {fileID: 1699223318} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &2053542335 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2053542333} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 64e104da36bd3b04b90c6ae969ac66dc, type: 3} - m_Name: - m_EditorClassIdentifier: - customColliderContainer: {fileID: 0} ---- !u!114 &2053542336 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2053542333} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 947b27445602ed640b885db7e667dfc1, type: 3} - m_Name: - m_EditorClassIdentifier: - grabButton: 3 - grabPrecognition: 0 - throwMultiplier: 1 - createRigidBodyWhenNotTouching: 0 - controllerAttachPoint: {fileID: 0} - controllerEvents: {fileID: 0} - interactTouch: {fileID: 0} --- !u!114 &2053542337 MonoBehaviour: m_ObjectHideFlags: 0 @@ -5917,21 +5787,6 @@ MonoBehaviour: gripSenseAxisChanged: 0 gripSensePressed: 0 controllerVisible: 1 ---- !u!114 &2053542338 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2053542333} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 65eb64f0f2fd6d64faddbcf5d7d3bdbb, type: 3} - m_Name: - m_EditorClassIdentifier: - useButton: 3 - controllerEvents: {fileID: 0} - interactTouch: {fileID: 0} - interactGrab: {fileID: 0} --- !u!114 &2053542340 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Interaction Scripts/ControllerInput.cs b/Assets/Scripts/Interaction Scripts/ControllerInput.cs index 94a890857..473d5ea0c 100644 --- a/Assets/Scripts/Interaction Scripts/ControllerInput.cs +++ b/Assets/Scripts/Interaction Scripts/ControllerInput.cs @@ -37,9 +37,6 @@ public class ControllerInput : MonoBehaviour private VRTK_StraightPointerRenderer RightPointerRenderer; // The VRTK Pointer Renderer Component (script) of the right controller. private VRTK_UIPointer RightUIPointer; // The VRTK UI Pointer Component (script) of the right controller. - private bool boolLeftPointerEnabled; // Whether the left controller's pointer is enabled or disabled. - private bool boolRightPointerEnabled; // Whether the right controller's pointer is enabled or disabled. - // Awake is called on initialization, BEFORE Start. void Awake() @@ -50,18 +47,17 @@ void Awake() RightPointerRenderer = RightController.GetComponent(); RightUIPointer = RightController.GetComponent(); - LeftPointerRenderer.enabled = false; - LeftPointer.enabled = false; - RightUIPointer.enabled = false; - RightPointerRenderer.enabled = false; - RightPointer.enabled = false; + // LeftPointerRenderer.enabled = false; + // LeftPointer.enabled = false; + // RightUIPointer.enabled = false; + // RightPointerRenderer.enabled = false; + // RightPointer.enabled = false; - LeftUI.SetActive(false); - RightUI.SetActive(false); + // LeftUI.SetActive(false); + // RightUI.SetActive(false); } - /******************************/ // LEFT HAND GETTER METHODS // /******************************/ @@ -267,7 +263,7 @@ public Vector3 LeftAngularVelocity() /// True if the left controller's pointer is enabled. public bool LeftPointerEnabled() { - return boolLeftPointerEnabled; + return LeftPointerRenderer.enabled && LeftPointer.enabled; } /// @@ -426,7 +422,7 @@ public bool RightStickMoved() { return true; } - else if ( RightController.GetComponent().GetAxis(VRTK_ControllerEvents.Vector2AxisAlias.Touchpad).y != 0.0f) + else if (RightController.GetComponent().GetAxis(VRTK_ControllerEvents.Vector2AxisAlias.Touchpad).y != 0.0f) { return true; } @@ -503,7 +499,7 @@ public Vector3 RightAngularVelocity() /// True if the right controller's pointer is enabled. public bool RightPointerEnabled() { - return boolRightPointerEnabled; + return RightUIPointer.enabled && RightPointerRenderer.enabled && RightPointer.enabled; } /// @@ -601,47 +597,13 @@ public Vector3 AngularVelocityDelta() return LeftAngularVelocity - RightAngularVelocity; } - /// - /// The dot product of the difference in velocity between the two controllers and their distance. Can be used as a world scaling factor. - /// - /// A float that approximates a reasonable (neither too fast, nor too slow) world scaling factor. - public float ScalingFactor() - { - Vector3 LeftVelocity = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceLeftHand()); - Vector3 RightVelocity = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceRightHand()); - Vector3 VelocityDelta = LeftVelocity - RightVelocity; - - Vector3 LeftPosition = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.LeftController).position; - Vector3 RightPosition = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.RightController).position; - Vector3 Distance = LeftPosition - RightPosition; - - return Vector3.Dot(VelocityDelta, Distance); - } - - /// - /// The dot product of the difference in velocity between the two controllers and their local distance. Can be used as a local scaling factor. - /// - /// A float that approximates a reasonable (neither too fast, nor too slow) local scaling factor. - public float LocalScalingFactor() - { - Vector3 LeftVelocity = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceLeftHand()); - Vector3 RightVelocity = VRTK_DeviceFinder.GetControllerVelocity(VRTK_DeviceFinder.GetControllerReferenceRightHand()); - Vector3 VelocityDelta = LeftVelocity - RightVelocity; - - Vector3 LeftLocalPosition = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.LeftController).localPosition; - Vector3 RightLocalPosition = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.RightController).localPosition; - Vector3 localDistance = LeftLocalPosition - RightLocalPosition; - - return Vector3.Dot(VelocityDelta, localDistance); - } - /// /// Whether both controllers' pointers are enabled or disabled. /// /// True if both controllers' pointers are enabled. public bool BothPointerEnabled() { - return boolLeftPointerEnabled && boolRightPointerEnabled; + return LeftPointerRenderer.enabled && LeftPointer.enabled && RightUIPointer.enabled && RightPointerRenderer.enabled && RightPointer.enabled; } /// @@ -664,11 +626,13 @@ public bool BothUIsEnabled() /// public void EnableLeftPointer() { - if (!boolLeftPointerEnabled) + if (!LeftPointerRenderer.enabled) { LeftPointerRenderer.enabled = true; + } + if (!LeftPointer.enabled) + { LeftPointer.enabled = true; - boolLeftPointerEnabled = true; } } @@ -688,11 +652,13 @@ public void EnableLeftUI() /// public void DisableLeftPointer() { - if (boolLeftPointerEnabled) + if (LeftPointerRenderer.enabled) { LeftPointerRenderer.enabled = false; + } + if (LeftPointer.enabled) + { LeftPointer.enabled = false; - boolLeftPointerEnabled = false; } } @@ -707,7 +673,11 @@ public void DisableLeftUI() } } - + // TODO: documentation + public void LeftAttemptGrab() + { + LeftController.GetComponent().AttemptGrab(); + } /*******************************/ // RIGHT HAND SETTER METHODS // @@ -718,12 +688,18 @@ public void DisableLeftUI() /// public void EnableRightPointer() { - if (!boolRightPointerEnabled) + + if (!RightUIPointer.enabled) { RightUIPointer.enabled = true; + } + if (!RightPointerRenderer.enabled) + { RightPointerRenderer.enabled = true; + } + if (!RightPointer.enabled) + { RightPointer.enabled = true; - boolRightPointerEnabled = true; } } @@ -743,12 +719,17 @@ public void EnableRightUI() /// public void DisableRightPointer() { - if (boolRightPointerEnabled) + if (RightUIPointer.enabled) { RightUIPointer.enabled = false; + } + if (RightPointerRenderer.enabled) + { RightPointerRenderer.enabled = false; + } + if (RightPointer.enabled) + { RightPointer.enabled = false; - boolRightPointerEnabled = false; } } @@ -763,7 +744,11 @@ public void DisableRightUI() } } - + // TODO: documentation + public void RightAttemptGrab() + { + RightController.GetComponent().AttemptGrab(); + } /******************************/ // COMPOSITE SETTER METHODS // @@ -774,21 +759,29 @@ public void DisableRightUI() /// public void EnableBothPointers() { - // If not already enabled, enables the left controller's pointer. - if (!boolLeftPointerEnabled) + // If not already disabled, disables the left controller's pointer. + if (!LeftPointerRenderer.enabled) { LeftPointerRenderer.enabled = true; + } + if (!LeftPointer.enabled) + { LeftPointer.enabled = true; - boolLeftPointerEnabled = true; } - // If not already enabled, enables the right controller's pointer. - if (!boolRightPointerEnabled) + // If not already disabled, disables the right controller's pointer. + if (!RightUIPointer.enabled) { RightUIPointer.enabled = true; + } + if (!RightPointerRenderer.enabled) + { RightPointerRenderer.enabled = true; + } + if (!RightPointer.enabled) + { RightPointer.enabled = true; - boolRightPointerEnabled = true; } + } /// @@ -814,19 +807,26 @@ public void EnableBothUIs() public void DisableBothPointers() { // If not already disabled, disables the left controller's pointer. - if (boolLeftPointerEnabled) + if (LeftPointerRenderer.enabled) { LeftPointerRenderer.enabled = false; + } + if (LeftPointer.enabled) + { LeftPointer.enabled = false; - boolLeftPointerEnabled = false; } // If not already disabled, disables the right controller's pointer. - if (boolRightPointerEnabled) + if (RightUIPointer.enabled) { RightUIPointer.enabled = false; + } + if (RightPointerRenderer.enabled) + { RightPointerRenderer.enabled = false; + } + if (RightPointer.enabled) + { RightPointer.enabled = false; - boolRightPointerEnabled = false; } } diff --git a/Assets/Scripts/Interaction Scripts/ThirdPersonView.cs b/Assets/Scripts/Interaction Scripts/ThirdPersonView.cs index baa0c2f60..f7a2b4357 100644 --- a/Assets/Scripts/Interaction Scripts/ThirdPersonView.cs +++ b/Assets/Scripts/Interaction Scripts/ThirdPersonView.cs @@ -15,15 +15,14 @@ public class ThirdPersonView : MonoBehaviour { public ControllerInput controllerInput; /// Initiate a singleton of the ControllerState class. Assign it to the Controller GameObject. - private enum ControllerState { IDLE, SCALING, SELECTING_DRONE, SELECTING_SENSOR, AIMING_SELECTOR, SETTING_WAYPOINT_HEIGHT, PLACING_WAYPOINT, MOVING_WAYPOINT, UNDOING, REDOING } + private enum ControllerState { IDLE, SCALING, SELECTING_DRONE, SELECTING_SENSOR, AIMING_SELECTOR, SETTING_WAYPOINT_HEIGHT, ADDING_WAYPOINT, MOVING_WAYPOINT, UNDOING, REDOING } private ControllerState controllerState; - public GameObject Pivot; /// pivot is the center of the table public GameObject World; /// The World GameObject. All its children will be scaled, rotate and move with it. private Vector3 WorldScaleInitial; ///originalScale is the original localScale of the world - private Vector3 WorldScaleMin; /// This is the TODO of the originalScale of the world - private Vector3 WorldScaleMax; /// This is the TODO times the originalScale of the world + private float WorldScaleMin; /// This is the TODO of the originalScale of the world + private float WorldScaleMax; /// This is the TODO times the originalScale of the world public float minScale = 0.1f; /// This the minimum size (with respect to the original world size) that the player can scale the world at. For example, MinimumScale = 0.1 signifies that the world can be scaled down to 1/10th of its original size. public float maxScale = 10.0f; /// This the maximum size (with respect to the original world size) that the player can scale the world at. For example, MaximumScale = 10 signifies that the world can be scaled up to 10 times its original size. @@ -36,6 +35,7 @@ public enum Direction { REGULAR, INVERSE } public enum RotationalDirection { REGULAR, INVERSE } public RotationalDirection rotationalDirection = RotationalDirection.REGULAR; + private bool canAddWaypoint = true; // Whether a new waypoint can be placed. Useful to avoid accidental waypoint if trying to move a fixed waypoint. //private enum CollisionType { NOTHING, WAYPOINT, OTHER }; // These are the possible values for objects we could be colliding with //private CollisionPair mostRecentCollision; //private List currentCollisions; @@ -47,8 +47,8 @@ void Awake() // This provides us with basis to create bounds on scaling and something to return to. WorldScaleInitial = World.transform.localScale; // These are the bounds on scaling. - WorldScaleMin = Vector3.Scale(WorldScaleInitial, new Vector3(minScale, minScale, minScale)); - WorldScaleMax = Vector3.Scale(WorldScaleInitial, new Vector3(maxScale, maxScale, maxScale)); + WorldScaleMin = Vector3.Scale(WorldScaleInitial, new Vector3(minScale, minScale, minScale)).sqrMagnitude; + WorldScaleMax = Vector3.Scale(WorldScaleInitial, new Vector3(maxScale, maxScale, maxScale)).sqrMagnitude; } @@ -56,14 +56,27 @@ void Awake() void Start() { // Enable the required UI elements for this interaction mode. - controllerInput.EnableRightPointer(); - controllerInput.EnableBothUIs(); + // controllerInput.EnableBothPointers(); + // controllerInput.EnableBothUIs(); } // Fixed update is called n times per frame, where n is the physics step (and can be different from the progression of video frames). void FixedUpdate() { + // If not currently scaling, allow the player to move and rotate the world. + if (controllerState != ControllerState.SCALING) + { + if (controllerInput.RightStickMoved()) + { + RotateWorld(); + } + if (controllerInput.LeftStickMoved()) + { + MoveWorld(); + } + } + // Query for the controller state, determined by user input. switch(controllerState) { @@ -97,13 +110,22 @@ void FixedUpdate() break; } - if (controllerInput.RightTrigger()) + // If the right trigger is pressed + // and the user is not currently touching + // an existing waypoint, add a new waypoint. + if (controllerInput.RightTrigger() && !controllerInput.RightIsTouchingWaypoint() && canAddWaypoint) { - controllerState = ControllerState.PLACING_WAYPOINT; + controllerState = ControllerState.ADDING_WAYPOINT; controllerInput.DisableRightPointer(); - /// TODO: start linecollider break; } + // Else, start moving the touched waypoint. + else if (controllerInput.RightTrigger()) + { + controllerState = ControllerState.MOVING_WAYPOINT; + controllerInput.DisableRightPointer(); + break; + } if (controllerInput.RightA()) { @@ -121,15 +143,7 @@ void FixedUpdate() break; } - if (controllerInput.RightStickMoved()) /// Rotate the world - { - RotateWorld(); - } - if (controllerInput.LeftStickMoved()) /// Move the world - { - MoveWorld(); - } if (controllerInput.LeftX()) /// Cycle through drones { @@ -201,46 +215,46 @@ void FixedUpdate() break; } - case ControllerState.PLACING_WAYPOINT: + case ControllerState.ADDING_WAYPOINT: { - if (controllerInput.RightIsGrabbingWaypoint()) - { - controllerState = ControllerState.MOVING_WAYPOINT; - break; - } - - if (controllerInput.RightGrip()) /// Cancel waypoint placement - { - /// TODO: stop showing line - controllerState = ControllerState.IDLE; - controllerInput.EnableRightPointer(); - break; - } - - if (!controllerInput.RightTrigger()) - { - controllerState = ControllerState.IDLE; - Drone currentlySelectedDrone = WorldProperties.GetSelectedDrone(); - currentlySelectedDrone.AddWaypoint(controllerInput.RightUITransform().position); - controllerInput.EnableRightPointer(); - } - else - { - /// TODO: continue line showing and slightly faded wp - } + controllerState = ControllerState.MOVING_WAYPOINT; + controllerInput.HideWaypointPlacementVisualizer(); + Drone currentlySelectedDrone = WorldProperties.GetSelectedDrone(); + currentlySelectedDrone.AddWaypoint(controllerInput.RightUITransform().position); + controllerInput.EnableRightPointer(); break; - } case ControllerState.MOVING_WAYPOINT: { - if (!controllerInput.RightIsGrabbingWaypoint()) + // If the user is currently touching a waypoint, + // but is not grabbing it... grab it! + // This helps avoid logic errors, and + // lets the user instantly reposition + // newly added waypoints. + if (!controllerInput.RightIsGrabbingWaypoint() + && controllerInput.RightIsTouchingWaypoint()) + { + canAddWaypoint = false; + controllerInput.RightAttemptGrab(); + } + // Else, if we are not grabbing something, + // return to the idle state. + else if (!controllerInput.RightIsGrabbingWaypoint() && !controllerInput.RightTrigger()) { controllerState = ControllerState.IDLE; + canAddWaypoint = true; controllerInput.EnableRightPointer(); - break; } break; + + // if (controllerInput.RightGrip()) /// Cancel waypoint placement + // { + // / TODO: stop showing line + // controllerState = ControllerState.IDLE; + // controllerInput.EnableRightPointer(); + // break; + // } } case ControllerState.UNDOING: @@ -286,31 +300,27 @@ void FixedUpdate() private void ScaleWorld() { - // Get the scaling factor, and adjust its size. - float ScalingFactor = 1.0f + 0.2f * controllerInput.ScalingFactor(); // TODO: scaling factor should be directly calculated here, and not computed in controller input. + // Compute the scaling factor. + Vector3 velocityDelta = controllerInput.VelocityDelta(); + Vector3 distance = controllerInput.Distance(); + float ScalingFactor = 1.0f + 0.2f * Vector3.Dot(velocityDelta, distance); + + // Compute the scaling magnitude. Vector3 ScalingVector = Vector3.Scale(World.transform.localScale, new Vector3(ScalingFactor, ScalingFactor, ScalingFactor)); + float scalingMagnitude = ScalingVector.sqrMagnitude; - //Checking Scaling Bounds - if (ScalingVector.sqrMagnitude > WorldScaleMin.sqrMagnitude && ScalingVector.sqrMagnitude < WorldScaleMax.sqrMagnitude) + // Check if the scaling magnitude is withing boundaries. + // Otherwise, the world will become too big or too small. + if (scalingMagnitude > WorldScaleMin && scalingMagnitude < WorldScaleMax) { - // FIXME: Jank. and comments. - Vector3 A = World.transform.position; - Vector3 B = Pivot.transform.position; - B.y = A.y; - Vector3 startScale = World.transform.localScale; - Vector3 endScale = World.transform.localScale * ScalingFactor; - - Vector3 C = A - B; // diff from object pivot to desired pivot/origin + Vector3 endScale = ScalingFactor * startScale; + // Scaling also moves the object out of place. The following is a temporary fix, but it distorts the map. + endScale.y = startScale.y; - // calc final position post-scale - Vector3 FinalPosition = (C * ScalingFactor) + B; - - // finally, actually perform the scale/translation + // Finally, scale the world. World.transform.localScale = endScale; - World.transform.position = FinalPosition; } - } @@ -326,7 +336,7 @@ private void RotateWorld() { angle = controllerInput.RightStickDelta().x * rotationalSpeed * 360 * Time.fixedDeltaTime; } - World.transform.RotateAround(Pivot.transform.position, Vector3.up, angle); + World.transform.RotateAround(World.transform.position, Vector3.up, angle); } diff --git a/Assets/Scripts/Waypoint Scripts/WaypointProperties.cs b/Assets/Scripts/Waypoint Scripts/WaypointProperties.cs index 29e8a8b68..fddf670d9 100644 --- a/Assets/Scripts/Waypoint Scripts/WaypointProperties.cs +++ b/Assets/Scripts/Waypoint Scripts/WaypointProperties.cs @@ -11,7 +11,6 @@ /// public class WaypointProperties : MonoBehaviour { - private GameObject controller; // TODO: hardcoded, remove. [Header("Connected gameobjects")] public Waypoint classPointer; @@ -23,7 +22,7 @@ public class WaypointProperties : MonoBehaviour [Header ("Waypoint Materials")] public Material unpassedWaypoint; public Material passedWaypoint; - public Material touchedWaypoint; + public Material grabbedWaypoint; public Material lockedWaypoint; public Material uploadedWaypoint; @@ -34,6 +33,7 @@ public class WaypointProperties : MonoBehaviour public Material unselectedPassedLine; public Material selectedGroundpointLine; public Material unselectedGroundpointLine; + public Material grabbedLine; public enum WaypointStatus { @@ -58,11 +58,9 @@ public enum WaypointStatus private Vector3 WorldScaleCurrent; private Vector3 WorldScaleActual; - public static GameObject controller_right; void Start() { - controller = GameObject.Find("Controller"); waypointStatus = WaypointStatus.STATIC; prevWaypointStatus = WaypointStatus.STATIC; @@ -71,7 +69,6 @@ void Start() World = GameObject.FindGameObjectWithTag("World"); WorldScaleInitial = World.transform.localScale; - controller_right = GameObject.Find("controller_right"); if (classPointer.prevPathPoint != null) { @@ -134,10 +131,15 @@ void InteractableObjectUngrabbed(object sender, VRTK.InteractableObjectEventArgs // change the color to un grabbed this.GetComponent().material = unpassedWaypoint; + LineProperties.material = selectedUnpassedLine; + + if (nextPoint != null) + { + nextPoint.waypointProperties.LineProperties.material = selectedUnpassedLine; + } // Trigger UpdateWaypoints call for drone. referenceDrone.DronePathUpdated(); - } //called if an object is grabbed @@ -150,7 +152,8 @@ void Grabbed(object sender, InteractableObjectEventArgs e) waypointStatus = WaypointStatus.GRABBED; // change the color to grabbed - this.GetComponent().material = touchedWaypoint; + this.GetComponent().material = grabbedWaypoint; + LineProperties.material = grabbedLine; if (classPointer.prevPathPoint != null) { @@ -162,6 +165,7 @@ void Grabbed(object sender, InteractableObjectEventArgs e) if (classPointer.nextPathPoint != null) { nextPoint = classPointer.nextPathPoint; + nextPoint.waypointProperties.LineProperties.material = grabbedLine; } // Start updating the line renderer. @@ -208,6 +212,8 @@ IEnumerator updateLine() public void UnSelected() { GetComponent().isGrabbable = false; + // Do not highlight waypoints when they are touched. + GetComponent().enabled = false; switch (waypointStatus) { @@ -225,7 +231,7 @@ public void UnSelected() LineProperties.material = unselectedUnpassedLine; break; case WaypointStatus.GRABBED: - this.GetComponent().material = touchedWaypoint; + this.GetComponent().material = grabbedWaypoint; LineProperties.material = unselectedUnpassedLine; break; case WaypointStatus.PASSED: @@ -242,6 +248,8 @@ public void UnSelected() public void Selected() { GetComponent().isGrabbable = true; + // Highlight waypoints when they are touched. + GetComponent().enabled = true; switch (waypointStatus) { @@ -258,7 +266,7 @@ public void Selected() LineProperties.material = selectedUnpassedLine; break; case WaypointStatus.GRABBED: - this.GetComponent().material = touchedWaypoint; + this.GetComponent().material = grabbedWaypoint; LineProperties.material = selectedUnpassedLine; break; case WaypointStatus.PASSED: @@ -302,6 +310,9 @@ public void LockWaypoint() Debug.Log("Invalid command. Please check logic."); } + // Do not highlight waypoints when they are touched. + GetComponent().enabled = false; + prevWaypointStatus = waypointStatus; waypointStatus = WaypointStatus.LOCKED; @@ -325,6 +336,9 @@ public void LockWaypoint() /// public void UnlockWaypoint() { + // Highlight waypoints when they are touched. + GetComponent().enabled = true; + waypointStatus = prevWaypointStatus; prevWaypointStatus = WaypointStatus.STATIC; GetComponent().isGrabbable = true; @@ -396,10 +410,6 @@ public void SetLine() ComputeWorldScaleActual(); LineProperties.startWidth = WorldScaleActual.y / 200; LineProperties.endWidth = WorldScaleActual.y / 200; - - // Code in master - // LineProperties.startWidth = controller.GetComponent().actualScale.y / 200; - // LineProperties.endWidth = controller.GetComponent().actualScale.y / 200; } } @@ -415,9 +425,6 @@ public void SetLineCollider() // Code in WaypointSystemUpgrade lineCollider.radius = WorldScaleActual.y / 50; - // Code in Master - // lineCollider.radius = controller.GetComponent().actualScale.y / 50; - lineCollider.center = Vector3.zero; lineCollider.transform.position = (endpoint + this.gameObject.transform.position) / 2; lineCollider.direction = 2; @@ -451,10 +458,6 @@ public void CreateGroundpoint() thisGroundpoint.transform.localScale = WorldScaleActual / 100; thisGroundpoint.transform.parent = World.transform; - // Code in master - // thisGroundpoint.transform.localScale = controller.GetComponent().actualScale / 100; - // thisGroundpoint.transform.parent = world.transform; - groundpointLine = thisGroundpoint.GetComponent(); } @@ -470,10 +473,6 @@ public void CreateWaypointIndicator() groundpointLine.startWidth = WorldScaleActual.y / 400; groundpointLine.endWidth = WorldScaleActual.y / 400; - // Code in master - // groundpointLine.startWidth = controller.GetComponent().actualScale.y / 400; - // groundpointLine.endWidth = controller.GetComponent().actualScale.y / 400; - if (referenceDrone.selected) { groundpointLine.material = selectedGroundpointLine; diff --git a/Assets/Scripts/WorldProperties.cs b/Assets/Scripts/WorldProperties.cs index 4b1c2a775..2fe98ade1 100644 --- a/Assets/Scripts/WorldProperties.cs +++ b/Assets/Scripts/WorldProperties.cs @@ -106,7 +106,7 @@ void Start() MeshEarthPrefab.transform.localRotation = Quaternion.Euler(MeshRotation); MeshEarthPrefab.transform.localScale = MeshScale; - //AddClipShader(this.transform); + AddClipShader(this.transform); } ///