source: GTP/trunk/Lib/Geom/OgreStuff/include/ode/collision_trimesh.h @ 1809

Revision 1809, 7.0 KB checked in by gumbau, 18 years ago (diff)
Line 
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 */
51dTriMeshDataID dGeomTriMeshDataCreate();
52void dGeomTriMeshDataDestroy(dTriMeshDataID g);
53
54enum { TRIMESH_FACE_NORMALS, TRIMESH_LAST_TRANSFORMATION };
55void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void* data);
56
57
58/*
59 * Build TriMesh data with single pricision used in vertex data .
60 */
61void dGeomTriMeshDataBuildSingle(dTriMeshDataID g,
62                                 const void* Vertices, int VertexStride, int VertexCount,
63                                 const void* Indices, int IndexCount, int TriStride);
64/* same again with a normals array (used as trimesh-trimesh optimization) */
65void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g,
66                                  const void* Vertices, int VertexStride, int VertexCount,
67                                  const void* Indices, int IndexCount, int TriStride,
68                                  const void* Normals);
69/*
70* Build TriMesh data with double pricision used in vertex data .
71*/
72void dGeomTriMeshDataBuildDouble(dTriMeshDataID g,
73                                 const void* Vertices,  int VertexStride, int VertexCount,
74                                 const void* Indices, int IndexCount, int TriStride);
75/* same again with a normals array (used as trimesh-trimesh optimization) */
76void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g,
77                                  const void* Vertices,  int VertexStride, int VertexCount,
78                                  const void* Indices, int IndexCount, int TriStride,
79                                  const void* Normals);
80
81/*
82 * Simple build. Single/double precision based on dSINGLE/dDOUBLE!
83 */
84void dGeomTriMeshDataBuildSimple(dTriMeshDataID g,
85                                 const dReal* Vertices, int VertexCount,
86                                 const int* Indices, int IndexCount);
87/* same again with a normals array (used as trimesh-trimesh optimization) */
88void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g,
89                                  const dReal* Vertices, int VertexCount,
90                                  const int* Indices, int IndexCount,
91                                  const int* Normals);
92/*
93 * Per triangle callback. Allows the user to say if he wants a collision with
94 * a particular triangle.
95 */
96typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
97void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback);
98dTriCallback* dGeomTriMeshGetCallback(dGeomID g);
99
100/*
101 * Per object callback. Allows the user to get the list of triangles in 1
102 * shot. Maybe we should remove this one.
103 */
104typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
105void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback);
106dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g);
107
108/*
109 * Ray callback.
110 * Allows the user to say if a ray collides with a triangle on barycentric
111 * coords. The user can for example sample a texture with alpha transparency
112 * to determine if a collision should occur.
113 */
114typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
115void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback);
116dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g);
117
118/*
119 * Trimesh class
120 * Construction. Callbacks are optional.
121 */
122dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
123
124void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data);
125
126// enable/disable/check temporal coherence
127void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable);
128int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass);
129
130/*
131 * Clears the internal temporal coherence caches. When a geom has its
132 * collision checked with a trimesh once, data is stored inside the trimesh.
133 * With large worlds with lots of seperate objects this list could get huge.
134 * We should be able to do this automagically.
135 */
136void dGeomTriMeshClearTCCache(dGeomID g);
137
138
139/*
140 * returns the TriMeshDataID
141 */
142dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g);
143
144/*
145 * Gets a triangle.
146 */
147void dGeomTriMeshGetTriangle(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
148
149/*
150 * Gets the point on the requested triangle and the given barycentric
151 * coordinates.
152 */
153void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
154
155/*
156
157This is how the strided data works:
158
159struct StridedVertex{
160        dVector3 Vertex;
161        // Userdata
162};
163int VertexStride = sizeof(StridedVertex);
164
165struct StridedTri{
166        int Indices[3];
167        // Userdata
168};
169int TriStride = sizeof(StridedTri);
170
171*/
172
173
174
175
176#ifdef __cplusplus
177}
178#endif
179
180#endif  /* _ODE_COLLISION_TRIMESH_H_ */
181
Note: See TracBrowser for help on using the repository browser.