public static ReturnStatus GetShapeInstanceResults(ref INTERACTION_SCENE scene, List <INTERACTION_SHAPE_INSTANCE_RESULTS> results) { UInt32 nResults; IntPtr papResultsBuffer; var rs = LeapIEGetShapeInstanceResults(ref scene, out nResults, out papResultsBuffer); results.Clear(); if (rs == ReturnStatus.Success) { for (int i = 0; i < nResults; i++) { IntPtr resultPtr; StructMarshal <IntPtr> .ArrayElementToStruct(papResultsBuffer, i, out resultPtr); INTERACTION_SHAPE_INSTANCE_RESULTS result; StructMarshal <INTERACTION_SHAPE_INSTANCE_RESULTS> .PtrToStruct(resultPtr, out result); results.Add(result); } } Logger.HandleReturnStatus(scene, "Get Velocities", LogLevel.AllCalls, rs); return(rs); }
public void ArrayElementToStructTest() { Marshal.StructureToPtr(_testStruct, (IntPtr)((long)_ptr + _size * ARRAY_TEST_INDEX), false); TestMarshaledStruct output; StructMarshal <TestMarshaledStruct> .ArrayElementToStruct(_ptr, ARRAY_TEST_INDEX, out output); Assert.That(_testStruct.id, Is.EqualTo(output.id), "Input must match output."); }
public static ReturnStatus GetDebugLines(ref INTERACTION_SCENE scene, List <INTERACTION_DEBUG_LINE> lines) { UInt32 lineCount; IntPtr arrayPtr; var rs = LeapIEGetDebugLines(ref scene, out lineCount, out arrayPtr); lines.Clear(); for (int i = 0; i < lineCount; i++) { INTERACTION_DEBUG_LINE line; StructMarshal <INTERACTION_DEBUG_LINE> .ArrayElementToStruct(arrayPtr, i, out line); lines.Add(line); } return(rs); }
public static ReturnStatus GetDebugStrings(ref INTERACTION_SCENE scene, List <string> strings) { UInt32 nStrings; IntPtr pppStrings; var rs = LeapIEGetDebugStrings(ref scene, out nStrings, out pppStrings); strings.Clear(); if (rs == ReturnStatus.Success) { for (int i = 0; i < nStrings; i++) { IntPtr charPtr; StructMarshal <IntPtr> .ArrayElementToStruct(pppStrings, i, out charPtr); string str = Marshal.PtrToStringAnsi(charPtr); strings.Add(str); } } Logger.HandleReturnStatus(scene, "Get Debug Strings", LogLevel.AllCalls, rs); return(rs); }