aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/include/ode/collision_trimesh.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ode-0.9/include/ode/collision_trimesh.h')
-rwxr-xr-xlibraries/ode-0.9/include/ode/collision_trimesh.h205
1 files changed, 205 insertions, 0 deletions
diff --git a/libraries/ode-0.9/include/ode/collision_trimesh.h b/libraries/ode-0.9/include/ode/collision_trimesh.h
new file mode 100755
index 0000000..ad85a6e
--- /dev/null
+++ b/libraries/ode-0.9/include/ode/collision_trimesh.h
@@ -0,0 +1,205 @@
1/*************************************************************************
2 * *
3 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of EITHER: *
8 * (1) The GNU Lesser General Public License as published by the Free *
9 * Software Foundation; either version 2.1 of the License, or (at *
10 * your option) any later version. The text of the GNU Lesser *
11 * General Public License is included with this library in the *
12 * file LICENSE.TXT. *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
15 * *
16 * This library is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
20 * *
21 *************************************************************************/
22
23/*
24 * TriMesh code by Erwin de Vries.
25 *
26 * Trimesh data.
27 * This is where the actual vertexdata (pointers), and BV tree is stored.
28 * Vertices should be single precision!
29 * This should be more sophisticated, so that the user can easyly implement
30 * another collision library, but this is a lot of work, and also costs some
31 * performance because some data has to be copied.
32 */
33
34#ifndef _ODE_COLLISION_TRIMESH_H_
35#define _ODE_COLLISION_TRIMESH_H_
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/*
42 * Data storage for triangle meshes.
43 */
44struct dxTriMeshData;
45typedef struct dxTriMeshData* dTriMeshDataID;
46
47/*
48 * These dont make much sense now, but they will later when we add more
49 * features.
50 */
51ODE_API dTriMeshDataID dGeomTriMeshDataCreate(void);
52ODE_API void dGeomTriMeshDataDestroy(dTriMeshDataID g);
53
54
55
56enum { TRIMESH_FACE_NORMALS };
57ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void* in_data);
58ODE_API void* dGeomTriMeshDataGet(dTriMeshDataID g, int data_id);
59
60
61
62/**
63 * We need to set the last transform after each time step for
64 * accurate collision response. These functions get and set that transform.
65 * It is stored per geom instance, rather than per dTriMeshDataID.
66 */
67ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, dMatrix4 last_trans );
68ODE_API dReal* dGeomTriMeshGetLastTransform( dGeomID g );
69
70/*
71 * Build TriMesh data with single precision used in vertex data .
72 */
73ODE_API void dGeomTriMeshDataBuildSingle(dTriMeshDataID g,
74 const void* Vertices, int VertexStride, int VertexCount,
75 const void* Indices, int IndexCount, int TriStride);
76/* same again with a normals array (used as trimesh-trimesh optimization) */
77ODE_API void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g,
78 const void* Vertices, int VertexStride, int VertexCount,
79 const void* Indices, int IndexCount, int TriStride,
80 const void* Normals);
81/*
82* Build TriMesh data with double pricision used in vertex data .
83*/
84ODE_API void dGeomTriMeshDataBuildDouble(dTriMeshDataID g,
85 const void* Vertices, int VertexStride, int VertexCount,
86 const void* Indices, int IndexCount, int TriStride);
87/* same again with a normals array (used as trimesh-trimesh optimization) */
88ODE_API void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g,
89 const void* Vertices, int VertexStride, int VertexCount,
90 const void* Indices, int IndexCount, int TriStride,
91 const void* Normals);
92
93/*
94 * Simple build. Single/double precision based on dSINGLE/dDOUBLE!
95 */
96ODE_API void dGeomTriMeshDataBuildSimple(dTriMeshDataID g,
97 const dReal* Vertices, int VertexCount,
98 const int* Indices, int IndexCount);
99/* same again with a normals array (used as trimesh-trimesh optimization) */
100ODE_API void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g,
101 const dReal* Vertices, int VertexCount,
102 const int* Indices, int IndexCount,
103 const int* Normals);
104
105/* Preprocess the trimesh data to remove mark unnecessary edges and vertices */
106ODE_API void dGeomTriMeshDataPreprocess(dTriMeshDataID g);
107/* Get and set the internal preprocessed trimesh data buffer, for loading and saving */
108ODE_API void dGeomTriMeshDataGetBuffer(dTriMeshDataID g, unsigned char** buf, int* bufLen);
109ODE_API void dGeomTriMeshDataSetBuffer(dTriMeshDataID g, unsigned char* buf);
110
111
112/*
113 * Per triangle callback. Allows the user to say if he wants a collision with
114 * a particular triangle.
115 */
116typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
117ODE_API void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback);
118ODE_API dTriCallback* dGeomTriMeshGetCallback(dGeomID g);
119
120/*
121 * Per object callback. Allows the user to get the list of triangles in 1
122 * shot. Maybe we should remove this one.
123 */
124typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
125ODE_API void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback);
126ODE_API dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g);
127
128/*
129 * Ray callback.
130 * Allows the user to say if a ray collides with a triangle on barycentric
131 * coords. The user can for example sample a texture with alpha transparency
132 * to determine if a collision should occur.
133 */
134typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
135ODE_API void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback);
136ODE_API dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g);
137
138/*
139 * Trimesh class
140 * Construction. Callbacks are optional.
141 */
142ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
143
144ODE_API void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data);
145ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g);
146
147
148// enable/disable/check temporal coherence
149ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable);
150ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass);
151
152/*
153 * Clears the internal temporal coherence caches. When a geom has its
154 * collision checked with a trimesh once, data is stored inside the trimesh.
155 * With large worlds with lots of seperate objects this list could get huge.
156 * We should be able to do this automagically.
157 */
158ODE_API void dGeomTriMeshClearTCCache(dGeomID g);
159
160
161/*
162 * returns the TriMeshDataID
163 */
164ODE_API dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g);
165
166/*
167 * Gets a triangle.
168 */
169ODE_API void dGeomTriMeshGetTriangle(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
170
171/*
172 * Gets the point on the requested triangle and the given barycentric
173 * coordinates.
174 */
175ODE_API void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
176
177/*
178
179This is how the strided data works:
180
181struct StridedVertex{
182 dVector3 Vertex;
183 // Userdata
184};
185int VertexStride = sizeof(StridedVertex);
186
187struct StridedTri{
188 int Indices[3];
189 // Userdata
190};
191int TriStride = sizeof(StridedTri);
192
193*/
194
195
196ODE_API int dGeomTriMeshGetTriangleCount (dGeomID g);
197
198ODE_API void dGeomTriMeshDataUpdate(dTriMeshDataID g);
199
200#ifdef __cplusplus
201}
202#endif
203
204#endif /* _ODE_COLLISION_TRIMESH_H_ */
205