Author Topic: Convert joints to bones(done)  (Read 7418 times)

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Convert joints to bones(done)
« on: July 19, 2016, 06:02:22 am »
Currently the models are posed using the hard way, that is calculating the new positions of all vertex using the joint and vertex group data.

I think the original armature code was done by Hypergeek? It did created normal looking bones, though the vertex groups are not connected to correct bones. That is because the last joint can't form a bone itself, so does the first joint of the model which is usually used to move the entire model.

CC joints


Bones



« Last Edit: July 27, 2016, 07:30:02 am by utunnels »

alfadorredux

  • Entity
  • Mystical Knight (+700)
  • *
  • Posts: 746
  • Just a purple cat
    • View Profile
Re: Convert joints to bones, possible?
« Reply #1 on: July 19, 2016, 08:15:06 am »
For that example to come out right in terms of which vertex groups are connected to what, it almost looks like you need to add an extra joint right at the wrist to solve the "last joint" problem--let's call it A. Then your bones become 13-A in the hand (blue), A-12 in the forearm (green), and 12-11 in the upper arm (red), and all the attachments make sense.

Aren't the same joints in fairly consistent positions inside the data for all the models? That should make it possible to interpolate extras in the same locations for everyone. (Worst case, it might be necessary to flag some joint locations somehow.)

Also, I wonder if the existence of the two shoulder joints isn't due to the original animation code's insistence on rotating each joint in only one direction at a time, as I seem to recall was the case? That would require one joint to rotate the arm around its long axis and another to move it up and down relative to the model, but I'm not sure if that makes sense from a rigging point of view. That would allow 11 and 10 to be consolidated to one joint.

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #2 on: July 19, 2016, 10:22:08 am »
Yes, it seems the double shoulder joint set up is for tranlation and rotation.
Usually joint 10 doesn't rotate, instead joint 11 does.
But the two joints at at exactly the same location.

To form a bone, there must be a head and a tail vector, and they can't be the same one. I was thinking about making small bones(for example, 0.1 in length) for this purpose, but it seems the positions of the tail and head affect the result of the transform, so it is a bit hard to determine.

An extreme approach is using all small bones, which simplifies the logic but I'm not sure if it is possible(and it is too alien for any modeler to use).
« Last Edit: July 19, 2016, 10:45:33 am by utunnels »

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #3 on: July 19, 2016, 12:48:20 pm »
For that example to come out right in terms of which vertex groups are connected to what, it almost looks like you need to add an extra joint right at the wrist to solve the "last joint" problem--let's call it A. Then your bones become 13-A in the hand (blue), A-12 in the forearm (green), and 12-11 in the upper arm (red), and all the attachments make sense.
This is how the default pose looks.

An extreme approach is using all small bones, which simplifies the logic but I'm not sure if it is possible(and it is too alien for any modeler to use).
Well I posed every "bone" manually. The result seemed promising...


But when applied the pose to the mesh, it looked like this.  :o
I think I need some sleep before starting to figure out what went wrong.


alfadorredux

  • Entity
  • Mystical Knight (+700)
  • *
  • Posts: 746
  • Just a purple cat
    • View Profile
Re: Convert joints to bones, possible?
« Reply #4 on: July 19, 2016, 08:16:04 pm »
Looks to me like the problem there is the shoulder joints 10/11 and 6/7 connecting down to the waist joint 2, rather than to something at shoulder level (maybe joint 3? Or is that too high up?) Alternatively, shift the second "double" joints in towards the center of the body, maybe?

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #5 on: July 19, 2016, 08:55:19 pm »
Yeah, sounds like that. Joint 3 is mainly for the head, and joint 2 is for the body.
Some vertices of the shoulders are also connect to joint 2 and they use weight values to adjust how much they are affected by the 2 joints.

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #6 on: July 21, 2016, 02:58:51 am »
Well it seems things are not that simple.

Cross models use 2 different sets of position if a vertex group is connected to 2 joints. When a transform is applied, the two vertices calculate individually then combine the final results using the weight values.

However, blender models use only 1 set of vertices.

Cross:
finalV = transformA(V1)*weightA + transformB(V2)*weightB

Blender:
finalV = transformA(V)*weightA + transformB(V)*weightB

