Programming A Small Text Value Transfer Tool

Louis Miles

Well-Known Member
OP
Member
Joined
Jul 26, 2016
Messages
114
Trophies
0
Age
22
XP
480
Country
Germany
Hello :)
I'm currently stuck in a bad situation regarding Mario Galaxy Modding. It is a small but bad issue that could be fixed with the help of a little program. All what's required is a tool that can transfer values from a text based file (bvh animation format) to another text file in a different structure. For a specific value it requires a small calculation (but for this i already wrote a small Python script that can calculate this). I have not much knowledge about programming and not much time to learn so I wanted to ask if anyone would like to help me to create a small program like this. It would solve a huge SMG modding problem!

Basically it's about transferring animation frames from a ".bvh" text file to another specific text file. The bvh files usually look like this:
bvh.png
And the text file into which the frames need to be transferred to look like this:
txt.png


If anyone is interested, please let me know!

Thanks in advance :)
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
33,901
Trophies
2
Website
trastindustries.com
XP
22,659
Country
United Kingdom
Bones animation... How unusual compared to what we normally see.

This does not look like a simple swap values around on a spreadsheet type conversion deal.

The BVH sample there seems to have no provisions for a scaling factor. That said I suppose you can invent one, or indeed set it at 1 and have nothing happen.

Formats in terms of precision also look a bit variable in that for the second one (negative, 3 numbers, decimal, 13 0s/positions is that) compared to the base, though nothing too drastic and you can always add more zeros (we can spare a discussion of interpolation).

32767 is also a somewhat notable number in that it is 7FFF in hex or 15 1 values in binary (presumably the 16th being some kind of sign) which has me wondering, though I guess this is for conversion back into a more machine readable format.
This would also bring in the angle multiplier I see there. Is this the calculation you speak of?

When it says joint 0 and joint 1 are they two independent entities or are they two states of animation?
I would also be concerned you are losing information in conversion there; the first format looks to be a bunch of positions to be in at certain frame counts, where the latter I am not sure about (do we have a larger version of an example file?) or if those times it has 4 entries for a line then that looks like could possibly be frame counts.

The second format also seems to have taken things that were simple numbers before and now possible turned them into is that eigen vectors (row ones at that but that is a stylistic concern at best) or at least some form of matrix that I have no particular context for.

No doubt you can convert from one to the other (though I am less sure about back again if that is going to be all the information they have)
 

Louis Miles

Well-Known Member
OP
Member
Joined
Jul 26, 2016
Messages
114
Trophies
0
Age
22
XP
480
Country
Germany
Hi! Sorry for my late reply!

Thank you for your help! Someone has already contacted me and wrote such a program in Python, but it is not complete yet. An additional calculation would be needed, namely how to get the rotation out of two coordinates that virtually form a bone from a model. And this rotation has to be added to all the rotation frames from one bone.

Here is the tool: https://github.com/MrL314/bvh2txt

A big problem with these BVH files is that they output every single frame of an animation and not just the frames where something is happening. This means that the animation files are extremely large in the end. Either a slightly modified BVH plug-in for Blender would be needed that only outputs the important frames (the original plug-in consists of a Python file) or using a different file format. The problem is, however, that many other file formats such as DAE or FBX are super confusing and therefore probably difficult to convert.

All this is kind of a mess where I've spent ages researching :blink:

The BVH sample there seems to have no provisions for a scaling factor. That said I suppose you can invent one, or indeed set it at 1 and have nothing happen.

Sadly the bvh format does not support scaling animations. Only rotations and translations. But it's fine for me at the moment as my animations don't have that many frames with scaling so I can manually edit the animations in the end to add them.

32767 is also a somewhat notable number in that it is 7FFF in hex or 15 1 values in binary (presumably the 16th being some kind of sign) which has me wondering, though I guess this is for conversion back into a more machine readable format.
This would also bring in the angle multiplier I see there. Is this the calculation you speak of?

Yes the calculation values go from 0 to 65535. The Angle Multiplier sets how big the rotation will be and ususally 2 is used which allows enough rotations. It's quite odd how the values work however. For example with Angle Modifier 2 the values from 65535 to 32768 mean ~0° to -720° while the values from 0 to 32767 mean 0° to ~719,97°.
I've already written a little python script that can calculate the rotations, but I'm not sure if it is completely accurate as the output animations sometimes have incorrect rotations:

ROTATION = float( input('Enter rotation of a bvh file (example: "44.995524") ') )
#This is only for Angle Multiplier 2

#CHECK: [- Degree] or [+ Degree] or [0°]
# [0°]
if(ROTATION == 0):
RESULT = 0
# [+ Degree]
if(ROTATION > 0):
ROTATION = ROTATION * 45.51111111111111
ROTATION = 0 + ROTATION
RESULT = round(ROTATION)
# [- Degree]
if(ROTATION < 0):
ROTATION = -1 * ROTATION # [-] becomes [+]
ROTATION = ROTATION * 45.51111111111111
ROTATION = 65536 - ROTATION
ROTATION = round(ROTATION)
if(ROTATION == 65536):
RESULT = 0
else:
RESULT = ROTATION
print("Result: ")
print(RESULT)

Another thing that would solve everything would be a program that can export Autodesk Maya's ".anim" files out from other files, but I've been looking for a long time and unfortunately there just doesn't seem to be anything like that :hateit:(The .anim format is actually quite simple, which surprised me that apart from Maya itself (which is expensive), there isn't a single converter for that)
 
Last edited by Louis Miles,
General chit-chat
Help Users
    AncientBoi @ AncientBoi: anyways, ta-ta, and enjoy your day