NavMeshGraph.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:GdxDemo3D 作者:
/**
 * Creates Vector3 objects from the vertices of the mesh. The resulting array follows the ordering of the provided
 * index array.
 *
 * @param mesh
 * @param indices
 * @return
 */
private static Vector3[] createVertexVectors(Mesh mesh, short[] indices) {
    FloatBuffer verticesBuffer = mesh.getVerticesBuffer();
    int positionOffset = mesh.getVertexAttributes().findByUsage(VertexAttributes.Usage.Position).offset / 4;
    int vertexSize = mesh.getVertexSize() / 4;
    Vector3[] vertexVectors = new Vector3[mesh.getNumIndices()];
    for (int i = 0; i < indices.length; i++) {
        short index = indices[i];
        int a = index * vertexSize + positionOffset;
        float x = verticesBuffer.get(a++);
        float y = verticesBuffer.get(a++);
        float z = verticesBuffer.get(a);
        vertexVectors[index] = new Vector3(x, y, z);
    }
    return vertexVectors;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号