Zaela / ZEQClient

ZEQClient for EQEmu
5 stars 4 forks source link

Question about animation rotation #3

Open danwilkins opened 9 years ago

danwilkins commented 9 years ago

Hi. I am writing my own client as well. Do you have some time to help with finishing animations? They are in but the rotations for things like arms are a little weird. I notice that in the bone rotations, you negate the x and z AND you rotate by pi * 0.5. Why do you do this? Do you render with degrees or radians? Thanks for your time.

Zaela commented 9 years ago

Hi there Bootman Dan,

I saw your private messages on the EQEmu forums. I believe I did figure out how to unpack the rotations at some point a few months ago, though not against the same code (I found myself interested in learning to use OpenGL calls directly rather than using Irrlicht), and I never found the time/motivation to flesh it out into complete animations. The individual frames do look correct, though. Needed some corrections in the Frag12 unpacking as well as some very specific Matrix operations. I feel like this may not have been my exact final code for this, but it's all I could find.

The relevant Skeleton code looks like the following. The Frag12 unpacking is in there (note the weird order for rotations), as well as which Matrix operations to use when and in which order, though nothing for animating/blending between frames. The base position for each bone is translated, but not rotated; each animation frame has its translation is "transformed" in a particular way by its parent frame before being applied after the rotation. http://pastebin.com/kUmKyYbm

Had to use a custom Matrix implementation to get stuff to work correctly, it might be backwards relative to glm matrices, not sure. The relevant parts used in the Skeleton code above are here: http://pastebin.com/XenUuYTw

There are definitely some things I still hadn't figured out. Some models have Frag12s that aren't handled correctly by the above (I think they have 0 for the denom and either very high values or 0 for the coordinates) and end up being way in the wrong position / maybe unmoving (can't remember). Easy to see this on Innoruuk, his fingers are like this. Presumably should have its values inherited from its parents in some other manner, or something like that.

If you have any questions about the above stuff I'll try to answer!

My old codebase isn't too great, would probably be a good idea to start all the graphics parts from scratch if you were going to seriously work at it. I also have a newer, standalone client networking library ( https://github.com/Zaela/EQNet) which improves on the netcode in the old codebase; I think ideally there would be a separate library for networking and another one for graphics/collision, then some fairly thin code to glue them together and manage things like inventory and mobs and other game-state things. Keep things nice and clean, unlike the old codebase which has graphics loading triggered directly from packet reads and such.

Like I said, I had been looking at using raw OpenGL calls instead of using a 3D graphics engine like Irrlicht. EQ uses some super basic/cheap methods for transparency and the like -- so basic that I think some of it isn't supported by Irrlicht out of the box. I've been using SFML just as a cross-platform windowing and input system for my experiments with that. Might be worth doing something like that instead if you already have good experience with OpenGL and know its pitfalls.

On Wed, Nov 4, 2015 at 1:02 AM, danwilkins notifications@github.com wrote:

Hi. I am writing my own client as well. Do you have some time to help with finishing animations? They are in but the rotations for things like arms are a little weird. I notice that in the bone rotations, you negate the x and z AND you rotate by pi * 0.5. Why do you do this? Do you render with degrees or radians? Thanks for your time.

— Reply to this email directly or view it on GitHub https://github.com/Zaela/ZEQClient/issues/3.