| 407 | } |
| 408 | |
| 409 | AffineSpace3ff XMLLoader::loadQuaternion(const Ref<XML>& xml) |
| 410 | { |
| 411 | Vec3f scale(1.f, 1.f, 1.f); |
| 412 | Vec3f shift(0.f, 0.f, 0.f); |
| 413 | Vec3f skew(0.f, 0.f, 0.f); |
| 414 | Vec3f translate(0.f, 0.f, 0.f); |
| 415 | Vec4f q(0.f, 0.f, 0.f, 1.f); |
| 416 | |
| 417 | if (xml->parm("translate") != "") |
| 418 | translate = string_to_Vec3f(xml->parm("translate")); |
| 419 | if (xml->parm("scale") != "") |
| 420 | scale = string_to_Vec3f(xml->parm("scale")); |
| 421 | if (xml->parm("skew") != "") |
| 422 | skew = string_to_Vec3f(xml->parm("skew")); |
| 423 | if (xml->parm("shift") != "") |
| 424 | shift = string_to_Vec3f(xml->parm("shift")); |
| 425 | if (xml->parm("rotate") != "") { |
| 426 | q = string_to_Vec4f(xml->parm("rotate")); |
| 427 | // convert from degree to radians |
| 428 | q.w = 2.f*M_PI/360.f*q.w; |
| 429 | Quaternion3f Q = Quaternion3f::rotate(Vec3fa(q.x, q.y, q.z), q.w); |
| 430 | q = Vec4f(Q.i, Q.j, Q.k, Q.r); |
| 431 | } |
| 432 | if (xml->parm("quaternion") != "") { |
| 433 | q = string_to_Vec4f(xml->parm("quaternion")); |
| 434 | } |
| 435 | |
| 436 | AffineSpace3ff res(LinearSpace3fa( |
| 437 | Vec3ff(scale.x, shift.x, shift.y, q.x), |
| 438 | Vec3ff(skew.x, scale.y, shift.z, q.y), |
| 439 | Vec3ff(skew.y, skew.z, scale.z, q.z)), |
| 440 | Vec3ff(translate.x, translate.y, translate.z, q.w)); |
| 441 | |
| 442 | if (xml->body.size() == 16) { |
| 443 | res = AffineSpace3ff(LinearSpace3fa(Vec3ff(xml->body[ 0].Float(),xml->body[ 4].Float(),xml->body[ 8].Float(),xml->body[12].Float()), |
| 444 | Vec3ff(xml->body[ 1].Float(),xml->body[ 5].Float(),xml->body[ 9].Float(),xml->body[13].Float()), |
| 445 | Vec3ff(xml->body[ 2].Float(),xml->body[ 6].Float(),xml->body[10].Float(),xml->body[14].Float())), |
| 446 | Vec3ff(xml->body[ 3].Float(),xml->body[ 7].Float(),xml->body[11].Float(),xml->body[15].Float())); |
| 447 | } |
| 448 | return res; |
| 449 | } |
| 450 | |
| 451 | template<typename Vector> |
| 452 | Vector XMLLoader::loadBinary(const Ref<XML>& xml) |
nothing calls this directly
no test coverage detected