1
0

drawstuff.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright ODE
  3. * Ode.NET - .NET bindings for ODE
  4. * Jason Perkins ([email protected])
  5. * Licensed under the New BSD
  6. * Part of the OpenDynamicsEngine
  7. Open Dynamics Engine
  8. Copyright (c) 2001-2007, Russell L. Smith.
  9. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions
  12. are met:
  13. Redistributions of source code must retain the above copyright notice,
  14. this list of conditions and the following disclaimer.
  15. Redistributions in binary form must reproduce the above copyright notice,
  16. this list of conditions and the following disclaimer in the documentation
  17. and/or other materials provided with the distribution.
  18. Neither the names of ODE's copyright owner nor the names of its
  19. contributors may be used to endorse or promote products derived from
  20. this software without specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  27. TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. *
  34. */
  35. using System;
  36. using System.Runtime.InteropServices;
  37. using Ode.NET;
  38. namespace Drawstuff.NET
  39. {
  40. #if dDOUBLE
  41. using dReal = System.Double;
  42. #else
  43. using dReal = System.Single;
  44. #endif
  45. public static class ds
  46. {
  47. public const int VERSION = 2;
  48. public enum Texture
  49. {
  50. None,
  51. Wood
  52. }
  53. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  54. public delegate void CallbackFunction(int arg);
  55. [StructLayout(LayoutKind.Sequential)]
  56. public struct Functions
  57. {
  58. public int version;
  59. public CallbackFunction start;
  60. public CallbackFunction step;
  61. public CallbackFunction command;
  62. public CallbackFunction stop;
  63. public string path_to_textures;
  64. }
  65. [DllImport("drawstuff", EntryPoint = "dsDrawBox")]
  66. public static extern void DrawBox(ref d.Vector3 pos, ref d.Matrix3 R, ref d.Vector3 sides);
  67. [DllImport("drawstuff", EntryPoint = "dsDrawCapsule")]
  68. public static extern void DrawCapsule(ref d.Vector3 pos, ref d.Matrix3 R, dReal length, dReal radius);
  69. [DllImport("drawstuff", EntryPoint = "dsDrawConvex")]
  70. public static extern void DrawConvex(ref d.Vector3 pos, ref d.Matrix3 R, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons);
  71. [DllImport("drawstuff", EntryPoint = "dsSetColor")]
  72. public static extern void SetColor(float red, float green, float blue);
  73. [DllImport("drawstuff", EntryPoint = "dsSetTexture")]
  74. public static extern void SetTexture(Texture texture);
  75. [DllImport("drawstuff", EntryPoint = "dsSetViewpoint")]
  76. public static extern void SetViewpoint(ref d.Vector3 xyz, ref d.Vector3 hpr);
  77. [DllImport("drawstuff", EntryPoint = "dsSimulationLoop")]
  78. public static extern void SimulationLoop(int argc, string[] argv, int window_width, int window_height, ref Functions fn);
  79. }
  80. }