Beispiel #1
0
        private static IEnumerator partsCombiner(Request request, AvatarDefinition definition, BodyColorMaterialProperties bodycolor, List <ViewPart> parts, int maxAtlasDimension)
        {
            int meshCount = parts.Count;

            Mesh[]  meshes          = new Mesh[meshCount];
            int[][] meshBoneIndexes = new int[meshCount][];
            for (int i = 0; i < meshCount; i++)
            {
                string[] boneNames = parts[i].GetBoneNames();
                meshes[i]          = parts[i].GetMesh();
                meshBoneIndexes[i] = new int[boneNames.Length];
                for (int j = 0; j < boneNames.Length; j++)
                {
                    meshBoneIndexes[i][j] = definition.BoneIndexLookup[boneNames[j]];
                }
            }
            request.Mesh = Combine.CombineSkinnedMeshes(meshes, meshBoneIndexes, definition.BindPose);
            yield return(null);

            int curSize;

            Rect[] atlasUVOffsets = Combine.CalculateAtlasLayout(parts, out curSize);
            yield return(null);

            int renderTextureSize = Mathf.Min(Mathf.ClosestPowerOfTwo(curSize), maxAtlasDimension);

            request.Atlas = new RenderTexture(renderTextureSize, renderTextureSize, 0, RenderTextureFormat.ARGB32);
            request.Atlas.isPowerOfTwo = true;
            request.Atlas.filterMode   = FilterMode.Bilinear;
            request.Atlas.useMipMap    = false;
            Combine.BakeTexture(parts, atlasUVOffsets, bodycolor, request.Atlas);
            yield return(null);

            Combine.ApplyAtlasUV(meshes, request.Mesh, atlasUVOffsets);
        }
Beispiel #2
0
        public Request CombineParts(AvatarDefinition definition, BodyColorMaterialProperties bodycolor, List <ViewPart> parts, int maxAtlasDimension)
        {
            Request     request = new Request();
            IEnumerator value   = partsCombiner(request, definition, bodycolor ?? definition.BodyColor, parts, maxAtlasDimension);

            queue.Enqueue(new KeyValuePair <Request, IEnumerator>(request, value));
            return(request);
        }
 private static IEnumerator partsCombiner(AvatarService.Request request, AvatarDefinition definition, BodyColorMaterialProperties bodycolor, List <ViewPart> parts, int maxAtlasDimension)
 {
     AvatarService._partsCombiner_d__0 _partsCombiner_d__ = new AvatarService._partsCombiner_d__0(0);
     _partsCombiner_d__.request           = request;
     _partsCombiner_d__.definition        = definition;
     _partsCombiner_d__.bodycolor         = bodycolor;
     _partsCombiner_d__.parts             = parts;
     _partsCombiner_d__.maxAtlasDimension = maxAtlasDimension;
     return(_partsCombiner_d__);
 }