forked from PoseAI/PoseCameraAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoseAISourceNative.cs
More file actions
38 lines (32 loc) · 1.24 KB
/
PoseAISourceNative.cs
File metadata and controls
38 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2022 Pose AI Ltd. All rights reserved
using System;
using UnityEngine;
namespace PoseAI
{
/*
* A character component which can be used to supply a source to the
* PoseAICharacterController and PoseAIAnimator. This source uses a direct call to
* ProcessNativePacket to provide the PoseAI Engine information as an formated packet.
* This is useful when the Unity game and the engine are on the same device, and could
* be connected with simple messaging (similar to the Unity iOS demo app)
*/
public class PoseAISourceNative : PoseAISource
{
[Tooltip("Format of the rig for streaming. Determines joint names and reference neutral rotations")]
public PoseAI_Rigs RigType = PoseAI_Rigs.Unity;
private PoseAIRigBase _rigObj;
public override PoseAIRigBase GetRig()
{
if (_rigObj == null)
_rigObj = PoseAIRigFactory.SelectRig(RigType);
return _rigObj;
}
public void ProcessNativePacket(string packetAsJsonString)
{
if (!GetRig().OverwriteFromJSON(packetAsJsonString))
{
Debug.Log("Could not read native packet: " + packetAsJsonString);
}
}
}
}