How to use b3d in blender?

User avatar
Tcll
Member
Posts: 65
Joined: Thu Jul 25, 2019 21:43
GitHub: Tcll
IRC: Tcll Tcll5850 DarkPikachu
In-game: Tcll
Location: The Gates of Darkness.

Re: How to use b3d in blender?

by Tcll » Post

cronvel wrote:
Mon Sep 07, 2020 12:48
Damn, so we are tied with a file format without anything but deprecated exporter? :/
I'll try and see what I can do to maybe rush something out sooner, just to give you guys something decent to work with...
just keep in mind, it'll probably be very basic as I've had to break a few things to redo the code.

to explain a bit, I'm trying to organize everything first before writing, rather than re-iterate through everything numerous times like every other script does.
I got caught up on bone matrices, and properly organizing the ROOT node before life decided to shove me in a hole...
I wish there was more official documentation so I could know how much slack I had with the format (how I could organize things more effectively)

EDIT:
btw, regarding your animations being lost
B3D is similar to IQM in that there's no individual animations
all animations are just 1 large animation indexed by frame number

though the script I'm working with (2.79) does support iterating both ipo and action animations
there could be changes in 2.8 causing issues with animation referencing the script is not aware of.
I'm just guessing at this point though cause I can't test... =3=

EDIT2:
just so nobody gets discouraged, life finally cut me some slack (not sure for how long), and I've gotten some free time to work on things a bit better...
and working have I been these past few days, though I've currently hit a snag with animation data and am currently working on a HexEdit template to help me get past it:
Image
older shots:
+ Spoiler
figured it'd also help document the format a bit better :)

eventually I'll have the structs colored so stuff is easier to make out on the hex side, much like my old works with other model formats:
+ Spoiler
so yeah, progress is finally on the way again ;D

EDIT3:
oh cool, Minetest ignores the global MESH chunk material and just defaults to 0 per TRIS chunk :srs:

Code: Select all

        if (triangle_brush_id != -1)
	{
		loadTextures(Materials[triangle_brush_id]);
		B3dMaterial = &Materials[triangle_brush_id];
		meshBuffer->Material = B3dMaterial->Material;
	}
	else
		B3dMaterial = 0; // this should be the MESH material ID
why does Minetest keep disappointing me... u.u

though it's good to know multi-material IS supported at least...

EDIT4:
the HexEdit template is mostly functional and should work for most proper B3D files
if anyone would like me to release it as is, let me know :)
otherwise, after I finish the export script, I'll work on coloring the structs and providing more info to make things less cryptic ;)

