.bvh to .mcfunction file converter.

Overview

bvh-to-mcf

.bvh file to .mcfunction converter

Example video of it in action: https://www.youtube.com/watch?v=L2yVFUgoeBY

This program lets you import armature animations into Minecraft by converting .bvh files into .mcfunction.

Using programs like blender, you can export animations to .bvh which can be converted by this program into .mcfunction.

Usage

See example.py for an example. There is a lot to write so it is recommended that you make a separate file to run the program.

Python:

  1. Create a folder named 'data' in the same directory as main.py. This is where your .bvh files should be.
  2. Create an instance of a MainConverter class with a path to where the functions should be written to. WARNING: THIS WILL DELETE THE FOLDER AND ALL IT'S CONTENTS
converter = MainConverter('C:/Users/USER/AppData/Roaming/.minecraft/saves/WORLD_NAME/datapacks/DATAPACK_NAME/data/animate/functions/FOLDER')
  1. Load the .bvh file into the converter with a scale value and Euler rotation order (optional, default 'xyz')
converter.load_file('data/ANIMATION_FILE.bvh', 2.0, 'xyz')
  1. Create an armature by defining it's name, root entity UUID, and in-game bones. Example:
converter.globalize_armature('character_1', '54e5e739-9221-45fc-a06f-b5326d174cf7',
                                 [('Head',
                                   '2f9d6e9a-aaca-4964-9059-ec43f2016499',
                                   '19c4830d-8714-4e62-b041-0cde12b6de96',
                                   Vector3(0.0, 8.0, 0.0).scaled_pixels_to_meter(),
                                   Vector3(0.0, 1.0, 0.0).scaled_pixels_to_meter(),
                                   Vector3(0.0, 1.0, 0.0),
                                   'diamond_hoe{CustomModelData:101}'
                                   ),
                                  ('Body',
                                   '41451f74-0acb-4406-a42f-cc90a4a04c9b',
                                   '530b439d-1760-4652-93a7-3320f269358a',
                                   Vector3(0.0, 12.0, 0.0).scaled_pixels_to_meter(),
                                   Vector3(0.0, 0.0, 0.0).scaled_pixels_to_meter(),
                                   Vector3(0.0, 1.0, 0.0),
                                   'diamond_hoe{CustomModelData:102}'
                                   ),
                                   # ... more bones
                                 ]
                               )

The armature name should be alphanumeric + dash/underscores, no spaces.

The root entity UUID should be the UUID of the entity you want the armature to be centered at. The function will not spawn the root entity in, so you should spawn a marker entity and get it's UUID first.

Each bone is represented as a tuple. The items in the tuple are, in order:

  • Name of the bone. This should match the name of the bones in the .bvh file.
  • UUID of the AEC (will be spawned in, pick an arbitrary UUID).
  • UUID of the Armor Stand (will be spawned in, pick an arbitrary UUID).
  • Size Vector: Define the size of the bone in Minecraft. e.g. 'Head' has a size vector of Vector3(0.0, 8.0, 0.0).scaled_pixels_to_meter() because it is 8 pixels tall. So if Head had a child, for example a hat, it will be placed visually on top of the head. This vector should correspond to the block model. e.g. If the 'Arm' model is pointing down, the vector should be (0.0, -8.0, 0.0). If it is pointing in the x-direction, the vector should be (8.0, 0.0, 0.0).
  • Offset Vector: Define the offset of the bone in Minecraft relative to it's parent. e.g. 'Head' with an offset vector of (0.0, 0.0, 0.0) is too low and overlaps with the body. Thus an offset vector of Vector3(0.0, 1.0, 0.0).scaled_pixels_to_meter() is used. This offset vector is rotated by the parent's rotation, it is not a global offset.
  • Initial-Pose vector: Define the T-pose direction of the bone. Check which direction the bone is facing while poseless in the .bvh model. e.g. A model doing a T-pose may have the left-arm pointing in the x-direction. Then, the vector would be (1.0, 0.0, 0.0). Magnitude does not matter.
  1. Repeat steps 3 and 4 if you have more armatures to export to the same folder.
  2. Generate a reset function for each of the armatures.
converter.reset_function('character_1')
  1. Generate a search function for each of the armatures.
converter.search_function('character_1')

Minecraft

  1. You should have spawned in entities as described in step 4 in instructions for Python.
  2. Add scoreboard.
/scoreboard objectives add animation_time dummy
  1. Reset entities. The function should be in the folder defined in step 2 in instructions for Python
    e.g. if your path is C:/Users/USER/AppData/Roaming/.minecraft/saves/WORLD_NAME/datapacks/DATAPACK_NAME/data/animate/functions/FOLDER, you should be able to run your function using:
    /function animate:FOLDER/reset
  2. Play animation: In the same folder as the reset function in step 3, there should be a 'main' function.
    e.g. if your reset function was /function animate:FOLDER/reset, your main function should be /function animate:FOLDER/main. Running this function in Minecraft will display a single frame, with the frame number being the value of global's animation_time score. Set a clock with the 'main' function command and scoreboard players add global animation_time 1. e.g. In a loop:
