7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VRoidの服をVCIで着替える

Last updated at Posted at 2020-05-30

概要

VRoidの服をVCIで着替えてみました。
inバーチャルキャスト

バージョン

Unity : 2019.3.0f6
UniVCI : 0.27
UniVRM : 0.55
バーチャルキャスト : 1.9.2d

Unity完結式の手動作成手順

image.png

準備

VRM取り込み
VRMのオブジェクトにVCI Objectを追加
不要メッシュ等の削除or透過(ホントは全て削除したい)
主要ボーンをVCI Objectの直下へ引っ張り出す

●主要ボーンのオブジェクトへ以下を追加
・VCI Sub Item
・Rigidbody
・VCI Attachable
・Box Collider

全部位設定

●VCI Sub Item
・GrabbableをOnに設定
・ScalableをOnに設定
・Group Idを1に設定
※VCI Sub Itemは手動だと強制個別なので要気合

●Rigidbody
・Use GravityをOffに設定
・Is KinematicをOnに設定

●VCI Attachable
・Sizeを1に設定
・Distanceを0.05に設定

●Box Collider
・Sizeを0.1に設定
・Is TriggerをOnに設定

個別部位設定

各VCI AttachableのElementを対応する部位ごとに設定

●ChestのBox Colliderだけ
・Centerを0, 0.1, 0に設定
・Sizeを0.2に設定
※この部位の大きさの違いが目立つので、調整しやすいように大きくしておく

●HandのBox Colliderだけ
・Sizeを0に設定
※着た後に強制選択状態になってしまうので対策

luaコード

VCI ObjectのScriptsに以下を設定

local Attached = false

function onUse(use)
    local owner = vci.studio.GetOwner()

    -- 体幹
    SetAtt(owner, "Hips", "J_Bip_C_Hips", Attached)
    SetAtt(owner, "Spine", "J_Bip_C_Spine", Attached)
    SetAtt(owner, "Chest", "J_Bip_C_Chest", Attached)

    -- 足
    SetAtt(owner, "LeftUpperLeg", "J_Bip_L_UpperLeg", Attached)
    SetAtt(owner, "RightUpperLeg", "J_Bip_R_UpperLeg", Attached)
    SetAtt(owner, "LeftLowerLeg", "J_Bip_L_LowerLeg", Attached)
    SetAtt(owner, "RightLowerLeg", "J_Bip_R_LowerLeg", Attached)
    SetAtt(owner, "LeftFoot", "J_Bip_L_Foot", Attached)
    SetAtt(owner, "RightFoot", "J_Bip_R_Foot", Attached)

    -- 腕
    SetAtt(owner, "LeftUpperArm", "J_Bip_L_UpperArm", Attached)
    SetAtt(owner, "RightUpperArm", "J_Bip_R_UpperArm", Attached)
    SetAtt(owner, "LeftLowerArm", "J_Bip_L_LowerArm", Attached)
    SetAtt(owner, "RightLowerArm", "J_Bip_R_LowerArm", Attached)
    SetAtt(owner, "LeftHand", "J_Bip_L_Hand", Attached)
    SetAtt(owner, "RightHand", "J_Bip_R_Hand", Attached)

    Attached = not Attached
end

function SetAtt(owner, boneName, itemName, attached)
    local bone = owner.GetBoneTransform(boneName)
    local item = vci.assets.GetSubItem(itemName)
    if bone ~= nil and item ~= nil then
        -- 位置と回転の合わせ
        item.SetPosition(bone.position)
        item.SetRotation(bone.rotation)

        -- 脱着
        if attached then
            item.DetachFromAvatar()
        else
            item.AttachToAvatar()
        end
    end
end

備考

VCI Attachableを有効にするには通常のColliderが必須(更にGrabbableOnも必須)
AttachToAvatarする時の位置合わせは同期が必要かと思ったけど、特に何もしなくても良さそう
服のサイズを着るアバターでVRM化してから作業すればサイズは丁度
素体側ではみ出やすい部位は透過すると良いかも
今回のバージョンではGetAvatarsによるゲストのTransform取得が動かない?(ので他の人に着せられない)
変換ツール作成予定→できた(https://120byte.booth.pm/items/2115099)

7
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?