legacy-벽그리기 관련 클래스 및 프리팹 삭제
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b81a68959a265e04896b05dc65cf3bf9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,214 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
//TODO::areabox가 아니라 TwinObject를 대상으로 동작하도록 수정
|
||||
public class ObjectDistanceLine : MonoBehaviour
|
||||
{
|
||||
private Vector3 centerPoint = new();
|
||||
private Vector3[] edges = new Vector3[4];
|
||||
|
||||
private LineRenderer[] lineRenderers = new LineRenderer[4];
|
||||
private int[] distances = new int[4];
|
||||
private Vector3[] hits = new Vector3[4];
|
||||
[SerializeField]
|
||||
private float thickness;
|
||||
|
||||
private int rot;
|
||||
private Dictionary<Vector3, Vector3> dirTable = new();
|
||||
|
||||
TwinObject target;
|
||||
HashSet<TwinObject> targets = new();
|
||||
public event Action onTargetEvent;
|
||||
public event Action onTargetMissing;
|
||||
public event Action<Vector3, int, int> onLineUpdate;
|
||||
public override void AfterAwake()
|
||||
{
|
||||
//var labelCanvas;
|
||||
var lineMat = Resources.Load<Material>("Materials/Mat_LineRender");
|
||||
for (int i = 0; i < lineRenderers.Length; i++)
|
||||
{
|
||||
lineRenderers[i] = new GameObject("DistanceLine").AddComponent<LineRenderer>();
|
||||
lineRenderers[i].transform.SetParent(transform, true);
|
||||
lineRenderers[i].material = lineMat;
|
||||
lineRenderers[i].positionCount = 2;
|
||||
lineRenderers[i].startWidth = thickness;
|
||||
lineRenderers[i].endWidth = thickness;
|
||||
}
|
||||
//onTargetEvent += ()=>labelCanvas.panel_objectdistancelabellist.SetActive(true);
|
||||
//onTargetMissing += ()=>labelCanvas.panel_objectdistancelabellist.SetActive(false);
|
||||
//onLineUpdate += labelCanvas.panel_objectdistancelabellist.DistanceLabelsSetting;
|
||||
}
|
||||
|
||||
public void SetTarget(TwinObject target)
|
||||
{
|
||||
if (target is Wall || target is WallGroup)
|
||||
return;
|
||||
this.target = target;
|
||||
targets.Add(target);
|
||||
gameObject.SetActive(true);
|
||||
onTargetEvent?.Invoke();
|
||||
}
|
||||
|
||||
private void EdgePoints()
|
||||
{
|
||||
var size = target.physics.areabox.bounds.size;
|
||||
edges[0] = centerPoint + EdgePointCalculate(-size.x, -size.z, centerPoint);
|
||||
edges[1] = centerPoint + EdgePointCalculate(size.x, -size.z, centerPoint);
|
||||
edges[2] = centerPoint + EdgePointCalculate(size.x, size.z, centerPoint);
|
||||
edges[3] = centerPoint + EdgePointCalculate(-size.x, size.z, centerPoint);
|
||||
}
|
||||
|
||||
private void CenterPoints()
|
||||
{
|
||||
var size = target.physics.areabox.bounds.size;
|
||||
edges[0] = centerPoint + EdgePointCalculate(-size.x, 0f, centerPoint);
|
||||
edges[1] = centerPoint + EdgePointCalculate(size.x, 0f, centerPoint);
|
||||
edges[2] = centerPoint + EdgePointCalculate(0f, -size.z, centerPoint);
|
||||
edges[3] = centerPoint + EdgePointCalculate(0f, size.z, centerPoint);
|
||||
}
|
||||
private Vector3 EdgePointCalculate(float xValue, float zValue, Vector3 center)
|
||||
{
|
||||
//대각선의 길이,
|
||||
//중점길이
|
||||
var point = center + (new Vector3(xValue, 0, zValue) * 0.5f);
|
||||
var length = Vector3.Distance(point, center);
|
||||
var dir = (point - center).normalized * length;
|
||||
//var pos = RotateVector3(dir, rot);
|
||||
var pos = Quaternion.AngleAxis(rot, Vector3.up) * dir;
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void Off()
|
||||
{
|
||||
targets.Clear();
|
||||
onTargetMissing?.Invoke();
|
||||
}
|
||||
|
||||
void LineRenderSetActive(bool isActive)
|
||||
{
|
||||
foreach(var line in lineRenderers)
|
||||
{
|
||||
line.enabled = isActive;
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (target == null || targets.Count >1)
|
||||
{
|
||||
Off();
|
||||
LineRenderSetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
//if (areabox == null)
|
||||
// return;
|
||||
//Distance가 4개 모두 0이면 return?
|
||||
LineRenderSetActive(true);
|
||||
rot = Mathf.RoundToInt(target.physics.areabox.transform.localEulerAngles.y);
|
||||
centerPoint = new Vector3(target.physics.areabox.bounds.center.x, 0, target.physics.areabox.bounds.center.z);
|
||||
|
||||
var angle = rot % 90f;
|
||||
if (Mathf.Approximately(angle, 0f))
|
||||
CenterPoints();
|
||||
else
|
||||
EdgePoints();
|
||||
|
||||
var xOrder = edges.OrderBy(l => l.x);
|
||||
var zOrder = edges.OrderBy(l => l.z);
|
||||
dirTable.Clear();
|
||||
dirTable.TryAdd(xOrder.ElementAt(0), Vector3.left);
|
||||
dirTable.TryAdd(xOrder.ElementAt(3), Vector3.right);
|
||||
dirTable.TryAdd(zOrder.ElementAt(0), Vector3.back);
|
||||
dirTable.TryAdd(zOrder.ElementAt(3), Vector3.forward);
|
||||
|
||||
for (int i = 0; i < edges.Length; i++)
|
||||
{
|
||||
//var dir = Dir(dirTable[edges[i]]);
|
||||
var dir = dirTable[edges[i]];
|
||||
if (Physics.Raycast(edges[i], dir, out RaycastHit hit, Mathf.Infinity))
|
||||
{
|
||||
hits[i] = hit.point;
|
||||
}
|
||||
else
|
||||
{
|
||||
hits[i] = edges[i];
|
||||
}
|
||||
distances[i] = Mathf.RoundToInt(Vector3.Distance(hits[i], edges[i]) * 1000f);
|
||||
|
||||
lineRenderers[i].SetPosition(0, edges[i]);
|
||||
lineRenderers[i].SetPosition(1, hits[i]);
|
||||
//3방향중 점중 가장 짧은거
|
||||
|
||||
var pos = DistanceTextPos(edges[i], hits[i]);
|
||||
if (Mathf.Abs(pos.y) == Mathf.Infinity || float.IsNaN(pos.y))
|
||||
continue;
|
||||
onLineUpdate?.Invoke(pos, i, distances[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 DistanceTextPos(Vector3 edge, Vector3 hit)
|
||||
{
|
||||
var x = Screen.width;
|
||||
var y = Screen.height;
|
||||
|
||||
var hitpoint = Camera.main.WorldToScreenPoint(hit);
|
||||
var edgePoint = Camera.main.WorldToScreenPoint(edge);
|
||||
|
||||
//카메라 끝점 edge와 hit 사이;
|
||||
|
||||
//기울기 가져온다
|
||||
var m = (hitpoint.y - edgePoint.y) / (hitpoint.x - edgePoint.x);
|
||||
if (hitpoint.y > y)
|
||||
{
|
||||
var yPos = y;
|
||||
var xPos = ((yPos - edgePoint.y) / m) + edgePoint.x;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
else if (hitpoint.y < 0)
|
||||
{
|
||||
var yPos = 0;
|
||||
var xPos = ((yPos - edgePoint.y) / m) + edgePoint.x;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
|
||||
if (hitpoint.x > x)
|
||||
{
|
||||
var xPos = x;
|
||||
var yPos = (m * (xPos - edgePoint.x)) + edgePoint.y;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
else if (hitpoint.x < 0)
|
||||
{
|
||||
var xPos = 0;
|
||||
var yPos = (m * (xPos - edgePoint.x)) + edgePoint.y;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
|
||||
var center = (hitpoint + edgePoint) * 0.5f;
|
||||
return center;
|
||||
}
|
||||
|
||||
void Gizmo()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// for (int i = 0; i < edges.Length; ++i)
|
||||
// {
|
||||
// Gizmos.DrawSphere(edges[i].pos, 0.1f);
|
||||
// }
|
||||
|
||||
// for (int i = 0; i < hits.Length; ++i)
|
||||
// {
|
||||
// var dir = Dir(dirTable[edges[i]]);
|
||||
// Handles.color = Color.yellow;
|
||||
// Handles.DrawLine(edges[i].pos, hits[i], 1);
|
||||
// Gizmos.DrawRay(edges[i].pos, dir * 10f);
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfac6b2ea97a0274787f0bf0d086a76d
|
||||
@@ -1,98 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &773014853897234323
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5307351691218631136}
|
||||
- component: {fileID: 406005293515689265}
|
||||
- component: {fileID: 2719472009069581452}
|
||||
- component: {fileID: 6042705491278776367}
|
||||
m_Layer: 0
|
||||
m_Name: BoxHighLight
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5307351691218631136
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 773014853897234323}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.944, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &406005293515689265
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 773014853897234323}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &2719472009069581452
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 773014853897234323}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: fdfc42a87e616734cb4a503399904be2, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
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
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!114 &6042705491278776367
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 773014853897234323}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 450f3092679e926458cec39db26d9f4d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c726e9bb7adcf674890d0b67adea3991
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,206 +0,0 @@
|
||||
using RTG;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using XRLib;
|
||||
using Studio.UI;
|
||||
|
||||
namespace Studio.RuntimeGizmo
|
||||
{
|
||||
public class GizmoController : MonoBehaviour, ISingle
|
||||
{
|
||||
public enum GizmoType
|
||||
{
|
||||
Move,
|
||||
Rotate,
|
||||
Scale,
|
||||
Universal,
|
||||
}
|
||||
|
||||
public bool visible;
|
||||
HashSet<GameObject> gizmoTargets = new();
|
||||
ObjectTransformGizmo moveGizmo;
|
||||
ObjectTransformGizmo rotateGizmo;
|
||||
ObjectTransformGizmo scaleGizmo;
|
||||
ObjectTransformGizmo universalGizmo;
|
||||
|
||||
GizmoType currentType;
|
||||
GizmoType inputType;
|
||||
|
||||
public event Action onGizmoDragEnd;
|
||||
public override void AfterAwake()
|
||||
{
|
||||
moveGizmo = RTGizmosEngine.Get.CreateObjectMoveGizmo();
|
||||
moveGizmo.Gizmo.PostDragUpdate += GizmoDragUpdate;
|
||||
moveGizmo.Gizmo.PostDragEnd += GizmoDragEnd;
|
||||
rotateGizmo = RTGizmosEngine.Get.CreateObjectRotationGizmo();
|
||||
rotateGizmo.Gizmo.PostDragUpdate += GizmoDragUpdate;
|
||||
rotateGizmo.Gizmo.PostDragEnd += GizmoDragEnd;
|
||||
scaleGizmo = RTGizmosEngine.Get.CreateObjectScaleGizmo();
|
||||
universalGizmo = RTGizmosEngine.Get.CreateObjectUniversalGizmo();
|
||||
|
||||
moveGizmo.SetTargetObjects(gizmoTargets);
|
||||
rotateGizmo.SetTargetObjects(gizmoTargets);
|
||||
scaleGizmo.SetTargetObjects(gizmoTargets);
|
||||
universalGizmo.SetTargetObjects(gizmoTargets);
|
||||
|
||||
SetGizmosActive(false);
|
||||
currentGizmo = moveGizmo;
|
||||
}
|
||||
private void GizmoDragUpdate(Gizmo gizmo, int t)
|
||||
{
|
||||
foreach (var target in gizmoTargets)
|
||||
{
|
||||
if (target.TryGetComponent<WallGroup>(out WallGroup test))
|
||||
{
|
||||
test.LineResetting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GizmoDragEnd(Gizmo gizmo, int t)
|
||||
{
|
||||
foreach (var target in gizmoTargets)
|
||||
{
|
||||
if (target.TryGetComponent<WallGroup>(out WallGroup test))
|
||||
{
|
||||
onGizmoDragEnd?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Attach(TwinObject target)
|
||||
{
|
||||
gizmoTargets.Add(target.gameObject);
|
||||
}
|
||||
|
||||
public void Detach(TwinObject target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gizmoTargets.Remove(target.gameObject);
|
||||
}
|
||||
|
||||
public void Add(TwinObject[] targets)
|
||||
{
|
||||
foreach (var t in targets)
|
||||
gizmoTargets.Add(t.gameObject);
|
||||
}
|
||||
|
||||
//public void Clear(TwinObject to)
|
||||
//{
|
||||
// gizmoTargets.Clear();
|
||||
// SetGizmosActive(false);
|
||||
//}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
{
|
||||
inputType = GizmoType.Move;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.W))
|
||||
{
|
||||
inputType = GizmoType.Rotate;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.E))
|
||||
{
|
||||
inputType = GizmoType.Scale;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
inputType = GizmoType.Universal;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
//FindSingle<Canvas_EditorView>().panel_objecttool.RemoveObject();
|
||||
}
|
||||
|
||||
if (!visible || gizmoTargets.Count == 0)
|
||||
{
|
||||
SetGizmosActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentGizmo != null)
|
||||
{
|
||||
currentGizmo.Gizmo.SetEnabled(true);
|
||||
currentGizmo.RefreshPositionAndRotation();
|
||||
}
|
||||
}
|
||||
|
||||
if (inputType == currentType)
|
||||
return;
|
||||
|
||||
GizmoChange();
|
||||
}
|
||||
|
||||
ObjectTransformGizmo currentGizmo;
|
||||
void GizmoChange()
|
||||
{
|
||||
currentType = inputType;
|
||||
SetGizmosActive(false);
|
||||
switch (currentType)
|
||||
{
|
||||
case GizmoType.Move:
|
||||
currentGizmo = moveGizmo;
|
||||
break;
|
||||
case GizmoType.Rotate:
|
||||
currentGizmo = rotateGizmo;
|
||||
break;
|
||||
case GizmoType.Scale:
|
||||
currentGizmo = scaleGizmo;
|
||||
break;
|
||||
case GizmoType.Universal:
|
||||
currentGizmo = universalGizmo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGizmosActive(bool value)
|
||||
{
|
||||
moveGizmo.Gizmo.SetEnabled(value);
|
||||
rotateGizmo.Gizmo.SetEnabled(value);
|
||||
scaleGizmo.Gizmo.SetEnabled(value);
|
||||
universalGizmo.Gizmo.SetEnabled(value);
|
||||
}
|
||||
|
||||
internal void ActiveMoveGizmo()
|
||||
{
|
||||
currentGizmo = moveGizmo;
|
||||
inputType = GizmoType.Move;
|
||||
//inputType = currentType;
|
||||
}
|
||||
|
||||
internal void ActiveRotateGizmo()
|
||||
{
|
||||
currentGizmo = rotateGizmo;
|
||||
inputType = GizmoType.Rotate;
|
||||
//inputType = currentType;
|
||||
}
|
||||
|
||||
internal void ActiveScaleGizmo()
|
||||
{
|
||||
currentGizmo = scaleGizmo;
|
||||
inputType = GizmoType.Scale;
|
||||
//inputType = currentType;
|
||||
}
|
||||
|
||||
internal void ActiveUniversalGizmo()
|
||||
{
|
||||
currentGizmo = universalGizmo;
|
||||
currentType = GizmoType.Universal;
|
||||
}
|
||||
|
||||
internal bool GetGizmoHover()
|
||||
{
|
||||
return currentGizmo.Gizmo.IsHovered;
|
||||
}
|
||||
internal bool isControlling(TwinObject selectedObject)
|
||||
{
|
||||
return gizmoTargets.Contains(selectedObject.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88cb56ffcef128649a12bf8dddf5e78c
|
||||
@@ -1,54 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Pool;
|
||||
using Studio.Interfaces;
|
||||
using static Studio.Wall;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class BoxHighLighter : MonoBehaviour, IPooledObject
|
||||
{
|
||||
private Material material;
|
||||
private MeshRenderer meshRenderer;
|
||||
|
||||
public IObjectPool<Component> Pool { get; set; }
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
Pool.Release(this);
|
||||
}
|
||||
//TODO::
|
||||
public override void AfterAwake()
|
||||
{
|
||||
material = Resources.Load<Material>("Materials/Mat_BoxHighLight");
|
||||
meshRenderer = GetComponent<MeshRenderer>();
|
||||
meshRenderer.material = material;
|
||||
}
|
||||
|
||||
private void WallBoxSize(Wall wall)
|
||||
{
|
||||
var ySize = wall.meshfilter.mesh.bounds.size.y;
|
||||
|
||||
var start = wall.n_GonPoints[(int)VertexPoint.LeftCenter];
|
||||
var end = wall.n_GonPoints[(int)VertexPoint.RightCenter];
|
||||
var zSize = Vector3.Distance(start, end);
|
||||
//zfighting¶§¹®¿¡ 0.01¾¿ ´õÇØÁÜ
|
||||
transform.localPosition = Vector3.up * (ySize * 0.5f);
|
||||
transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
|
||||
transform.localScale = new Vector3(0.11f, ySize + 0.01f, zSize + 0.01f);
|
||||
}
|
||||
|
||||
public void TwinObjectBoxSize(TwinObject twinObject)
|
||||
{
|
||||
if(twinObject is Wall)
|
||||
{
|
||||
WallBoxSize((Wall)twinObject);
|
||||
return;
|
||||
}
|
||||
|
||||
var collider = twinObject.GetComponent<BoxCollider>();
|
||||
transform.localScale = collider.size;
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 450f3092679e926458cec39db26d9f4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c98df20933569634ab50df6409b85478
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c7ec05ae4c6c4b46aac9febf2dd8ed5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,62 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Pool;
|
||||
using Studio.Interfaces;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public class Room
|
||||
{
|
||||
public List<LinePoint> points = new();
|
||||
public List<Vector3> positions = new();
|
||||
public LinePoint firstPoints;
|
||||
public void AddLinePoint(LinePoint point)
|
||||
{
|
||||
if (points.Contains(point))
|
||||
return;
|
||||
points.Add(point);
|
||||
}
|
||||
|
||||
public void RemoveLinePoint(LinePoint point)
|
||||
{
|
||||
points.Remove(point);
|
||||
}
|
||||
|
||||
public bool IsContains(LinePoint point)
|
||||
{
|
||||
return points.Contains(point);
|
||||
}
|
||||
}
|
||||
|
||||
public class Floor : MonoBehaviour,IPooledObject
|
||||
{
|
||||
public MeshFilter meshfilter;
|
||||
private MeshRenderer mr;
|
||||
|
||||
public float height = 2;
|
||||
|
||||
private Room room;
|
||||
public Vector3[] vertexPosition;
|
||||
|
||||
public IObjectPool<Component> Pool { get; set; }
|
||||
|
||||
//첫생성할때 이벤트
|
||||
public void Set(Room room)
|
||||
{
|
||||
meshfilter = GetComponent<MeshFilter>();
|
||||
mr = GetComponent<MeshRenderer>();
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
//재 배열 할때 이벤트
|
||||
public void ReSetting(Room room)
|
||||
{
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb4aefcee2a6b5346b2363a25b06984c
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Pool;
|
||||
using UnityEngine.UIElements;
|
||||
using Studio;
|
||||
using static UnityEngine.Rendering.DebugUI;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class LinePoint : MonoBehaviour
|
||||
{
|
||||
public Vector3 position { get { return transform.position; } }
|
||||
public Color color;
|
||||
private MeshRenderer mr;
|
||||
private BoxCollider coll;
|
||||
public HashSet<LinePoint> connectPoints = new();
|
||||
public bool visited;
|
||||
public override void AfterAwake()
|
||||
{
|
||||
mr = GetComponent<MeshRenderer>();
|
||||
coll = GetComponent<BoxCollider>();
|
||||
}
|
||||
public void Displayable(bool value)
|
||||
{
|
||||
mr.enabled = value;
|
||||
coll.enabled = value;
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
public void Disconnect(LinePoint point)
|
||||
{
|
||||
connectPoints.Remove(point);
|
||||
}
|
||||
|
||||
public void Connect(LinePoint point)
|
||||
{
|
||||
connectPoints.Add(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 161e164c5c3c5034c9e7287ee5f92424
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,183 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TriLibCore.Dae.Schema;
|
||||
using UnityEngine;
|
||||
using XRLib;
|
||||
|
||||
namespace Studio.Manage
|
||||
{
|
||||
public class MeshCreator : Manager
|
||||
{
|
||||
Vector3[] vertices;
|
||||
int[] triangles;
|
||||
public Vector3[] n_GonPoints ;
|
||||
private MeshFilter meshfilter;
|
||||
//private Vector3 offset = Vector3.zero;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void MeshDeformer<T>(HashSet<T> type)
|
||||
{
|
||||
if(type is HashSet<Floor>)
|
||||
{
|
||||
var floors = type as HashSet<Floor>;
|
||||
foreach(var floor in floors)
|
||||
{
|
||||
MeshDeformer(floor.meshfilter, floor.vertexPosition, 0.1f);
|
||||
}
|
||||
}
|
||||
if(type is HashSet<Wall>)
|
||||
{
|
||||
var walls =type as HashSet<Wall>;
|
||||
foreach (var wall in walls)
|
||||
{
|
||||
wall.SetMeshVertice();
|
||||
MeshDeformer(wall.meshfilter, wall.n_GonPoints, wall.height, wall.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void MeshDeformer(MeshFilter filter, Vector3[] positions,float height ,Vector3 offset= default(Vector3))
|
||||
{
|
||||
meshfilter = filter;
|
||||
//this.offset = offset;
|
||||
n_GonPoints = positions;
|
||||
var polygon = positions.Length;
|
||||
SetMeshData(polygon, height);
|
||||
MeshRefresh();
|
||||
}
|
||||
private void SetMeshData(int polygon, float height)
|
||||
{
|
||||
/////* -------------------- <20>ظ<EFBFBD> -------------------- */
|
||||
vertices = new Vector3[(polygon + 1) + (polygon + 1) + (polygon * 4) - (polygon * 2)];
|
||||
|
||||
var sum = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < n_GonPoints.Length; i++)
|
||||
{
|
||||
sum += n_GonPoints[i];
|
||||
}
|
||||
|
||||
var center = sum / n_GonPoints.Length;
|
||||
vertices[0] = new Vector3(center.x, -height * 0.5f, center.z) /*+ offset*/;
|
||||
for (int i = 1; i <= polygon; i++)
|
||||
{
|
||||
vertices[i]
|
||||
= new Vector3(n_GonPoints[i - 1].x, -height * 0.5f, n_GonPoints[i - 1].z) /*+ offset*/;
|
||||
}
|
||||
// 4
|
||||
triangles = new int[(3 * polygon) + (3 * polygon) + (6 * polygon)];
|
||||
for (int i = 0; i < polygon - 1; i++)
|
||||
{
|
||||
triangles[i * 3] = 0;
|
||||
triangles[i * 3 + 1] = i + 2;
|
||||
triangles[i * 3 + 2] = i + 1;
|
||||
}
|
||||
|
||||
triangles[3 * polygon - 3] = 0;
|
||||
triangles[3 * polygon - 2] = 1;
|
||||
triangles[3 * polygon - 1] = polygon;
|
||||
|
||||
/* -------------------- <20><><EFBFBD><EFBFBD> -------------------- */
|
||||
|
||||
int vIdx = polygon + 1;
|
||||
vertices[vIdx++] = new Vector3(center.x, height * 0.5f, center.z) /*+ offset*/;
|
||||
for (int i = 1; i <= polygon; i++)
|
||||
{
|
||||
vertices[vIdx++]
|
||||
= new Vector3(n_GonPoints[i - 1].x, height * 0.5f, n_GonPoints[i - 1].z) /*+ offset*/;
|
||||
}
|
||||
//8
|
||||
int tIdx = 3 * polygon;
|
||||
for (int i = 0; i < polygon - 1; i++)
|
||||
{
|
||||
triangles[tIdx++] = polygon + 1;
|
||||
triangles[tIdx++] = i + 1 + polygon + 1;
|
||||
triangles[tIdx++] = i + 2 + polygon + 1;
|
||||
}
|
||||
|
||||
triangles[tIdx++] = polygon + 1;
|
||||
triangles[tIdx++] = polygon + polygon + 1;
|
||||
triangles[tIdx++] = 1 + polygon + 1;
|
||||
|
||||
/* -------------------- <20><><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD> -------------------- */
|
||||
|
||||
vIdx = 2 * polygon + 2;
|
||||
for (int i = 1; i <= polygon; i++)
|
||||
{
|
||||
vertices[vIdx++]
|
||||
= new Vector3(n_GonPoints[i - 1].x, -height * 0.5f, n_GonPoints[i - 1].z) /*+ offset*/;
|
||||
}
|
||||
//11
|
||||
for (int i = 1; i <= polygon; i++)
|
||||
{
|
||||
vertices[vIdx++]
|
||||
= new Vector3(n_GonPoints[i - 1].x, height * 0.5f, n_GonPoints[i - 1].z) /*+ offset*/;
|
||||
}
|
||||
//
|
||||
tIdx = 6 * polygon;
|
||||
for (int i = 0; i < polygon - 1; i++)
|
||||
{
|
||||
triangles[tIdx++] = (2 * polygon + 2) + i + 0;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + i + 1;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + i + polygon;
|
||||
|
||||
triangles[tIdx++] = (2 * polygon + 2) + i + 1;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + i + 1 + polygon;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + i + polygon;
|
||||
}
|
||||
|
||||
triangles[tIdx++] = (2 * polygon + 2) + polygon - 1;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + 0;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + polygon - 1 + polygon;
|
||||
|
||||
triangles[tIdx++] = (2 * polygon + 2) + 0;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + polygon;
|
||||
triangles[tIdx++] = (2 * polygon + 2) + polygon - 1 + polygon;
|
||||
|
||||
}
|
||||
|
||||
void UVCreate()
|
||||
{
|
||||
float scaleFactor = 0.5f;
|
||||
|
||||
int[] tris = meshfilter.mesh.triangles;
|
||||
|
||||
Vector3[] verts = meshfilter.mesh.vertices;
|
||||
Vector2[] uvs = new Vector2[verts.Length];
|
||||
|
||||
// Iterate over each face (here assuming triangles)
|
||||
for (int index = 0; index < tris.Length; index += 3)
|
||||
{
|
||||
// Get the three vertices bounding this triangle.
|
||||
Vector3 v1 = verts[tris[index]];
|
||||
Vector3 v2 = verts[tris[index + 1]];
|
||||
Vector3 v3 = verts[tris[index + 2]];
|
||||
|
||||
// Compute a vector perpendicular to the face.
|
||||
Vector3 normal = Vector3.Cross(v3 - v1, v2 - v1);
|
||||
|
||||
// Form a rotation that points the z+ axis in this perpendicular direction.
|
||||
// Multiplying by the inverse will flatten the triangle into an xy plane.
|
||||
Quaternion rotation = Quaternion.Inverse(Quaternion.LookRotation(normal));
|
||||
|
||||
// Assign the uvs, applying a scale factor to control the texture tiling.
|
||||
uvs[tris[index]] = (Vector2)(rotation * v1) * scaleFactor;
|
||||
uvs[tris[index + 1]] = (Vector2)(rotation * v2) * scaleFactor;
|
||||
uvs[tris[index + 2]] = (Vector2)(rotation * v3) * scaleFactor;
|
||||
}
|
||||
meshfilter.mesh.uv = uvs;
|
||||
}
|
||||
void MeshRefresh()
|
||||
{
|
||||
meshfilter.mesh.Clear();
|
||||
meshfilter.mesh.vertices = vertices;
|
||||
meshfilter.mesh.triangles = triangles;
|
||||
UVCreate();
|
||||
meshfilter.mesh.RecalculateNormals();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed109573c27d22b4c9bfb47d87eb2d28
|
||||
@@ -1,213 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using XRLib;
|
||||
using Studio.UI;
|
||||
|
||||
namespace Studio.UI
|
||||
{
|
||||
//TODO::areabox가 아니라 TwinObject를 대상으로 동작하도록 수정
|
||||
public class ObjectDistanceLine : MonoBehaviour, ISingle
|
||||
{
|
||||
private Vector3 centerPoint = new();
|
||||
private Vector3[] edges = new Vector3[4];
|
||||
|
||||
private LineRenderer[] lineRenderers = new LineRenderer[4];
|
||||
private int[] distances = new int[4];
|
||||
private Vector3[] hits = new Vector3[4];
|
||||
[SerializeField]
|
||||
private float thickness;
|
||||
|
||||
private int rot;
|
||||
private Dictionary<Vector3, Vector3> dirTable = new();
|
||||
|
||||
TwinObject target;
|
||||
HashSet<TwinObject> targets = new();
|
||||
public event Action onTargetEvent;
|
||||
public event Action onTargetMissing;
|
||||
public event Action<Vector3, int, int> onLineUpdate;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
var lineMat = Resources.Load<Material>("Materials/Mat_LineRender");
|
||||
for (int i = 0; i < lineRenderers.Length; i++)
|
||||
{
|
||||
lineRenderers[i] = new GameObject("DistanceLine").AddComponent<LineRenderer>();
|
||||
lineRenderers[i].transform.SetParent(transform, true);
|
||||
lineRenderers[i].material = lineMat;
|
||||
lineRenderers[i].positionCount = 2;
|
||||
lineRenderers[i].startWidth = thickness;
|
||||
lineRenderers[i].endWidth = thickness;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTarget(TwinObject target)
|
||||
{
|
||||
if (target is Wall || target is WallGroup)
|
||||
return;
|
||||
this.target = target;
|
||||
targets.Add(target);
|
||||
gameObject.SetActive(true);
|
||||
onTargetEvent?.Invoke();
|
||||
}
|
||||
|
||||
private void EdgePoints()
|
||||
{
|
||||
var size = target.physics.areabox.bounds.size;
|
||||
edges[0] = centerPoint + EdgePointCalculate(-size.x, -size.z, centerPoint);
|
||||
edges[1] = centerPoint + EdgePointCalculate(size.x, -size.z, centerPoint);
|
||||
edges[2] = centerPoint + EdgePointCalculate(size.x, size.z, centerPoint);
|
||||
edges[3] = centerPoint + EdgePointCalculate(-size.x, size.z, centerPoint);
|
||||
}
|
||||
|
||||
private void CenterPoints()
|
||||
{
|
||||
var size = target.physics.areabox.bounds.size;
|
||||
edges[0] = centerPoint + EdgePointCalculate(-size.x, 0f, centerPoint);
|
||||
edges[1] = centerPoint + EdgePointCalculate(size.x, 0f, centerPoint);
|
||||
edges[2] = centerPoint + EdgePointCalculate(0f, -size.z, centerPoint);
|
||||
edges[3] = centerPoint + EdgePointCalculate(0f, size.z, centerPoint);
|
||||
}
|
||||
private Vector3 EdgePointCalculate(float xValue, float zValue, Vector3 center)
|
||||
{
|
||||
//대각선의 길이,
|
||||
//중점길이
|
||||
var point = center + (new Vector3(xValue, 0, zValue) * 0.5f);
|
||||
var length = Vector3.Distance(point, center);
|
||||
var dir = (point - center).normalized * length;
|
||||
//var pos = RotateVector3(dir, rot);
|
||||
var pos = Quaternion.AngleAxis(rot, Vector3.up) * dir;
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void Off()
|
||||
{
|
||||
targets.Clear();
|
||||
onTargetMissing?.Invoke();
|
||||
}
|
||||
|
||||
void LineRenderSetActive(bool isActive)
|
||||
{
|
||||
foreach(var line in lineRenderers)
|
||||
{
|
||||
line.enabled = isActive;
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (target == null || targets.Count >1)
|
||||
{
|
||||
Off();
|
||||
LineRenderSetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
//if (areabox == null)
|
||||
// return;
|
||||
//Distance가 4개 모두 0이면 return?
|
||||
LineRenderSetActive(true);
|
||||
rot = Mathf.RoundToInt(target.physics.areabox.transform.localEulerAngles.y);
|
||||
centerPoint = new Vector3(target.physics.areabox.bounds.center.x, 0, target.physics.areabox.bounds.center.z);
|
||||
|
||||
var angle = rot % 90f;
|
||||
if (Mathf.Approximately(angle, 0f))
|
||||
CenterPoints();
|
||||
else
|
||||
EdgePoints();
|
||||
|
||||
var xOrder = edges.OrderBy(l => l.x);
|
||||
var zOrder = edges.OrderBy(l => l.z);
|
||||
dirTable.Clear();
|
||||
dirTable.TryAdd(xOrder.ElementAt(0), Vector3.left);
|
||||
dirTable.TryAdd(xOrder.ElementAt(3), Vector3.right);
|
||||
dirTable.TryAdd(zOrder.ElementAt(0), Vector3.back);
|
||||
dirTable.TryAdd(zOrder.ElementAt(3), Vector3.forward);
|
||||
|
||||
for (int i = 0; i < edges.Length; i++)
|
||||
{
|
||||
//var dir = Dir(dirTable[edges[i]]);
|
||||
var dir = dirTable[edges[i]];
|
||||
if (Physics.Raycast(edges[i], dir, out RaycastHit hit, Mathf.Infinity))
|
||||
{
|
||||
hits[i] = hit.point;
|
||||
}
|
||||
else
|
||||
{
|
||||
hits[i] = edges[i];
|
||||
}
|
||||
distances[i] = Mathf.RoundToInt(Vector3.Distance(hits[i], edges[i]) * 1000f);
|
||||
|
||||
lineRenderers[i].SetPosition(0, edges[i]);
|
||||
lineRenderers[i].SetPosition(1, hits[i]);
|
||||
//3방향중 점중 가장 짧은거
|
||||
|
||||
var pos = DistanceTextPos(edges[i], hits[i]);
|
||||
if (Mathf.Abs(pos.y) == Mathf.Infinity || float.IsNaN(pos.y))
|
||||
continue;
|
||||
onLineUpdate?.Invoke(pos, i, distances[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 DistanceTextPos(Vector3 edge, Vector3 hit)
|
||||
{
|
||||
var x = Screen.width;
|
||||
var y = Screen.height;
|
||||
|
||||
var hitpoint = Camera.main.WorldToScreenPoint(hit);
|
||||
var edgePoint = Camera.main.WorldToScreenPoint(edge);
|
||||
|
||||
//카메라 끝점 edge와 hit 사이;
|
||||
|
||||
//기울기 가져온다
|
||||
var m = (hitpoint.y - edgePoint.y) / (hitpoint.x - edgePoint.x);
|
||||
if (hitpoint.y > y)
|
||||
{
|
||||
var yPos = y;
|
||||
var xPos = ((yPos - edgePoint.y) / m) + edgePoint.x;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
else if (hitpoint.y < 0)
|
||||
{
|
||||
var yPos = 0;
|
||||
var xPos = ((yPos - edgePoint.y) / m) + edgePoint.x;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
|
||||
if (hitpoint.x > x)
|
||||
{
|
||||
var xPos = x;
|
||||
var yPos = (m * (xPos - edgePoint.x)) + edgePoint.y;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
else if (hitpoint.x < 0)
|
||||
{
|
||||
var xPos = 0;
|
||||
var yPos = (m * (xPos - edgePoint.x)) + edgePoint.y;
|
||||
hitpoint = new Vector3(xPos, yPos);
|
||||
}
|
||||
|
||||
var center = (hitpoint + edgePoint) * 0.5f;
|
||||
return center;
|
||||
}
|
||||
|
||||
void Gizmo()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// for (int i = 0; i < edges.Length; ++i)
|
||||
// {
|
||||
// Gizmos.DrawSphere(edges[i].pos, 0.1f);
|
||||
// }
|
||||
|
||||
// for (int i = 0; i < hits.Length; ++i)
|
||||
// {
|
||||
// var dir = Dir(dirTable[edges[i]]);
|
||||
// Handles.color = Color.yellow;
|
||||
// Handles.DrawLine(edges[i].pos, hits[i], 1);
|
||||
// Gizmos.DrawRay(edges[i].pos, dir * 10f);
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfb96440ee0eee141bff26728b6f399b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,184 +0,0 @@
|
||||
using RTG;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using XRLib;
|
||||
using Studio;
|
||||
|
||||
public class ObjectHandler : MonoBehaviour, ISingle
|
||||
{
|
||||
Vector3 groundPoint;
|
||||
bool onClickGround;
|
||||
bool onClickTwinObject;
|
||||
|
||||
public TwinObject heldObject;
|
||||
public TwinObject clickObject;
|
||||
|
||||
Dictionary<(bool, bool, bool), HandState> handleStateTable = new();
|
||||
public event Action<TwinObject> onDrop;
|
||||
public event Action<TwinObject> onSelect;
|
||||
public event Action<TwinObject> onDeselect;
|
||||
|
||||
List<TwinObject> selectedObjects = new();
|
||||
|
||||
public override void AfterAwake()
|
||||
{
|
||||
GenerateStateTable();
|
||||
}
|
||||
|
||||
void GenerateStateTable()
|
||||
{
|
||||
//heldObject==null && onClickGround && onClickTwinObject
|
||||
handleStateTable.Add((true, true, true), HandState.Select);
|
||||
handleStateTable.Add((true, true, false), HandState.Ground);
|
||||
handleStateTable.Add((true, false, true), HandState.Nothing);
|
||||
handleStateTable.Add((true, false, false), HandState.Nothing);
|
||||
handleStateTable.Add((false, true, true), HandState.Drop);
|
||||
handleStateTable.Add((false, true, false), HandState.Nothing);
|
||||
handleStateTable.Add((false, false, true), HandState.Nothing);
|
||||
handleStateTable.Add((false, false, false), HandState.Nothing);
|
||||
}
|
||||
|
||||
public void Grab(TwinObject to)
|
||||
{
|
||||
heldObject = to;
|
||||
}
|
||||
|
||||
public void Select(TwinObject to)
|
||||
{
|
||||
if (!to.physics.activeSelf)
|
||||
return;
|
||||
|
||||
if (multiSelect)
|
||||
{
|
||||
if (selectedObjects.Remove(clickObject))
|
||||
{
|
||||
onDeselect?.Invoke(clickObject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var twinobj in selectedObjects)
|
||||
{
|
||||
onDeselect?.Invoke(twinobj);
|
||||
}
|
||||
selectedObjects.Clear();
|
||||
}
|
||||
clickObject = to;
|
||||
selectedObjects.Add(clickObject);
|
||||
onSelect?.Invoke(clickObject);
|
||||
}
|
||||
|
||||
public void OnClickGround(RaycastHit hit, Component comp)
|
||||
{
|
||||
if (EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
return;
|
||||
}
|
||||
onClickGround = true;
|
||||
groundPoint = hit.point;
|
||||
}
|
||||
|
||||
public void OnClickTwinObject(RaycastHit hit, Component comp)
|
||||
{
|
||||
//if (FindSingle<GizmoController>().GetGizmoHover())
|
||||
// return;
|
||||
onClickTwinObject = true;
|
||||
clickObject = comp as TwinObject;
|
||||
}
|
||||
|
||||
public void OnStayGround(RaycastHit hit, Component comp)
|
||||
{
|
||||
//if (FindSingle<GizmoController>().GetGizmoHover())
|
||||
// return;
|
||||
|
||||
var pos = hit.point;
|
||||
|
||||
if (heldObject != null)
|
||||
{
|
||||
var height = heldObject.physics.areabox.bounds.size.y * 0.5f;
|
||||
pos = new Vector3(pos.x, height, pos.z);
|
||||
}
|
||||
groundPoint = pos;
|
||||
}
|
||||
|
||||
public enum HandState
|
||||
{
|
||||
Select,
|
||||
Drop,
|
||||
Ground,
|
||||
Nothing,
|
||||
}
|
||||
|
||||
public HandState eventState
|
||||
{
|
||||
get
|
||||
{
|
||||
var key = (heldObject == null, onClickGround, onClickTwinObject);
|
||||
return handleStateTable[key];
|
||||
}
|
||||
}
|
||||
|
||||
public bool multiSelect;
|
||||
void Update()
|
||||
{
|
||||
multiSelect = Input.GetKey(KeyCode.LeftShift);
|
||||
HandlingAction();
|
||||
}
|
||||
|
||||
void HandlingAction()
|
||||
{
|
||||
switch (eventState)
|
||||
{
|
||||
case HandState.Select:
|
||||
Select(clickObject);
|
||||
break;
|
||||
case HandState.Drop:
|
||||
onDrop?.Invoke(heldObject);
|
||||
heldObject = null;
|
||||
break;
|
||||
|
||||
case HandState.Ground:
|
||||
if (multiSelect)
|
||||
break;
|
||||
|
||||
//if (FindSingle<GizmoController>().GetGizmoHover())
|
||||
// break;
|
||||
|
||||
foreach (var twinobj in selectedObjects)
|
||||
{
|
||||
onDeselect?.Invoke(twinobj);
|
||||
}
|
||||
selectedObjects.Clear();
|
||||
break;
|
||||
|
||||
case HandState.Nothing:
|
||||
if (heldObject == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
heldObject.transform.position = groundPoint;
|
||||
break;
|
||||
}
|
||||
clickObject = null;
|
||||
onClickGround = false;
|
||||
onClickTwinObject = false;
|
||||
}
|
||||
|
||||
void DeselectObject(TwinObject to)
|
||||
{
|
||||
onDeselect?.Invoke(to);
|
||||
}
|
||||
|
||||
public void Remove(TwinObject to)
|
||||
{
|
||||
if (selectedObjects.Contains(to))
|
||||
{
|
||||
//onDeselectEvent?.Invoke(to);
|
||||
selectedObjects.Remove(to);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b9ba1fe538a19041ae4eafed201ebfb
|
||||
@@ -1,54 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
[Serializable]
|
||||
public class TwoPointLine
|
||||
{
|
||||
private LineRenderer lineRenderer;
|
||||
private Color Color;
|
||||
|
||||
public TwoPointLine(LineRenderer lineRenderer)
|
||||
{
|
||||
this.lineRenderer = lineRenderer;
|
||||
}
|
||||
|
||||
public void LineRenderSetting(Material lineMat, float thickness)
|
||||
{
|
||||
Color = lineMat.color;
|
||||
lineRenderer.material = lineMat;
|
||||
lineRenderer.positionCount = 2;
|
||||
lineRenderer.startWidth = thickness;
|
||||
lineRenderer.endWidth = thickness;
|
||||
}
|
||||
public void RendererUpdate(Vector3 lcp, Vector3 rcp)
|
||||
{
|
||||
lineRenderer.SetPosition(0, lcp);
|
||||
lineRenderer.SetPosition(1, rcp);
|
||||
}
|
||||
|
||||
public void Select()
|
||||
{
|
||||
var mpb = new MaterialPropertyBlock();
|
||||
lineRenderer.GetPropertyBlock(mpb);
|
||||
mpb.SetColor("_BaseColor", Color.red);
|
||||
lineRenderer.SetPropertyBlock(mpb);
|
||||
}
|
||||
|
||||
public void Deselect()
|
||||
{
|
||||
var mpb = new MaterialPropertyBlock();
|
||||
lineRenderer.GetPropertyBlock(mpb);
|
||||
mpb.SetColor("_BaseColor", Color);
|
||||
lineRenderer.SetPropertyBlock(mpb);
|
||||
}
|
||||
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
if (lineRenderer == null)
|
||||
return;
|
||||
lineRenderer.enabled = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5071a6680f92e44284a8d00b1debc1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,545 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using UnityEngine;
|
||||
using XRLib;
|
||||
using static Studio.Enums;
|
||||
using Color = UnityEngine.Color;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class Wall : TwinObject
|
||||
{
|
||||
public enum VertexPoint
|
||||
{
|
||||
RightTop,
|
||||
LeftCenter,
|
||||
LeftTop,
|
||||
LeftBottom,
|
||||
RightCenter,
|
||||
RightBottom
|
||||
}
|
||||
public MeshFilter meshfilter;
|
||||
private LineRenderer lineRenderer;
|
||||
private MeshRenderer mr;
|
||||
|
||||
public float height = 2;
|
||||
private float thickness = 0.1f;
|
||||
public Vector3 offset = new Vector3(0, 1, 0);
|
||||
public Vector3[] n_GonPoints = new Vector3[6];
|
||||
|
||||
private TwoPointLine line;
|
||||
public Color wallColor;
|
||||
|
||||
//private CreateWireFrame wireFrame;
|
||||
public HashSet<LinePoint> includedPoints = new();
|
||||
private Dictionary<VirtualPoint, bool> linePointTable = new Dictionary<VirtualPoint, bool>();
|
||||
|
||||
public LinePoint leftCenterPoint;
|
||||
public LinePoint rightCenterPoint;
|
||||
|
||||
private Vector3[] linePoints = new Vector3[6];
|
||||
private Vector3[] vertexs = new Vector3[6];
|
||||
|
||||
private BoxCollider boxCollider;
|
||||
public override void AfterAwake()
|
||||
{
|
||||
var mat = Resources.Load<Material>("Materials/Mat_WallMat");
|
||||
//wireFrame = new GameObject("WireFrame").AddComponent<CreateWireFrame>();
|
||||
//wireFrame.transform.SetParent(transform);
|
||||
//wireFrame.Displayable(false);
|
||||
meshfilter = GetComponent<MeshFilter>();
|
||||
mr = GetComponent<MeshRenderer>();
|
||||
mr.material = mat;
|
||||
wallColor = mr.material.color;
|
||||
lineRenderer = GetComponent<LineRenderer>();
|
||||
line = new(lineRenderer);
|
||||
boxCollider = GetComponent<BoxCollider>();
|
||||
physics.areabox = boxCollider;
|
||||
base.AfterAwake();
|
||||
}
|
||||
public void Generate(LinePoint lcp, LinePoint rcp, Material lineMat, float thickness)
|
||||
{
|
||||
this.thickness = thickness;
|
||||
leftCenterPoint = lcp;
|
||||
rightCenterPoint = rcp;
|
||||
|
||||
lcp.Connect(rcp);
|
||||
rcp.Connect(lcp);
|
||||
|
||||
//SetVirtualEdgePoints(leftCenterPoint.position, rightCenterPoint.position, thickness);
|
||||
var dir = (rcp.position- lcp.position).normalized;
|
||||
var vt1 = dir * (thickness * 0.5f);
|
||||
var vp1 = RotateVector3(vt1, 90f);
|
||||
var vp2 = RotateVector3(vt1, -90f);
|
||||
|
||||
var dir2 = (lcp.position - rcp.position).normalized;
|
||||
var vt2 = dir2 * (thickness * 0.5f);
|
||||
var vp3 = RotateVector3(vt2, 90f);
|
||||
var vp4 = RotateVector3(vt2, -90f);
|
||||
|
||||
vp1 += lcp.position;
|
||||
vp4 += rcp.position;
|
||||
vp2 += lcp.position;
|
||||
vp3 += rcp.position;
|
||||
|
||||
var points = new Vector3[] { vp2, vp3, vp1, vp4, lcp.position, rcp.position };
|
||||
vertexs = points;
|
||||
|
||||
for (int i = 0; i < vertexs.Length; i++)
|
||||
{
|
||||
linePoints[i] = vertexs[i];
|
||||
}
|
||||
|
||||
line.RendererUpdate(leftCenterPoint.position, rightCenterPoint.position);
|
||||
//BoxColliderSizeSetting(leftCenterPoint, rightCenterPoint);
|
||||
var distnace = Vector3.Distance(lcp.position, rcp.position)/*-0.1f<0 ? 0 : Vector3.Distance(p1.position, p2.position) - 0.1f*/;
|
||||
var pos = (lcp.position + rcp.position) * 0.5f;
|
||||
boxCollider.center = new Vector3(0f, height * 0.5f, 0f);
|
||||
boxCollider.size = new Vector3(thickness, 2f, distnace);
|
||||
transform.position = pos;
|
||||
boxCollider.transform.LookAt(rcp.position);
|
||||
|
||||
SetActiveRenderer(true);
|
||||
|
||||
line.LineRenderSetting(lineMat, this.thickness);
|
||||
boxCollider.enabled = false;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
linePointTable.TryAdd((VirtualPoint)i, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void EdgeRecalculate()
|
||||
{
|
||||
SetVirtualEdgePoints(leftCenterPoint.position, rightCenterPoint.position);
|
||||
}
|
||||
|
||||
public void PreviewLineUpdate()
|
||||
{
|
||||
SetVirtualEdgePoints(leftCenterPoint.position, rightCenterPoint.position);
|
||||
|
||||
for (int i = 0; i < vertexs.Length; i++)
|
||||
{
|
||||
linePoints[i] = vertexs[i];
|
||||
}
|
||||
|
||||
//includedPoints.Clear();
|
||||
//includedPoints.Add(leftCenterPoint);
|
||||
//includedPoints.Add(rightCenterPoint);
|
||||
line.RendererUpdate(leftCenterPoint.position, rightCenterPoint.position);
|
||||
//BoxColliderSizeSetting(leftCenterPoint, rightCenterPoint);
|
||||
//SetActiveRenderer(true);
|
||||
}
|
||||
|
||||
public void MoveLine()
|
||||
{
|
||||
EdgeRecalculate();
|
||||
line.RendererUpdate(leftCenterPoint.position, rightCenterPoint.position);
|
||||
}
|
||||
|
||||
public void SetMeshVertice()
|
||||
{
|
||||
var vertices = new Vector3[]
|
||||
{
|
||||
linePoints[(int)VirtualPoint.RightTop],
|
||||
vertexs[(int)VirtualPoint.LeftCenter],
|
||||
linePoints[(int)VirtualPoint.LeftTop],
|
||||
linePoints[(int)VirtualPoint.LeftBottom],
|
||||
vertexs[(int)VirtualPoint.RightCenter],
|
||||
linePoints[(int)VirtualPoint.RightBottom]
|
||||
};
|
||||
SetActiveRenderer(false);
|
||||
MeshDeformer(vertices.Length, vertices);
|
||||
}
|
||||
|
||||
public Vector3[] GetApplyPointPositions(VirtualPoint[] vps)
|
||||
{
|
||||
var p1 = vertexs[(int)vps[0]];
|
||||
var p2 = vertexs[(int)vps[1]];
|
||||
|
||||
var dir = (p2 - p1).normalized;
|
||||
var dir2 = (p1 - p2).normalized;
|
||||
|
||||
p1 += (dir2 * 2f);
|
||||
p2 += (dir * 2f);
|
||||
|
||||
return new Vector3[] { p1, p2 };
|
||||
}
|
||||
public bool NearVritualEdgePoint(Vector3 point, VirtualPoint vp)
|
||||
{
|
||||
var p1 = vertexs[(int)vp];
|
||||
var p2 = vertexs[(int)vp + 1];
|
||||
|
||||
var distance = Vector3.Distance(p1, point);
|
||||
var distance2 = Vector3.Distance(p2, point);
|
||||
if (distance < distance2)
|
||||
{
|
||||
if (linePointTable[vp])
|
||||
{
|
||||
vp += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!linePointTable[vp + 1])
|
||||
{
|
||||
vp += 1;
|
||||
}
|
||||
}
|
||||
SetVertex(vp, point);
|
||||
return true;
|
||||
}
|
||||
//<2F>ش<EFBFBD> line<6E><65> <20><><EFBFBD><EFBFBD> Meshwall<6C><6C> <20><><EFBFBD><EFBFBD>
|
||||
private void MeshDeformer(int polygon, Vector3[] points)
|
||||
{
|
||||
if (points == null || points.Length == 0)
|
||||
return;
|
||||
if (PrevPointsCompare(points))
|
||||
return;
|
||||
Matrix4x4 wolrdtoLocal = transform.worldToLocalMatrix;
|
||||
for (int i = 0; i < points.Length; i++)
|
||||
{
|
||||
Vector3 local = wolrdtoLocal.MultiplyPoint3x4(points[i]);
|
||||
n_GonPoints[i] = local;
|
||||
}
|
||||
// SetMeshData(polygon);
|
||||
// MeshRefresh();
|
||||
}
|
||||
private bool PrevPointsCompare(Vector3[] points)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var point in points)
|
||||
{
|
||||
var distance = Vector3.Distance(n_GonPoints[index], point);
|
||||
if (distance > 0.01f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void MaterialChange(Material mat)
|
||||
{
|
||||
mr.material = mat;
|
||||
}
|
||||
|
||||
public LinePoint[] GetCenterPoints()
|
||||
{
|
||||
var centerPoints = new LinePoint[2] { leftCenterPoint, rightCenterPoint };
|
||||
return centerPoints;
|
||||
}
|
||||
|
||||
public Vector3[] GetLeftPointPositions()
|
||||
{
|
||||
var lt = vertexs[(int)VirtualPoint.LeftTop];
|
||||
var lb = vertexs[(int)VirtualPoint.LeftBottom];
|
||||
return new Vector3[] { lt, lb };
|
||||
}
|
||||
|
||||
public Vector3[] GetRightPointPositions()
|
||||
{
|
||||
var rt = vertexs[(int)VirtualPoint.RightTop];
|
||||
var rb = vertexs[(int)VirtualPoint.RightBottom];
|
||||
return new Vector3[] { rt, rb };
|
||||
}
|
||||
|
||||
public Vector3[] GetCenterPointPositions()
|
||||
{
|
||||
var ct = vertexs[(int)VirtualPoint.LeftCenter];
|
||||
var cb = vertexs[(int)VirtualPoint.RightCenter];
|
||||
return new Vector3[] { ct, cb };
|
||||
}
|
||||
|
||||
|
||||
private void NearVertextPoint(Vector3 points, VirtualPoint vp)
|
||||
{
|
||||
var p1 = vertexs[(int)vp];
|
||||
var p2 = vertexs[(int)vp + 1];
|
||||
|
||||
var distance = Vector3.Distance(p1, points);
|
||||
var distance2 = Vector3.Distance(p2, points);
|
||||
|
||||
if (distance < distance2)
|
||||
{
|
||||
SetVertex(vp, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVertex(vp + 1, points);
|
||||
}
|
||||
}
|
||||
void SetVertex(VirtualPoint vp, Vector3 point)
|
||||
{
|
||||
linePoints[(int)vp] = point;
|
||||
linePointTable[vp] = true;
|
||||
}
|
||||
|
||||
//Top,Top bottom, bottom <20><> <20>Ѵ<EFBFBD> false<73>ų<EFBFBD> <20>Ѵ<EFBFBD> true <20>ΰ<EFBFBD>쿡<EFBFBD><ECBFA1> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϳ<EFBFBD> true<75><65> <20><><EFBFBD><EFBFBD>ѹ<EFBFBD> <20><><EFBFBD>ؾ<EFBFBD><D8BE>Ѵ<EFBFBD>.
|
||||
public bool RefreshVirtualPoint(VirtualPoint cvp, VirtualPoint tvp, ref VirtualPoint[] vps)
|
||||
{
|
||||
if (linePointTable[cvp] != linePointTable[cvp + 2])
|
||||
{
|
||||
vps = linePointTable[cvp] ? new VirtualPoint[2] { cvp + 2, cvp + 3 } : new VirtualPoint[2] { cvp, cvp + 1 };
|
||||
return true;
|
||||
}
|
||||
|
||||
if (linePointTable[tvp] != linePointTable[tvp + 2])
|
||||
{
|
||||
vps = linePointTable[tvp] ? new VirtualPoint[2] { tvp + 1, tvp + 2 } : new VirtualPoint[2] { tvp - 1, tvp };
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void CalculateCrossing(Wall subWall)
|
||||
{
|
||||
var mVL = GetLeftPointPositions();
|
||||
var mVR = GetRightPointPositions();
|
||||
var sVL = subWall.GetLeftPointPositions();
|
||||
var sVR = subWall.GetRightPointPositions();
|
||||
Vector3 crossPoint = Vector3.zero;
|
||||
//mvl[1], svl[0] <20>̶<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ
|
||||
//mvr[1],svr[0] <20>̶<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ false
|
||||
if (Wathf.GetCrossVector(mVL, sVL, ref crossPoint))
|
||||
{
|
||||
NearVertextPoint(crossPoint, VirtualPoint.LeftTop);
|
||||
}
|
||||
|
||||
if (Wathf.GetCrossVector(mVL, sVR, ref crossPoint))
|
||||
{
|
||||
NearVertextPoint(crossPoint, VirtualPoint.LeftTop);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
if (Wathf.GetCrossVector(mVR, sVL, ref crossPoint))
|
||||
{
|
||||
NearVertextPoint(crossPoint, VirtualPoint.RightTop);
|
||||
}
|
||||
|
||||
if (Wathf.GetCrossVector(mVR, sVR, ref crossPoint))
|
||||
{
|
||||
NearVertextPoint(crossPoint, VirtualPoint.RightTop);
|
||||
}
|
||||
}
|
||||
|
||||
public void PositionChange(LinePoint point)
|
||||
{
|
||||
//if (!movePoint.ContainsKey(point))
|
||||
// return;
|
||||
var virtualPoint = VirtualPoint.LeftCenter;
|
||||
if (leftCenterPoint.Equals(point))
|
||||
virtualPoint = VirtualPoint.LeftCenter;
|
||||
else
|
||||
virtualPoint = VirtualPoint.RightCenter;
|
||||
//var virtualPoint = movePoint[point];
|
||||
linePoints[(int)virtualPoint] = point.position;
|
||||
line.RendererUpdate(leftCenterPoint.position, rightCenterPoint.position);
|
||||
}
|
||||
|
||||
public void RealTimeLineRenderSetting(LinePoint p1, LinePoint p2)
|
||||
{
|
||||
line.RendererUpdate(p1.position, p2.position);
|
||||
BoxColliderSizeSetting(p1, p2);
|
||||
}
|
||||
private void BoxColliderSizeSetting(LinePoint p1, LinePoint p2)
|
||||
{
|
||||
var distnace = Vector3.Distance(p1.position, p2.position)/*-0.1f<0 ? 0 : Vector3.Distance(p1.position, p2.position) - 0.1f*/;
|
||||
var pos = (p1.position + p2.position) * 0.5f;
|
||||
boxCollider.center = new Vector3(0f, height * 0.5f, 0f); ;
|
||||
boxCollider.size = new Vector3(thickness, 2f, distnace);
|
||||
transform.position = pos;
|
||||
boxCollider.transform.LookAt(p2.position);
|
||||
}
|
||||
|
||||
public override void SetDisplayable(bool value)
|
||||
{
|
||||
IsDisplayable = value;
|
||||
SetActiveRenderer(value);
|
||||
}
|
||||
|
||||
public override void SetInteractible(bool value)
|
||||
{
|
||||
IsInteractible = value;
|
||||
physics.areabox.enabled = value;
|
||||
}
|
||||
|
||||
void SetWallColor(Color color)
|
||||
{
|
||||
var mpb = new MaterialPropertyBlock();
|
||||
mr.GetPropertyBlock(mpb);
|
||||
mpb.SetColor("_BaseColor", color);
|
||||
mr.SetPropertyBlock(mpb);
|
||||
}
|
||||
public override void Select()
|
||||
{
|
||||
Debug.Log("SelectWall");
|
||||
SetWallColor(Color.red);
|
||||
line.Select();
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
//SetWallColor(wallColor);
|
||||
//line.Deselect();
|
||||
}
|
||||
|
||||
public void SetActiveRenderer(bool value)
|
||||
{
|
||||
if (IsDisplayable)
|
||||
{
|
||||
line.SetActive(value);
|
||||
//wireFrame.Displayable(!value);
|
||||
mr.enabled = !value;
|
||||
var centrPoints = GetCenterPoints();
|
||||
foreach (var point in centrPoints)
|
||||
{
|
||||
point.Displayable(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
line.SetActive(false);
|
||||
//wireFrame.Displayable(false);
|
||||
mr.enabled = false;
|
||||
var centrPoints = GetCenterPoints();
|
||||
foreach (var point in centrPoints)
|
||||
{
|
||||
point.Displayable(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (var kvp in linePointTable.ToList())
|
||||
{
|
||||
linePointTable[kvp.Key] = false;
|
||||
}
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
foreach (var kvp in linePointTable.ToList())
|
||||
{
|
||||
linePointTable[kvp.Key] = false;
|
||||
}
|
||||
foreach (var crashWall in crashWalls)
|
||||
{
|
||||
crashWall.crashWalls.Remove(this);
|
||||
}
|
||||
crashLinePoints.Clear();
|
||||
crashWalls.Clear();
|
||||
includedPoints.Clear();
|
||||
|
||||
var mpb = new MaterialPropertyBlock();
|
||||
mr.GetPropertyBlock(mpb);
|
||||
mpb.SetColor("_BaseColor", wallColor);
|
||||
mr.SetPropertyBlock(mpb);
|
||||
|
||||
line.Deselect();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetVirtualEdgePoints(Vector3 start, Vector3 end)
|
||||
{
|
||||
//var _thickness = thickness;
|
||||
var dir = (end - start).normalized;
|
||||
var vt1 = dir * (thickness * 0.5f);
|
||||
var vp1 = RotateVector3(vt1, 90f);
|
||||
var vp2 = RotateVector3(vt1, -90f);
|
||||
|
||||
var dir2 = (start - end).normalized;
|
||||
var vt2 = dir2 * (thickness * 0.5f);
|
||||
var vp3 = RotateVector3(vt2, 90f);
|
||||
var vp4 = RotateVector3(vt2, -90f);
|
||||
|
||||
vp1 += start;
|
||||
vp4 += end;
|
||||
|
||||
vp2 += start;
|
||||
vp3 += end;
|
||||
|
||||
var points = new Vector3[] { vp2, vp3, vp1, vp4, start, end };
|
||||
vertexs= points;
|
||||
|
||||
}
|
||||
Vector3 RotateVector3(Vector3 d, float rot)
|
||||
{
|
||||
var ea = Quaternion.AngleAxis(rot, Vector3.up) * d;
|
||||
return ea;
|
||||
}
|
||||
|
||||
public HashSet<LinePoint> crashLinePoints = new();
|
||||
public HashSet<Wall> crashWalls = new();
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.transform.TryGetComponent<LinePoint>(out LinePoint point))
|
||||
{
|
||||
crashLinePoints.Add(point);
|
||||
}
|
||||
if(other.transform.TryGetComponent<Wall>(out Wall wall))
|
||||
{
|
||||
crashWalls.Add(wall);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.transform.TryGetComponent<LinePoint>(out LinePoint point))
|
||||
{
|
||||
crashLinePoints.Remove(point);
|
||||
}
|
||||
if (other.transform.TryGetComponent<Wall>(out Wall wall))
|
||||
{
|
||||
crashWalls.Remove(wall);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool CheckVirtualPointConnection()
|
||||
{
|
||||
var b1 = linePointTable[VirtualPoint.LeftTop] == linePointTable[VirtualPoint.RightTop];
|
||||
var b2 = linePointTable[VirtualPoint.LeftBottom] == linePointTable[VirtualPoint.RightBottom];
|
||||
return b1 && b2;
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><D7B8><EFBFBD><EFBFBD>
|
||||
public Vector3[] GetLeftLinePointPositions()
|
||||
{
|
||||
var lt = linePoints[(int)VirtualPoint.LeftTop];
|
||||
var lb = linePoints[(int)VirtualPoint.LeftBottom];
|
||||
return new Vector3[] { lt, lb };
|
||||
}
|
||||
public Vector3[] GetRightLinePointPositions()
|
||||
{
|
||||
var rt = linePoints[(int)VirtualPoint.RightTop];
|
||||
var rb = linePoints[(int)VirtualPoint.RightBottom];
|
||||
return new Vector3[] { rt, rb };
|
||||
}
|
||||
public Vector3[] GetCenterLinePointPositions()
|
||||
{
|
||||
var ct = linePoints[(int)VirtualPoint.LeftCenter];
|
||||
var cb = linePoints[(int)VirtualPoint.RightCenter];
|
||||
return new Vector3[] { ct, cb };
|
||||
}
|
||||
|
||||
|
||||
internal bool isConnected(Wall target)
|
||||
{
|
||||
if(target.leftCenterPoint == leftCenterPoint || target.rightCenterPoint == leftCenterPoint)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.leftCenterPoint == rightCenterPoint || target.rightCenterPoint == rightCenterPoint)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6aed9867f2e5ba348a12c86c96ec915d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd6fb1311e666d24b98345ca73618b5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Pool;
|
||||
using XRLib;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class WallGroup : TwinObject
|
||||
{
|
||||
public HashSet<Wall> groupWalls = new();
|
||||
public HashSet<LinePoint> groupPoints = new();
|
||||
|
||||
public Transform walls;
|
||||
public Transform linepoints;
|
||||
public Action<TwinObject> onRemove;
|
||||
|
||||
public override void AfterAwake()
|
||||
{
|
||||
walls = Find<Transform>(nameof(walls));
|
||||
linepoints = Find<Transform>(nameof(linepoints));
|
||||
}
|
||||
|
||||
public bool CheckIncludeGroupWall(Wall wall)
|
||||
{
|
||||
if (groupWalls.Contains(wall))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
public void AddWall(Wall wallLine)
|
||||
{
|
||||
if(groupWalls.Add(wallLine))
|
||||
{
|
||||
wallLine.transform.SetParent(walls);
|
||||
var centerPoints = wallLine.GetCenterPoints();
|
||||
foreach(var centerPoint in centerPoints) {
|
||||
AddGroupPoints(centerPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGroupPoints(LinePoint centerPoint)
|
||||
{
|
||||
centerPoint.transform.SetParent(linepoints);
|
||||
groupPoints.Add(centerPoint);
|
||||
}
|
||||
|
||||
public override void SetDisplayable(bool value)
|
||||
{
|
||||
foreach (var wallLine in groupWalls)
|
||||
{
|
||||
wallLine.SetDisplayable(!value);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetInteractible(bool value)
|
||||
{
|
||||
foreach(var wallLine in groupWalls)
|
||||
{
|
||||
wallLine.SetInteractible(!value);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
foreach(var wallLine in groupWalls)
|
||||
{
|
||||
wallLine.Select();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
foreach (var wallLine in groupWalls)
|
||||
{
|
||||
wallLine.Deselect();
|
||||
}
|
||||
}
|
||||
|
||||
public void LineResetting()
|
||||
{
|
||||
foreach (var walls in groupWalls)
|
||||
{
|
||||
walls.MoveLine();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContainPointInWallGroup(Wall wall)
|
||||
{
|
||||
var linePoints = wall.GetCenterPoints();
|
||||
foreach(var point in linePoints)
|
||||
{
|
||||
if(groupPoints.Contains(point))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
groupWalls.Clear();
|
||||
groupPoints.Clear();
|
||||
gameObject.SetActive(false);
|
||||
|
||||
foreach(var w in groupWalls)
|
||||
{
|
||||
onRemove?.Invoke(w);
|
||||
}
|
||||
|
||||
//onRemoveWallGroupEvent?.Invoke(this);
|
||||
}
|
||||
|
||||
public override void MaterialChange(Material mat)
|
||||
{
|
||||
foreach(var wallLine in groupWalls)
|
||||
{
|
||||
wallLine.MaterialChange(mat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aad4aafa7bca21e459def11608c3ccb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,23 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine.SceneManagement;
|
||||
using TMPro;
|
||||
|
||||
[Serializable]
|
||||
public class timestampClass
|
||||
{
|
||||
public string TimeStamp;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class msg_TimeClass
|
||||
{
|
||||
public string msg_time;
|
||||
}
|
||||
public class DataReader : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
|
||||
@@ -23,8 +23,6 @@ namespace Studio.Manage
|
||||
Join(new NodeGizmoController());
|
||||
Join(new AGVNodeLinkManager());
|
||||
Join(new AGVManager());
|
||||
Join(new WallBuilder());
|
||||
Join(new MeshCreator());
|
||||
Join(new SaveSceneSettingManager());
|
||||
|
||||
foreach(var m in managers)
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
using RTG;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XRLib;
|
||||
using XRLib.UI;
|
||||
|
||||
namespace Studio.UI
|
||||
{
|
||||
public class Panel_ObjectTool : PanelBase
|
||||
{
|
||||
private HashSet<TwinObject> targets = new();
|
||||
public event Action onClickMove;
|
||||
public event Action onClickScale;
|
||||
public event Action onClickRotate;
|
||||
public event Action<TwinObject> onClickRemove;
|
||||
public event Action<IEnumerable<TwinObject>> onClickTexture;
|
||||
|
||||
private Button button_texture;
|
||||
|
||||
public Vector3 plusPos;
|
||||
public float plus;
|
||||
public override void AfterAwake()
|
||||
{
|
||||
Button button_move = Find<Button>(nameof(button_move));
|
||||
button_move.onClick.AddListener(ActiveMoveGizmo);
|
||||
|
||||
Button button_rotate = Find<Button>(nameof(button_rotate));
|
||||
button_rotate.onClick.AddListener(ActiveRotateGizmo);
|
||||
|
||||
Button button_scale = Find<Button>(nameof(button_scale));
|
||||
button_scale.onClick.AddListener(ActiveScaleGizmo);
|
||||
|
||||
Button button_remove = Find<Button>(nameof(button_remove));
|
||||
button_remove.onClick.AddListener(RemoveObject);
|
||||
|
||||
button_texture = Find<Button>(nameof(button_texture));
|
||||
button_texture.onClick.AddListener(TexturePopupOpen);
|
||||
}
|
||||
internal void Attach(TwinObject to)
|
||||
{
|
||||
targets.Add(to);
|
||||
TextureButtonControl();
|
||||
FindSingle<ObjectDistanceLine>().SetTarget(to);
|
||||
SetActive(true);
|
||||
}
|
||||
|
||||
private void TextureButtonControl()
|
||||
{
|
||||
var wallCount = targets.OfType<Wall>().Count();
|
||||
var wallGroupCount = targets.OfType<WallGroup>().Count();
|
||||
|
||||
var value = wallCount > 0 || wallGroupCount > 0 ? true : false;
|
||||
button_texture.gameObject.SetActive(value);
|
||||
}
|
||||
|
||||
public void Detach(TwinObject to)
|
||||
{
|
||||
targets.Remove(to);
|
||||
|
||||
if (targets.Count == 0)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
targets.Clear();
|
||||
SetActive(false);
|
||||
FindSingle<ObjectDistanceLine>().Off();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
var size = Vector3.zero;
|
||||
var center = Vector3.zero;
|
||||
foreach(var t in targets)
|
||||
{
|
||||
size += t.physics.Size;
|
||||
center += t.transform.position;
|
||||
}
|
||||
plusPos = new Vector3(0, 0, size.z * plus);
|
||||
center /= targets.Count;
|
||||
var pos2 = Camera.main.WorldToScreenPoint(center + plusPos);
|
||||
YClampPosition(ref pos2, center);
|
||||
transform.position = pos2 /*+ new Vector3((rectTransform.sizeDelta.x * 0.5f), 0f)*/;
|
||||
}
|
||||
|
||||
//높이와 위치를 제한하다
|
||||
//TODO::매직넘버 삭제!!!
|
||||
private void YClampPosition(ref Vector3 screenPos, Vector3 center)
|
||||
{
|
||||
var pos = Camera.main.WorldToScreenPoint(center);
|
||||
if (pos.y < Screen.height && pos.y > 0)
|
||||
{
|
||||
var y = Mathf.Clamp(screenPos.y, rectTransform.sizeDelta.y, Screen.height - 100);
|
||||
screenPos = new Vector3(screenPos.x, y);
|
||||
}
|
||||
if (pos.x < Screen.width - 500 && pos.x > 0)
|
||||
{
|
||||
var x = Mathf.Clamp(screenPos.x, rectTransform.sizeDelta.x, Screen.width - 500);
|
||||
screenPos = new Vector3(x, screenPos.y);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActiveMoveGizmo()
|
||||
{
|
||||
onClickMove?.Invoke();
|
||||
}
|
||||
|
||||
private void ActiveRotateGizmo()
|
||||
{
|
||||
onClickRotate?.Invoke();
|
||||
}
|
||||
|
||||
void ActiveScaleGizmo()
|
||||
{
|
||||
onClickScale?.Invoke();
|
||||
}
|
||||
|
||||
public void RemoveObject()
|
||||
{
|
||||
foreach(var target in targets)
|
||||
{
|
||||
onClickRemove?.Invoke(target);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
private void TexturePopupOpen()
|
||||
{
|
||||
onClickTexture?.Invoke(targets);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50aac845575b87e4191031edfac340da
|
||||
Reference in New Issue
Block a user