Exemplo n.º 1
0
    public void TestTearClothMesh()
    {
        Vector4[] particles = { new Vector4(1,  1, 0), new Vector4(0,  1, 0), new Vector4(-1,  1, 0),
                                new Vector4(1,  0, 0), new Vector4(0,  0, 0), new Vector4(-1,  0, 0),
                                new Vector4(1, -1, 0), new Vector4(0, -1, 0), new Vector4(-1, -1, 0) };
        int[]     indices = { 0, 1, 4, 0, 4, 3, 1, 2, 5, 1, 5, 4,
                              3,     4, 7, 3, 7, 6, 4, 5, 8, 4, 8, 7 };
        float     stretchStiffness = 1.0f;
        float     bendStiffness    = 1.0f;
        float     pressure         = 0.0f;

        FlexExt.Asset.Handle handle = FlexExt.CreateTearingClothFromMesh(ref particles[0], particles.Length, particles.Length * 2, ref indices[0], indices.Length / 3, stretchStiffness, bendStiffness, pressure);

        float maxStrain = 0.0f;
        int   maxSplits = 10;

        FlexExt.TearingParticleClone[] particlesCopies = new FlexExt.TearingParticleClone[10];
        int numParticlesCopies = 0;
        int maxCopies          = 10;

        FlexExt.TearingMeshEdit[] triangleEdits = new FlexExt.TearingMeshEdit[10];
        int numTriangleEdits = 0;
        int maxEdits         = 10;

        FlexExt.TearClothMesh(handle, maxStrain, maxSplits, ref particlesCopies[0], ref numParticlesCopies, maxCopies, ref triangleEdits[0], ref numTriangleEdits, maxEdits);
        // todo: make the mesh tear

        FlexExt.DestroyTearingCloth(handle);
    }
Exemplo n.º 2
0
    public void TestCreateTearingClothFromMesh()
    {
        Vector4[] particles = { new Vector4(1,  1, 0, 1), new Vector4(0,  1, 0, 1), new Vector4(-1,  1, 0, 1),
                                new Vector4(1,  0, 0, 1), new Vector4(0,  0, 0, 1), new Vector4(-1,  0, 0, 1),
                                new Vector4(1, -1, 0, 1), new Vector4(0, -1, 0, 1), new Vector4(-1, -1, 0, 1) };
        int[]     indices = { 0, 1, 4, 0, 4, 3, 1, 2, 5, 1, 5, 4,
                              3,     4, 7, 3, 7, 6, 4, 5, 8, 4, 8, 7 };
        float     stretchStiffness = 1.0f;
        float     bendStiffness    = 1.0f;
        float     pressure         = 0.0f;

        FlexExt.Asset.Handle handle = FlexExt.CreateTearingClothFromMesh(ref particles[0], particles.Length, particles.Length * 2, ref indices[0], indices.Length / 3, stretchStiffness, bendStiffness, pressure);
        FlexExt.Asset        asset  = handle.asset;

        Assert.AreEqual(particles.Length, asset.numParticles);
        Assert.AreEqual(indices.Length / 3, asset.numTriangles);

        FlexExt.DestroyTearingCloth(handle);
    }