123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|399|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Local bone origin?

Fri, 03 Feb 2012, 15:19
Afr0
So, with the risk of being labeled a psychopath, since I'm worried about this on my birthday, I'm going to post this here because I'm afraid I need some help.
How do I find or calculate the local origin of a bone?
According to the developer who's been guiding me on how to render a bodymesh, I need to (referring to the vertices) "rotate them around the local bone origin first, then translate the result to the global bone origin coordinate."
Translating to the global origin is easy, cos each bone has a global origin. To get the local one, do I have to calculate it manually?

Here's my code so far:






-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 03 Feb 2012, 17:27
CodersRule
Afr0, it's okay. That's not why we think you're a psychopath.
Sat, 04 Feb 2012, 06:21
Afr0
I could say the same thing to you.
Sun, 05 Feb 2012, 07:26
CodersRule
I'm sure that anyone who knows me well could.
Sun, 05 Feb 2012, 08:31
steve_ancell
An answer to this topic still hasn't been found, somebody throw Afr0 a frickin' bone here!. Pun intended LMAO!.

*Ducks once again, in fear of flying rotten vegetables.*
Sun, 05 Feb 2012, 12:54
HoboBen
If I'm understanding you right, you have

* global position of any bone
* the local positions (relative to a given bone) of vertices

Assuming bones can't scale (if they do, this adds an extra step) what you do is

* first conceptually consider the bone as being at 0,0,0 with a rotation of 0,0,0

* conceptually the vertices local offsets are now global offsets.

* conceptually rotate the bone to it's original orientation

* to match, the vertices must be rotated relative to 0,0,0 using trigonometry:

For the original point:


For a translated point:


Rearrange to solve x:


* Then, conceptually translate the bone from 0,0,0 to it's original position

* Do the same for vertices (i.e. just add the bone's global position).

Note: you can probably do this more efficiently with matrices (especially in 3D), but I haven't covered that yet!

-=-=-
blog | work | code | more code
Mon, 06 Feb 2012, 05:16
Afr0
o_O

Any way you could translate that from math to pseudocode?

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!