Compare commits
2 Commits
20250716me
...
75f387723d
| Author | SHA1 | Date | |
|---|---|---|---|
| 75f387723d | |||
| d9c3a9f827 |
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using Assets.WorkSpace.R;
|
||||||
|
using Octopus.Simulator.Networks;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -117,7 +119,7 @@ namespace RTG
|
|||||||
public CameraHotkeys Hotkeys { get { return _hotkeys; } }
|
public CameraHotkeys Hotkeys { get { return _hotkeys; } }
|
||||||
public CameraLimit LimitSetting { get { return _cameraLimitSetting; } }
|
public CameraLimit LimitSetting { get { return _cameraLimitSetting; } }
|
||||||
|
|
||||||
|
private WebReceiver _receiver;
|
||||||
public bool IsViewportHoveredByDevice()
|
public bool IsViewportHoveredByDevice()
|
||||||
{
|
{
|
||||||
Vector2 devicePos = RTInputDevice.Get.Device.GetPositionYAxisUp();
|
Vector2 devicePos = RTInputDevice.Get.Device.GetPositionYAxisUp();
|
||||||
@@ -140,7 +142,8 @@ namespace RTG
|
|||||||
|
|
||||||
SetFocusPoint(GetFocusPoint());
|
SetFocusPoint(GetFocusPoint());
|
||||||
AdjustOrthoSizeForFocusPt();
|
AdjustOrthoSizeForFocusPt();
|
||||||
|
_receiver = FindAnyObjectByType<WebReceiver>();
|
||||||
|
_receiver.onCameraReceived += SetCamera;
|
||||||
_isObjectVisibilityDirty = true;
|
_isObjectVisibilityDirty = true;
|
||||||
}
|
}
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@@ -155,6 +158,16 @@ namespace RTG
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetCamera(string json)
|
||||||
|
{
|
||||||
|
var cam = JsonUtility.FromJson<CameraEntity>(json);
|
||||||
|
if (_targetCamera != null)
|
||||||
|
{
|
||||||
|
_targetCamera.transform.position = new Vector3(cam.posX, cam.posY, cam.posZ);
|
||||||
|
_targetCamera.transform.transform.eulerAngles = new Vector3(cam.rotX, cam.rotY, cam.rotZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFieldOfView(float fov)
|
public void SetFieldOfView(float fov)
|
||||||
{
|
{
|
||||||
_targetCamera.fieldOfView = fov;
|
_targetCamera.fieldOfView = fov;
|
||||||
|
|||||||
@@ -122,8 +122,6 @@ namespace Octopus.Simulator.Networks
|
|||||||
public event Action<MQTTClient> onConnected;
|
public event Action<MQTTClient> onConnected;
|
||||||
private void OnConnected(MQTTClient client, string clientName)
|
private void OnConnected(MQTTClient client, string clientName)
|
||||||
{
|
{
|
||||||
Debug.Log("연결완료");
|
|
||||||
|
|
||||||
clientTable.Add(clientName, client);
|
clientTable.Add(clientName, client);
|
||||||
onConnected?.Invoke(client);
|
onConnected?.Invoke(client);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ using TMPro;
|
|||||||
using UVC.Networks;
|
using UVC.Networks;
|
||||||
using Best.MQTT;
|
using Best.MQTT;
|
||||||
using Best.MQTT.Packets;
|
using Best.MQTT.Packets;
|
||||||
|
using RTG;
|
||||||
|
using Assets.WorkSpace.R;
|
||||||
|
|
||||||
namespace Octopus.Simulator
|
namespace Octopus.Simulator
|
||||||
{
|
{
|
||||||
@@ -36,7 +38,7 @@ namespace Octopus.Simulator
|
|||||||
Button_Play = transform.Find(nameof(Button_Play)).GetComponent<Button>();
|
Button_Play = transform.Find(nameof(Button_Play)).GetComponent<Button>();
|
||||||
Button_FastForward = transform.Find(nameof(Button_FastForward)).GetComponent<Button>();
|
Button_FastForward = transform.Find(nameof(Button_FastForward)).GetComponent<Button>();
|
||||||
Button_Logic = transform.Find(nameof(Button_Logic)).GetComponent<Button>();
|
Button_Logic = transform.Find(nameof(Button_Logic)).GetComponent<Button>();
|
||||||
Button_Reset= transform.Find(nameof(Button_Reset)).GetComponent<Button>();
|
Button_Reset = transform.Find(nameof(Button_Reset)).GetComponent<Button>();
|
||||||
Button_Complete = transform.Find(nameof(Button_Complete)).GetComponent<Button>();
|
Button_Complete = transform.Find(nameof(Button_Complete)).GetComponent<Button>();
|
||||||
text_FastForward = Button_FastForward.GetComponentInChildren<TMP_Text>();
|
text_FastForward = Button_FastForward.GetComponentInChildren<TMP_Text>();
|
||||||
onPlaying += onPlay;
|
onPlaying += onPlay;
|
||||||
@@ -69,6 +71,8 @@ namespace Octopus.Simulator
|
|||||||
isplaying = false;
|
isplaying = false;
|
||||||
Button_Play.image.sprite = pause;
|
Button_Play.image.sprite = pause;
|
||||||
onPlaying?.Invoke(isplaying);
|
onPlaying?.Invoke(isplaying);
|
||||||
|
var cameraData = Tar();
|
||||||
|
Application.ExternalCall("setCamAngle", cameraData);
|
||||||
var requestURL = $"{requestAPI}/{WebParameters.id}/pause";
|
var requestURL = $"{requestAPI}/{WebParameters.id}/pause";
|
||||||
webmanager.Reqeust<HistoryParameters>(requestURL, RequestType.POST, null);
|
webmanager.Reqeust<HistoryParameters>(requestURL, RequestType.POST, null);
|
||||||
}
|
}
|
||||||
@@ -196,21 +200,40 @@ namespace Octopus.Simulator
|
|||||||
var requsetURL = $"{webmanager.apiConfig.history}/{WebParameters.id}/toggle-realtime";
|
var requsetURL = $"{webmanager.apiConfig.history}/{WebParameters.id}/toggle-realtime";
|
||||||
RealTime rt = new RealTime();
|
RealTime rt = new RealTime();
|
||||||
rt.realTime = false;
|
rt.realTime = false;
|
||||||
webmanager.Reqeust<RealTime>(requsetURL, RequestType.POST, (value)=>ResumeSimulation(), rt);
|
webmanager.Reqeust<RealTime>(requsetURL, RequestType.POST, (value) => ResumeSimulation(), rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResumeSimulation()
|
public void ResumeSimulation()
|
||||||
{
|
{
|
||||||
var reqeustURL = $"{webmanager.apiConfig.history}/{WebParameters.id}/resume";
|
var reqeustURL = $"{webmanager.apiConfig.history}/{WebParameters.id}/resume";
|
||||||
emptyClass ec = new emptyClass();
|
emptyClass ec = new emptyClass();
|
||||||
webmanager.Reqeust<emptyClass>(reqeustURL, RequestType.POST,null,ec);
|
webmanager.Reqeust<emptyClass>(reqeustURL, RequestType.POST, null, ec);
|
||||||
Application.ExternalCall("setCamAngle", "Test");
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private string Tar()
|
||||||
|
{
|
||||||
|
var camera = RTFocusCamera.Get.TargetCamera;
|
||||||
|
var camPos = camera.transform.position;
|
||||||
|
var cmaRot = camera.transform.eulerAngles;
|
||||||
|
|
||||||
|
CameraEntity cameraEntity = new();
|
||||||
|
cameraEntity.posX = camPos.x;
|
||||||
|
cameraEntity.posY = camPos.y;
|
||||||
|
cameraEntity.posZ = camPos.z;
|
||||||
|
cameraEntity.rotX = cmaRot.x;
|
||||||
|
cameraEntity.rotY = cmaRot.y;
|
||||||
|
cameraEntity.rotZ = cmaRot.z;
|
||||||
|
|
||||||
|
var json = JsonUtility.ToJson(cameraEntity);
|
||||||
|
Debug.Log(json);
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
//MQTT 재연결
|
//MQTT 재연결
|
||||||
private void ReConnect(MQTTClient client)
|
private void ReConnect(MQTTClient client)
|
||||||
{
|
{
|
||||||
if(isplaying)
|
if (isplaying)
|
||||||
SetMqttConnect();
|
SetMqttConnect();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ namespace Octopus.Simulator.Networks
|
|||||||
public event Action onParameterRecived;
|
public event Action onParameterRecived;
|
||||||
public event Action<string> onMqttConfigReceived;
|
public event Action<string> onMqttConfigReceived;
|
||||||
public event Action<string> onWebConfigReceived;
|
public event Action<string> onWebConfigReceived;
|
||||||
|
public event Action<string> onCameraReceived;
|
||||||
|
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
@@ -48,9 +50,10 @@ namespace Octopus.Simulator.Networks
|
|||||||
Debug.Log($"webconfig:{json}");
|
Debug.Log($"webconfig:{json}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void camAngle(string angle)
|
public void camAngle(string json)
|
||||||
{
|
{
|
||||||
Debug.Log($"webCam:{angle}");
|
onCameraReceived?.Invoke(json);
|
||||||
|
Debug.Log($"webCam:{json}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,11 @@ namespace Assets.WorkSpace.R
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class CameraEntity
|
public class CameraEntity
|
||||||
{
|
{
|
||||||
public string posX;
|
public float posX;
|
||||||
public string posY;
|
public float posY;
|
||||||
public string posZ;
|
public float posZ;
|
||||||
public string rotX;
|
public float rotX;
|
||||||
public string rotY;
|
public float rotY;
|
||||||
public string rotZ;
|
public float rotZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user