public void WriteToJson(IResMgr resmgr, GameObject node, Component component, MyJson.JsonNode_Object json) { FB.PosePlus.AniPlayer ic = component as FB.PosePlus.AniPlayer; MyJson.JsonNode_Array anis = new MyJson.JsonNode_Array(); json["clips"] = anis; foreach (var m in ic.clips) { string hash = resmgr.SaveAniClip(m); anis.Add(new MyJson.JsonNode_ValueString(hash)); } }
public void WriteBinary(FB.PosePlus.AniPlayer player, int totalFrame, int binarySingleFrameSize) { var binaryTotalFrameSize = totalFrame * binarySingleFrameSize; var clips = player.clips; int totalBones = player.bones.Count; //ChunkData for (int i = 0, l = clips.Count; i < l; i++) { var clip = clips[i]; if (clip == null) { continue; } var frames = clip.frames; for (int j = 0, ll = frames.Count; j < ll; j++) { var frame = frames[j]; if (frame == null) { continue; } var bones = frame.bonesinfo; for (int k = 0, lll = bones.Count; k < lll; k++) { var boneName = clip.boneinfo[k]; var bonePos = bones[k]; if (bonePos == null || player.getbone(boneName) == null) { continue; } // this._bufferWriter.Write(bonePos.r.x); this._bufferWriter.Write(bonePos.r.y); this._bufferWriter.Write(bonePos.r.z); this._bufferWriter.Write(bonePos.r.w); this._bufferWriter.Write(bonePos.t.x); this._bufferWriter.Write(bonePos.t.y); this._bufferWriter.Write(bonePos.t.z); } } } }
public Component ReadFromJson(IResMgr resmgr, GameObject node, MyJson.JsonNode_Object json, DelayProcess dp) { FB.PosePlus.AniPlayer c = node.GetComponent(comptype) as FB.PosePlus.AniPlayer; if (c == null)//这就可能了 { c = node.AddComponent <FB.PosePlus.AniPlayer>(); } var clips = json["clips"].AsList(); c.clips = new List <FB.PosePlus.AniClip>(); for (int i = 0; i < clips.Count; i++) { string hashname = clips[i].AsString(); c.clips.Add(resmgr.GetAniClip(hashname)); } return(c); }
public override bool WriteToJson(GameObject obj, Component component, MyJson_Object compJson) { FB.PosePlus.AniPlayer comp = component as FB.PosePlus.AniPlayer; var animationsItem = new MyJson_Array(); compJson["_animations"] = animationsItem; var animator = obj.GetComponent <Animator>(); if (comp.clips.Count > 0 && animator != null) { int gltfHash = animator.runtimeAnimatorController.GetInstanceID(); string url = ResourceManager.instance.SaveAniPlayer(comp, animator); var assetIndex = ResourceManager.instance.AddAssetUrl(url); var aniItem = new MyJson_Tree(); aniItem.SetInt("asset", assetIndex); animationsItem.Add(aniItem); } return(true); }