I am trying to make a soft body by making a sphere and taking all the meshParts from it and making a soft body from that sphere. and when I render it in libgdx I use a model of sphere so that the soft body is visible which translate as the soft body moves but few vertices are sticked to the spawn location (origin) can anyone suggest me what am I doing wrong ?
this is my create method :
ModelBuilder modelBuilder1;
modelBuilder1 = new ModelBuilder();
final Material material = new Material(ColorAttribute.createDiffuse(Color.RED));
final long attributes = VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal;
final Model sphere = modelBuilder1.createSphere(2f, 2f, 2f, 24, 24, material, attributes);
meshPart = sphere.meshParts.get(0);
indexMap = BufferUtils.newShortBuffer(meshPart.size);
positionOffset = meshPart.mesh.getVertexAttribute(VertexAttributes.Usage.Position).offset;
normalOffset = meshPart.mesh.getVertexAttribute(VertexAttributes.Usage.Normal).offset;
softBodyBall = new btSoftBody(worldInfo, meshPart.mesh.getVerticesBuffer(), meshPart.mesh.getVertexSize(), positionOffset, 3, meshPart.mesh.getIndicesBuffer(), meshPart.offset, meshPart.size, indexMap, 0);
softBodyBall.setPose(true, false);
dynamicsWorld.addSoftBody(softBodyBall);
btSoftBody.Material pm = softBodyBall.appendMaterial();
softBodyBall.generateBendingConstraints(2, pm);
pm.setKLST(0.9f);
pm.setFlags(0);
softBodyBall.generateBendingConstraints(2, pm);
softBodyBall.setConfig_piterations(7);
softBodyBall.setConfig_kDF(0.2f);
softBodyBall.randomizeConstraints();
softBodyBall.setTotalMass(1);
softBodyBall.translate(new Vector3(1, 5, 1));
instance = new ModelInstance(sphere);
and this is my render method
softBodyBall.getVertices(meshPart.mesh.getVerticesBuffer(), softBodyBall.getNodeCount(), meshPart.mesh.getVertexSize(), 0);
softBodyBall.getWorldTransform(instance.transform);
final float delta = Math.min(1f / 30f, Gdx.graphics.getDeltaTime());
dynamicsWorld.stepSimulation(delta, 5, 1f / 30f);
batch.begin(camera);
batch.render(instance,environment);
batch.render(instances, environment);
batch.end();
here is the image how it looks like : https://drive.google.com/file/d/1-9UjdlyIAotZPgrLKaoG0Dm5UEVLdzY1/view?usp=sharing