Skip to content

Commit

Permalink
Merge branch 'v3_0_samples'
Browse files Browse the repository at this point in the history
  • Loading branch information
gpsnmeajp committed Nov 6, 2019
2 parents 690466c + e0c04a5 commit dfc6298
Show file tree
Hide file tree
Showing 22 changed files with 1,052 additions and 235 deletions.
89 changes: 52 additions & 37 deletions EVMC4U/CameraReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,56 @@ public class CameraReceiver : MonoBehaviour, IExternalReceiver
private Quaternion cameraRotFilter = Quaternion.identity;

//メッセージ処理一時変数struct(負荷対策)
Vector3 pos;
Quaternion rot;
//Vector3 pos;
//Quaternion rot;

//カメラ情報のキャッシュ
Vector3 cameraPos = Vector3.zero;
Quaternion cameraRot = Quaternion.identity;
float fov = 0;

void Start()
{
externalReceiverManager = new ExternalReceiverManager(NextReceivers);
StatusMessage = "Waiting for Master...";
}

//デイジーチェーンを更新
public void UpdateDaisyChain()
{
externalReceiverManager.GetIExternalReceiver(NextReceivers);
}

void Update()
{
//カメラがセットされているならば
if (VMCControlledCamera != null && VMCControlledCamera.transform != null && fov != 0)
{
//カメラ移動フィルタ
if (CameraPositionFilterEnable)
{
cameraPosFilter = (cameraPosFilter * CameraFilter) + cameraPos * (1.0f - CameraFilter);
VMCControlledCamera.transform.localPosition = cameraPosFilter;
}
else
{
VMCControlledCamera.transform.localPosition = cameraPos;
}
//カメラ回転フィルタ
if (CameraRotationFilterEnable)
{
cameraRotFilter = Quaternion.Slerp(cameraRotFilter, cameraRot, 1.0f - CameraFilter);
VMCControlledCamera.transform.localRotation = cameraRotFilter;
}
else
{
VMCControlledCamera.transform.localRotation = cameraRot;
}
//FOV同期
VMCControlledCamera.fieldOfView = fov;
}
}

public void MessageDaisyChain(ref uOSC.Message message, int callCount)
{
//Startされていない場合無視
Expand Down Expand Up @@ -111,41 +152,15 @@ private void ProcessMessage(ref uOSC.Message message)
&& (message.values[8] is float)
)
{
//カメラがセットされているならば
if (VMCControlledCamera != null && VMCControlledCamera.transform != null)
{
pos.x = (float)message.values[1];
pos.y = (float)message.values[2];
pos.z = (float)message.values[3];
rot.x = (float)message.values[4];
rot.y = (float)message.values[5];
rot.z = (float)message.values[6];
rot.w = (float)message.values[7];
float fov = (float)message.values[8];

//カメラ移動フィルタ
if (CameraPositionFilterEnable)
{
cameraPosFilter = (cameraPosFilter * CameraFilter) + pos * (1.0f - CameraFilter);
VMCControlledCamera.transform.localPosition = cameraPosFilter;
}
else
{
VMCControlledCamera.transform.localPosition = pos;
}
//カメラ回転フィルタ
if (CameraRotationFilterEnable)
{
cameraRotFilter = Quaternion.Slerp(cameraRotFilter, rot, 1.0f - CameraFilter);
VMCControlledCamera.transform.localRotation = cameraRotFilter;
}
else
{
VMCControlledCamera.transform.localRotation = rot;
}
//FOV同期
VMCControlledCamera.fieldOfView = fov;
}
cameraPos.x = (float)message.values[1];
cameraPos.y = (float)message.values[2];
cameraPos.z = (float)message.values[3];
cameraRot.x = (float)message.values[4];
cameraRot.y = (float)message.values[5];
cameraRot.z = (float)message.values[6];
cameraRot.w = (float)message.values[7];
fov = (float)message.values[8];
//受信と更新のタイミングは切り離した
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions EVMC4U/CommunicationValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void Start()
StatusMessage = "Waiting for Master...";
}

//デイジーチェーンを更新
public void UpdateDaisyChain()
{
externalReceiverManager.GetIExternalReceiver(NextReceivers);
}

int GetAvailable()
{
return Available;
Expand Down
6 changes: 6 additions & 0 deletions EVMC4U/DeviceReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ void Start()
}
}

//デイジーチェーンを更新
public void UpdateDaisyChain()
{
externalReceiverManager.GetIExternalReceiver(NextReceivers);
}

public void MessageDaisyChain(ref uOSC.Message message, int callCount)
{
//Startされていない場合無視
Expand Down
Loading

0 comments on commit dfc6298

Please sign in to comment.