Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions Assets/Neuron/Scripts/Editor.meta

This file was deleted.

55 changes: 0 additions & 55 deletions Assets/Neuron/Scripts/Editor/NeuronAnimatorEditor.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Assets/Neuron/Scripts/Editor/NeuronAnimatorEditor.cs.meta

This file was deleted.

49 changes: 21 additions & 28 deletions Assets/Neuron/Scripts/NeuronAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,35 @@ public class NeuronAnimator : MonoBehaviour
{
#region Editable variables

[SerializeField]
string _address = "127.0.0.1";

[SerializeField]
int _port = 7001;

[SerializeField]
NeuronConnection.SocketType _socketType = NeuronConnection.SocketType.TCP;

[SerializeField]
int _actorID = 0;
public string address = "127.0.0.1";
public int port = 7001;
public NeuronConnection.SocketType socketType = NeuronConnection.SocketType.TCP;
public int actorID = 0;

#endregion

#region MonoBehavior functions

void Awake()
protected virtual void Awake()
{
_animator = GetComponent<Animator>();
ScanBones();
}

void OnEnable()
protected virtual void OnEnable()
{
_source = NeuronConnection.Connect(_address, _port, _socketType);
if (_source != null) _actor = _source.AcquireActor(_actorID);
_source = NeuronConnection.Connect(address, port, socketType);
if (_source != null) _actor = _source.AcquireActor(actorID);
}

void OnDisable()
protected virtual void OnDisable()
{
if (_source != null) NeuronConnection.Disconnect(_source);
_source = null;
_actor = null;
}

void Update()
protected virtual void Update()
{
if (_actor == null) return;

Expand Down Expand Up @@ -124,7 +117,7 @@ void Update()
FixUpWithFeetPosition();
}

void UpdateRoot()
protected void UpdateRoot()
{
var hips = _animator.GetBoneTransform(HumanBodyBones.Hips);

Expand All @@ -139,7 +132,7 @@ void UpdateRoot()
hips.localRotation = r_rot * Quaternion.Euler(rot) * r_rot_inv * d_rot;
}

void UpdateBoneRotation(
protected void UpdateBoneRotation(
HumanBodyBones humanBone,
NeuronBones neuronBone0,
NeuronBones neuronBone1 = NeuronBones.NumOfBones,
Expand All @@ -164,7 +157,7 @@ void UpdateBoneRotation(
bone.localRotation = r_rot * Quaternion.Euler(rot) * r_rot_inv * d_rot;
}

void FixUpWithFeetPosition()
protected void FixUpWithFeetPosition()
{
var lfeet = _animator.GetBoneTransform(HumanBodyBones.LeftFoot);
var rfeet = _animator.GetBoneTransform(HumanBodyBones.RightFoot);
Expand All @@ -184,21 +177,21 @@ void FixUpWithFeetPosition()

#region Private variables

const int kBoneCount = (int)HumanBodyBones.LastBone;
protected const int kBoneCount = (int)HumanBodyBones.LastBone;

Animator _animator;
NeuronSource _source;
NeuronActor _actor;
protected Animator _animator;
protected NeuronSource _source;
protected NeuronActor _actor;

float _scaleFactorForHips;
Quaternion[] _resetRotations = new Quaternion[kBoneCount];
Quaternion[] _defaultRotations = new Quaternion[kBoneCount];
protected float _scaleFactorForHips;
protected Quaternion[] _resetRotations = new Quaternion[kBoneCount];
protected Quaternion[] _defaultRotations = new Quaternion[kBoneCount];

#endregion

#region Private functions

void ScanBones()
protected void ScanBones()
{
// The height of the hips in the base model.
const float kBaseHipsHeight = 1.113886f;
Expand Down