public GpuSkinAnimationGroup(GpuSkinData data)
        {
            Fps         = data.Fps;
            FrameLength = 1f / Fps;

            BuildAnimationData(data);
        }
Beispiel #2
0
        public void AddInstancingBatchData(int skinId, GpuSkinData data, Material material, Texture tex)
        {
            Mesh[] skinMeshes = new Mesh[data.SkinMeshes.Length];
            for (int i = 0; i < data.SkinMeshes.Length; i++)
            {
                Mesh mesh = new Mesh();
                mesh.name      = "GpuSkin_" + data.SkinMeshes[i].Name;
                mesh.vertices  = data.SkinMeshes[i].Vertices;
                mesh.triangles = data.SkinMeshes[i].Triangles;
                mesh.SetIndices(data.SkinMeshes[i].Indices, MeshTopology.Triangles, 0);
                mesh.normals = data.SkinMeshes[i].Normals;
                mesh.uv      = data.SkinMeshes[i].Uv;
                List <Vector4> uvs2 = new List <Vector4>();
                uvs2.AddRange(data.SkinMeshes[i].BoneIndex);
                mesh.SetUVs(1, uvs2);
                List <Vector4> uvs3 = new List <Vector4>();
                uvs3.AddRange(data.SkinMeshes[i].Weights);
                mesh.SetUVs(2, uvs3);
                skinMeshes[i] = mesh;
            }
            InstancingBatchData instancingData = new InstancingBatchData(skinMeshes, new MaterialPropertyBlock(), material);

            instancingData.SetMaterialProperty(tex, data.BlockWidth, data.BlockHeight, data.AnimationTextureWidth, data.AnimationTextureHeight);
            m_instancingBatchDataDic.Add(skinId, instancingData);
        }
        private void BuildAnimationData(GpuSkinData pData)
        {
            m_animationsData = new Dictionary <RoleAnimationType, AnimationData>(new RoleAnimationTypeCompare());

            for (int i = 0; i < pData.Clips.Length; i++)
            {
                RoleAnimationType animType;

                if (AnimationType.AnimationTypeConvert.TryGetValue(pData.Clips[i].ClipName, out animType))
                {
                    GpuSkinAnimationClipData aniData = new GpuSkinAnimationClipData();
                    aniData.FrameCount      = pData.Clips[i].FrameNum;
                    aniData.Name            = pData.Clips[i].ClipName;
                    aniData.Type            = animType;
                    aniData.StartFrameIndex = pData.Clips[i].StartFrameIndex;
                    m_animationsData.Add(animType, aniData);
                }
            }
        }