跳转至

Json配置示例

提示

请使用 BeJSON 等网站校验和格式化Json文件

注意

此页面所有示例均基于SDK 2的配置属性

最基础的配置

功能点

  • 通过读取三张贴图文件和moc模型文件显示Live2D模型
  • 模型包含两个待机(idle)动作和一个鼠标点击动作(tap)
  • 鼠标点击动作包含语音文件和淡入淡出效果
  • 模型包含两个表情文件(expressions)
  • 模型包含物理效果(physics.json)和部件置换效果(pose.json)
  • 模型激活自动对口型功能(lip_sync)

要点

  • 该配置为Json标准格式
  • 该配置所有符号均为英文符号,切勿使用中文!
  • 配置中所有的文件路径均为相对路径,以该配置文件路径为根路径
  • 大括号 “{ }” 包含的内容格式为 "键":"值"
  • 中括号 “[ ]” 包含的内容为一个或者多个大括号

示例

{
    "version": "1.0.0",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "motions": {
        "idle": [
            {
                "file": "motions/haru_idle_01.mtn"
            },
            {
                "file": "motions/haru_idle_02.mtn"
            }
        ],
        "tap": [
            {
                "file": "motions/haru_normal_01.mtn",
                "sound": "sounds/haru_normal_01.mp3",
                "fade_in": 300,
                "fade_out": 500
            }
        ]
    },
    "expressions": [
        {
            "name": "f01.exp.json",
            "file": "expressions/f01.exp.json"
        },
        {
            "name": "f02.exp.json",
            "file": "expressions/f02.exp.json"
        }
    ],
    "physics": "haru.physics.json",
    "pose": "haru.pose.json",
    "lip_sync": "true"
}

带有触摸区域的模型配置

功能点

  • 配置包含两个触摸区域(face和hand)
  • 配置包含一个face区域点击动作("tap_face")和hand区域点击动作("tap_hand")

要点

  • 配置项添加hit_areas属性,其中id为制作模型时定义的区域id值
  • 点击动作的键名需要在尾部添加对应的区域名,如"tap" -> "tap_face"

示例

{
    "version": "1.0.0",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "hit_areas": [
        {
            "name": "face",
            "id": "D_PSD.55"
        },
        {
            "name": "hand",
            "id": "D_PSD.16"
        }
    ],
    "motions": {
        "idle": [
            {
                "file": "motions/haru_idle_01.mtn"
            },
            {
                "file": "motions/haru_idle_02.mtn"
            }
        ],
        "tap_face": [
            {
                "file": "motions/haru_normal_01.mtn",
                "sound": "sounds/haru_normal_01.mp3"
            }
        ],
        "tap_hand": [
            {
                "file": "motions/haru_normal_02.mtn",
                "sound": "sounds/haru_normal_02.mp3"
            }
        ]
    },
    "physics": "haru.physics.json",
    "lip_sync": "true"
}

带有点击参数的模型配置

功能点

  • 鼠标横向拖拽手部区域,拖拽到一定距离之后触发“hit”动作组下面的“drag”动作

要点

  • 配置里加入hit_areas属性
  • 配置里加入hit_params属性

提示

  • axis为0时,向左拖动减小参数值,向右增加参数值
  • axis为1时,向上拖动减小参数值,向下增加参数值
  • factor为每像素改变的参数值,模型缩放大小会影响该值,例如模型当前缩放为0.5,factor为0.1,则实际每像素改变的参数值为 0.5 * 0.1 = 0.05

示例

{
    "version": "1.0.0",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "hit_areas": [
        {
            "name": "face",
            "id": "D_PSD.55"
        },
        {
            "name": "hand",
            "id": "D_PSD.16"
        }
    ],
    "hit_params": [
        {
            "id": "PARAM_DRAG",
            "hit_area": "hand",
            "axis": 0,
            "factor": 0.01,
            "max_mtn": "hit:drag"
        }
    ],
    "motions": {
        "idle": [
            {
                "file": "motions/haru_idle_01.mtn"
            }
        ],
        "hit": [
            {
                "name": "drag",
                "file": "motions/haru_normal_01.mtn",
                "sound": "sounds/haru_normal_01.mp3"
            }
        ]
    },
    "physics": "haru.physics.json",
    "lip_sync": "true"
}

带有循环参数的模型配置

用途

  • 模型含有某些需要独立于mtn动作存在的循环动画

功能点

  • PARAM_LOOP值以3000毫秒为周期做线性循环

要点

  • 配置项添加loop_params属性

示例

{
    "version": "1.0.0",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "loop_params": [
        {
            "id": "PARAM_LOOP",
            "duration": "3000",
            "type": 0
        }
    ],
    "motions": {
        "idle": [
            {
                "file": "motions/haru_idle_01.mtn"
            }
        ]
    },
    "physics": "haru.physics.json",
    "lip_sync": "true"
}

