MCPcopy Index your code
hub / github.com/binzume/modelconv

github.com/binzume/modelconv @v0.3.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.5 ↗ · + Follow
637 symbols 1,761 edges 58 files 32 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Experimental 3D model converter

Build Status Go Reference license

Goで3Dモデルファイルを読み書きするライブラリ&変換ツールです.

Format Read Write Comment
.mqo/.mqoz ボーン・モーフに対応
.gltf/.glb 他フォーマットへの変換は暫定実装
.vrm glTF 用のエクステンション
.pmx/.pmd .pmd は Read only
.fbx 出力はASCIIのみ
.unity Unity 2018以降のシーンに対応
.vmd 暫定実装

仕様が良くわかからないものは実際のファイルを見ながら雰囲気で実装してるので,読み込めないデータがあるかもしれません.

Command-line tool

cmd/modelconv

以下の組み合わせの変換が可能です.

  • (.pmd | .pmx | .mqo | .mqoz | .fbx | .unity) → (.pmx | .mqo| .mqoz | .glb | .gltf | .vrm)
  • (.glb | .gltf | .vrm) → (.glb | .gltf | .vrm) (※1)

※1: glTF同士の変換は特別扱いをしているため,モデルに変更を加えるオプションは未対応です.(scaleは可能)

Install "modelconv" commant

新し目のGoがあればビルドできると思います. Releasesにビルド済みのWindows用の実行ファイルを置いてあります.

go install github.com/binzume/modelconv/cmd/modelconv@latest

Usage examples

MMD to VRM

modelconv -autotpose "右腕,左腕" "model.pmx" "model.vrm"
modelconv -vrmconfig "model.vrmconfig.json" "model.pmx" "model.vrm"

gltf to glb

modelconv "model.gltf" "model.glb"
modelconv -format glb "model.gltf"

Unity to glb

modelconv  "test.unitypackage#Assets/scene.unity" "scene.glb"
modelconv  "YourProject/Assets/Scenes/scene.unity" "scene.glb"

Scaling

modelconv -scale 1.5 "model.glb" "model_scaled.glb"
modelconv -scaleY 1.5 -scaleX 1.3 "model.mqo" "model_scaled.mqo"

Flags

Flag Description Default
-format Output format
-scale Scale See Unit
-scaleX Scale x-axis 1.0
-scaleY Scale y-axis 1.0
-scaleZ Scale z-axis 1.0
-rot180 rotate 180 degrees around Y-axis
-hide hide objects (OBJ1,OBJ2,...)
-hidemat hide materials (MAT1,MAT2,...)
-unlit unlit materials (MAT1,MAT2,...)
-vrmconfig Config file for VRM "inputfile.vrmconfig.json"
-autotpose Arm bone names
-chparent replace parent bone (BONE1:PARENT1,BONE2:PARENT2,...)
-physics Convert Physics colliders (experinemtal) false

vrmconfig:

設定ファイルのjsonは converter/vrmconfig_presets にあるファイルや, Qiitaの記事も参考にしてください.

MMDからの変換時にはデフォルトで mmd.json が使われます.

hide,hidemat,unlit:

対象のオブジェクトやマテリアルの名前をカンマ区切りで指定してください.ワイルドカード(*)が利用可能です.

autotpose:

腕のボーンを指定するとX軸に沿うように形状を調整します(暫定実装)

Unit:

  • MQO: 1mm
  • MMD: 80mm
  • glTF/VRM: 1m

例: MMD → VRM : default scale = 0.08

API

T.B.D.

Example: .pmx to .mqoz

    mmdModel, err :=  mmd.Load("model.pmx")
    if err != nil {
        return err
    }
    mqDoc, err := converter.NewMMDToMQOConverter(nil).Convert(mmdModel)
    if err != nil {
        return err
    }
    err = mqo.Save(mqDoc, "model.mqoz")
    if err != nil {
        return err
    }

License

MIT License

Extension points exported contracts — how you extend this code

Plugin (Interface)
(no doc) [3 implementers]
mqo/mqo.go
Object (Interface)
(no doc) [1 implementers]
fbx/fbx_object.go
Component (Interface)
(no doc) [1 implementers]
unity/unity_components.go
Assets (Interface)
(no doc)
unity/unity_assets.go
Element (Interface)
(no doc)
unity/unity.go

Core symbols most depended-on inside this repo

read
called by 77
mmd/base_parser.go
write
called by 62
mmd/pmx_writer.go
readFloat
called by 55
mqo/mqo_parser.go
FindChild
called by 32
fbx/fbx_node.go
Close
called by 32
unity/unity_assets.go
NewNode
called by 31
fbx/fbx_node.go
Mul
called by 28
geom/matrix4.go
readIndex
called by 26
mmd/pmx_parser.go

Shape

Method 362
Struct 139
Function 124
Interface 6
TypeAlias 6

Languages

Go100%

Modules by API surface

fbx/fbx_geometry.go34 symbols
unity/unity_assets.go32 symbols
fbx/fbx_node.go32 symbols
mqo/mqo.go28 symbols
mqo/bone_plugin.go27 symbols
fbx/fbx_object.go27 symbols
mqo/mqo_parser.go22 symbols
mmd/pmx_writer.go22 symbols
unity/unity_components.go21 symbols
converter/mqo2gltf.go20 symbols
vrm/vrm.go19 symbols
fbx/binary_parser.go18 symbols

For agents

$ claude mcp add modelconv \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact