------------------------------------------------------------------------------------------------ Extract bind pose matrix
| 256 | // ------------------------------------------------------------------------------------------------ |
| 257 | // Extract bind pose matrix |
| 258 | void AnimResolver::ExtractBindPose(aiMatrix4x4 &out) { |
| 259 | // If we have no envelopes, return identity |
| 260 | if (envelopes.empty()) { |
| 261 | out = aiMatrix4x4(); |
| 262 | return; |
| 263 | } |
| 264 | aiVector3D angles, scaling(1.f, 1.f, 1.f), translation; |
| 265 | |
| 266 | if (trans_x) translation.x = trans_x->keys[0].value; |
| 267 | if (trans_y) translation.y = trans_y->keys[0].value; |
| 268 | if (trans_z) translation.z = trans_z->keys[0].value; |
| 269 | |
| 270 | if (rotat_x) angles.x = rotat_x->keys[0].value; |
| 271 | if (rotat_y) angles.y = rotat_y->keys[0].value; |
| 272 | if (rotat_z) angles.z = rotat_z->keys[0].value; |
| 273 | |
| 274 | if (scale_x) scaling.x = scale_x->keys[0].value; |
| 275 | if (scale_y) scaling.y = scale_y->keys[0].value; |
| 276 | if (scale_z) scaling.z = scale_z->keys[0].value; |
| 277 | |
| 278 | // build the final matrix |
| 279 | aiMatrix4x4 s, rx, ry, rz, t; |
| 280 | aiMatrix4x4::RotationZ(angles.z, rz); |
| 281 | aiMatrix4x4::RotationX(angles.y, rx); |
| 282 | aiMatrix4x4::RotationY(angles.x, ry); |
| 283 | aiMatrix4x4::Translation(translation, t); |
| 284 | aiMatrix4x4::Scaling(scaling, s); |
| 285 | out = t * ry * rx * rz * s; |
| 286 | } |
| 287 | |
| 288 | // ------------------------------------------------------------------------------------------------ |
| 289 | // Do a single interpolation on a channel |
no test coverage detected