So I ended up with a situation where I needed to add a few more bones to my rig in blender.
I subdivided the armatures that were needed deleted the old modifiers and vertex groups then re-skinned the mesh weights.
I have done this in the past no problem, but now its acting up on export. I have verified that the bone exists…
========= An error was encountered =========
File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\json_exporter.py", line 94, in execute
self.skeletons.append(Skeleton(object, context, skeletonId, self.settings.ignoreIKBones))
File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\armature.py", line 84, in __init__
self.bones.append(Bone(bone, bpySkeleton, self.bones))
File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\armature.py", line 23, in __init__
self.parentBoneIndex = Skeleton.get_bone(bpyBone.parent.name, bonesSoFar).index if bpyBone.parent else -1
File "C:\Users\pryme\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\babylon_js\armature.py", line 162, in get_bone
raise Exception('bone name "' + boneName + '" not found in skeleton')
ERROR: bone name "Lower.Thigh.L" not found in skeleton
========= end of processing =========
UPDATE
so I have narrowed it down to the fact that I subdivided the bone… let me see if I can recreate!
UPDATE2
maybe I spoke too soon… hmmm… I was not able to recreate in a simple setup.
In the exporter I see
# should not happen, but if it does clearly a bug, so terminate
o_O…
UPDATE3
So I added to the line right before the Error Drop:
for bone in bones:
Logger.log("Bone:"+bone.name)
Which made the log output be:
Python World class constructor completed
processing begun of skeleton: Root, id: 0
processing begun of bone: Crotch, index: 0
processing begun of bone: Upper.Thigh.L, index: 1
processing begun of bone: Upper.Calf.L, index: 2
Bone:Crotch
Bone:Upper.Thigh.L
========= An error was encountered =========
...
I think its interesting that it says its trying to process the calf at index 2. Is there a way to verify the index of the each of the bones? I would imagine that is just done through hierarchy.
For something like this, a Blend file is definitely going to be required. It could be an un-forseen bug, but if I put a comment that says this should not happen, probably better to address the skeleton than screw with the program. There could then be other assumptions you run a foul of. I would not be able to look at it for maybe a week. Do not know if @gryff is interested, or could look at it earlier than that.
FYI, the index thing has nothing to do with Blender. It is for the export. This is the values which get placed in the matrix indices for each vertex of each mesh. means nothing to Blender. Bones are processed however Blender gives them to me. Program does not care.
@JCPalmer : if @Pryme8 wants to post the .blend file, I will take a look at it Jeff. But if it is a code issue, then I might not find anything as I can’t compete with you guys in that area
Thanks, but maybe his surgery resulted in some odd thing like multiple root bones. Though that should still work, any triage you can do would be helpful.
@Pryme8 and @JCPalmer : So has the issue been fixed, as I see no link to a file? You can always PM me the link, if you are worried about ppl stealing your character.
I was really disappointed with what github did. It deleted every line and then added them all back. Here are the changes to Bone & Skeleton from Netbeans (old on left). Basically, I pulled finding the index of the parent out of the Bone constructor. This relied on Blender ordering the bones of a parent before children.
Also I have noticed git does that a lot, I wish I knew how to not make it do that as well sometimes. About to test it now, but from just reading it seems on point. @JCPalmer Thank you a lot for your help my friend.
UPDATE
Looks like it worked!
dope, I should push my vertex group changes here at some point too to the exporters. As it is it does not add anything to the file (for file size reason), but if you told told the exporter in a menu item to export specific groups on the mesh it will have them listed in json format in the log, which are useful for lots of reason.
Figured there would be others that might need this.
Everything seems to work, except now if I scale a skeleton from the root bone and let all the “children” be scaled
bone = scene.getBoneByName('Crotch')
bone.scale(d,d,d,true)
Basically what happens now is all the bones but the ones that were added through subdivision do not get scaled now, I don’t even know where to start debugging this. @JCPalmer I know you are a busy man but any ideas where I can look?
They are coming back with parent as null and _parent as the correct value, once in the scene.
In the .babylon file all the parent indexes are correct.
I really don’t want to have to do a re-rig but at this point it sounds like I need to, if we cant figure out this hierarchy problem. (at some point it should be figured out though cause Im pretty sure its a bug)
I just got what you were saying, so maybe I need to reorder the skeleton list in the .babylon file?
And now looking at the files I think you are 100% right… in a working one the bones are parents are listed before the children on the bones list and in the unworking one I have like bone ID 3 referencing bone ID 43 are its parent.
So I am guessing what I would need to do is a pass where I increment through the bones and order them correctly by referencing their parent?
Actually as I am doing more testing its looking like these last changes broke the skeleton stuff… I mean it works but it does not now when you start working with them.
I did a whole rerig, and am having troubles with some of the same issues but in a different way now.
Ill do one more re-rig, but I’m pretty sure anytime you get into an complex parenting things go haywire.