FLEX  0.8
flexExt.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2013-2015 NVIDIA Corporation. All rights reserved.
27 
28 
29 #ifndef FLEX_EXT_H
30 #define FLEX_EXT_H
31 
33 #if _WIN32
34 #define FLEX_API __declspec(dllexport)
35 #else
36 #define FLEX_API
37 #endif
38 
40 
41 extern "C" {
42 
48 {
49  // particles
50  float* mParticles;
52 
53  // springs
58 
59  // rigid body stiffness
61  float mRigidCenter[3];
62 
63  // faces for cloth
66 
67  // inflatable params
68  bool mInflatable;
72 };
73 
78 {
81 
85 
87 
88  void* mUserData;
89 };
90 
95 {
98 
101 
104 };
105 
110 {
111  float mPosition[3];
112  float mRadius;
113  float mStrength;
116 };
117 
121 struct FlexExtContainer;
122 
133 FLEX_API int flexExtCreateWeldedMeshIndices(const float* vertices, int numVertices, int* uniqueVerts, int* originalToUniqueMap, float threshold);
134 
150 FLEX_API FlexExtAsset* flexExtCreateClothFromMesh(const float* particles, int numVertices, const int* indices, int numTriangles, float stretchStiffness, float bendStiffness, float tetherStiffness, float tetherGive, float pressure);
151 
162 FLEX_API FlexExtAsset* flexExtCreateRigidFromMesh(const float* vertices, int numVertices, const int* indices, int numTriangleIndices, float radius);
163 
168 FLEX_API void flexExtDestroyAsset(FlexExtAsset* asset);
169 
176 FLEX_API FlexExtContainer* flexExtCreateContainer(FlexSolver* solver, int maxParticles);
177 
182 FLEX_API void flexExtDestroyContainer(FlexExtContainer* container);
183 
190 FLEX_API int flexExtAllocParticles(FlexExtContainer* container, int n, int* indices);
191 
198 FLEX_API void flexExtFreeParticles(FlexExtContainer* container, int n, const int* indices);
199 
206 FLEX_API int flexExtGetActiveList(FlexExtContainer* container, int* indices);
207 
222 FLEX_API FlexExtInstance* flexExtCreateInstance(FlexExtContainer* container, const FlexExtAsset* asset, const float* transform, float vx, float vy, float vz, int phase, float invMassScale);
223 
229 FLEX_API void flexExtDestroyInstance(FlexExtContainer* container, const FlexExtInstance* instance);
230 
242 FLEX_API void flexExtGetParticleData(FlexExtContainer* container, float** particles, float** velocities, int** phases, float** normals);
243 
250 FLEX_API void flexExtGetTriangleData(FlexExtContainer* container, int** indices, float** normals);
251 
258 FLEX_API void flexExtGetRigidData(FlexExtContainer* container, float** rotations, float** positions);
259 
288 FLEX_API void flexExtTickContainer(FlexExtContainer* container, float dt, int numSubsteps, FlexTimers* timers=NULL);
289 
295 FLEX_API void flexExtPushToDevice(FlexExtContainer* container);
296 
302 FLEX_API void flexExtPullFromDevice(FlexExtContainer* container);
303 
304 /*
305  * Set force fields on the container
306  * @param[in] container The container to update
307  * @param[in] forceFields A pointer to an array of force field data, may be host or GPU memory
308  * @param[in] numForceFields The number of force fields to send to the device
309  * @param[in] source The memory space to copy the force fields from
310  */
311 FLEX_API void flexExtSetForceFields(FlexExtContainer* container, const FlexExtForceField* forceFields, int numForceFields, FlexMemory source);
312 
313 /*
314  * Evaluate force fields and update particle velocities
315  * expected to be called in the following sequence: flexExtPushToDevice, flexExtApplyForceFields, flexUpdateSolver, flexExtPullFromDevice, flexSynchronize
316  * @param[in] container The container to update
317  * @param[in] dt The time-step in seconds
318  */
319 FLEX_API void flexExtApplyForceFields(FlexExtContainer* container, float dt);
320 
321 } // extern "C"
322 
323 #endif // FLEX_EXT_H
324 
int * mParticleIndices
Simulation particle indices.
Definition: flexExt.h:79
float mInflatableVolume
The rest volume for the inflatable constraint.
Definition: flexExt.h:69
Apply field value as an impulse.
Definition: flexExt.h:100
int mNumSprings
Number of springs.
Definition: flexExt.h:57
FLEX_API FlexExtAsset * flexExtCreateRigidFromMesh(const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float radius)
FLEX_API void flexExtTickContainer(FlexExtContainer *container, float dt, int numSubsteps, FlexTimers *timers=NULL)
Definition: flex.h:158
float mRadius
Radius of the force field.
Definition: flexExt.h:112
int mNumParticles
Number of simulation particles.
Definition: flexExt.h:80
float mRigidStiffness
Rigid body constraint stiffness.
Definition: flexExt.h:60
bool mInflatable
Whether an inflatable constraint should be added.
Definition: flexExt.h:68
int * mTriangleIndices
Indexed triangle mesh for clothing.
Definition: flexExt.h:64
FLEX_API void flexExtDestroyInstance(FlexExtContainer *container, const FlexExtInstance *instance)
FLEX_API int flexExtAllocParticles(FlexExtContainer *container, int n, int *indices)
Definition: flexExt.h:77
FLEX_API void flexExtGetRigidData(FlexExtContainer *container, float **rotations, float **positions)
int mTriangleIndex
Index in the container's triangle array.
Definition: flexExt.h:82
Apply field value as a velocity change.
Definition: flexExt.h:103
const FlexExtAsset * mAsset
Source asset used to create this instance.
Definition: flexExt.h:86
float mInflatableStiffness
How stiff the inflatable is.
Definition: flexExt.h:71
FLEX_API void flexExtGetTriangleData(FlexExtContainer *container, int **indices, float **normals)
FLEX_API void flexExtApplyForceFields(FlexExtContainer *container, float dt)
FLEX_API void flexExtGetParticleData(FlexExtContainer *container, float **particles, float **velocities, int **phases, float **normals)
FLEX_API void flexExtSetForceFields(FlexExtContainer *container, const FlexExtForceField *forceFields, int numForceFields, FlexMemory source)
Apply field value as a force.
Definition: flexExt.h:97
FLEX_API int flexExtCreateWeldedMeshIndices(const float *vertices, int numVertices, int *uniqueVerts, int *originalToUniqueMap, float threshold)
void * mUserData
User data pointer.
Definition: flexExt.h:88
FlexMemory
Definition: flex.h:206
FLEX_API void flexExtDestroyContainer(FlexExtContainer *container)
FlexForceExtMode
Definition: flexExt.h:94
FLEX_API void flexExtPushToDevice(FlexExtContainer *container)
FLEX_API FlexExtInstance * flexExtCreateInstance(FlexExtContainer *container, const FlexExtAsset *asset, const float *transform, float vx, float vy, float vz, int phase, float invMassScale)
FLEX_API FlexExtAsset * flexExtCreateClothFromMesh(const float *particles, int numVertices, const int *indices, int numTriangles, float stretchStiffness, float bendStiffness, float tetherStiffness, float tetherGive, float pressure)
FlexForceExtMode mMode
Mode of field application.
Definition: flexExt.h:114
float * mSpringRestLengths
Spring rest-lengths.
Definition: flexExt.h:56
float * mParticles
Local space particle positions, x,y,z,1/mass.
Definition: flexExt.h:50
int mNumTriangles
Number of triangles.
Definition: flexExt.h:65
bool mLinearFalloff
Linear or no falloff.
Definition: flexExt.h:115
float mPosition[3]
Center of force field.
Definition: flexExt.h:111
int * mSpringIndices
Spring indices.
Definition: flexExt.h:54
Definition: flexExt.h:47
int mRigidIndex
Index in the container's rigid body constraints array.
Definition: flexExt.h:83
float mRigidCenter[3]
Local space center of mass of the particles.
Definition: flexExt.h:61
FLEX_API void flexExtFreeParticles(FlexExtContainer *container, int n, const int *indices)
FLEX_API FlexExtContainer * flexExtCreateContainer(FlexSolver *solver, int maxParticles)
float mStrength
Strength of the force field.
Definition: flexExt.h:113
float mInflatablePressure
How much over the rest volume the inflatable should attempt to maintain.
Definition: flexExt.h:70
int mNumParticles
Number of particles.
Definition: flexExt.h:51
FLEX_API void flexExtPullFromDevice(FlexExtContainer *container)
FLEX_API void flexExtDestroyAsset(FlexExtAsset *asset)
FLEX_API int flexExtGetActiveList(FlexExtContainer *container, int *indices)
float * mSpringCoefficients
Spring coefficients.
Definition: flexExt.h:55
Definition: flexExt.h:109
int mInflatableIndex
Index in the container's inflatables array.
Definition: flexExt.h:84