public KinectProtocol_v1() { BinaryWritableContainer m_packetContainer = new BinaryWritableContainer(); TaggedBundle m_kinectHeader; TaggedBundle m_skeletonExtra; TaggedBundle m_skeletonVertices; TaggedBundle m_kinectJoystick; TaggedBundle m_kinectCustom; m_kinectHeader = new TaggedBundle(19); m_kinectHeader.Add((VersionNumber = new WritableVersionNumber("01.02.03.04"))); m_kinectHeader.Add((PlayerCount = new WritableByte(0))); m_kinectHeader.Add((Flags = new WritableUInt(0))); // flags m_kinectHeader.Add((FloorClipPlane = new WritableFloorClipPlane(0.1f, 0.1f, 0.1f, 0.1f))); m_kinectHeader.Add((GravityNormal = new WritableVertex(0.0f, 0.0f, 0.0f))); // gravity normal m_packetContainer.Add(m_kinectHeader); byte[] trackingStates = new byte[20]; for (uint i = 0; i < trackingStates.Length; i++) { trackingStates[i] = (byte)Microsoft.Kinect.JointTrackingState.Tracked; } m_skeletonExtra = new TaggedBundle(20); m_skeletonExtra.Add((SkeletonTrackingStates = new WritableTrackingStates(trackingStates))); // for joints m_skeletonExtra.Add((CenterOfMass = new WritableVertex(0.1f, 0.1f, 0.1f))); // center of mass m_skeletonExtra.Add((Quality = new WritableUInt(0))); // Quality m_skeletonExtra.Add((SkeletonTrackState = new WritableUInt((uint)Microsoft.Kinect.SkeletonTrackingState.Tracked))); // TrackState m_packetContainer.Add(m_skeletonExtra); WritableVertex[] vertices = new WritableVertex[20]; for (uint i = 0; i < vertices.Length; i++) { vertices[i] = new WritableVertex(0.0f, 0.33f, 2f); } m_skeletonVertices = new TaggedBundle(21); m_skeletonVertices.Add((SkeletonJoints = new WritableVertices(vertices))); m_packetContainer.Add(m_skeletonVertices); m_kinectJoystick = new TaggedBundle(24); m_kinectJoystick.Add((Joystick1 = new WritableJoystick(new sbyte[6], 0))); m_kinectJoystick.Add((Joystick2 = new WritableJoystick(new sbyte[6], 0))); m_packetContainer.Add(m_kinectJoystick); m_kinectCustom = new TaggedBundle(25); m_kinectCustom.Add((UserBytes = new WritableByteArray(null))); m_packetContainer.Add(m_kinectCustom); // compute CRC // this simply adds four 0 bytes for now m_packet = new CRC(m_packetContainer); }
public void ActivateBundle( TaggedBundle bundle){ // is there an asset bundle to be loaded with this ? if (bundle.assetBundleInfo != null){ AssetBundleLoader.GetInstance().Load(bundle.assetBundleInfo); } // Unlike scripted object, we DO NOT automatically add our stuff on awake... // add any Voicemaps or Vitals behaviors we are carrying if (bundle.voiceList != null && bundle.voiceList.Name != ""){ VoiceMgr.GetInstance().AddVoiceList(bundle.voiceList); } if (bundle.voiceLists != null){ foreach (VoiceList vl in bundle.voiceLists){ VoiceMgr.GetInstance().AddVoiceList(vl); } } if (bundle.vitalsBehaviors != null && bundle.vitalsBehaviors.Count > 0){ foreach (VitalsBehavior vb in bundle.vitalsBehaviors){ VitalsBehaviorManager.GetInstance().AddToLibrary(vb); } } // is this late enough to cause override of any content in the patient records ? if (bundle.scanRecords != null && bundle.scanRecords.Count > 0){ Patient patient = FindObjectOfType<Patient>(); if (patient != null){ foreach (ScanRecord record in bundle.scanRecords){ patient.LoadScanRecord(record); } } } }