1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
/*
* Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#ifndef CLOTHING_ASSET_AUTHORING_H
#define CLOTHING_ASSET_AUTHORING_H
#include "Asset.h"
#include "IProgressListener.h"
#include "ClothingPhysicalMesh.h"
namespace nvidia
{
namespace apex
{
PX_PUSH_PACK_DEFAULT
class ClothingPhysicalMesh;
/**
\brief The clothing authoring asset. This is used to generate streams that can then be deserialized into a regular asset.
*/
class ClothingAssetAuthoring : public AssetAuthoring
{
public:
/**
\brief set the default value for all coefficients if none is available
*/
virtual void setDefaultConstrainCoefficients(const ClothingConstrainCoefficients& coeff) = 0;
/**
\brief set the value which is considered invalid when painting
*/
virtual void setInvalidConstrainCoefficients(const ClothingConstrainCoefficients& coeff) = 0;
/**
\brief Sets the graphical and physical mesh for the given graphical lod level.
\param [in] lod Identifier for that lod level.
\param [in] graphicalMesh The graphical mesh to be rendered in that lod level.
\param [in] physicalMesh The physical mesh to be simulated on that lod level. The reference to the same physical mesh can be
given for different graphical lods. It is copied internally.
<br><b>Note:</b> If the same physical mesh is used several time, the paint values are copied from the
graphical mesh the first time the physical mesh is passed in here.
\param [in] normalResemblance This angle (in degrees) specifies how similar the normal from the physical and graphical mesh need to
be in order for them to be accepted as immediate mode skinning pairs. Use 90 or bigger for any
resemblance. Must be in range (0, 90], but it's highly recommended to use more than 5 degrees.
\param [in] ignoreUnusedVertices All Vertices that have the 'usedForPhysics' property set to false will be ignored when transferring
the painted values from the graphical to the physical mesh
\param [in] progress Progress bar callback class.
*/
virtual void setMeshes(uint32_t lod, RenderMeshAssetAuthoring* graphicalMesh, ClothingPhysicalMesh* physicalMesh,
float normalResemblance = 25, bool ignoreUnusedVertices = true, IProgressListener* progress = NULL) = 0;
/**
\brief Assigns a platform tag to a graphical lod.
*/
virtual bool addPlatformToGraphicalLod(uint32_t lod, PlatformTag platform) = 0;
/**
\brief Removes a platform tag from a graphical lod.
*/
virtual bool removePlatform(uint32_t lod, PlatformTag platform) = 0;
/**
\brief Get number of platform tags for a given lod.
*/
virtual uint32_t getNumPlatforms(uint32_t lod) const = 0;
/**
\brief Get i-th platform tag of given lod;
*/
virtual PlatformTag getPlatform(uint32_t lod, uint32_t i) const = 0;
/**
\brief Returns the number of LoDs that have been set in the ClothingAssetAuthoring::setMeshes call
*/
virtual uint32_t getNumLods() const = 0;
/**
\brief Returns the n-th LoD value from the ClothingAssetAuthoring::setMeshes call.
\note These values do not have to be a continuous list
*/
virtual int32_t getLodValue(uint32_t lod) const = 0;
/**
\brief Clears all lods and meshes.
*/
virtual void clearMeshes() = 0;
/**
\brief Returns a reference to the internal copy of the physical mesh for the given graphical lod. Returned object MUST be destroyed by the user immediately after use.
*/
virtual ClothingPhysicalMesh* getClothingPhysicalMesh(uint32_t graphicalLod) const = 0;
/**
\brief assigns name and bindpose to a bone. This needs to be called for every bone at least once
\param [in] boneIndex The bone index the information is provided for.
\param [in] boneName The bone name. An internal copy of this string will be made.
\param [in] bindPose The bind or rest pose of this bone.
\param [in] parentIndex The bone index of the parent bone, -1 for root bones.
*/
virtual void setBoneInfo(uint32_t boneIndex, const char* boneName, const PxMat44& bindPose, int32_t parentIndex) = 0;
/**
\brief Specifies the root bone.
\param [in] boneName The bone name.
*/
virtual void setRootBone(const char* boneName) = 0;
/**
\brief add a convex collision representation to a bone, vertices must be in bone-bind-pose space!
\param [in] boneName name of the bone this collision info is for.
\param [in] positions array of vertices with the positions.
\param [in] numPositions number of elements in positions array. if set to 0, bone collision will be capsule.
*/
virtual uint32_t addBoneConvex(const char* boneName, const PxVec3* positions, uint32_t numPositions) = 0;
/**
\brief add a convex collision representation to a bone, vertices must be in bone-bind-pose space!
\param [in] boneIndex index of the bone this collision info is for.
\param [in] positions array of vertices with the positions.
\param [in] numPositions number of elements in positions array. if set to 0, bone collision will be capsule.
*/
virtual uint32_t addBoneConvex(uint32_t boneIndex, const PxVec3* positions, uint32_t numPositions) = 0;
/**
\brief add a capsule to the bone's collision. all relative to bone-bind-pose space!
\param [in] boneName name of the bone this collision info is for.
\param [in] capsuleRadius The radius of the capsule. if set to 0, bone collision will default back to convex
\param [in] capsuleHeight The height of the capsule
\param [in] localPose The frame of the capsule relative to the frame of the bone (not world space)
*/
virtual void addBoneCapsule(const char* boneName, float capsuleRadius, float capsuleHeight, const PxMat44& localPose) = 0;
/**
\brief add a capsule to the bone's collision. all relative to bone-bind-pose space!
\param [in] boneIndex index of the bone this collision info is for.
\param [in] capsuleRadius if set to 0, bone collision will default back to convex
\param [in] capsuleHeight The height of the capsule
\param [in] localPose The frame of the capsule relative to the frame of the bone (not world space)
*/
virtual void addBoneCapsule(uint32_t boneIndex, float capsuleRadius, float capsuleHeight, const PxMat44& localPose) = 0;
/**
\brief clear all collision information for a given bone name
*/
virtual void clearBoneActors(const char* boneName) = 0;
/**
\brief clear all collision information for a given bone index
*/
virtual void clearBoneActors(uint32_t boneIndex) = 0;
/**
\brief clear all collision information for any bone
*/
virtual void clearAllBoneActors() = 0;
/**
\brief Set up the collision volumes for PhysX3.
The boneNames, radii and localPositions array need to be of size numSpheres, each triplet describes a sphere that is attached to a bone.
The pairs array describes connections between pairs of spheres. It defines capsules with 2 radii.
\param [in] boneNames names of the bones to which a spheres are added
\param [in] radii radii of the spheres
\param [in] localPositions sphere positions relative to the bone
\param [in] numSpheres number of spheres that are being defined
\param [in] pairs pairs of indices that reference 2 spheres to define a capsule with 2 radii
\param [in] numIndices size of the pairs array
*/
virtual void setCollision(const char** boneNames, float* radii, PxVec3* localPositions, uint32_t numSpheres, uint16_t* pairs, uint32_t numIndices) = 0;
/**
\brief Set up the collision volumes for PhysX3.
*/
virtual void setCollision(uint32_t* boneIndices, float* radii, PxVec3* localPositions, uint32_t numSpheres, uint16_t* pairs, uint32_t numIndices) = 0;
/**
\brief Clear the collision volumes for PhysX3.
*/
virtual void clearCollision() = 0;
/**
\brief Number of hierarchical levels. 0 to turn off
If either the hierarchical solver iterations or the hierarchical levels are set to 0, this feature is turned off
*/
virtual void setSimulationHierarchicalLevels(uint32_t levels) = 0;
/**
\brief The radius of the cloth/softbody particles.
*/
virtual void setSimulationThickness(float thickness) = 0;
/**
\brief The amount of virtual particles created. 0 means none, 1 means 2 or 3 per triangle.
*/
virtual void setSimulationVirtualParticleDensity(float density) = 0;
/**
\brief The sleep velocity. If all vertices of a cloth/softbody are below this velocity for some time, it falls asleep
*/
virtual void setSimulationSleepLinearVelocity(float sleep) = 0;
/**
\brief The direction of gravity. Can be used for cooking.
*/
virtual void setSimulationGravityDirection(const PxVec3& gravity) = 0;
/**
\brief Turn off Continuous collision detection for clothing.
Fast moving objects can cause massive forces to the cloth, especially when some kinematic actors move large distances within one frame.
Without CCD those collisions are not detected and thus don't influence the cloth.
\note Whenever the isContinuous parameter in ClothingActor::updateState is set to false, cloth CCD will be temporarily disabled as well
*/
virtual void setSimulationDisableCCD(bool disable) = 0;
/**
\brief Turns on twoway interaction with rigid body. Only of limited use for clothing
*/
virtual void setSimulationTwowayInteraction(bool enable) = 0;
/**
\brief EXPERIMENTAL: Turns on local untangling
\see CLF_UNTANGLING
*/
virtual void setSimulationUntangling(bool enable) = 0;
/**
\brief The scale of the cloth rest length
*/
virtual void setSimulationRestLengthScale(float scale) = 0;
/**
\brief Provide a scaling to the serialize functionality.
This is useful when the game runs in a different scale than the tool this asset was created in
\deprecated Only works with deprecated serialization, use applyTransformation instead!
*/
virtual void setExportScale(float scale) = 0;
/**
\brief Apply an arbitrary transformation to either the physical, the graphical mesh or both.
This is a permanent transformation and it changes the object state. Should only be called immediately before serialization
and without further modifying the object later on.
\param transformation This matrix is allowed to contain a translation and a rotation.
\param scale Apply a uniform scaling as well
\param applyToGraphics Apply the transformation and scale to the graphical part of the asset
\param applyToPhysics Apply the transformation and scale to the physical part of the asset
\note if the 3x3 part of the transformation parameter contains mirroring of axis (= negative determinant) some additional processing is done.
This includes flipping of simulation triangles and adaption of the mesh-mesh skinning.
*/
virtual void applyTransformation(const PxMat44& transformation, float scale, bool applyToGraphics, bool applyToPhysics) = 0;
/**
\brief Move every bone bind pose to a new position.
\param newBindPoses array of matrices for the new bind poses. This must be in object space (not relative to the parent bone!)
\param newBindPosesCount number of matrices in the specified array
\param isInternalOrder using internal numbering or external numbering?
\param maintainCollisionWorldSpace The collision volumes do not move to the new bone bind pose
*/
virtual void updateBindPoses(const PxMat44* newBindPoses, uint32_t newBindPosesCount, bool isInternalOrder, bool maintainCollisionWorldSpace) = 0;
/**
\brief If enabled, the normals of the physical mesh are derived
from the directions of the physical vertex to the bind poses of the assigned bones
*/
virtual void setDeriveNormalsFromBones(bool enable) = 0;
/**
\brief Returns the material interface
*/
virtual NvParameterized::Interface* getMaterialLibrary() = 0;
/**
\brief Adds a new material library to the asset
\param [in] materialLibrary User-generated material library object.
\param [in] materialIndex Default value for the Actor to know which material to use in the library
\param [in] transferOwnership Hands ownership to the authoring asset.
*/
virtual bool setMaterialLibrary(NvParameterized::Interface* materialLibrary, uint32_t materialIndex, bool transferOwnership) = 0;
/**
\brief Gets the parameterized render mesh associated with this asset.
\param [in] lodLevel The LoD level of the render mesh asset
\return NULL if lodLevel is not valid
\see ClothingAssetAuthoring::getNumLods()
\note Under no circumstances you should modify the positions of the render mesh asset's vertices. This will certainly break clothing
*/
virtual ::NvParameterized::Interface* getRenderMeshAssetAuthoring(uint32_t lodLevel) const = 0;
/**
\brief Retrieves the bind pose transform of this bone.
*/
virtual bool getBoneBindPose(uint32_t boneIndex, PxMat44& bindPose) const = 0;
/**
\brief Directly sets the bind pose transform of this bone
*/
virtual bool setBoneBindPose(uint32_t boneIndex, const PxMat44& bindPose) = 0;
};
PX_POP_PACK
} // namespace nvidia
} // namespace nvidia
#endif // CLOTHING_ASSET_AUTHORING_H
|