From 1f055792f5f298df756bf4b721e6cb580bf0cf0f Mon Sep 17 00:00:00 2001 From: Patrice Vignola Date: Sat, 15 Aug 2015 22:15:26 -0400 Subject: [PATCH] - Added the smooth rotation lerping when clicking on a node (to be tested visually) --- Assets/Scripts/NetworkingSphere.cs | 59 +++++++++++++++++++++++++++ Assets/Scripts/PersonDetailsPanel.cs | 11 +---- ProjectSettings/ProjectSettings.asset | 20 ++++----- ProjectSettings/ProjectVersion.txt | 2 +- 4 files changed, 69 insertions(+), 23 deletions(-) diff --git a/Assets/Scripts/NetworkingSphere.cs b/Assets/Scripts/NetworkingSphere.cs index 89bf30d..2076501 100644 --- a/Assets/Scripts/NetworkingSphere.cs +++ b/Assets/Scripts/NetworkingSphere.cs @@ -125,6 +125,9 @@ public class NetworkingSphere : MonoBehaviour node.Select(true); _selectedNode = node; + + // Testing to see how it looks and feels like + FocusOnNode(node); } private void AssignLinks(Level lvl) @@ -141,4 +144,60 @@ public class NetworkingSphere : MonoBehaviour peopleNodes[id2].AddLink(link); } } + + public void FocusOnNode(PersonNode node) + { + StopCoroutine("RotateTowardsNodeCoroutine"); + StartCoroutine("RotateTowardsNodeCoroutine", node); + + /* + Debug.Log(node.transform.eulerAngles); + + float xangle = (Mathf.Atan2(finalPos.z, finalPos.y) - Mathf.Atan2(initialPos.z, initialPos.y)) * Mathf.Rad2Deg; + + Debug.Log(node.transform.position); + transform.Rotate(new Vector3(90, 0, 0)); + //transform.rotation = transform.rotation * Quaternion.AngleAxis(xangle, Vector3.right); + Debug.Log(xangle); + float yAngle = (Mathf.Atan2(finalPos.x, finalPos.z) - Mathf.Atan2(node.transform.position.x, node.transform.position.z)) * Mathf.Rad2Deg; + Debug.Log(yAngle); + //transform.Rotate(new Vector3(xangle, yAngle, 0)); + + //float zAngle = (Mathf.Atan2(finalPos.y, finalPos.x) - Mathf.Atan2(initialPos.y, initialPos.x)) * Mathf.Rad2Deg; + + //transform.rotation = transform.rotation * Quaternion.AngleAxis(xangle, Vector3.right) * Quaternion.AngleAxis(yAngle, Vector3.up) * Quaternion.AngleAxis(zAngle, Vector3.forward); + */ + } + + private IEnumerator RotateTowardsNodeCoroutine(PersonNode node) + { + //Vector3 finalPos = new Vector3(0f, 0f, -SphereRadius); + + Quaternion initialRot = transform.localRotation; + + + transform.localRotation = Quaternion.identity; // Temporary hack for the game jam + + + Vector3 nodePos = node.transform.position; + + Vector3 longDir = nodePos; + longDir.y = 0; + + float longitude = Vector3.Angle(-Vector3.forward, longDir) * (longDir.x < 0 ? -1 : 1); + float latitude = Mathf.Asin(nodePos.normalized.y) * Mathf.Rad2Deg; + + Quaternion finalRot = Quaternion.AngleAxis(-latitude, Vector3.right) * Quaternion.AngleAxis(longitude, Vector3.up); + + float ratio = 0f; + + while (ratio < 1f) + { + ratio += Time.deltaTime / 1.5f; + + transform.localRotation = Quaternion.Lerp(initialRot, finalRot, Mathf.SmoothStep(0f, 1f, ratio)); + + yield return null; + } + } } diff --git a/Assets/Scripts/PersonDetailsPanel.cs b/Assets/Scripts/PersonDetailsPanel.cs index 35c235e..3668009 100644 --- a/Assets/Scripts/PersonDetailsPanel.cs +++ b/Assets/Scripts/PersonDetailsPanel.cs @@ -29,7 +29,7 @@ public class PersonDetailsPanel : MonoBehaviour, IObserver { _model.UnSubscribe(this); } - + _node = node; _model = node.Model; @@ -78,15 +78,6 @@ public class PersonDetailsPanel : MonoBehaviour, IObserver friendPicture.rectTransform.anchorMax = new Vector2(0.26f, (1f - height * i)); friendPicture.rectTransform.offsetMin = Vector2.zero; friendPicture.rectTransform.offsetMax = Vector2.zero; - - if (i == _model.FriendList.Count - 1) - { - Debug.Log(friendPicture.rectTransform.position); - } - else if (i == 0) - { - Debug.Log(friendPicture.rectTransform.position); - } } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 84deb8f..dd32a95 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,14 +3,17 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 7 + serializedVersion: 6 AndroidProfiler: 0 defaultScreenOrientation: 4 targetDevice: 2 + targetGlesGraphics: -1 + targetIOSGraphics: -1 targetResolution: 0 accelerometerFrequency: 60 companyName: DefaultCompany productName: DeathBook + cloudProjectId: defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_ShowUnitySplashScreen: 1 @@ -23,6 +26,7 @@ PlayerSettings: m_ActiveColorSpace: 0 m_MTRendering: 1 m_MobileMTRendering: 0 + m_UseDX11: 1 m_Stereoscopic3D: 0 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 @@ -77,7 +81,6 @@ PlayerSettings: metroEnableIndependentInputSource: 0 metroEnableLowLatencyPresentationAPI: 0 xboxOneDisableKinectGpuReservation: 0 - virtualRealitySupported: 0 productGUID: 402278fad2098ce4eab29439139ae9ad AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 9 @@ -120,7 +123,6 @@ PlayerSettings: iOSLaunchScreenCustomXibPath: AndroidTargetDevice: 0 AndroidSplashScreenScale: 0 - androidSplashScreen: {fileID: 0} AndroidKeystoreName: AndroidKeyaliasName: AndroidTVCompatibility: 1 @@ -134,7 +136,6 @@ PlayerSettings: resolutionDialogBanner: {fileID: 0} m_BuildTargetIcons: [] m_BuildTargetBatching: [] - m_BuildTargetGraphicsAPIs: [] webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} actionOnDotNetUnhandledException: 1 @@ -196,7 +197,6 @@ PlayerSettings: ps4ApplicationParam2: 0 ps4ApplicationParam3: 0 ps4ApplicationParam4: 0 - ps4GarlicHeapSize: 2048 ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ ps4pnSessions: 1 ps4pnPresence: 1 @@ -339,7 +339,8 @@ PlayerSettings: blackberrySquareSplashScreen: {fileID: 0} tizenProductDescription: tizenProductURL: - tizenSigningProfileName: + tizenCertificatePath: + tizenCertificatePassword: tizenGPSPermissions: 0 tizenMicrophonePermissions: 0 stvDeviceAddress: @@ -397,9 +398,4 @@ PlayerSettings: - WebGL::template WebGL::emscriptenArgs: WebGL::template: APPLICATION:Default - firstStreamedSceneWithResources: 0 - cloudProjectId: - projectId: - projectName: - organizationId: - cloudEnabled: 0 + firstStreamedLevelWithResources: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 78b2941..802c8ce 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.1.1f1 +m_EditorVersion: 5.0.2f1 m_StandardAssetsVersion: 0