bool MD5AnimParser::ParseFrame() { std::size_t animatedComponentsCount = m_animatedComponents.size(); if (animatedComponentsCount == 0) { Error("Animated components count is missing or invalid"); return false; } std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); return false; } String line; std::size_t count = 0; do { if (!Advance()) return false; std::size_t index = 0; std::size_t size = m_currentLine.GetSize(); do { float f; int read; if (std::sscanf(&m_currentLine[index], "%f%n", &f, &read) != 1) { UnrecognizedLine(true); return false; } index += read; m_animatedComponents[count] = f; count++; } while (index < size); } while (count < animatedComponentsCount); m_frames[m_frameIndex].joints.resize(jointCount); for (std::size_t i = 0; i < jointCount; ++i) { Quaternionf jointOrient = m_joints[i].bindOrient; Vector3f jointPos = m_joints[i].bindPos; UInt32 j = 0; if (m_joints[i].flags & 1) // Px jointPos.x = m_animatedComponents[m_joints[i].index + j++]; if (m_joints[i].flags & 2) // Py jointPos.y = m_animatedComponents[m_joints[i].index + j++]; if (m_joints[i].flags & 4) // Pz jointPos.z = m_animatedComponents[m_joints[i].index + j++]; if (m_joints[i].flags & 8) // Qx jointOrient.x = m_animatedComponents[m_joints[i].index + j++]; if (m_joints[i].flags & 16) // Qy jointOrient.y = m_animatedComponents[m_joints[i].index + j++]; if (m_joints[i].flags & 32) // Qz jointOrient.z = m_animatedComponents[m_joints[i].index + j++]; jointOrient.ComputeW(); m_frames[m_frameIndex].joints[i].orient = jointOrient; m_frames[m_frameIndex].joints[i].pos = jointPos; } if (!Advance(false)) return true; if (m_currentLine != '}') { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING Warning("Hierarchy braces closing not found"); #endif // On tente de survivre à l'erreur m_keepLastLine = true; } return true; }
Matrix4f computeModelViewMatrix( const Quaternionf& quat, const Vector3f& eye ) { Matrix3f rotationMatrix; quat.get_rotation_matrix( rotationMatrix ); return computeModelViewMatrix( rotationMatrix, eye ); }
// quaternion slerp template<> Quaternionf lerp(float t, const Quaternionf& a, const Quaternionf& b) { return a.slerp(t,b); }