// object owning accessory should be locked private static void Render3D(IPluginViewSettings pluginViewSettings, viz.Accessory accessory) { AccessoryPlugin3DViewSettings accessoryViewSettings = pluginViewSettings as AccessoryPlugin3DViewSettings; if ((accessoryViewSettings != null) && (accessory != null)) { if (accessoryViewSettings.RenderOrientationCube) { accessory.SetMode(viz.AccessoryMode.RotationCube); accessory.Render(); } if (accessoryViewSettings.RenderFrustum) { accessory.SetMode(viz.AccessoryMode.ViewFrustum); accessory.Render(); } if (accessoryViewSettings.RenderFloorPlane) { accessory.SetMode(viz.AccessoryMode.FloorPlane); accessory.Render(); } } }
// instance for accessory should be locked private static void HandleEvent(KStudioEvent eventObj, viz.Accessory accessory) { if (eventObj != null) { if ((eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.Body) || (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.BodyMonitor)) { if (accessory != null) { uint bufferSize; IntPtr bufferPtr; eventObj.AccessUnderlyingEventDataBuffer(out bufferSize, out bufferPtr); if (bufferSize >= AccessoryPlugin.cMinimumBodyFrameSize) { viz.Vector floorPlane; viz.Vector upVector; unsafe { float *pFloats = (float *)((bufferPtr + AccessoryPlugin.cFloorClipPlaneOffset).ToPointer()); if (pFloats[3] == 0.0f) { // if W is 0, assume no real floor plane floorPlane = new viz.Vector(0.0f, 0.0f, 0.0f, 0.0f); } else { floorPlane = new viz.Vector(pFloats[0], pFloats[1], pFloats[2], pFloats[3]); } pFloats = (float *)((bufferPtr + AccessoryPlugin.cUpVectorOffset).ToPointer()); upVector = new viz.Vector(0.0f, 0.0f, 0.0f, 0.0f); // never use up vector for visualizing the floor accessory.UpdateFloorPlaneAndUpVector(floorPlane, upVector); } } } } } }