I think that is why the shoulders are deformed beyond recognition.
« Last Edit: July 21, 2016, 03:45:07 am by utunnels »

alfadorredux

  • Entity
  • Mystical Knight (+700)
  • *
  • Posts: 746
  • Just a purple cat
    • View Profile
Re: Convert joints to bones, possible?
« Reply #7 on: July 21, 2016, 08:00:06 am »
Geh. That's a lot more complicated, then.

Shift the second shoulder joint to create a bone that goes all the way to the "spine", then reassign the shoulder vertices? (Assuming that "connected to both arm and waist joint" = "shoulder vertex".)

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #8 on: July 21, 2016, 09:14:44 am »
I don't think so. Those vertices do not just belong to one joints, actually, vertices on the elbows and wrists follows the same rules yet they seem OK. Maybe their initial position are along the same axis, while the shoulder and waist vertices are almost perpendicular to each other.

(I hate math)

alfadorredux

  • Entity
  • Mystical Knight (+700)
  • *
  • Posts: 746
  • Just a purple cat
    • View Profile
Re: Convert joints to bones, possible?
« Reply #9 on: July 21, 2016, 06:00:51 pm »
Blender can now attach the same vertices to more than one bone, according to what turned up when I applied some search-fu to the problem. It seems to depend on assigning the vertices to two or more vertex groups, then assigning each vertex group to a bone (that's from the very end of this section of the manual). No idea how you'd go about doing that from a loading/conversion script, but it must be possible. So in this case, you'd stick the shoulder vertices to the upper arm and the spine, I guess.

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #10 on: July 21, 2016, 07:46:15 pm »
I think you misunderstood me.
It is not about assigning a vertex to 2 bones, which is already done, but Cross actually uses 2 vertex positions before combining the results. Blender(and other 3d software) uses the same vertex.

When not using bones, I can use the final result to create the vertex in the mesh, but if bones are involved the transform should be done after the mesh is created....


Edited:

A possible solution:
1. Create the T-posed mesh using the old way.
2. Posed the bones, but do not link them to the mesh.
3. Created another set of bones using the positions of the posed ones.
4. Link the mesh to the 2nd set of bones and delete the old bones.
5. Find a way to animate the new skeleton.

The first 4 steps are easy. I am now thinking about how to do the 5th step.
« Last Edit: July 21, 2016, 08:08:48 pm by utunnels »

alfadorredux

  • Entity
  • Mystical Knight (+700)
  • *
  • Posts: 746
  • Just a purple cat
    • View Profile
Re: Convert joints to bones, possible?
« Reply #11 on: July 21, 2016, 08:04:49 pm »
Okay, yes, I did misunderstand. Sorry.

I wonder what they used to create this setup in the first place. Some kind of Squeenix studio homebrew?


utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #12 on: July 21, 2016, 08:17:46 pm »
Meow, reply edited, sorry.
Cross models are like marionette, a piles of limbs and parts scattered around the central point without the joints/strings.

alfadorredux

  • Entity
  • Mystical Knight (+700)
  • *
  • Posts: 746
  • Just a purple cat
    • View Profile
Re: Convert joints to bones, possible?
« Reply #13 on: July 21, 2016, 09:25:15 pm »
In a marionette, at least all the parts connect together in a way that kinda-sorta-maybe-almost makes sense. I'm not so sure about the Cross models.  :?

Yeah, I would think that doing up a new set of bones similar to the old ones and transferring the mesh onto them would produce something without these weird brokennesses. Recovering the old animations...well, an animation is just a succession of poses. Screencapping everything pose by pose (ideally from several angles) and then imitating the poses with the rigged model should be possible (but really tedious).

utunnels

  • Guru of Reason Emeritus
  • Zurvan Surfer (+2500)
  • *
  • Posts: 2797
    • View Profile
Re: Convert joints to bones, possible?
« Reply #14 on: July 21, 2016, 09:51:03 pm »
Well, think cross models like normal models in blender. Break down all the vertex groups into individual sub-models (for example, the head and the torso both have a portion of the neck) in the beginning then interpolate them together.

Edit*
Like this (almost).
« Last Edit: July 21, 2016, 10:17:23 pm by utunnels »