Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Bones in OBJ file

Credits go to Dennis for helping out!
This thread is locked; no one can reply to it. rss feed Print
Bones in OBJ file
Arthur Kalliokoski
Second in Command
February 2005
avatar

The Wavefront OBJ 3D file format is remarkably easy to parse, but doesn't have "bones" (animation matrices). If I wanted character poses, I'd just have a multitude of meshes from the keyframes (hey, memory is cheap now), but for mechanical movement I'd like something a little smoother.

The best hack I've come up with so far is to create a plane mesh, give it a name with a specific substring such as xxxAXISnn, and the loader would recognize by the name that this isn't something to render, but specifies a rotation vector.

The simplest way I can think of is to add a plane, move one vertex to where the rotation takes place, the opposing vertex to where the rotation vector lies, and move the other two vertices to be very near the first vertex is. The loader would get the distances between the four vertices, and the most distant pair are the axis, with the one having the closest neighbors as the origin, so to speak.

Maybe this makes it clearer.

{"name":"608956","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/6\/c6f9c1e83c8392876c43410c3fe0a033.png","w":1166,"h":509,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/6\/c6f9c1e83c8392876c43410c3fe0a033"}608956

Anyone have better ideas? Cookies await.

They all watch too much MSNBC... they get ideas.

Dennis
Member #1,090
July 2003
avatar

I think I would leave the plane undistorted and would use its' center position and unified surface normal as the rotation axis.

{"name":"608957","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/5\/6556af8a218e2eff70b826f7cbd8f9b3.png","w":800,"h":500,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/5\/6556af8a218e2eff70b826f7cbd8f9b3"}608957

Arthur Kalliokoski
Second in Command
February 2005
avatar

I'd have a harder time adjusting it to exactly where I want.

I was hoping that someone would know, for example, how to get Blender to output a line segment, which OBJ does understand, although I don't know if Blender would support that, either.

They all watch too much MSNBC... they get ideas.

Dennis
Member #1,090
July 2003
avatar

I'd have a harder time adjusting it to exactly where I want.

Maybe I do not fully understand what you are trying to do but how is it harder to define just one position and a plane orientation than to define four different positions individually.

In your example, you already know the position of the center of the wheel, so you could just align the plane position to that.

But again, maybe I do not fully understand what you want to do.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Dennis said:

define four different positions individually.

I can grab the "home" vertex in Blender and set the position with the transform input widget, and do the same for the vector vertex. The other two vertices need only be obviously closer to the home vertex.

{"name":"608960","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/8\/5883ef1d39db6259e4511dac9a116bb0.png","w":635,"h":338,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/8\/5883ef1d39db6259e4511dac9a116bb0"}608960

[EDIT]

In other words, the two extra vertices are used to place the "home" (what else would I call it?) vertex. The loader simply finds which vertex is farthest from the other three, and sets that to the end of the rotation vector, and the vertex that's farthest from the vector vertex is the home vertex.

They all watch too much MSNBC... they get ideas.

Dennis
Member #1,090
July 2003
avatar

Yes, but... you could set the position and rotation of the plane just as easily in object mode. The position is your "home" and the surface normal of the plane standing on that "home" is the rotation axis.

If the OBJ format does not contain the plane position and only contains its vertices, you can calculate the plane position by going halfway across the diagonal between the first and the third vertex or second and fourth.
{"name":"608961","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/f\/0f0323ff27b240c20581f93fcf211223.png","w":824,"h":733,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/f\/0f0323ff27b240c20581f93fcf211223"}608961

edit:
Another word for "home" for the purpose here might be "pivot point" or just "pivot".

Arthur Kalliokoski
Second in Command
February 2005
avatar

I suppose it looks neater. Thanks!

They all watch too much MSNBC... they get ideas.

Go to: