Skip to main content

A Python tool for baking root motion data from PNG sequence frames into JSON format

Project description

Paper2D Root Motion Baker

A Python tool for baking root motion data from PNG sequence frames into JSON format.

Requirements

  1. This tool is implemented in Python to bake sequential PNG frame data into JSON format.

Implementation Principles

  1. PNG images arranged according to naming rules, with consistent resolution.
  2. The first PNG image is designated as the baseline root motion image.
  3. Detect a unique marker color point and set its coordinates as the root motion X/Y origin (0, 0).
  4. Process each image in sequence and calculate X/Y coordinate changes based on the relative point.
  5. Export a JSON file containing coordinates for each frame.

Usage Example

prmb --marker-color 251 242 54 "E:\KXHWL\Source" "E:\KXHWL\Source\motion_data.json"

Installation

You can install the package via pip:

pip install paper2d-root-motion-baker

Requirements

  • Python 3.7+
  • Pillow (PIL)
  • NumPy

Installation

  1. Clone this repository
  2. Install dependencies:
pip install -r requirements.txt

Usage

prmb <input_directory> <output_json> [--marker-color R G B]

Arguments

  • input_directory: Directory containing PNG sequence frames
  • output_json: Path for the output JSON file
  • --marker-color: RGB values for the marker color (default: 255 0 0 for red)

Example

prmb ./sprite_sequence output.json --marker-color 255 0 0

Input Requirements

  1. PNG sequence frames must:
    • Be in the same directory
    • Have consistent dimensions
    • Be named in a sortable sequence
  2. Each frame must contain exactly one marker point of the specified color
  3. The first frame is used as the reference frame (0,0)

Output Format

The tool generates a JSON file with the following structure:

{
  "frames": [
    {
      "frame": 0,
      "position": {
        "x": 0,
        "y": 0
      }
    },
    {
      "frame": 1,
      "position": {
        "x": 10,
        "y": 5
      }
    }
    // ... more frames
  ],
  "metadata": {
    "frame_count": 2,
    "version": "1.0"
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paper2d_root_motion_baker-0.1.3.tar.gz (8.1 kB view details)

Uploaded Source

File details

Details for the file paper2d_root_motion_baker-0.1.3.tar.gz.

File metadata

File hashes

Hashes for paper2d_root_motion_baker-0.1.3.tar.gz
Algorithm Hash digest
SHA256 339ab5e4df7e5031c07989b3e8dce418e8ba694f8b693cd863fa2f58ffc483f0
MD5 22e17d25706e470d3a8867cb72dc28c2
BLAKE2b-256 22e38bb73ff65928f3f682fa87506c217a61d2112c3d3fb6c5da564dca459f6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page