scoreboard players add global animation_time 1
function animate:FOLDER/main
Owner
Hanmin Kim
I create stuff UofT CS '25
Hanmin Kim
Etherium unit conversation and arithmetic library

etherunit Etherium unit conversation and arithmetic library Install pip install -u etherunit Usage from etherunit import Ether, Gwei, Wei, E Creat

Yasin Özel 1 Nov 10, 2021
A multipurpose python module

pysherlock pysherlock is a Python library for dealing with web scraping using images, it's a Python application of the rendertron headless browser API

Sachit 2 Nov 11, 2021
A dictionary that can be flattened and re-inflated

deflatable-dict A dictionary that can be flattened and re-inflated. Particularly useful if you're interacting with yaml, for example. Installation wit

Lucas Sargent 2 Oct 18, 2021
Simple code to generate a password for your account!

Password-Generator Simple code to generate a password for your account! Password Generator for passwords for your accounts or anything else! This code

DEEM 1 Jun 05, 2022
Utility to play with ADCS, allows to request tickets and collect information about related objects.

certi Utility to play with ADCS, allows to request tickets and collect information about related objects. Basically, it's the impacket copy of Certify

Eloy 185 Dec 29, 2022
Library for processing molecules and reactions in python way

Chython [ˈkʌɪθ(ə)n] Library for processing molecules and reactions in python way. Features: Read/write/convert formats: MDL .RDF (.RXN) and .SDF (.MOL

16 Dec 01, 2022
Dependency injection lib for Python 3.8+

PyDI Dependency injection lib for python How to use To define the classes that should be injected and stored as bean use decorator @component @compone

Nikita Antropov 2 Nov 09, 2021
A script to parse and display buy_tag and sell_reason for freqtrade backtesting trades

freqtrade-buyreasons A script to parse and display buy_tag and sell_reason for freqtrade backtesting trades Usage Copy the buy_reasons.py script into

Robert Davey 31 Jan 01, 2023
Build capture utility for Linux

CX-BUILD Compilation Database alternative Build Prerequisite the CXBUILD uses linux system call trace utility called strace which was customized. So I

GLaDOS (G? L? Automatic Debug Operation System) 3 Nov 03, 2022
Check username

Checker-Oukee Check username It checks the available usernames and creates a new account for them Doesn't need proxies Create a file with usernames an

4 Jun 05, 2022
A primitive Python wrapper around the Gromacs tools.

README: GromacsWrapper A primitive Python wrapper around the Gromacs tools. The library is tested with GROMACS 4.6.5, 2018.x, 2019.x, 2020.x, and 2021

Becksteinlab 140 Dec 28, 2022
Easy compression and extraction for any compression or archival format.

Tzar: Tar, Zip, Anything Really Easy compression and extraction for any compression or archival format. Usage/Examples tzar compress large-dir compres

DanielVZ 37 Nov 02, 2022
A thing to simplify listening for PG notifications with asyncpg

asyncpg-listen This library simplifies usage of listen/notify with asyncpg: Handles loss of a connection Simplifies notifications processing from mult

ANNA 18 Dec 23, 2022
A collection of common regular expressions bundled with an easy to use interface.

CommonRegex Find all times, dates, links, phone numbers, emails, ip addresses, prices, hex colors, and credit card numbers in a string. We did the har

Madison May 1.5k Dec 31, 2022
UUID version 7, which are time-sortable (following the Peabody RFC4122 draft)

uuid7 - time-sortable UUIDs This module implements the version 7 UUIDs, proposed by Peabody and Davis in https://www.ietf.org/id/draft-peabody-dispatc

Steve Simmons 22 Dec 20, 2022
An awesome tool to save articles from RSS feed to Pocket automatically.

RSS2Pocket An awesome tool to save articles from RSS feed to Pocket automatically. About the Project I used to use IFTTT to save articles from RSS fee

Hank Liao 10 Nov 12, 2022
About Library for extract infomation from thai personal identity card.

ThaiPersonalCardExtract Library for extract infomation from thai personal identity card. imprement from easyocr and tesseract New Feature v1.3.2 🎁 In

ggafiled 26 Nov 15, 2022
A plugin to simplify creating multi-page Dash apps

Multi-Page Dash App Plugin A plugin to simplify creating multi-page Dash apps. This is a preview of functionality that will of Dash 2.1. Background Th

Plotly 19 Dec 09, 2022
✨ Un générateur de lien raccourcis en fonction d'un lien totalement fait en Python par moi, et en français.

Shorter Link ❗ Un générateur de lien raccourcis en fonction d'un lien totalement fait en Python par moi, et en français. Dépendences : pip install pys

MrGabin 3 Jun 06, 2021
produces PCA on genotypes from fasta files (popPhyl's ID format)

popPhyl_PCA Performs PCA of genotypes. Works in two steps. 1. Input file A single fasta file containing different loci, in different populations/speci

camille roux 2 Oct 08, 2021