EDIT5:
ok so going through the animation code, I realized I needed a little bit more out of my template for validation purposes...
does anyone know of a good quat to euler code that doesn't need branching logic to handle singularities, or better yet doesn't deal with atan2() at all??
(I'm actually going for a quat -> mtx33 -> euler as the codes there seem more solid)

I'd prefer a code that maintains the original value as much possible...
or in other words, maintaining crazy values like 720 degrees instead of substituting 0 degrees for a gimbal lock case
is it possible to passively ignore gimbal lock with a better equation??

EDIT5.5: after some research, I still haven't found what I'm looking for... (gotta love DDG)
it appears what I'm talking about prior would be extrinsic rotation about the original axis (how OpenGL actually works)
(frame rotation (every euler equation ever) is intrinsic and causes singularities)
is there an extrinsic quat -> euler or mtx33 -> euler equation anywhere??

cronvel
Member
Posts: 40
Joined: Fri Jan 11, 2019 16:50
GitHub: cronvel

Re: How to use b3d in blender?

by cronvel » Post

So, I have a new question for the Blender Guru ^^
I'm currently working on a mod that manage player/entities 's skins/models/animations/gears. That mod include a brand new model, and I have some trouble with animation/armature.

If I'm not wrong, for exporting to b3d for Minetest, you first need to join all objects. During my tests, only the first object will appear in MT. But since it's very UNpractical (especially with the texture “overlay” of minecraft 1.8 skins), I prefer to work with multiple objects, and only join them just before exporting.

Each object (e.g. head, arm, body) are assigned to a bone, but when I join them all, all bone assignments are lost, so the workaround for me was to assign that big object to the armature using right-click > “Parent” > “with automatic weight”.

Automatic weight was doing well at the beginning, but now that my model is more and more complicated, with more bones dedicated for gear's attachments (e.g. wielded item, hat, ...), it is not working anymore, vertices get assigned to the wrong bone and everything is messy.

So my question is: how to preserve bone assignments in the join process?

User avatar
Tcll
Member
Posts: 65
Joined: Thu Jul 25, 2019 21:43
GitHub: Tcll
IRC: Tcll Tcll5850 DarkPikachu
In-game: Tcll
Location: The Gates of Darkness.

Re: How to use b3d in blender?

by Tcll » Post

cronvel wrote:
Wed Sep 16, 2020 07:41
So, I have a new question for the Blender Guru ^^
I'm currently working on a mod that manage player/entities 's skins/models/animations/gears. That mod include a brand new model, and I have some trouble with animation/armature.

If I'm not wrong, for exporting to b3d for Minetest, you first need to join all objects. During my tests, only the first object will appear in MT. But since it's very UNpractical (especially with the texture “overlay” of minecraft 1.8 skins), I prefer to work with multiple objects, and only join them just before exporting.

Each object (e.g. head, arm, body) are assigned to a bone, but when I join them all, all bone assignments are lost, so the workaround for me was to assign that big object to the armature using right-click > “Parent” > “with automatic weight”.

Automatic weight was doing well at the beginning, but now that my model is more and more complicated, with more bones dedicated for gear's attachments (e.g. wielded item, hat, ...), it is not working anymore, vertices get assigned to the wrong bone and everything is messy.

So my question is: how to preserve bone assignments in the join process?
just to note, I'm not a guru, I just know a somewhat decent amount of stuff. ;)

first off, a minor comment on the multiple objects bit
my test export of Brawl Pikachu was actually done with multiple objects linked to 1 armature in 2.79b, which created a NODE ROOT in the B3D data that those objects were assigned to...
so this may likely be an issue with the 2.8 script as, with a quick glance, it does appear to do things differently (the problem with code ports) >_>
but yes, the 2.79b script works appropriately here.

as for the weight issue, I haven't looked to see if that's just related to the 2.8 script...
try a 2.79b export and see if that fixes your issue, I might be able to get a better understanding if not.


btw, I haven't stopped working on my exporter, I'm just waiting on a response on another forum...
currently this is what I have, but I still need to replace atan2() to get it to work for HexEdit:

Code: Select all

from math import atan2, degrees
def quaternion_to_euler(x, y, z, w):
    return degrees(atan2(
        2.*(w*x+y*z),
        1-2.*(x*x+y*y)
    )), degrees(atan2(
        2.*(w*y-z*x),
        1-2.*(x*x+z*z)
    )), degrees(atan2(
        2.*(w*z+x*y),
        1-2.*(y*y+z*z)
    ))
^ I expect the Y axis to break as I'm no mathematician, this is just some scotch-tape work
(I need this for export verification on my exporter (comparison with Blender))

User avatar
Nathan.S
Member
Posts: 1023
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: How to use b3d in blender?

by Nathan.S » Post

Last I exported B3d files I used this exporter, https://github.com/GreenXenith/io_scene_b3d
From what I remember it exported every object in the scene, so objects I didn't want I just moved to another layer thing.(I forget what the layers are called in 2.8.2, collections maybe)

Using automatic weights for lowpoly models is probably a bad idea. I don't know what your model looks like, but if the limbs are all their own boxes, you should just do vertex groups for the bones, those will be preserved when joining meshes together. (I'm a little surprised that automatic weights aren't, as they are also vertex groups, but I don't use those so I'm not too familiar with the inner workings of them.)

Always make sure you have a sane naming convention for your bones and then when you parent the mesh to the armature select 'Armature Deform - With Empty Groups' This will add a empty vertex group to your mesh for every bone, named the same as the bone. You can then go through the mesh in edit mode and assign the vertices to the groups as needed. If you ever decide to add more bones to the armature you can manually add a new vertex group to the mesh and it will follow the newly added bone. Assuming of course you give them both the same name.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
GreenXenith
Member
Posts: 1326
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenXenith
In-game: GreenXenith
Location: The singularity
Contact:

Re: How to use b3d in blender?

by GreenXenith » Post

Nathan.S wrote:
Fri Sep 18, 2020 13:44
Last I exported B3d files I used this exporter, https://github.com/GreenXenith/io_scene_b3d
From what I remember it exported every object in the scene, so objects I didn't want I just moved to another layer thing.(I forget what the layers are called in 2.8.2, collections maybe)
There should be a checkbox in the export options to export all or just selected, and it works fine for me. The exporter itself is a mess as the original port was not great. The only thing I did was fix some export errors. I may rewrite it myself sometime.
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenXenith#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.

cronvel
Member
Posts: 40
Joined: Fri Jan 11, 2019 16:50
GitHub: cronvel

Re: How to use b3d in blender?

by cronvel » Post

Yes I'm already using GreenXenith's fork for exporting.
I usually unselect everything before saving, I had trouble multiple times when something was selected (the Python script have tendencies to throw an exception in that case).
I will give a try to Nathan solution, but for instance I don't know how to assign vertices to vertex group.

User avatar
Nathan.S
Member
Posts: 1023
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: How to use b3d in blender?

by Nathan.S » Post

You should find exactly what you need here, https://youtu.be/YmZpGt2Jg90?t=661 :)
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

cronvel
Member
Posts: 40
Joined: Fri Jan 11, 2019 16:50
GitHub: cronvel

Re: How to use b3d in blender?

by cronvel » Post

@Nathan.S Oh yes it works! Thanks a lot!

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests