跳轉至

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"
}