Skip to content

Commit

Permalink
WIP7 v0.604
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonexo3 committed Aug 7, 2018
1 parent b2c357e commit df7f4c4
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 41 deletions.
64 changes: 32 additions & 32 deletions Assets/MapEditor.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions Assets/Scripts/Ozone SCMAP Code/Lua/Parser/LuaParser_Write.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion Assets/Scripts/Ozone SCMAP Code/Lua/SaveLua_Marker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
32 changes: 27 additions & 5 deletions Assets/Scripts/UI/Marker/MarkerObject.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MapLua;

Expand All @@ -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
Expand All @@ -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
{
Expand All @@ -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;
}
}
}
8 changes: 5 additions & 3 deletions Assets/Scripts/UI/Tools/Markers/MarkerSelectionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MarkerObject>().Owner.zoom * 0.1f);
}

Expand All @@ -494,7 +494,9 @@ public void AlighCameraMarker()
SelectedGameObjects[0].GetComponent<MarkerObject>().Tr.position = CameraControler.Current.Pivot.localPosition;
SelectedGameObjects[0].GetComponent<MarkerObject>().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<MarkerObject>().Tr.rotation = rot;

Expand Down

0 comments on commit df7f4c4

Please sign in to comment.