Пример #1
0
        public void LoadClusterData()
        {
            var resourceStream = GeometryBlockInfo.GetResourceFromCache();

            if (resourceStream == null)
            {
                return;
            }

            var clusterBlock = new StructureBspClusterDataBlockNew();

            using (var binaryReader = new BinaryReader(resourceStream))
            {
                clusterBlock.Read(binaryReader);

                var vertexBufferResources = GeometryBlockInfo.Resources.Where(
                    x => x.Type == GlobalGeometryBlockResourceBlock.TypeEnum.VertexBuffer).ToArray();
                for (var i = 0;
                     i < clusterBlock.Section.VertexBuffers.Length && i < vertexBufferResources.Length;
                     ++i)
                {
                    clusterBlock.Section.VertexBuffers[i].VertexBuffer.Data =
                        resourceStream.GetResourceData(vertexBufferResources[i]);
                }
            }
            ClusterData = new[] { clusterBlock };
        }
        internal virtual StructureBspClusterDataBlockNew[] ReadStructureBspClusterDataBlockNewArray(BinaryReader binaryReader)
        {
            var elementSize = Deserializer.SizeOf(typeof(StructureBspClusterDataBlockNew));
            var blamPointer = binaryReader.ReadBlamPointer(elementSize);
            var array       = new StructureBspClusterDataBlockNew[blamPointer.Count];

            using (binaryReader.BaseStream.Pin())
            {
                for (int i = 0; i < blamPointer.Count; ++i)
                {
                    binaryReader.BaseStream.Position = blamPointer[i];
                    array[i] = new StructureBspClusterDataBlockNew(binaryReader);
                }
            }
            return(array);
        }