public void OnReceivedBoneSizes( CmdResponseBoneSize[] boneSizes ) { for( int i = 0; i < boneSizes.Length && i < (int)NeuronBones.NumOfBones; ++i ) { this.boneSizes[i] = boneSizes[i].BoneLength; } for( int i = 0; i < receivedBoneSizesCallbacks.Count; ++i ) { receivedBoneSizesCallbacks[i](); } }
public virtual void OnCommandResponded( IntPtr respondheader, IntPtr respondData ) { CommandPack pack = new CommandPack(); try { pack = (CommandPack)Marshal.PtrToStructure( respondheader, typeof( CommandPack ) ); } catch( Exception e ) { Debug.LogException( e ); } switch( pack.CommandId ) { case CmdId.Cmd_AvatarCount: { int actorCount = BitConverter.ToInt32( pack.CmdParaments, 0 ); OnReceivedActorCount( actorCount ); } break; case CmdId.Cmd_DataFrequency: { int actorId = BitConverter.ToInt32( pack.CmdParaments, 0 ); int frequency = BitConverter.ToInt32( pack.CmdParaments, sizeof( int ) ); NeuronActor actor = FindActiveActor( actorId ); if( actor == null ) { actor = FindSuspendedActor( actorId ); } if( actor != null ) { actor.OnReceivedDataFrequency( frequency ); } } break; case CmdId.Cmd_BoneSize: { int actorId = BitConverter.ToInt32( pack.CmdParaments, 0 ); CmdResponseBoneSize[] boneSizes = new CmdResponseBoneSize[(int)pack.DataCount]; // fill bone size IntPtr offset = respondData; Int64 len = Marshal.SizeOf( boneSizes[0] ); for (int i = 0; i < boneSizes.Length; i++) { try { boneSizes[i] = (CmdResponseBoneSize)Marshal.PtrToStructure( offset, typeof( CmdResponseBoneSize ) ); } catch( Exception e ) { Debug.LogException( e ); } offset = new IntPtr( offset.ToInt64() + len ); } NeuronActor actor = FindActiveActor( actorId ); if( actor == null ) { actor = FindSuspendedActor( actorId ); } actor.OnReceivedBoneSizes( boneSizes ); } break; case CmdId.Cmd_CombinationMode: { int actorId = BitConverter.ToInt32( pack.CmdParaments, 0 ); SensorCombinationModes combMode = (SensorCombinationModes)BitConverter.ToInt32( pack.CmdParaments, sizeof( int ) ); NeuronActor actor = FindActiveActor( actorId ); if( actor == null ) { actor = FindSuspendedActor( actorId ); } actor.OnReceivedCombinationMode( combMode ); } break; } }