void MeshLoaderSPM::readChunkAnimationSkeletal() { /* Read skeletal animation basics */ const io::stringc AnimName(File_->readStringData()); /* Add new skeletal animation */ SkeletalAnimation* Anim = gSharedObjects.SceneMngr->createAnimation<SkeletalAnimation>("SPM Animation"); AnimationSkeleton* Skeleton = Anim->createSkeleton(); /* Read animation joints */ const u32 JointCount = File_->readValue<u32>(); Joints_.resize(JointCount); for (u32 i = 0; i < JointCount; ++i) readChunkAnimationJoint(Joints_[i]); /* Build joint construction */ foreach (SJointSPM &Joint, Joints_) { /* Create joint object */ Joint.JointObject = Skeleton->createJoint( Transformation(Joint.Position, Joint.Rotation, Joint.Scale), Joint.Name ); /* Setup vertex weights */ std::vector<SVertexGroup> VertexGroups; VertexGroups.resize(Joint.VertexWeights.size()); u32 i = 0; foreach (const SVertexWeightSPM &Vertex, Joint.VertexWeights) { VertexGroups[i++] = SVertexGroup( CurMesh_, Vertex.Surface, Vertex.Index, Vertex.Weight ); } Joint.JointObject->setVertexGroups(VertexGroups); /* Setup keyframes */ foreach (const SKeyframeSPM &Keyframe, Joint.Keyframes) { Anim->addKeyframe( Joint.JointObject, Keyframe.Frame, Transformation(Keyframe.Position, Keyframe.Rotation, Keyframe.Scale) ); } }