README.TXT 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. The ODE Model Processor
  2. -----------------------
  3. Copyright 2007, Department of Information Science,
  4. University of Otago, Dunedin, New Zealand.
  5. Author: Richard Barrington <[email protected]>
  6. This is a Content Processor and Tag library written for use with
  7. Microsoft Visual C# 2005 Express Edition and Microsoft XNA Game
  8. Studio Express 1.0.
  9. It can be used to read .x model vertex and index data before
  10. insertion into the content pipeline. This is used to build ODE
  11. Triangle Meshes which are then used for collision detection that
  12. is more accurate than the default XNA bounding boxes or spheres.
  13. Usage is fairly simple:
  14. Build the library and reference the DLL in your project.
  15. Add the DLL to the Content Pipeline
  16. Set the content processor for you .x models to OdeModelProcessor.
  17. Create triangle meshes as follows:
  18. 1) Create a space, but only one for all of models.
  19. 2) Create a triangle data.
  20. 3) Load the model.
  21. 4) Retreive the tag from the model.
  22. 6) Build the triangle mesh by calling d.GeomTriMeshDataBuildSimple.
  23. Eg:
  24. IntPtr space = d.SimpleSpaceCreate(IntPtr.Zero);
  25. IntPtr triangleData = d.GeomTriMeshDataCreate();
  26. Model obj = content.Load<Model>("Content\\mycube");
  27. OdeTag tag = (OdeTag)obj.Tag;
  28. IntPtr vertexArray = tag.getVertices();
  29. IntPtr indexArray = tag.getIndices();
  30. d.GeomTriMeshDataBuildSimple
  31. (
  32. triangleData,
  33. vertexArray, tag.getVertexStride(), tag.getVertexCount(),
  34. indexArray, tag.getIndexCount(), tag.getIndexStride()
  35. );
  36. IntPtr triangleMesh = d.CreateTriMesh(space, triangleData, null, null, null);
  37. You can load multiple models and test for collisions with something
  38. like this in the update method:
  39. d.GeomSetPosition(odeTri1, obj1Position.X, obj1Position.Y, obj1Position.Z);
  40. d.GeomSetPosition(odeTri2, obj2Position.X, obj2Position.Y, obj2Position.Z);
  41. int numberOfContacts = d.Collide(odeTri1, odeTri2, ODE_CONTACTS,
  42. contactGeom, d.ContactGeom.SizeOf);
  43. Where odeTri1 and odeTri2 are triangle meshes you've created, obj1Position
  44. and obj2Position are the positions of your rendered models in the scene,
  45. ODE_CONTACTS is a constant defining the maximum number of contacts
  46. to test for, contactGeom is a d.ContactGeom[] of length ODE_CONTACTS.
  47. If numberOfContacts is greater than 0, you have a collision.
  48. Other ODE functions such as d.SpaceCollide() also work; see ODE.NET BoxTest.cs.
  49. This library is free software; you can redistribute it and/or
  50. modify it under the same terms as the ODE and ODE.Net libraries.
  51. Specifically, the terms are one of EITHER:
  52. (1) The GNU Lesser General Public License as published by the Free
  53. Software Foundation; either version 2.1 of the License, or (at
  54. your option) any later version. The text of the GNU Lesser
  55. General Public License is included with this library in the
  56. file LICENSE.TXT.
  57. (2) The BSD-style license that is included with this library in
  58. the file LICENSE-BSD.TXT.
  59. This library is distributed in the hope that it will be useful,
  60. but WITHOUT ANY WARRANTY; without even the implied warranty of
  61. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
  62. LICENSE.TXT and LICENSE-BSD.TXT for more details.