项目作者: fghrsh

项目描述 :
Live2D 看板娘插件 (https://www.fghrsh.net/post/123.html) 上使用的后端 API
高级语言: PHP
项目地址: git://github.com/fghrsh/live2d_api.git
创建时间: 2018-03-02T17:31:21Z
项目社区:https://github.com/fghrsh/live2d_api

开源协议:MIT License

下载


Live2D API

Live2D 看板娘插件 (https://www.fghrsh.net/post/123.html) 上使用的后端 API

特性

  • 原生 PHP 开发,无需伪静态,开箱即用
  • 支持 模型、皮肤 的 顺序切换 和 随机切换
  • 支持 单模型 单皮肤 切换、多组皮肤 递归穷举
  • 支持 同分组 多个模型 或 多个路径 的 加载切换

使用

环境要求

  • PHP 版本 >= 5.2
  • 依赖 PHP 扩展:json

目录结构

  1. model_list.json // 模型列表
  2. ├─model // 模型路径
  3. └─GroupName // 模组分组
  4. └─ModelName // 模型名称
  5. ├─add // 更新皮肤列表
  6. ├─get // 获取模型配置
  7. ├─rand // 随机切换模型
  8. ├─rand_textures // 随机切换皮肤
  9. ├─switch // 顺序切换模型
  10. ├─switch_textures // 顺序切换皮肤
  11. └─tools
  12. modelList.php // 列出模型列表
  13. modelTextures.php // 列出皮肤列表
  14. name-to-lower.php // 文件名格式化

添加模型

  • 单模型 单皮肤 切换
    • 单次加载只输出一个皮肤
    • 皮肤放在 textures 文件夹,自动识别
  1. index.json
  2. model.moc
  3. textures.cache // 皮肤列表缓存,自动生成
  4. ├─motions
  5. idle_01.mtn
  6. idle_02.mtn
  7. idle_03.mtn
  8. └─textures
  9. default-costume.png
  10. school-costume.png
  11. winter-costume.png
  • 单模型 多组皮肤 递归穷举
    • 多组皮肤 组合模型、穷举组合
    • 皮肤文件夹按 texture_XX 命名
    • 添加 textures_order.json 列出组合
      1. index.json
      2. model.moc
      3. textures.cache
      4. textures_order.json
      5. ├─motions
      6. idle_01.mtn
      7. idle_02.mtn
      8. idle_03.mtn
      9. ├─texture_00
      10. 00.png
      11. ├─texture_01
      12. 00.png
      13. 01.png
      14. 02.png
      15. ├─texture_02
      16. 00.png
      17. 01.png
      18. 02.png
      19. └─texture_03
      20. 00.png
      21. 01.png

textures_order.json

  1. [
  2. ["texture_00"],
  3. ["texture_01","texture_02"],
  4. ["texture_03"]
  5. ]

textures.cache

  1. [
  2. ["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/00.png"],
  3. ["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/01.png"],
  4. ["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/00.png"],
  5. ["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/01.png"],
  6. ["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/00.png"],
  7. ["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/01.png"]
  8. ]
  • 同分组 多个模型 或 多个路径 切换
    • 修改 model_list.json 添加多个模型
  1. ├─model
  2. ├─Group1
  3. ├─Model1
  4. index.json
  5. └─Model2
  6. index.json
  7. ├─Group2
  8. └─Model1
  9. index.json
  10. └─GroupName
  11. └─ModelName
  12. index.json
  13. model.moc
  14. ├─motions
  15. └─textures

model_list.json

  1. {
  2. "models": [
  3. "GroupName/ModelName",
  4. [
  5. "Group1/Model1",
  6. "Group1/Model2",
  7. "Group2/Model1"
  8. ]
  9. ],
  10. "messages": [
  11. "Example 1",
  12. "Example 2"
  13. ]
  14. }

接口用法

  • /add/ - 检测 新增皮肤 并更新 缓存列表
  • /get/?id=1-23 获取 分组 1 的 第 23 号 皮肤
  • /rand/?id=1 根据 上一分组 随机切换
  • /switch/?id=1 根据 上一分组 顺序切换
  • /rand_textures/?id=1-23 根据 上一皮肤 随机切换 同分组其他皮肤
  • /switch_textures/?id=1-23 根据 上一皮肤 顺序切换 同分组其他皮肤

版权声明

(>▽<) 都看到这了,点个 Star 吧 ~

API 内所有模型 版权均属于原作者,仅供研究学习,不得用于商业用途

MIT © FGHRSH