NvCloth icon indicating copy to clipboard operation
NvCloth copied to clipboard

There is a gap in the skirt, how to solve it?

Open binzi56 opened this issue 3 years ago • 2 comments

The cloth I created through InitializeFromData() has added motion constraints, but the skirt seems to be stretched, and I don’t know where the problem is; if it is a simple piece of cloth, it will not be stretched without adding a distance constraint; Is it because of the skirt? How to set it up?

截屏2022-11-22 15 58 26 The above is what it should look like, The following is what it looks like after I pass in the vertices after the simulation operation, and it is stretched a bit seriously. 截屏2022-11-22 15 57 35

binzi56 avatar Nov 22 '22 08:11 binzi56

Adding tether constraints, or gradually reducing the particle mass at lower parts of the skirt can both help reduce stretching.

mtamis-NV avatar Dec 05 '22 10:12 mtamis-NV

Thanks for the answer, I still have a problem here, the dress seems to be torn, there are gaps, how to solve it? Looking at the official document, it may be a constraint problem. The following is my code, including Fabric and Motion constraints. Other constraints are gone, so I don’t know where the problem is. After I remove the Motion constraints and the effect is the same.

        nv::cloth::BoundedData positions = nv::cloth::ClothMeshData::ToBoundedData(verticesXYZ);
        nv::cloth::BoundedData indices = nv::cloth::ClothMeshData::ToBoundedData(indexs);

        ClothMeshData cloth_mesh;
        PxVec3 originPoint = PxVec3(originData->x, originData->y, originData->z);
        originPoint = PxVec3(0, 0, 0);
        PxMat44 transform =  PxTransform(originPoint, PxQuat(0, PxVec3(1.f, 0.f, 0.f)));
        cloth_mesh.InitializeFromData(positions, indices, transform);
        cloth_mesh.AttachClothUsingTopVertices(0.1);

        nv::cloth::ClothMeshDesc mesh_desc = cloth_mesh.GetClothMeshDesc();
        nv::cloth::Vector<int32_t>::Type phaseTypeInfo;
        app.mFabric = NvClothCookFabricFromMesh(factory, mesh_desc, PxVec3(0.0f, -4.f, 0.0f), &phaseTypeInfo, false);
       
        ...
        
        // MARK: - Set distance constraints
        nv::cloth::Range<physx::PxVec4> distance_constraints = app.cloth->getMotionConstraints();
        for (int i = 0; i < (int)distance_constraints.size(); i++) {
            distance_constraints[i] = physx::PxVec4(particlesCopy[i].getXYZ(), 0.002f * (i % 800) * 0.002f * (i % 800));
        }
截屏2023-01-06 11 18 01 Tether constraint scale = 1.0 截屏2023-02-03 15 18 52 Tether constraint scale = 0.8

@mtamis-NV When the Tether constraint scale is 0.8 below, the gap can be clearly seen. I guess that the positions and indices passed in by the constraint or cloth_mesh initialization are not enough. The official room is another initialization method.

binzi56 avatar Jan 06 '23 07:01 binzi56