亲密度系统

功能点

  • 根据亲密度参数设置,亲密度为0-100,初始亲密度为50,模型激活状态下每分钟亲密度奖励为0,非激活状态下奖励为0,每日奖励上限不设限
  • 配置包含一个点击动作,当前亲密度值在10-50之间时可被触发,触发后亲密度奖励为5

要点

  • 配置项添加intimacy_param 属性
  • 在影响好感度的动作属性内添加intimacy属性

示例

{
    "version": "1.0.0",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "intimacy_param": {
        "init_value": 50,
        "min_value": 0,
        "max_value": 100,
        "bonus_active": 0,
        "bonus_inactive": 0,
        "bonus_limit": -1
    },
    "motions": {
        "idle": [
            {
                "file": "motions/haru_idle_01.mtn"
            }
        ],
        "tap": [
            {
                "file": "motions/haru_normal_01.mtn",
                "sound": "sounds/haru_normal_01.mp3",
                "intimacy": {
                    "min": 10,
                    "max": 50,
                    "bonus": 5
                }
            }
        ]
    },
    "physics": "haru.physics.json",
    "lip_sync": "true"
}

模型之间的交互

功能点

  • 点击id为“model1”的模型,触发id为“model2”的tap动作组内的“mtn1”动作事件

要点

  • 被控制的模型需要添加“id”属性
  • 主控模型动作属性内添加"start_mtn"命令,格式为"command":"start_mtn model_id group:motion"
  • model_id为被控制的模型id,group:motion为被控制的模型id内的动作组:动作名,若不指定动作名则在动作组内随机执行一个动作

提示

  • 在动作事件内加入command命令,则会在触发动作事件的同时执行命令,若希望在动作执行完毕之后再触发命令,请使用post_command属性,或者配合next_mtn属性:
    • 添加一个空的动作事件,仅包含name属性和command属性
    • 将空动作事件name值赋予需要触发的动作事件的next_mtn属性内
  • 模型id要定的尽量复杂,否则万一和别人的模型id重复了,有可能会导致命令执行失败或者执行错误

示例

主控模型

{
    "version": "1.0.0",
    "id": "model1",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "motions": {
        "idle": [
            {
                "file": "motions/haru_idle_01.mtn"
            },
            {
                "file": "motions/haru_idle_02.mtn"
            }
        ],
        "tap": [
            {
                "file": "motions/haru_normal_01.mtn",
                "sound": "sounds/haru_normal_01.mp3",
                "command": "start_mtn model2 tap:mtn1"
            }
        ]
    },
    "physics": "haru.physics.json",
    "lip_sync": "true"
}

被控模型

{
    "version": "1.0.0",
    "id": "model2",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "motions": {
        "idle": [
            {
                "file": "motions/haru_idle_01.mtn"
            },
            {
                "file": "motions/haru_idle_02.mtn"
            }
        ],
        "tap": [
            {
                "name": "mtn1",
                "file": "motions/haru_normal_01.mtn",
                "sound": "sounds/haru_normal_01.mp3"
            }
        ]
    },
    "physics": "haru.physics.json",
    "lip_sync": "true"
}

和模型玩猜拳

功能点

  • 点击模型触发猜拳事件并与模型进行猜拳互动

要点

  • 猜拳事件添加choices属性
  • 为三个选择项提供不同的事件组
  • 每个事件组提供三个事件,对应石头、剪刀、布三种响应事件

示例

{
    "version": "1.0.0",
    "model": "haru.moc",
    "textures": [
        "haru.1024/texture_00.png",
        "haru.1024/texture_01.png",
        "haru.1024/texture_02.png"
    ],
    "motions": {
        "tap": [
            {
                "text": "玩猜拳吗?",
                "choices": [
                    {
                        "text": "石头",
                        "next_mtn": "rock"
                    },
                    {
                        "text": "剪刀",
                        "next_mtn": "scissors"
                    },
                    {
                        "text": "布",
                        "next_mtn": "paper"
                    }
                ]
            }
        ],
        "rock": [
            {
                "text": "我出石头!平手!"
            },
            {
                "text": "我出剪刀!输掉了~"
            },
            {
                "text": "我出布!赢啦!"
            }
        ],
        "scissors": [
            {
                "text": "我出石头!赢啦!"
            },
            {
                "text": "我出剪刀!平手!"
            },
            {
                "text": "我出布!输掉了~"
            }
        ],
        "paper": [
            {
                "text": "我出石头!输掉了~"
            },
            {
                "text": "我出剪刀!赢啦!"
            },
            {
                "text": "我出布!平手!"
            }
        ],
        "idle": [
            {
                "file": "motions/idle/Epsilon_idle_01.mtn"
            }
        ]
    },
    "physics": "haru.physics.json",
    "lip_sync": "true"
}