- MMD (PMD/PMX/VMD) play and load library
- Viewer (MMD/OBJ)
- saba_viewer
- Example
- simple_mmd_viewer_glfw (OpenGL 4.1)
- simple_mmd_viewer_dx11 (DirectX 11)
- simple_mmd_viewer_vulkan (Vulkan 1.0.65)
- Transparent Window (GLFW 3.3.2 or higher, Windows)
UV was flipped with this commit.
- Windows
- Visual Studio 2019
- Visual Studio 2017
- Visual Studio 2015 Update 3
- Linux
- Mac
- OBJ
- PMD
- PMX
- VMD
- VPD
- x file (mmd extension)
Please install CMake before the build.
Please prepare the following libraries.
- OpenGL
- Bullet Physics
- GLFW
Do not use the msys/cmake
.
Pelase use the mingw64/mingw-w64-x86_64-cmake
.
https://gitlab.kitware.com/cmake/cmake/-/issues/21649
Prepare the mingw64 environment as follows.
pacman -S base-devel mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-ninja
pacman -S mingw-w64-x86_64-mesa
Build Bullet Physics as follows.
cmake -G "Visual Studio 14 2015 Win64" ^
-D CMAKE_INSTALL_PREFIX=<Your Bullet Physics install directory> ^
-D INSTALL_LIBS=ON ^
-D USE_MSVC_RUNTIME_LIBRARY_DLL=On ^
-D BUILD_CPU_DEMOS=Off ^
-D BUILD_OPENGL3_DEMOS=Off ^
-D BUILD_BULLET2_DEMOS=Off ^
-D BUILD_UNIT_TESTS=Off ^
..
cmake --build . --config Debug --target ALL_BUILD
cmake --build . --config Debug --target INSTALL
cmake --build . --config Release --target ALL_BUILD
cmake --build . --config Release --target INSTALL
Please change -G "Visual Studio 14 2015 Win64"
according to your environment.
brew install bullet
Ubuntu:
apt-get install libbullet-dev
Arch linux:
pacman -S bullet
pacman -S mingw-w64-x86_64-bullet
brew install glfw
Ubuntu:
apt-get install libglfw3-dev
Arch linux:
pacman -S glfw
pacman -S mingw-w64-x86_64-glfw
git clone https://github.com/benikabocha/saba.git
cd saba
mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" ^
-D SABA_BULLET_ROOT=<Your Bullet Physics install directory> ^
-D SABA_GLFW_ROOT=<your GLFW install directory> ^
..
Open the created sln file in Visual Studio and build it.
"saba_viewer" project is the viewer application.
mkdir build
cd build
cmake ..
make -j4
./saba_viewer
If the operation is heavy, please try the following.
cmake -DCMAKE_BUILD_TYPE=RELEASE ..
make -j4
mkdir build
cd build
cmake ..
ninja
./saba_viewer
Initialize with the "init.json" or "init.lua" file placed in the current directory.
Write "init.json" or "init.lua" file in UTF-8.
{
"MSAAEnable": true,
"MSAACount": 8,
"Commands":[
{
"Cmd":"open",
"Args":["test.pmx"]
},
{
"Cmd":"open",
"Args":["test.vmd"]
}
]
}
Enable MSAA.
Set the number of MSAA samples.
Set the commands to be executed at startup.
MSAA = {
Enable = true,
Count = 8
}
InitCamera = {
Center = {x = 0, y = 10, z = 0},
Eye = {x = 0, y = 10, z = 50},
NearClip = 1.0,
FarClip = 2000.0,
Radius = 100
}
InitScene = {
UnitScale = 10
}
Commands = {
{
Cmd = "open",
Args = {"test.pmx"},
},
{
Cmd = "open",
Args = {"test.vmd"},
},
{
Cmd = "play"
},
}
Enable MSAA.
Set the number of MSAA samples.
Set camera center position at scene initialization.
Set camera eye position at scene initialization.
Set camera near clip at scene initialization.
Set camera far clip at scene initialization.
Set camera zoom radius at scene initialization.
Set grid size at scene initialization.
Set the commands to be executed at startup.
You can run the script.
The command line argument is the "Args" variable.
ModelIndex = 1
print(Args[1])
Commands = {
{
Cmd = "open",
Args = {Models[ModelIndex]},
},
{
Cmd = "open",
Args = {"test.vmd"},
},
{
Cmd = "play"
},
}
Drag and drop files, or use the "open" command.
- Drag and drop model(PMD/PMX) file.
- Drag and drop motion(VMD) file.
Drag the mouse to move the camera.
- Left Button (z + Left Button) : Rotate
- Right Button (c + Left Button) : Zoom
- Middle Button (x + Left Button) : Translate
open <file path>
Open the file.
Supported file types.
- OBJ
- PMD
- PMX
- VMD
The model file will be selected when opened.
The model name will be model_xxx
(nnn
is ID).
select <model name>
Select a model.
clear [-all]
Clear a model.
If invoked with no arguments, it clears the selected model.
If -all
is specified, all models will be cleared.
play
Play the animation.
stop
Stop the animation.
translate x y z
Translate the selected model.
rotate x y z
Rotate the selected model.
scale x y z
Scale the selected model.
refreshCustomCommand
Refresh the custom command.
enableUI [false]
Switch the display of the UI.
F1
key works the same way.
clearAnimation [-all]
Clear animation of selected model.
clearSceneAnimation
Clear animation of scene(eg camera).
You can create custom commands using Lua.
When "command.lua" is placed in the current directory and started up, the custom command written in Lua is loaded.
Write "command.lua" with UTF - 8.
For example, you can register a model or animation load as a macro.
function OpenModel(files)
return function ()
ExecuteCommand("clear", "-all")
for i, filename in ipairs(files) do
ExecuteCommand("open", filename)
end
end
end
function OpenAnim(files, isPlay)
return function ()
ExecuteCommand("clearAnimation", "-all")
ExecuteCommand("clearSceneAnimation")
for i, filename in ipairs(files) do
ExecuteCommand("open", filename)
end
if isPlay then
ExecuteCommand("play")
end
end
end
-- Register Model Load Command
RegisterCommand("", OpenModel({"Model1_Path"}), "01_Model/Menu1")
RegisterCommand("", OpenModel({"Model2_Path"}), "01_Model/Menu2")
-- Register Animation Load Command
anims = {
"ModelAnim_Path",
"CameraAnim_Path",
}
RegisterCommand("", OpenAnim(anims, true), "02_Anim/Anim1")
Here are functions that can be used in "command.lua".
RegisterCommand(commandName, commandFunc, menuName)
-- Register command.
-- commandName : Command name
-- If it is empty, the command name is set automatically.。
-- commandFunc : Command function
-- menuName : Menu name
-- This is the name when registering a custom command in the menu.。
-- If it is empty it will not be added to the menu.
-- '/' Separate the menu hierarchy.
ExecuteCommand(command, args)
-- Execute the command.
-- command : Execute the command.
--- args : Arguments to pass to the command.
--- It is a string or table.
- sanko-shoko.net (AR Example) http://www.sanko-shoko.net/note.php?id=sbtj