DavidSM64 / dkr_model_tool

A simple 3D Model tool for the DKR decomp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dkr_model_tool

This is a simple tool that can be used to convert 3D level models to/from the DKR binary format.

Note: This is still heavly work-in-progress, and is probably not ready to be used by anyone just yet. Feel free to look at the code to see how things work.

Requirements

I'm not sure of the minimum version of python you need, but for reference I use python 3.8.5

Packages

  • Pillow - For loading images
  • glfw - For creating a hidden opengl window; needed to generate the bitfields for segments.
  • PyOpenGL - For the preview window
  • PyQt5 - For the preview window
  • numpy - For the preview window

pip install Pillow PyOpenGL PyQt5 numpy glfw

Converting

Basic conversion:

python dkr_model_tool.py <import file path> -o <export file path>

Options

  • -s <Scale Factor> or --scale <Scale Factor>: Scales model on all 3 axises by a certain amount.
  • -a <Segment Count> or --autosplit <Segment Count>: Splits a model up into segments for more efficient rendering. Note: This option splits the model in half recursively, so it won't be the most efficient option.
  • -m <Split JSON filepath> or --manualsplit <Split JSON filepath>: Splits a model based on binary tree structure in a JSON file. The JSON file should look something like this: https://pastebin.com/raw/dvimevCS. value should be in the signed 16-bit integer range (-32768 to +32767), and axis should either be X, Y, or Z.

Supported import file formats

  • DKR level binary file (.bin/.cbin)
  • Wavefront OBJ (.obj)

Supported export file formats

  • DKR level binary file (.bin/.cbin)
  • Wavefront OBJ (.obj)

Note: If you have the DKR decomp setup on your computer, then you should link it by creating a file called path-to-decomp.txt in the root directory. If this is not set, then you may see temporary textures being used instead of vanilla textures.

Preview Window

python dkr_model_tool.py <import file path>

Allows you to view what the level should look like in-game. Should work with any model that can be imported.

Controls

  • W,A,S,D keys to move
  • Hold left mouse button, and then move mouse to change camera rotation.
  • You can use the mouse's scroll wheel to move forward/backward too.

License

MIT License

Copyright (c) 2022 David Benepe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A simple 3D Model tool for the DKR decomp

License:MIT License


Languages

Language:Python 100.0%