// 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); } } } } } }
public BodyOptions(float r, float g, float b) { BoneEffect = new viz.Effect { EnableLighting = true, Ambient = new viz.Vector(1.0f, 0.0f, 0.0f, 1.0f) { R = r, G = g, B = b }, Specular = new viz.Vector(1.0f, 1.0f, 1.0f, 1.0f), Power = 22.0f }; JointEffect = new viz.Effect { Diffuse = new viz.Vector(0.0f, 1.0f, 0.0f, 1.0f) };; ColorVector = new viz.Vector(1, 1, 1, 1) { R = r, G = g, B = b }; }
// object owning data should be locked private static void Render2D(IPluginViewSettings pluginViewSettings, viz.Texture texture, float left, float top, float width, float height, EventTypePluginData data, nui.Registration registration) { Debug.Assert(data != null); BodyPlugin2DViewSettings bodyPluginViewSettings = pluginViewSettings as BodyPlugin2DViewSettings; if ((bodyPluginViewSettings != null) && (registration != null) && (data.body != null) && data.bodiesValid) { if (bodyPluginViewSettings.RenderBodies || bodyPluginViewSettings.RenderHands) { viz.Body2DMode bodyMode = viz.Body2DMode.DepthIR; if ((texture != null) && (texture.GetWidth() == nui.Constants.STREAM_COLOR_WIDTH) && (texture.GetHeight() == nui.Constants.STREAM_COLOR_HEIGHT)) { bodyMode = viz.Body2DMode.Color; } data.body.Begin2D(left, top, width, height, bodyMode, registration.GetCalibrationData()); for (uint i = 0; i < BodyPlugin.bodyOptions.Length; ++i) { if (bodyPluginViewSettings.RenderBodies) { viz.Vector color = BodyPlugin.bodyOptions[i].ColorVector; color.A = 0.7f; data.body.RenderBones2D(i, color); } if (bodyPluginViewSettings.RenderHands) { data.body.RenderHandStates2D(i); } } data.body.End2D(); } } }
public BodyOptions(float r, float g, float b) { BoneEffect = new viz.Effect { EnableLighting = true, Ambient = new viz.Vector(1.0f, 0.0f, 0.0f, 1.0f) { R = r, G = g, B = b }, Specular = new viz.Vector(1.0f, 1.0f, 1.0f, 1.0f), Power = 22.0f }; JointEffect = new viz.Effect { Diffuse = new viz.Vector(0.0f, 1.0f, 0.0f, 1.0f) }; ; ColorVector = new viz.Vector(1, 1, 1, 1) { R = r, G = g, B = b }; }
// 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); } } } } } }