diff --git a/Assets/MapEditor.unity b/Assets/MapEditor.unity index 8b96f631..3fad6af0 100644 --- a/Assets/MapEditor.unity +++ b/Assets/MapEditor.unity @@ -43409,7 +43409,7 @@ Camera: serializedVersion: 2 m_Bits: 2560 m_RenderingPath: 1 - m_TargetTexture: {fileID: 1952646852} + m_TargetTexture: {fileID: 1024254469} m_TargetDisplay: 0 m_TargetEye: 3 m_HDR: 0 @@ -81188,6 +81188,37 @@ CanvasRenderer: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1023302967} m_CullTransparentMesh: 0 +--- !u!84 &1024254469 +RenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_Width: 256 + m_Height: 256 + m_AntiAliasing: 1 + m_DepthFormat: 1 + m_ColorFormat: 0 + m_MipMap: 0 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 --- !u!114 &1024880546 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 114181087517900934, guid: 30131436e7e207b4f82d0dedb78a89a4, @@ -150784,37 +150815,6 @@ CanvasRenderer: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1949818971} m_CullTransparentMesh: 0 ---- !u!84 &1952646852 -RenderTexture: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: - m_ImageContentsHash: - serializedVersion: 2 - Hash: 00000000000000000000000000000000 - m_ForcedFallbackFormat: 4 - m_DownscaleFallback: 0 - m_Width: 256 - m_Height: 256 - m_AntiAliasing: 1 - m_DepthFormat: 1 - m_ColorFormat: 0 - m_MipMap: 0 - m_GenerateMips: 1 - m_SRGB: 0 - m_UseDynamicScale: 0 - m_BindMS: 0 - m_TextureSettings: - serializedVersion: 2 - m_FilterMode: 1 - m_Aniso: 0 - m_MipBias: 0 - m_WrapU: 1 - m_WrapV: 1 - m_WrapW: 1 - m_Dimension: 2 - m_VolumeDepth: 1 --- !u!1 &1955277115 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Ozone SCMAP Code/Lua/Parser/LuaParser_Write.cs b/Assets/Scripts/Ozone SCMAP Code/Lua/Parser/LuaParser_Write.cs index 8f8172b5..4b8db287 100644 --- a/Assets/Scripts/Ozone SCMAP Code/Lua/Parser/LuaParser_Write.cs +++ b/Assets/Scripts/Ozone SCMAP Code/Lua/Parser/LuaParser_Write.cs @@ -141,6 +141,8 @@ public static string Vector3ToLua(string key, Vector3 value, bool NextLine = tru // Functions #region Functions + const string FloatToStringFormat = "G"; + public static string RectangleToLua(string key, Rect value, bool NextLine = true) { return key + SetValue + "RECTANGLE( " + value.x.ToString() + ", " + value.y.ToString() + ", " + value.width.ToString() + ", " + value.height.ToString() + " )" + GetNextValue(NextLine); @@ -151,6 +153,19 @@ public static string Vector3ToLuaFunction(string key, Vector3 value, bool NextLi return key + SetValue + "VECTOR3( " + value.x.ToString() + ", " + value.y.ToString() + ", " + value.z.ToString() + " )" + GetNextValue(NextLine); } + public static string Vector3ToLuaFunctionPrecision(string key, Vector3 value, bool NextLine = true, int Precision = 0) + { + string FormatString = "0"; + if (Precision > 0) + FormatString += "."; + + for (int i = 0; i < Precision; i++) + FormatString += "#"; + + return key + SetValue + "VECTOR3( " + value.x.ToString(FormatString) + ", " + value.y.ToString(FormatString) + ", " + value.z.ToString(FormatString) + " )" + GetNextValue(NextLine); + } + + public static string StringToLuaFunction(string key, string value, bool NextLine = true) { return key + SetValue + "STRING( " + Coma + value + Coma + " )" + GetNextValue(NextLine); diff --git a/Assets/Scripts/Ozone SCMAP Code/Lua/SaveLua_Marker.cs b/Assets/Scripts/Ozone SCMAP Code/Lua/SaveLua_Marker.cs index 3ce1ded1..97cff28b 100644 --- a/Assets/Scripts/Ozone SCMAP Code/Lua/SaveLua_Marker.cs +++ b/Assets/Scripts/Ozone SCMAP Code/Lua/SaveLua_Marker.cs @@ -762,7 +762,11 @@ public void SaveMarkerValues(LuaParser.Creator LuaFile) } //Transform - LuaFile.AddLine(LuaParser.Write.Vector3ToLuaFunction(LuaParser.Write.PropertieToLua(KEY_ORIENTATION), orientation)); + if(MarkerType == MarkerTypes.CameraInfo) + LuaFile.AddLine(LuaParser.Write.Vector3ToLuaFunctionPrecision(LuaParser.Write.PropertieToLua(KEY_ORIENTATION), orientation, true, 6)); + else + LuaFile.AddLine(LuaParser.Write.Vector3ToLuaFunction(LuaParser.Write.PropertieToLua(KEY_ORIENTATION), orientation)); + LuaFile.AddLine(LuaParser.Write.Vector3ToLuaFunction(LuaParser.Write.PropertieToLua(KEY_POSITION), position)); LuaFile.CloseTab(LuaParser.Write.EndBracketNext); diff --git a/Assets/Scripts/UI/Marker/MarkerObject.cs b/Assets/Scripts/UI/Marker/MarkerObject.cs index 7b11c57a..3f9f4a2c 100644 --- a/Assets/Scripts/UI/Marker/MarkerObject.cs +++ b/Assets/Scripts/UI/Marker/MarkerObject.cs @@ -1,5 +1,4 @@ using System.Collections; -using System.Collections.Generic; using UnityEngine; using MapLua; @@ -14,8 +13,20 @@ public static Quaternion ScmapRotToMarkerRot(Vector3 rot, SaveLua.Marker.MarkerT { if (Type == SaveLua.Marker.MarkerTypes.CameraInfo) { + //X > Height + //Y > Direction rot = new Vector3(rot.y, -rot.x, 0) * Mathf.Rad2Deg; - Debug.Log(rot); + + //Clamp unproper rotations + while (rot.x < -180) + rot.x += 360; + while (rot.x >= 360) + rot.x -= 360; + rot.x = Mathf.Clamp(rot.x, 0, 180); + + // Invert rotation and offset it by 90 degree + rot.x = 90f - rot.x; + return Quaternion.Euler(rot); } else @@ -32,11 +43,16 @@ public static Vector3 MarkerRotToScmapRot(Quaternion Rot, SaveLua.Marker.MarkerT Euler.z = 0; while (Euler.x < 0) - Euler.x += 360; + Euler.x += 360f; + + Euler.x = 90f - Euler.x; Euler = new Vector3(-Euler.y, Euler.x, 0); - Debug.Log(Euler); - return Euler * Mathf.Deg2Rad; + + Euler *= Mathf.Deg2Rad; + Euler.x = Round(Euler.x); + Euler.y = Round(Euler.y); + return Euler; } else { @@ -45,5 +61,11 @@ public static Vector3 MarkerRotToScmapRot(Quaternion Rot, SaveLua.Marker.MarkerT return Euler * Mathf.Deg2Rad; } } + + const float Rounding = 1000000f; + static float Round(float value) + { + return Mathf.Round(value * Rounding) / Rounding; + } } } diff --git a/Assets/Scripts/UI/Tools/Markers/MarkerSelectionOptions.cs b/Assets/Scripts/UI/Tools/Markers/MarkerSelectionOptions.cs index d1e8ddd7..9302d346 100644 --- a/Assets/Scripts/UI/Tools/Markers/MarkerSelectionOptions.cs +++ b/Assets/Scripts/UI/Tools/Markers/MarkerSelectionOptions.cs @@ -479,8 +479,8 @@ public void ToggleCameraSync() public void FocusCameraMarker() { Vector3 FocusPos = SelectedGameObjects[0].transform.position; - Quaternion FocusRot = Quaternion.Euler(Vector3.up * -180) * SelectedGameObjects[0].transform.rotation * Quaternion.Euler(Vector3.right * -90); - + //Quaternion FocusRot = Quaternion.Euler(Vector3.up * -180) * SelectedGameObjects[0].transform.rotation * Quaternion.Euler(Vector3.right * -90); + Quaternion FocusRot = Quaternion.LookRotation(-SelectedGameObjects[0].transform.forward, SelectedGameObjects[0].transform.up); CameraControler.FocusCamera(FocusPos, FocusRot, SelectedGameObjects[0].GetComponent().Owner.zoom * 0.1f); } @@ -494,7 +494,9 @@ public void AlighCameraMarker() SelectedGameObjects[0].GetComponent().Tr.position = CameraControler.Current.Pivot.localPosition; SelectedGameObjects[0].GetComponent().Owner.zoom = CameraControler.GetCurrentZoom(); - Quaternion rot = Quaternion.Euler(Vector3.up * 180) * CameraControler.Current.Pivot.localRotation * Quaternion.Euler(Vector3.right * 90); + + Quaternion rot = Quaternion.LookRotation(-CameraControler.Current.Pivot.forward, CameraControler.Current.Pivot.up); + //Quaternion rot = Quaternion.Euler(Vector3.up * 180) * CameraControler.Current.Pivot.localRotation * Quaternion.Euler(Vector3.right * 90); SelectedGameObjects[0].GetComponent().Tr.rotation = rot;