Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
制作柔体(球体)并在libgdx中平移时,网格的几个顶点会粘到原点?_Libgdx_Mesh_Softbody - Fatal编程技术网

制作柔体(球体)并在libgdx中平移时,网格的几个顶点会粘到原点?

制作柔体(球体)并在libgdx中平移时,网格的几个顶点会粘到原点?,libgdx,mesh,softbody,Libgdx,Mesh,Softbody,我试图通过制作一个球体,并从中取出所有的网格部分,然后从这个球体中制作一个柔体来制作一个柔体。 当我在libgdx中渲染它时,我使用了一个球体模型,这样可以看到柔体,柔体随着柔体的移动而移动,但很少有顶点附着到繁殖位置(原点) 谁能告诉我我做错了什么 这是我的创建方法: ModelBuilder modelBuilder1; modelBuilder1 = new ModelBuilder(); final Material material = new Mate

我试图通过制作一个球体,并从中取出所有的网格部分,然后从这个球体中制作一个柔体来制作一个柔体。 当我在libgdx中渲染它时,我使用了一个球体模型,这样可以看到柔体,柔体随着柔体的移动而移动,但很少有顶点附着到繁殖位置(原点) 谁能告诉我我做错了什么

这是我的创建方法:

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);
这是我的渲染方法

 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();
以下是它的外观图像: 找到了。 需要渲染每个顶点

softBodyBall.getVertices(meshPart.mesh.getVerticesBuffer(), meshPart.mesh.getVertexSize(), positionOffset, normalOffset,
                meshPart.mesh.getIndicesBuffer(), meshPart.offset, meshPart.size, indexMap, 0);
这而不是

softBodyBall.getVertices(meshPart.mesh.getVerticesBuffer(), softBodyBall.getNodeCount(), meshPart.mesh.getVertexSize(), 0);
找到了。 需要渲染每个顶点

softBodyBall.getVertices(meshPart.mesh.getVerticesBuffer(), meshPart.mesh.getVertexSize(), positionOffset, normalOffset,
                meshPart.mesh.getIndicesBuffer(), meshPart.offset, meshPart.size, indexMap, 0);
这而不是

softBodyBall.getVertices(meshPart.mesh.getVerticesBuffer(), softBodyBall.getNodeCount(), meshPart.mesh.getVertexSize(), 0);