Esempio n. 1
0
 public static void UnpackVertexData(RenderModelBlock renderModel)
 {
     foreach (var renderModelSectionBlock in renderModel.Sections)
     {
         renderModelSectionBlock.LoadSectionDataIfEmpty(  );
         if (renderModel.CompressionInfo.Length > 0 && renderModelSectionBlock.SectionData.Length > 0)
         {
             UnpackAttributeData(renderModelSectionBlock.SectionData[0].Section,
                                 renderModel.CompressionInfo[0]);
         }
     }
 }
Esempio n. 2
0
        private static RenderModelSectionBlock[] ProcessVariant(ModelVariantBlock variantBlock,
                                                                RenderModelBlock renderBlock, DetailLevel detailLevel)
        {
            var regionNames      = new List <StringIdent>(variantBlock.Regions.Length);
            var permutationNames = new List <StringIdent>(variantBlock.Regions.Length);

            foreach (var region in variantBlock.Regions)
            {
                regionNames.Add(region.RegionName);
                permutationNames.Add(region.Permutations.FirstOrDefault( )?.PermutationName ?? StringIdent.Zero);
            }
            var sectionIndices = SelectRenderModelSections(renderBlock, regionNames, permutationNames, detailLevel);

            return(renderBlock.Sections.Where((e, i) => sectionIndices.Contains(i)).ToArray( ));
        }
Esempio n. 3
0
        private static RenderModelSectionBlock[] ProcessRegions(
            IReadOnlyCollection <ModelRegionBlock> modelRegionBlock, RenderModelBlock renderBlock,
            DetailLevel detailLevel)
        {
            var regionNames = new List <StringIdent>(modelRegionBlock.Count);

            foreach (var region in modelRegionBlock)
            {
                regionNames.Add(region.Name);
            }
            var sectionIndices = SelectRenderModelSections(renderBlock, regionNames, null, detailLevel);

            var blocks = new RenderModelSectionBlock[sectionIndices.Length];

            for (var i = 0; i < blocks.Length; ++i)
            {
                blocks[i] = renderBlock.Sections[sectionIndices[i]];
            }
            return(blocks);
        }
Esempio n. 4
0
        /// <summary>
        ///     Returns array of indices of sections containing each region at a given level of detail
        /// </summary>
        /// <param name="renderBlock">Where the regions are located</param>
        /// <param name="regionNames">A list of names for each region to return</param>
        /// <param name="permutationNames"></param>
        /// <param name="detailLevel">The detail level of mesh to return</param>
        private static int[] SelectRenderModelSections(RenderModelBlock renderBlock,
                                                       List <StringIdent> regionNames, IReadOnlyList <StringIdent> permutationNames, DetailLevel detailLevel)
        {
            var indices = new int[renderBlock.Regions.Length];
            var index   = 0;

            foreach (var region in renderBlock.Regions)
            {
                if (regionNames.BinarySearch(region.Name) < 0)
                {
                    continue;
                }

                var sectionIndex =
                    GetSectionIndex(
                        permutationNames == null
                            ? region.Permutations[0]
                            : region.Permutations.SingleOrDefault(u => u.Name == permutationNames[0]) ??
                        region.Permutations[0], detailLevel);
                indices[index++] = sectionIndex;
            }
            return(indices.TakeSubset(0, index).ToArray( ));
        }