I'm still trying to get skeleton animation working, but first I need to be able to load a model.

At first I was like "WHAT THE HELL IS THIS?!". Then I was like "Oh, this actually kind of makes sense!". Then I was like "WHAT THE HECK IS A QUATERNION?!". Then I was like "Haha! There's a Quaternion class in LWJGL!". Then my example code was like

and I was like "NO WAI YOU DID NOT JUST DO THAT" and it was like "Oh, yes, I did." and I was like "But there is no quaternion-vector multiplication function in the LWJGL classes!" and it was like "Well, screw you." Then Google was like "Did ya mean quaternion-quaternion multiplication X 1 000 000?" and I was like "NO." and then, well, here I am.

So, how do I multiply a quaternion and a vector to get a new magical vector?

I assume that your question is "how do I rotate a vector by a quaternion that represents a rotation?" Because there's more that one meaning of multiple a vector by a quaternion. If so, the the answer depends on how many vectors you want to rotate since there are multiple formulations.

LWJGL's Quaternion class is ... well it just isn't very good. I'm not sure it even has a method to transform a Vector.

Java3D has a much more fully-featured quaternion class. You can find it here though you might want to find an alternative implementation with source both for licensing and documentation reasons (that one doesn't even have a javadoc artifact)

I assume that your question is "how do I rotate a vector by a quaternion that represents a rotation?" Because there's more that one meaning of multiple a vector by a quaternion. If so, the the answer depends on how many vectors you want to rotate since there are multiple formulations.

You're exactly right. I want to rotate my position vector by the orientation quaternion. What do you mean by multiple formulations?

LWJGL's Quaternion class is ... well it just isn't very good. I'm not sure it even has a method to transform a Vector.

Java3D has a much more fully-featured quaternion class. You can find it here though you might want to find an alternative implementation with source both for licensing and documentation reasons (that one doesn't even have a javadoc artifact)

I looked at the javadoc for that library, but I couldn't find a function for that either...

I want to rotate my position vector by the orientation quaternion. What do you mean by multiple formulations?

There are three main ways to have a quaternion represent a rotation. Each of these can be "reversed" yielding six formulations with different properties (they are all related). Given a specific mathematical formulation, each of may be used directly as if one was performing the operation in quaternions or it can be converted to some other mathematical type (almost always a matrix). The above (assuming I didn't screw up) is a direct formulation where the quaternion is assume to be of unit length (otherwise it will yield a scaled rotation, where the scaling factor is the magnitude of the quaternion squared). This question and your previous are really the same "in wolves clothing". If you were to pug the vectors (1,0,0), (0,1,0), & (0,0,1) into the above it will yield three vectors (really every where we're saying vectors should be bivectors, but that's a different story). Shove these three vectors into either a row or column of a matrix and you have the (misnamed) quaternion to matrix conversion. Make it a 4x4 matrix and you can shove the translation vector in the appropriate spot and bingo...you're done.

Quote

LWJGL's Quaternion class is ... well it just isn't very good.

It doesn't really do anything and was obviously thrown together by someone with no understanding of quaternions (no offense intended if said person is reading this...you're far from alone.)

The sweet point between direct computation and conversion to a matrix is hard to qualify. For scalar computation converting to matrices generally be a win past some very small number of conversions. For SIMD it really depends on the low level ops exposed.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org