How to take Vertices and Indexes back from SoftBody

s410i
Posts: 5
Joined: Thu Jul 14, 2011 2:20 pm

How to take Vertices and Indexes back from SoftBody

Post by s410i »

Hello,

I'm using DirectX Mesh object, from which I'm taking Vertices and Indexes. Than I'm putting them inside SoftBody using this line:

Code: Select all

psb = SoftBodyHelpers.CreateFromTriMesh(softBodyWorldInfo, intVerBuf, intIndexBuffer,true);
after that, I want to take all the points and put them back to Mesh to render them. But is it possible to take those points back?

There is a function in GraphicObjectFactory which is quite similar to what I want to do, but my psb.UserObject is not an Array:

Code: Select all

 public void RenderSoftBodyTextured(SoftBody softBody)
        {
            if (!(softBody.UserObject is Array))
                return;

            object[] userObjArr = softBody.UserObject as object[];
            float[] vertexBuffer = userObjArr[0] as float[];
            int [] indexBuffer = userObjArr[1] as int[];
......
Or maybe there is a better way?

Thank you for all responses!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to take Vertices and Indexes back from SoftBody

Post by Erwin Coumans »

There is a DirectX demo using the softbody, that shows how to copy the vertex positions/normals back to your mesh.

See Bullet/Demos/DX11ClothDemo

Thanks,
Erwin