1 | #ifndef NX_COOKING_H
|
---|
2 | #define NX_COOKING_H
|
---|
3 | /*----------------------------------------------------------------------------*\
|
---|
4 | |
|
---|
5 | | Public Interface to NovodeX Technology
|
---|
6 | |
|
---|
7 | | www.novodex.com
|
---|
8 | |
|
---|
9 | \*----------------------------------------------------------------------------*/
|
---|
10 |
|
---|
11 | #include "Nxc.h"
|
---|
12 | #include "Nxf.h"
|
---|
13 | #include "NxArray.h"
|
---|
14 | class NxUserAllocator;
|
---|
15 | class NxUserOutputStream;
|
---|
16 | class NxTriangleMeshDesc;
|
---|
17 | class NxConvexMeshDesc;
|
---|
18 | class NxStream;
|
---|
19 | class NxFluidDesc;
|
---|
20 | class NxTriangleMeshShape;
|
---|
21 | class NxTriangle;
|
---|
22 |
|
---|
23 | //#ifdef NX_SUPPORT_INTERNAL_FACES
|
---|
24 | class NxVec3;
|
---|
25 | class NxPlane;
|
---|
26 | class NxConvexMeshDesc2;
|
---|
27 | //#endif
|
---|
28 |
|
---|
29 | enum NxPlatform
|
---|
30 | {
|
---|
31 | PLATFORM_PC,
|
---|
32 | PLATFORM_XENON,
|
---|
33 | PLATFORM_PLAYSTATION3
|
---|
34 | };
|
---|
35 |
|
---|
36 | /**
|
---|
37 |
|
---|
38 | \brief Structure describing parameters affecting mesh cooking.
|
---|
39 |
|
---|
40 | @see NxSetCookingParams() NxGetCookingParams()
|
---|
41 | */
|
---|
42 | struct NxCookingParams
|
---|
43 | {
|
---|
44 | /**
|
---|
45 | \brief Target platform
|
---|
46 |
|
---|
47 | Should be set to the platform which you intend to load the cooked mesh data on. This allows
|
---|
48 | novodex to optimize the mesh data in an appropriate way for the platform and make sure that
|
---|
49 | endianess issues are accounted for correctly.
|
---|
50 | */
|
---|
51 | NxPlatform targetPlatform;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | \brief Skin width for convexes
|
---|
55 |
|
---|
56 | Specifies the amount to inflate the convex mesh by when the new convex hull generator is used
|
---|
57 | (the skinWidth is ignored when using the legacy convex hull generaror, enable with NX_CF_USE_LEGACY_COOKER).
|
---|
58 |
|
---|
59 | Inflating the mesh allows the user to hide interpentration errors by increasing the size of the
|
---|
60 | collision mesh with respect to the size of the rendered geometry.
|
---|
61 | */
|
---|
62 | float skinWidth;
|
---|
63 |
|
---|
64 | /**
|
---|
65 | \brief Favorize speed or memory for collision structures
|
---|
66 | */
|
---|
67 | bool hintCollisionSpeed;
|
---|
68 | };
|
---|
69 |
|
---|
70 | /**
|
---|
71 | \brief Sets cooking parameters
|
---|
72 |
|
---|
73 | \note #NxInitCooking() sets the parameters to there default values.
|
---|
74 |
|
---|
75 | \param[in] params Cooking parameters
|
---|
76 |
|
---|
77 | \return true on success.
|
---|
78 |
|
---|
79 | @see NxCookingParams NxGetCookingParams()
|
---|
80 | */
|
---|
81 | NX_C_EXPORT NXC_DLL_EXPORT bool NxSetCookingParams(const NxCookingParams& params);
|
---|
82 |
|
---|
83 | /**
|
---|
84 | \brief Gets cooking parameters
|
---|
85 |
|
---|
86 | \return Current cooking parameters.
|
---|
87 |
|
---|
88 | @see NxCookingParams NxSetCookingParams()
|
---|
89 | */
|
---|
90 | NX_C_EXPORT NXC_DLL_EXPORT const NxCookingParams& NxGetCookingParams();
|
---|
91 |
|
---|
92 | /**
|
---|
93 | \brief Checks endianness is the same between cooking & target platforms
|
---|
94 |
|
---|
95 | \return True if there is and endian mismatch.
|
---|
96 | */
|
---|
97 | NX_C_EXPORT NXC_DLL_EXPORT bool NxPlatformMismatch();
|
---|
98 |
|
---|
99 | /**
|
---|
100 | \brief Initializes cooking.
|
---|
101 |
|
---|
102 | This must be called at least once, before any cooking method is called (otherwise cooking fails).
|
---|
103 |
|
---|
104 | \param[in] allocator The memory allocator to use.
|
---|
105 | \param[in] outputStream The output stream to use.
|
---|
106 | \return true on success.
|
---|
107 |
|
---|
108 | @see NxCloseCooking()
|
---|
109 | */
|
---|
110 | NX_C_EXPORT NXC_DLL_EXPORT bool NxInitCooking(NxUserAllocator* allocator = NULL, NxUserOutputStream* outputStream = NULL);
|
---|
111 |
|
---|
112 |
|
---|
113 | /**
|
---|
114 | \brief Closes cooking.
|
---|
115 |
|
---|
116 | This must be called at the end of your app, to release cooking-related data.
|
---|
117 |
|
---|
118 | @see NxInitCooking()
|
---|
119 | */
|
---|
120 | NX_C_EXPORT NXC_DLL_EXPORT void NxCloseCooking();
|
---|
121 |
|
---|
122 | /**
|
---|
123 | \brief Cooks a triangle mesh. The results are written to the stream.
|
---|
124 |
|
---|
125 | To create a triangle mesh object(unlike previous versions) it is necasery to first 'cook' the mesh data into
|
---|
126 | a form which allows the SDK to perform efficient collision detection.
|
---|
127 |
|
---|
128 | NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream
|
---|
129 | suitable for loading and performing collision detection at runtime.
|
---|
130 |
|
---|
131 | NxCookConvex requires the input mesh to form a closed convex volume. This allows more efficient and robust
|
---|
132 | collision detection.
|
---|
133 |
|
---|
134 | \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called
|
---|
135 | when the application has finished using the cooking library.
|
---|
136 |
|
---|
137 | Example
|
---|
138 |
|
---|
139 | \include NxCookTriangleMesh_Example.cpp
|
---|
140 |
|
---|
141 | \param[in] desc The triangle mesh descriptor to read the mesh from.
|
---|
142 | \param[in] stream User stream to output the cooked data.
|
---|
143 | \return true on success
|
---|
144 |
|
---|
145 | @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams()
|
---|
146 | */
|
---|
147 |
|
---|
148 |
|
---|
149 | NX_C_EXPORT NXC_DLL_EXPORT bool NxCookTriangleMesh(const NxTriangleMeshDesc& desc, NxStream& stream);
|
---|
150 |
|
---|
151 | /**
|
---|
152 | \brief Cooks a convex mesh. The results are written to the stream.
|
---|
153 |
|
---|
154 | To create a triangle mesh object(unlike previous versions) it is necasery to first 'cook' the mesh data into
|
---|
155 | a form which allows the SDK to perform efficient collision detection.
|
---|
156 |
|
---|
157 | NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream
|
---|
158 | suitable for loading and performing collision detection at runtime.
|
---|
159 |
|
---|
160 | \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called
|
---|
161 | when the application has finished using the cooking library.
|
---|
162 |
|
---|
163 | Example
|
---|
164 |
|
---|
165 | \include NxCookConvexMesh_Example.cpp
|
---|
166 |
|
---|
167 | \param[in] desc The convex mesh descriptor to read the mesh from.
|
---|
168 | \param[in] stream User stream to output the cooked data.
|
---|
169 | \return true on success
|
---|
170 |
|
---|
171 | @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams()
|
---|
172 | */
|
---|
173 | NX_C_EXPORT NXC_DLL_EXPORT bool NxCookConvexMesh(const NxConvexMeshDesc& desc, NxStream& stream);
|
---|
174 |
|
---|
175 |
|
---|
176 | /**
|
---|
177 | \brief Cooks a series of triangle meshes into one fluid hardware mesh. The results are written to the stream.
|
---|
178 |
|
---|
179 | \note The restParticlesPerMeter,kernelRadiusMultiplier(etc) parameters must match the fluid which the mesh is used with.
|
---|
180 |
|
---|
181 | \param restParticlesPerMeter The particle resolution given as particles per linear meter measured when the fluid is
|
---|
182 | in its rest state (relaxed).
|
---|
183 | \param kernelRadiusMultiplier Radius of sphere of influence for particle interaction.
|
---|
184 | \param motionLimitMultiplier Maximal distance a particle is allowed to travel within one timestep.
|
---|
185 | \param packetSizeMultiplier This parameter controls the parallelization of the fluid.
|
---|
186 | \param descArray The triangle meshes to be cooked into the fluid mesh
|
---|
187 | \param stream The stream to write the results into
|
---|
188 |
|
---|
189 | \return true on success
|
---|
190 | */
|
---|
191 | NX_C_EXPORT NXC_DLL_EXPORT bool NxCookFluidHardwareMesh(NxReal restParticlesPerMeter, NxReal kernelRadiusMultiplier, NxReal motionLimitMultiplier, NxU32 packetSizeMultiplier, NxArray<NxTriangleMeshShape*>& descArray, NxStream& stream);
|
---|
192 |
|
---|
193 | /**
|
---|
194 | \brief Computes a CRC code for the fluid hardware mesh which can be used for caching.
|
---|
195 |
|
---|
196 | \note The restParticlesPerMeter,kernelRadiusMultiplier(etc) parameters must match the fluid which the mesh is used with.
|
---|
197 |
|
---|
198 | \param restParticlesPerMeter The particle resolution given as particles per linear meter measured when the fluid is
|
---|
199 | in its rest state (relaxed).
|
---|
200 | \param kernelRadiusMultiplier Radius of sphere of influence for particle interaction.
|
---|
201 | \param motionLimitMultiplier Maximal distance a particle is allowed to travel within one timestep.
|
---|
202 | \param packetSizeMultiplier This parameter controls the parallelization of the fluid.
|
---|
203 | \param descArray An array of triangle mesh descriptors.
|
---|
204 |
|
---|
205 | \return The 32bit CRC for the hardware mesh.
|
---|
206 | */
|
---|
207 | NX_C_EXPORT NXC_DLL_EXPORT NxU32 NxComputeFluidHardwareMeshCRC32(NxReal restParticlesPerMeter, NxReal kernelRadiusMultiplier, NxReal motionLimitMultiplier, NxU32 packetSizeMultiplier, NxArray<NxTriangleMeshShape*>& descArray);
|
---|
208 |
|
---|
209 |
|
---|
210 | /**
|
---|
211 | \brief Cooks a series of world space triangles into one fluid hardware mesh. The results are written to the stream.
|
---|
212 |
|
---|
213 | \note The restParticlesPerMeter,kernelRadiusMultiplier(etc) parameters must match the fluid which the mesh is used with.
|
---|
214 |
|
---|
215 | \param restParticlesPerMeter The particle resolution given as particles per linear meter measured when the fluid is
|
---|
216 | in its rest state (relaxed).
|
---|
217 | \param kernelRadiusMultiplier Radius of sphere of influence for particle interaction.
|
---|
218 | \param motionLimitMultiplier Maximal distance a particle is allowed to travel within one timestep.
|
---|
219 | \param packetSizeMultiplier This parameter controls the parallelization of the fluid.
|
---|
220 | \param descArray An array of world space triangles to build the fluid mesh from.
|
---|
221 | \param tcount The number of triangles in descArray
|
---|
222 | \param stream The stream to save to cooked results to
|
---|
223 |
|
---|
224 | \return true on success
|
---|
225 | */
|
---|
226 | NX_C_EXPORT NXC_DLL_EXPORT bool NxCookFluidHardwareTriangles(NxReal restParticlesPerMeter, NxReal kernelRadiusMultiplier, NxReal motionLimitMultiplier, NxU32 packetSizeMultiplier,const NxTriangle *descArray,NxU32 tcount,NxStream& stream);
|
---|
227 |
|
---|
228 |
|
---|
229 |
|
---|
230 | /**
|
---|
231 | \brief Report state of cooking memory usage.
|
---|
232 | */
|
---|
233 | NX_C_EXPORT NXC_DLL_EXPORT void NxReportCooking();
|
---|
234 |
|
---|
235 |
|
---|
236 | //exclude from docs
|
---|
237 | /// @cond
|
---|
238 | //#ifdef NX_SUPPORT_INTERNAL_FACES
|
---|
239 | NX_C_EXPORT NXC_DLL_EXPORT bool NxCookConvexMesh2(const NxConvexMeshDesc2& desc, NxStream& stream);
|
---|
240 | NX_C_EXPORT NXC_DLL_EXPORT bool NxSliceConvex(const NxConvexMeshDesc& desc, const NxPlane& localPlane, NxConvexMeshDesc2& positivePart, NxConvexMeshDesc2& negativePart, NxVec3& offsetP, NxVec3& offsetN);
|
---|
241 | NX_C_EXPORT NXC_DLL_EXPORT void NxReleaseSlicingData();
|
---|
242 | //#endif
|
---|
243 | /// @endcond
|
---|
244 |
|
---|
245 | #endif
|
---|
246 |
|
---|
247 |
|
---|
248 | //AGCOPYRIGHTBEGIN
|
---|
249 | ///////////////////////////////////////////////////////////////////////////
|
---|
250 | // Copyright © 2005 AGEIA Technologies.
|
---|
251 | // All rights reserved. www.ageia.com
|
---|
252 | ///////////////////////////////////////////////////////////////////////////
|
---|
253 | //AGCOPYRIGHTEND
|
---|
254 |
|
---|