.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
A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use that mirror

Kali Mirror Finder Using Single Python File A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use tha

MrSingh 6 Dec 12, 2022
Adding two matrix from scratch using python.

Adding-two-matrix-from-scratch-using-python. Here, I have take two matrix from user and add it without using any library. I made this program from scr

Sachin Vinayak Dabhade 4 Sep 24, 2021
A utility that makes it easy to work with Python projects containing lots of packages, of which you only want to develop some.

Mixed development source packages on top of stable constraints using pip mxdev [mɪks dɛv] is a utility that makes it easy to work with Python projects

BlueDynamics Alliance 6 Jun 08, 2022
✨ Un générateur d'adresse IP aléatoire totalement fait en Python par moi, et en français.

IP Generateur ❗ Un générateur d'adresse IP aléatoire totalement fait en Python par moi, et en français. 🔮 Avec l'utilisation du module "random", j'ai

MrGabin 3 Jun 06, 2021
Simple profile athena generator for Fortnite Private Servers.

Profile-Athena-Generator A simple profile athena generator for Fortnite Private Servers. This profile athena generrator features: Item variants Get al

Fevers 10 Aug 27, 2022
✨ Un pierre feuille ciseaux totalement fait en Python par moi, et en français.

Pierre Feuille Ciseaux ❗ Un pierre feuille ciseaux totalement fait en Python par moi. 🔮 Avec l'utilisation du module "random", j'ai pu faire un choix

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
Definitely legit social credit generator with python

definitely-legit-social-credit-generator I made this simple GUI program for a meme, no cap. Video: https://youtu.be/RmjxKtoli04 How to run: Clone this

Joshua Malabanan 8 Nov 01, 2021
A python mathematics module

A python mathematics module

Fayas Noushad 4 Nov 28, 2021
Produce a simulate-able SDF of an arbitrary mesh with convex decomposition.

Mesh-to-SDF converter Given a (potentially nasty, nonconvex) mesh, automatically creates an SDF file that describes that object. The visual geometry i

Greg Izatt 22 Nov 23, 2022
Small project to interact with python, C, HTML, JavaScript, PHP.

Micro Hidroponic Small project to interact with python, C, HTML, JavaScript, PHP. Table of Contents General Info Technologies Used Screenshots Usage P

Filipe Martins 1 Nov 10, 2021
A python lib for generate random string and digits and special characters or A combination of them

A python lib for generate random string and digits and special characters or A combination of them

Torham 4 Nov 15, 2022
ecowater-softner is a Python library for collecting information from Ecowater water softeners.

Ecowater Softner ecowater-softner is a Python library for collecting information from Ecowater water softeners. Installation Use the package manager p

6 Dec 08, 2022
Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them.

Find Unused Resource Keys Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them. It looks through a

Noël 5 Jan 08, 2022
python package for generating typescript grpc-web stubs from protobuf files.

grpc-web-proto-compile NOTE: This package has been superseded by romnn/proto-compile, which provides the same functionality but offers a lot more flex

Roman Dahm 0 Sep 05, 2021
Export watched content from Tautulli to the Letterboxd CSV Import Format

Export watched content from Tautulli to the Letterboxd CSV Import Format

Evan J 5 Aug 31, 2022
Manage your exceptions in Python like a PRO

A linter to manage all your python exceptions and try/except blocks (limited only for those who like dinosaurs).

Guilherme Latrova 353 Dec 31, 2022
A simple, console based nHentai Code Generator

nHentai Code Generator A simple, console based nHentai Code Generator. How to run? Windows Android Windows Make sure you have python and git installed

5 Jun 02, 2022
Animation retargeting tool for Autodesk Maya. Retargets mocap to a custom rig with a few clicks.

Animation Retargeting Tool for Maya A tool for transferring animation data and mocap from a skeleton to a custom rig in Autodesk Maya. Installation: A

Joaen 63 Jan 06, 2023
Go through a random file in your favourite open source projects!

Random Source Codes Never be bored again! Staring at your screen and just scrolling the great world wide web? Would you rather read through some code

Mridul Seth 1 Nov 03, 2022