<feat> 위치 기록/수정/삭제

This commit is contained in:
SOOBEEN HAN
2025-11-06 20:14:27 +09:00
parent 033c6aeb8e
commit 74759b0ab5
24 changed files with 1385 additions and 380 deletions

View File

@@ -1,32 +1,51 @@
using System;
using System.Collections.Generic;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
// 인터페이스
public interface IPointManagerView
{
void CreatePoint(RobotData pose);
void UpdatePointPosition(int index, RobotData pose);
void DeletePoint(int index);
void RedrawPoints(List<RobotData> poses); // (RobotProgram.Steps에서 변환)
}
public class PointManagerView : MonoBehaviour, IPointManagerView
{
[SerializeField] private GameObject pointPrefab; // 인스펙터에서 포인트 프리팹 연결
[SerializeField] private GameObject pointPrefab;
private List<GameObject> activePoints = new List<GameObject>();
public void CreatePoint(RobotData pose)
[SerializeField] public GameObject movingAlert;
[SerializeField]
[Tooltip("반투명 로봇 모델의 IK")]
public HybridInverseKinematicsNode kinematicsNode;
private Vector3 ConvertRobotDataToVector3(RobotData pose)
{
Vector3 position = new Vector3(pose.x, pose.y, pose.z);
float x = Convert.ToSingle(pose.x / -1000.0); // mm -> m
float y = Convert.ToSingle(pose.z / 1000.0); // Robot Z(mm) -> Unity Y(m)
float z = Convert.ToSingle(pose.y / -1000.0); // Robot Y(mm) -> Unity Z(m)
return new Vector3(x, y, z);
}
public void CreatePoint(RobotData pose, int index)
{
Vector3 position = ConvertRobotDataToVector3(pose);
GameObject pointObj = Instantiate(pointPrefab, position, Quaternion.identity, this.transform);
activePoints.Add(pointObj);
// (참고: 이 pointObj에 'InteractionView'가 감지할 수 있는 콜라이더와 스크립트가 있어야 함)
RobotPoint pointComponent = pointObj.GetComponent<RobotPoint>();
if (pointComponent != null)
{
pointComponent.pointIndex = activePoints.Count - 1;
}
else
{
Debug.LogError("point프리팹에 RobotPoint스크립트가 없음");
}
}
public void UpdatePointPosition(int index, RobotData pose)
{
if (index < 0 || index >= activePoints.Count) return;
activePoints[index].transform.position = new Vector3(pose.x, pose.y, pose.z);
activePoints[index].transform.position = ConvertRobotDataToVector3(pose);
}
public void DeletePoint(int index)
@@ -38,10 +57,9 @@ public class PointManagerView : MonoBehaviour, IPointManagerView
public void RedrawPoints(List<RobotData> poses)
{
// 기존 포인트 모두 삭제
foreach (var point in activePoints) Destroy(point);
activePoints.Clear();
// 모든 포인트 새로 생성
foreach (var pose in poses) CreatePoint(pose);
if (poses == null) return;
for (int i= 0; i < poses.Count; i++) CreatePoint(poses[i], i);
}
}