.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
You might also like...
Simple script to export contacts from telegram into vCard file

Telegram Contacts Exporter Simple script to export contacts from telegram into vCard file Getting Started Prerequisites You must to put your Telegram

Application for easy configuration of swap file and swappiness priority in slackware and others linux distributions.

Swap File Program created with the objective of assisting in the configuration of swap file in Distributions such as Slackware. Required packages: pyt

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

A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.
A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

This program organizes automatically files in folders named as file's extension

Auto Sorting System by Sergiy Grimoldi - V.0.0.2 This program organizes automatically files in folders named as file's extension How to use the code T

A simple python script to generate an iCalendar file for the university classes.
A simple python script to generate an iCalendar file for the university classes.

iCal Generator This is a simple python script to generate an iCalendar file for the university classes. Installation Clone the repository git clone ht

Enhanced version of blender's bvh add-on with more settings supported. The bvh's rest pose should have the same handedness as the armature while could use a different up/forward definiton.
Enhanced version of blender's bvh add-on with more settings supported. The bvh's rest pose should have the same handedness as the armature while could use a different up/forward definiton.

Enhanced bvh add-on (importer/exporter) for blender Enhanced bvh add-on (importer/exporter) for blender Enhanced bvh importer Enhanced bvh exporter Ho

Django-Text-to-HTML-converter - The simple Text to HTML Converter using Django framework

Django-Text-to-HTML-converter This is the simple Text to HTML Converter using Dj

strbind - lapidary text converter for translate an text file to the C-style string

strbind strbind - lapidary text converter for translate an text file to the C-style string. My motivation is fast adding large text chunks to the C co

Quick and dirty FAT12 filesystem to ZIP file converter

Quick and Dirty FAT12 Filesystem Converter This is a really crappy Python script I wrote to convert a semi-compatible FAT12 filesystem from my HP150's

This repo contain builders of cab file, html file, and docx file for CVE-2021-40444 exploit
This repo contain builders of cab file, html file, and docx file for CVE-2021-40444 exploit

CVE-2021-40444 builders This repo contain builders of cab file, html file, and docx file for CVE-2021-40444 exploit. This repo is just for testing, re

Extract an archive file (zip file or tar file) stored on AWS S3

S3 Extract Extract an archive file (zip file or tar file) stored on AWS S3. Details Downloads archive from S3 into memory, then extract and re-upload

Universal Office Converter - Convert between any document format supported by LibreOffice/OpenOffice.

Automated conversion and styling using LibreOffice Universal Office Converter (unoconv) is a command line tool to convert any document format that Lib

Regex Converter for Flask URL Routes

Flask-Reggie Enable Regex Routes within Flask Installation pip install flask-reggie Configuration To enable regex routes within your application from

Regex Converter for Flask URL Routes

Flask-Reggie Enable Regex Routes within Flask Installation pip install flask-reggie Configuration To enable regex routes within your application from

Simple text to phones converter for multiple languages

Phonemizer -- foʊnmaɪzɚ The phonemizer allows simple phonemization of words and texts in many languages. Provides both the phonemize command-line tool

This converter will create the exact measure for your cappuccino recipe from the grandiose Rafaella Ballerini!
This converter will create the exact measure for your cappuccino recipe from the grandiose Rafaella Ballerini!

About CappuccinoJs This converter will create the exact measure for your cappuccino recipe from the grandiose Rafaella Ballerini! Este conversor criar

A simple image/video to Desmos graph converter run locally
A simple image/video to Desmos graph converter run locally

Desmos Bezier Renderer A simple image/video to Desmos graph converter run locally Sample Result Setup Install dependencies apt update apt install git

Owner
Hanmin Kim
I create stuff UofT CS '25
Hanmin Kim
extract gene TSS/TES site form gencode/ensembl/gencode database GTF file and export bed format file.

GetTsite python Package extract gene TSS/TES site form gencode/ensembl/gencode database GTF file and export bed format file. Install $ pip install Get

laojunjun 7 Nov 21, 2022
Automatic generator of readmes for git repositories (Includes file' listing)

Readme Generator We are bored of write the same things once and once again. We trust in the comments made inside of our files, and we decided to autom

Natalia Vera Duran 6 Jul 20, 2021
Utility to extract Fantasy Grounds Unity Line-of-sight and lighting files from a Univeral VTT file exported from Dungeondraft

uvtt2fgu Utility to extract Fantasy Grounds Unity Line-of-sight and lighting files from a Univeral VTT file exported from Dungeondraft This program wo

Andre Kostur 29 Dec 5, 2022
Astvuln is a simple AST scanner which recursively scans a directory, parses each file as AST and runs specified method.

Astvuln Astvuln is a simple AST scanner which recursively scans a directory, parses each file as AST and runs specified method. Some search methods ar

Bitstamp Security 7 May 29, 2022
This code renames subtitle file names to your video files names, so you don't need to rename them manually.

Rename Subtitle This code renames your subtitle file names to your video file names so you don't need to do it manually Note: It only works for series

Mostafa Kazemi 4 Sep 12, 2021
Python code to generate and store certificates automatically , using names from a csv file

WOC-certificate-generator Python code to generate and store certificates automatically , using names from a csv file IMPORTANT In order to make the co

Google Developer Student Club - IIIT Kalyani 10 May 26, 2022
cssOrganizer - organize a css file by grouping them into categories

This python project was created to scan through a CSS file and produce a more organized CSS file by grouping related CSS Properties within selectors. Created in my spare time for fun and my own utility. It takes in a style.css file and creates a file called 'organized-style.css.

Andrew Espindola 0 Aug 31, 2022
Make some improvements in the Pizza class and pizzashop file by refactoring.

Make some improvements in the Pizza class and pizzashop file by refactoring.

James Brucker 1 Oct 18, 2021
This project is a set of programs that I use to create a README.md file.

This project is a set of programs that I use to create a README.md file.

Tom Dörr 223 Dec 24, 2022
Create a Web Component (a Custom Element) from a python file

wyc Create a Web Component (a Custom Element) from a python file (transpile python code to javascript (es2015)). Features Use python to define your cu

null 7 Oct 9, 2022