Drawstuff.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using Ode.NET;
  4. namespace Drawstuff.NET
  5. {
  6. #if dDOUBLE
  7. using dReal = System.Double;
  8. #else
  9. using dReal = System.Single;
  10. #endif
  11. public static class ds
  12. {
  13. public const int VERSION = 2;
  14. public enum Texture
  15. {
  16. None,
  17. Wood
  18. }
  19. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  20. public delegate void CallbackFunction(int arg);
  21. [StructLayout(LayoutKind.Sequential)]
  22. public struct Functions
  23. {
  24. public int version;
  25. public CallbackFunction start;
  26. public CallbackFunction step;
  27. public CallbackFunction command;
  28. public CallbackFunction stop;
  29. public string path_to_textures;
  30. }
  31. [DllImport("drawstuff", EntryPoint="dsDrawBox")]
  32. public static extern void DrawBox(ref d.Vector3 pos, ref d.Matrix3 R, ref d.Vector3 sides);
  33. [DllImport("drawstuff", EntryPoint = "dsDrawCapsule")]
  34. public static extern void DrawCapsule(ref d.Vector3 pos, ref d.Matrix3 R, dReal length, dReal radius);
  35. [DllImport("drawstuff", EntryPoint = "dsDrawConvex")]
  36. public static extern void DrawConvex(ref d.Vector3 pos, ref d.Matrix3 R, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons);
  37. [DllImport("drawstuff", EntryPoint="dsSetColor")]
  38. public static extern void SetColor(float red, float green, float blue);
  39. [DllImport("drawstuff", EntryPoint="dsSetTexture")]
  40. public static extern void SetTexture(Texture texture);
  41. [DllImport("drawstuff", EntryPoint="dsSetViewpoint")]
  42. public static extern void SetViewpoint(ref d.Vector3 xyz, ref d.Vector3 hpr);
  43. [DllImport("drawstuff", EntryPoint="dsSimulationLoop")]
  44. public static extern void SimulationLoop(int argc, string[] argv, int window_width, int window_height, ref Functions fn);
  45. }
  46. }