More Awesome Than You!
Welcome, Guest. Please login or register.
2024 April 28, 19:32:11

Login with username, password and session length
Search:     Advanced search
540270 Posts in 18066 Topics by 6513 Members
Latest Member: Linnie
* Home Help Search Login Register
+  More Awesome Than You!
|-+  TS2: Burnination
| |-+  The Podium
| | |-+  Combining Joint rotations
0 Members and 1 Chinese Bot are viewing this topic. « previous next »
Pages: [1] THANKS THIS IS GREAT Print
Author Topic: Combining Joint rotations  (Read 2232 times)
wes_h
Knuckleheaded Knob
**
Posts: 530


Lady on Rancho Como


View Profile
Combining Joint rotations
« on: 2007 May 22, 04:37:28 »
THANKS THIS IS GREAT

Not being the math major sort of guy, I sometimes take a while to puzzle some of the problems involved in writing programs out.
My latest problem involves joint rotation values. That is, when you look in the CRES, some of the body (at least) joints come with a non-zero rotation value. Since the joints are linked in a heirarchy, the rotation value from one joint affects the ultimate rotation value of all joints lower down the chain.

These rotations are apllied to the joints by the game prior to any rotation values contained in an animation. Exporting an animation into the game without having the joint movements modified by these values results in things moving, but in the wrong places (the legs go up in the air and the arms come out the front and back).

My latest challenge is how to combine two (or more) Euler rotation values (Roll, Pitch, Yaw) into one. At a minimum I need to combine the joint static rotation with the animation timecode rotation. I am having some problem at the conceptual level on how to approach doing this. Even a pseudocode example may be enough to jumpstart my progress.

Oh, yes, the project I am trying to finish is an animation exporter plugin for MilkShape. Essentially, it is an attempt to allow you to take a mesh and make an animation or export an animation from SimPE (this works in MilkShape ASCII format, but IK animations aren't supported), modify it in MilkShape, and then have the appropriate ANIM file written to disk. I have this completed as far as handling the translations correctly, but the joint rotations are twisted, as described above.

While I will make the source available eventually, I don't hold out much hope that anyone else will actually do anything with it. I have learned enough in this process to do other things, but I am basically lazy, and if I can go from inside MilkShape to ANIM, for body or object meshes, then that is all I intend to produce. People that want support for other programs can learn to program the plugins themselves, I will be happy to show how.

<* Wes *>
Logged
Marchioness
eevilcat
Retarded Reprobate
****
Posts: 1389


Poke, point, laugh...


View Profile
Re: Combining Joint rotations
« Reply #1 on: 2007 May 22, 16:56:08 »
THANKS THIS IS GREAT

assuming you want to multiply 2 euler rotation values a, b and return a new value c
assume typedef euler (float x; float y; float z; float w)

float t0 = (a->z - a->y) * (b->y - b->z)
float t1 = (a->w + a->x) * (b->w + b->x)
float t2 = (a->w - a->x) * (b->y + b->z)
float t3 = (a->z + a->y) * (b->w - b->x)
float t4 = (a->z - a->x) * (b->x - b->y)
float t5 = (a->z + a->x) * (b->x + b->y)
float t6 = (a->w + a->y) * (b->w - b->z)
float t7 = (a->w - a->y) * (b->w + b->z)
float t8 = t5 + t6 + t7
float t9 = (t4 + t8) * 0.5

c->w = t0 + t9 - t5
c->x = t1 + t9 - t8
c->y = t2 + t9 - t7
c->z = t3 + t9 - t6

My guess is that you have to know the parent joint hierarchy and apply the default position parent joint(s) rotation(s) in order for every child joint. I don't know the exact joint naming conventions for sims2 but for example to set an ankle rotation you would have to first apply a waist->hip->knee resting rotation first and in that order.
Logged

wes_h
Knuckleheaded Knob
**
Posts: 530


Lady on Rancho Como


View Profile
Re: Combining Joint rotations
« Reply #2 on: 2007 May 23, 03:12:04 »
THANKS THIS IS GREAT

Than you for the reply. I will try your code.
That looks like multiplying two quaternions or axis/angle definitions because of the XYZW data.
I shall try a euler (XYZ) to quaternion and axis angle conversion first.
It appears I was wrong on the heirarchy, I need only reverse the immediate joint rotation. The heirarchy is in the CRES, and gets exported into MilkShape from SimPE. In MilkShape, each joint refers to it's parent by name, so walking from a joint back to the root is pretty straightforward.
In spite of my butchered attempts, as long as I have the data formatted correctly, it appears that impossible looking joint rotations are not a source of problems for the game. It merely presents strange looking animations, no crashes or odd artifacts.
On the other hand, leave one bit out of the header, and the whole game crashes.
I am persevering.
<* Wes *>
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.062 seconds with 19 queries.