Skip to content

动画重定向

将 BVH 动作数据驱动到已绑骨的 3D 角色上,输出带动画的 GLB 文件。系统自动处理骨骼比例差异,确保动作在不同模型上都自然协调。input_motion 可直接使用动作检索接口返回的 asset_path

典型应用场景

  • 游戏角色动画:将动捕 BVH 数据重定向到自定义角色,快速完成动画制作
  • 与动作检索串联:搜索动作 → 获取 asset_path → 直接传入本接口,完成全自动化工作流

推荐工作流

  1. 准备已绑骨模型 → 输入带 Skin 骨骼的 GLB 文件(input_model
  2. 指定动作文件 → 使用动作检索返回的 asset_path 或上传 BVH 文件(input_motion
  3. 设置帧率 → 使用 fps: 30 指定输出帧率,fps: -1 保留原始帧率
  4. 获取动画 GLB → 结果为内嵌动画轨道的 GLB,可直接导入游戏引擎或渲染

本页使用的 API 参考 POST /motions/animations

与动作检索接口串联使用

将动作检索结果中的 asset_path(如 motions/h3d/bvh/00035389_000.bvh)直接作为 input_motion 的值传入,无需额外下载,实现搜索 → 驱动的全自动化流程。

基础示例

bash
curl -X POST 'https://api.v2fun.ai/api/v1/motions/animations' \
  -H 'Authorization: Bearer $V2FUN_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
      "input_model": "models/example_rigged.glb",
      "input_motion": "motions/example.bvh"
    }'
javascript
const response = await fetch('https://api.v2fun.ai/api/v1/motions/animations', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer $V2FUN_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "input_model": "models/example_rigged.glb",
    "input_motion": "motions/example.bvh"
  }),
});
const data = await response.json();
python
import requests

resp = requests.post(
    'https://api.v2fun.ai/api/v1/motions/animations',
    headers={
        'Authorization': 'Bearer $V2FUN_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        "input_model": "models/example_rigged.glb",
        "input_motion": "motions/example.bvh"
    },
)
print(resp.json())
java
import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
String body = "{\"input_model\":\"models/example_rigged.glb\",\"input_motion\":\"motions/example.bvh\"}";
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.v2fun.ai/api/v1/motions/animations"))
    .header("Authorization", "Bearer $V2FUN_API_KEY")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();
HttpResponse<String> response = client.send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

核心用例

动作重定向

将 BVH 动捕数据映射到已绑骨角色上,输出含完整动画轨道的 GLB。下方为输入的静态绑骨模型与输出的带动画模型对比(输出模型可在查看器中播放动画)。

bash
curl -X POST 'https://api.v2fun.ai/api/v1/motions/animations' \
  -H 'Authorization: Bearer $V2FUN_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
      "input_model": "https://asset.v2fun.ai/upload/animation-input-mannequin.glb",
      "input_motion": "motions/h3d/bvh/00041332_000.bvh",
      "fps": 30
    }'
javascript
const response = await fetch('https://api.v2fun.ai/api/v1/motions/animations', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer $V2FUN_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "input_model": "https://asset.v2fun.ai/upload/animation-input-mannequin.glb",
    "input_motion": "motions/h3d/bvh/00041332_000.bvh",
    "fps": 30
  }),
});
const data = await response.json();
python
import requests

resp = requests.post(
    'https://api.v2fun.ai/api/v1/motions/animations',
    headers={
        'Authorization': 'Bearer $V2FUN_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        "input_model": "https://asset.v2fun.ai/upload/animation-input-mannequin.glb",
        "input_motion": "motions/h3d/bvh/00041332_000.bvh",
        "fps": 30
    },
)
print(resp.json())
java
import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
String body = "{\"input_model\":\"https://asset.v2fun.ai/upload/animation-input-mannequin.glb\",\"input_motion\":\"motions/h3d/bvh/00041332_000.bvh\",\"fps\":30}";
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.v2fun.ai/api/v1/motions/animations"))
    .header("Authorization", "Bearer $V2FUN_API_KEY")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();
HttpResponse<String> response = client.send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
输入模型(已绑骨)
输出结果

返回结果示例:

json
{
  "status": "COMPLETED",
  "result": "models/867a17e3-ec0e-4977-8b14-6a44cc69c9cb.glb",
  "metadata": [
    {
      "t_pose_model": "models/be3d686b-4779-4e90-b2e1-ef4fc3f4800a.glb",
      "downloads": [
        {
          "asset_path": "models/867a17e3-ec0e-4977-8b14-6a44cc69c9cb.glb",
          "download_url": "https://..."
        }
      ]
    }
  ]
}

返回的 GLB 内嵌动画轨道,可直接导入 Unity / Unreal / Three.js 等引擎播放。