Esempio n. 1
0
 private Bone GetBone(ByteReader io)
 {
     var bone=new Bone();
     bone.Name=GetText(io);
     bone.EnglishName=GetText(io);
     bone.Position=io.GetVector3();
     bone.ParentIndex=GetBoneIndex(io);
     bone.Layer=io.GetInt();
     bone.Flags=(BONEFLAG)io.GetUShort();
     if(bone.HasFlag(BONEFLAG.HAS_TAILBONE)){
         bone.TailBoneIndex=GetBoneIndex(io);
     }
     else{
         bone.TailOffset=io.GetVector3();
     }
     if(bone.HasFlag(BONEFLAG.ROTATION_EFFECTED)
             || bone.HasFlag(BONEFLAG.TRANSLATION_EFFECTED)){
         bone.EffectIndex=GetBoneIndex(io);
         bone.EffectFactor=io.GetFloat();
     }
     if(bone.HasFlag(BONEFLAG.HAS_FIXEDAXIS)){
         bone.FixedAxis=io.GetVector3();
     }
     if(bone.HasFlag(BONEFLAG.HAS_LOCALAXIS)){
         bone.LocalAxisX=io.GetVector3();
         bone.LocalAxisZ=io.GetVector3();
     }
     if(bone.HasFlag(BONEFLAG.DEFORM_EXTERNAL_PARENT)){
         bone.ExternalParentKey=io.GetInt();
     }
     if(bone.HasFlag(BONEFLAG.HAS_IK)){
         var ik=new IKSolver();
         bone.IKSolver=ik;
         ik.TargetIndex=GetBoneIndex(io);
         ik.Iterations=io.GetInt();
         ik.UnitRadian=io.GetFloat();
         int Count=io.GetInt();
         ik.Chains=Enumerable.Range(1, Count).Select(_
                 =>{
                 var link=new IKLink();
                 link.BoneIndex=GetBoneIndex(io);
                 link.IsLimited=io.GetByte()==0 ? false : true;
                 if(link.IsLimited){
                 link.MinEulerRadians=io.GetVector3();
                 link.MaxEulerRadians=io.GetVector3();
                 }
                 return link;
                 }).ToArray();
     }
     return bone;
 }