Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ode/ode-0.9/contrib/OdeModelProcessor/README.TXT @ 216

Last change on this file since 216 was 216, checked in by mathiask, 16 years ago

[Physik] add ode-0.9

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