Compare commits
2 Commits
14b8c75785
...
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.Generic;
|
||||
using UnityEngine;
|
||||
@@ -117,7 +119,7 @@ namespace RTG
|
||||
public CameraHotkeys Hotkeys { get { return _hotkeys; } }
|
||||
public CameraLimit LimitSetting { get { return _cameraLimitSetting; } }
|
||||
|
||||
|
||||
private WebReceiver _receiver;
|
||||
public bool IsViewportHoveredByDevice()
|
||||
{
|
||||
Vector2 devicePos = RTInputDevice.Get.Device.GetPositionYAxisUp();
|
||||
@@ -140,7 +142,8 @@ namespace RTG
|
||||
|
||||
SetFocusPoint(GetFocusPoint());
|
||||
AdjustOrthoSizeForFocusPt();
|
||||
|
||||
_receiver = FindAnyObjectByType<WebReceiver>();
|
||||
_receiver.onCameraReceived += SetCamera;
|
||||
_isObjectVisibilityDirty = true;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
@@ -155,6 +158,16 @@ namespace RTG
|
||||
#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)
|
||||
{
|
||||
_targetCamera.fieldOfView = fov;
|
||||
|
||||
@@ -122,8 +122,6 @@ namespace Octopus.Simulator.Networks
|
||||
public event Action<MQTTClient> onConnected;
|
||||
private void OnConnected(MQTTClient client, string clientName)
|
||||
{
|
||||
Debug.Log("연결완료");
|
||||
|
||||
clientTable.Add(clientName, client);
|
||||
onConnected?.Invoke(client);
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ using TMPro;
|
||||
using UVC.Networks;
|
||||
using Best.MQTT;
|
||||
using Best.MQTT.Packets;
|
||||
using RTG;
|
||||
using Assets.WorkSpace.R;
|
||||
|
||||
namespace Octopus.Simulator
|
||||
{
|
||||
@@ -69,6 +71,8 @@ namespace Octopus.Simulator
|
||||
isplaying = false;
|
||||
Button_Play.image.sprite = pause;
|
||||
onPlaying?.Invoke(isplaying);
|
||||
var cameraData = Tar();
|
||||
Application.ExternalCall("setCamAngle", cameraData);
|
||||
var requestURL = $"{requestAPI}/{WebParameters.id}/pause";
|
||||
webmanager.Reqeust<HistoryParameters>(requestURL, RequestType.POST, null);
|
||||
}
|
||||
@@ -204,7 +208,26 @@ namespace Octopus.Simulator
|
||||
var reqeustURL = $"{webmanager.apiConfig.history}/{WebParameters.id}/resume";
|
||||
emptyClass ec = new emptyClass();
|
||||
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 재연결
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Octopus.Simulator.Networks
|
||||
public event Action onParameterRecived;
|
||||
public event Action<string> onMqttConfigReceived;
|
||||
public event Action<string> onWebConfigReceived;
|
||||
public event Action<string> onCameraReceived;
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
@@ -48,9 +50,10 @@ namespace Octopus.Simulator.Networks
|
||||
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]
|
||||
public class CameraEntity
|
||||
{
|
||||
public string posX;
|
||||
public string posY;
|
||||
public string posZ;
|
||||
public string rotX;
|
||||
public string rotY;
|
||||
public string rotZ;
|
||||
public float posX;
|
||||
public float posY;
|
||||
public float posZ;
|
||||
public float rotX;
|
||||
public float rotY;
|
||||
public float rotZ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user