Skip to content

intns/modconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

modconv

A C++ command-line tool for converting and editing proprietary 3D model files (.mod format) from Pikmin 1 for the GameCube and Wii.

Table of Contents

Features

  • File Handling

    • Load, parse, and write .mod files
    • Edit header data (date of creation / model flags)
    • Delete specific data chunks (materials, textures, vertices) from loaded models
    • Clear current model data
  • Import / Export

    • Import / export material and TEV (Texture Environment) settings to human-readable text files
    • Import / export model geometry to Wavefront .obj format
    • Import / export texture data from .txe files
    • Import / export trailing .ini data blocks
    • Export model data to .dmd format [WIP]

Building and Running

Prerequisites

  • Modern C++ compiler (GCC, Clang, or MSVC)

  • CMake

Compilation

Navigate to the project root directory:

mkdir build
cd build
cmake ..
cmake --build .

Running

Execute the compiled binary to start the interactive shell:

./modconv[.exe]

Usage

The tool uses an interactive command-line interface. Once started, it displays available commands.

Interactive Mode

Basic workflow:

  1. Load a .mod file
  2. Export data to editable formats or modify the file as needed
  3. Apply changes to the model
  4. Write the modified model to a new file

Example session:

load my_model.mod
export_materials materials.txt
# Edit materials.txt with a text editor
import_material materials.txt
write my_model_new.mod
close

Command-Line

1. Convert MOD to OBJ

# Windows
modconv.exe load model.mod export_obj model.obj

# Linux/Mac
./modconv load model.mod export_obj model.obj

2. Extract all textures from a MOD file

modconv load model.mod export_textures ./textures/

3. Export and reimport materials

modconv load model.mod export_materials materials.txt close load model2.mod import_material materials.txt write model2_updated.mod

4. Modify and save a MOD file

# Delete collision data and save
modconv load model.mod delete_chunk 0x100 delete_chunk 0x110 write model_no_collision.mod

System Design

  • MOD Class: Central class representing a loaded .mod file, containing vectors and objects for all data chunks (vertices, materials, meshes)

  • cmd Namespace: Manages the interactive command-line interface, parsing user input and executing corresponding functions

  • File I/O

    • util::fstream_reader & util::fstream_writer: Custom stream classes for binary file I/O with big-endian byte swapping
    • MaterialReader & MaterialWriter: Classes for serializing material data to/from human-readable text format
  • Data Structures: There are a variety of structs that directly map to binary structures in the .mod file format (Material, TEVInfo, Mesh, Joint, CollTriInfo, etc.)

Future Enhancements

  • Complete work-in-progress .obj and .dmd export functionality
  • Implement the stubbed objToDmd converter
  • Tidy the code further

About

A tool for reading and writing Pikmin 1 model files

Resources

License

Stars

Watchers

Forks

Packages

No packages published