This topic contains 9 replies, has 3 voices, and was last updated by wtherapy 4 years, 11 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)

- AuthorPosts
- November 16, 2012 at 5:17 pm #31019
Hello,

I am exporting an animation from 3dmax, first by matrices and then by quaternions, rotations and scaling.Using matrices the animation works fine, but using quats, rotations and scaling the model deforms horribly. The first frame looks good, but the following frames start to get deformed.However, there are some models that work well using quaternions, rotations and scaling.I can only presume there is bug in my code when converting from translation/rotation/scale to matrices ( although there are models that work with the entire animation ), so I would like to ask:– why is the pfAnimScale written at 7-floats boundary? Are there other relevant information beside pfAnimScale[0], pfAnimScale[1], pfAnimScale [2] that are supposed to be the scaling on x, y, z?– can a pfAnimRotation be treated like a normal quaternion, with the w ( cos(alfa) ) being the last element in the 4 floats read?– have other people encountered this kind of problems?November 19, 2012 at 3:06 pm #36285Nobody knows? Are the pfAnimMatrix coming from Translation*Rotation*Scaling ( OpenGL model, vectors are columns, multiplication at right side )?

November 20, 2012 at 9:31 am #36286Hi,

Sometimes the position, quaternion and scale isn’t sufficient to represent the required transformations needed so in some cases only exporting the transformations as matrices will work. From your description, it sounds like you may have hit one of these cases.If you want to rule out whether the problem is with your code or not, try viewing the scene in our PVRShaman utility.pfAnimMatrix contains the matrices provided by 3dsmax before they’re decomposed into position, quaternion and scale. So they aren’t actually constructed from the position, quaternion and scale that get exported.The last 4 values of each scale contains information on the axis system the scaling is performed in. The POD file format specification has details on them but in our code we tend to only use the first three values.Thanks,ScottNovember 20, 2012 at 2:19 pm #36287Hello Scott,

just thanks for the answer. So, my basic question now is – how can I export an animated model so that I can interpolate between animation frames ( typically to create animation blending )? Is there anything more I can expect from POD or I need to use some special settings from 3dsmax? Or should I move the question to a 3dmax forum 🙂 ?November 20, 2012 at 2:26 pm #36288Also, Shaman is viewing correctly the animated scene, when exported via Rotations, Translations and Scaling. Does Shaman use additional things, beside the T R S info, when computing the matrices?

November 20, 2012 at 2:55 pm #36289wtherapy wrote:Also, Shaman is viewing correctly the animated scene, when exported via Rotations, Translations and Scaling. Does Shaman use additional things, beside the T R S info, when computing the matrices?PVRShaman uses the PVRTModelPOD code that is included in the SDK’s tools, so nope, nothing additional.November 20, 2012 at 4:01 pm #36290For animation blending you don’t really need anything else but transformations ( Vec3,Vec3,Quat) and frame timing which is what you get from POD files.

Beyond that you will need to write some custom code for blending.In general , a typical flow for blending would be.1. Interpolate transforms for the first animation.2. Interpolate transforms for the second animation3. Blend 1 and 2 based on some factor.You will need to make sure that both animations are designed in such way that interpolation actually makes sense (visually) – for instance if you want to blend between walking and running you will have to make sure that both animations have their equivalent poses ( left foot down etc) at the same position in the normalized time scale.In other words, you can’t blend random animations and expect good results – you need to create animations with blending in mind.November 20, 2012 at 4:18 pm #36291hello,

I have already created the code for blending and worked well until I’ve encountered some ‘strange’ POD files. Those first animations was converting just fine from matrix to TRS ( I wasn’t aware, at that time, that powervr can export TRS, the importer was written by other developers ).In the current case, we encounter matrices that cannot be converted to TRS ( when the model is exported with matrices ) or the TRS exported ( when the model is exported with TRS ) does not expand to the matrices found when exported with matrices.Just one last question: are the matrices read from file always Line-ordered?November 20, 2012 at 5:08 pm #36292Using this code:

*PVRTMATRIX m0;**PVRTMatrixTranslation( m0, node->pfAnimPosition[j * 3], node->pfAnimPosition[j * 3 + 1], node->pfAnimPosition[j * 3 + 2] );**PVRTMATRIX m1;**PVRTQUATERNIONf q1;**q1.x = node->pfAnimRotation[j * 4 + 0];**q1.y = node->pfAnimRotation[j * 4 + 1];**q1.z = node->pfAnimRotation[j * 4 + 2];**q1.w = node->pfAnimRotation[j * 4 + 3];**PVRTMatrixRotationQuaternion(m1, q1);**PVRTMATRIX m2;**PVRTMatrixScaling(m2, node->pfAnimScale[j * 7], node->pfAnimScale[j * 7 + 1], node->pfAnimScale[j * 7 + 2]);**PVRTMatrixMultiply(m2, m2, m1);**PVRTMatrixMultiply(m2, m2, m0);*yields, in m2 the same matrix computed by me.What I have noticed is that the first 3×3 components are the same with the original matrix ( as exported with matrices ), but multiplied by -1.November 21, 2012 at 10:04 am #36293Also, this code:PVRTMat4 m40 = ((CPVRTModelPOD*)sc)->GetTranslationMatrix(*node);PVRTMat4 m41 = ((CPVRTModelPOD*)sc)->GetRotationMatrix(*node);PVRTMat4 m42 = ((CPVRTModelPOD*)sc)->GetScalingMatrix(*node);m40 *= m41;m40 *= m42;yields the same matrix as computed by me; the original matrix ( as exported with matrices ) is the same matrix, but with scaling of (-1, -1, -1 ). If there is a mirror, can I get this info from somewhere? Any help appreciated

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.