Beispiel #1
0
        public static HwDataBuffer FromData(BinaryReader reader, GameType gameType)
        {
            var  x = new HwDataBuffer();
            uint bufferElementCount = reader.ReadUInt32();

            if (bufferElementCount > 0)
            {
                uint isStreaming = reader.ReadUInt32();
                x.Flags = reader.ReadUInt32();
                var  format       = (BaseDataBufferFormat)reader.ReadUInt32();
                uint bufferStride = reader.ReadUInt32();

                if (isStreaming != 0 && isStreaming != 1)
                {
                    throw new InvalidDataException("Must be true or false");
                }

                if (format != BaseDataBufferFormat.Structured)
                {
                    bufferStride = HwBuffer.GetStrideForFormat(format);
                }

                x.Buffer = HwBuffer.FromData(reader, gameType, format, isStreaming != 0, bufferStride, bufferElementCount);
            }

            return(x);
        }
Beispiel #2
0
        public static HwBuffer FromData(BinaryReader reader, GameType gameType, BaseDataBufferFormat format, bool streaming, uint byteStride, uint elementCount)
        {
            var buffer = new HwBuffer
            {
                Format        = format,
                ElementStride = byteStride,
                ElementCount  = elementCount,
                Streaming     = streaming,
            };

            if (buffer.Streaming)
            {
                if (gameType == GameType.HZD)
                {
                    buffer.StreamInfo = BaseStreamHandle.FromData(reader, gameType);
                }
                else
                {
                    buffer.StreamInfo = null;
                }
            }
            else
            {
                // Read raw data
                buffer.Data = reader.ReadBytesStrict(elementCount * byteStride);
            }

            return(buffer);
        }
        public static HwBuffer FromData(BinaryReader reader, GameType gameType, BaseDataBufferFormat format, BaseRenderDataStreamingMode streamingMode, uint byteStride, uint elementCount)
        {
            if (streamingMode != BaseRenderDataStreamingMode.NotStreaming && streamingMode != BaseRenderDataStreamingMode.Streaming)
            {
                throw new InvalidDataException("Invalid streaming mode");
            }

            var buffer = new HwBuffer
            {
                Format        = format,
                ElementStride = byteStride,
                ElementCount  = elementCount,
                StreamingMode = streamingMode,
            };

            if (buffer.StreamingMode == BaseRenderDataStreamingMode.Streaming)
            {
                if (gameType == GameType.HZD)
                {
                    buffer.StreamInfo = BaseStreamHandle.FromData(reader, gameType);
                }
                else
                {
                    buffer.StreamInfo = null;
                }
            }
            else
            {
                // Read raw data
                buffer.Data = reader.ReadBytesStrict(elementCount * byteStride);
            }

            return(buffer);
        }
Beispiel #4
0
        public static HwIndexArray FromData(BinaryReader reader, GameType gameType)
        {
            var  array             = new HwIndexArray();
            uint indexElementCount = reader.ReadUInt32();

            if (indexElementCount > 0)
            {
                array.Flags = reader.ReadUInt32();
                var format        = (BaseIndexFormat)reader.ReadUInt32();
                var streamingMode = (BaseRenderDataStreamingMode)reader.ReadUInt32();

                array.ResourceDataHash = BaseGGUUID.FromData(reader);
                array.Buffer           = HwBuffer.FromIndexData(reader, gameType, format, streamingMode, indexElementCount);
            }

            return(array);
        }
        public static HwVertexArray FromData(BinaryReader reader, GameType gameType)
        {
            var x = new HwVertexArray();

            x.VertexCount = reader.ReadUInt32();
            uint streamCount = reader.ReadUInt32();

            x.IsStreaming = reader.ReadBooleanStrict();

            x.Streams = new List <VertexStream>((int)streamCount);

            for (uint i = 0; i < streamCount; i++)
            {
                uint flags            = reader.ReadUInt32();
                uint byteStride       = reader.ReadUInt32();
                uint elementDescCount = reader.ReadUInt32();

                var stream = new VertexStream();
                stream.Flags       = flags;
                stream.ElementInfo = new List <VertexElementDesc>((int)elementDescCount);

                for (uint j = 0; j < elementDescCount; j++)
                {
                    stream.ElementInfo.Add(new VertexElementDesc()
                    {
                        ByteOffset     = reader.ReadByte(),
                        StorageType    = (BaseVertexElementStorageType)reader.ReadByte(),
                        ComponentCount = reader.ReadByte(),
                        ElementType    = (BaseVertexElement)reader.ReadByte(),
                    });
                }

                stream.GUID   = new BaseGGUUID().FromData(reader);
                stream.Buffer = HwBuffer.FromVertexData(reader, gameType, x.IsStreaming, byteStride, x.VertexCount);

                x.Streams.Add(stream);
            }

            return(x);
        }
        public static HwVertexArray FromData(BinaryReader reader, GameType gameType)
        {
            var array = new HwVertexArray();

            array.VertexCount = reader.ReadUInt32();
            uint streamCount = reader.ReadUInt32();

            array.StreamingMode = (BaseRenderDataStreamingMode)reader.ReadByte();

            array.Streams = new List <VertexStream>((int)streamCount);

            for (uint i = 0; i < streamCount; i++)
            {
                uint flags            = reader.ReadUInt32();
                uint byteStride       = reader.ReadUInt32();
                uint elementDescCount = reader.ReadUInt32();

                var stream = new VertexStream();
                stream.Flags       = flags;
                stream.ElementInfo = new List <VertexElementDesc>((int)elementDescCount);

                for (uint j = 0; j < elementDescCount; j++)
                {
                    stream.ElementInfo.Add(new VertexElementDesc()
                    {
                        ByteOffset     = reader.ReadByte(),
                        StorageType    = (BaseVertexElementStorageType)reader.ReadByte(),
                        ComponentCount = reader.ReadByte(),
                        ElementType    = (BaseVertexElement)reader.ReadByte(),
                    });
                }

                stream.ResourceDataHash = BaseGGUUID.FromData(reader);
                stream.Buffer           = HwBuffer.FromVertexData(reader, gameType, array.StreamingMode, byteStride, array.VertexCount);

                array.Streams.Add(stream);
            }

            return(array);
        }
        public static HwIndexArray FromData(BinaryReader reader, GameType gameType)
        {
            var  x = new HwIndexArray();
            uint indexElementCount = reader.ReadUInt32();

            if (indexElementCount > 0)
            {
                x.Flags = reader.ReadUInt32();
                var  format      = (BaseIndexFormat)reader.ReadUInt32();
                uint isStreaming = reader.ReadUInt32();

                if (isStreaming != 0 && isStreaming != 1)
                {
                    throw new InvalidDataException("Must be true or false");
                }

                x.ResourceGUID = new BaseGGUUID().FromData(reader);
                x.Buffer       = HwBuffer.FromIndexData(reader, gameType, format, isStreaming != 0, indexElementCount);
            }

            return(x);
        }
Beispiel #8
0
        public static HwDataBuffer FromData(BinaryReader reader, GameType gameType)
        {
            var  buffer             = new HwDataBuffer();
            uint bufferElementCount = reader.ReadUInt32();

            if (bufferElementCount > 0)
            {
                var streamingMode = (BaseRenderDataStreamingMode)reader.ReadUInt32();
                buffer.Flags = reader.ReadUInt32();
                var  format       = (BaseDataBufferFormat)reader.ReadUInt32();
                uint bufferStride = reader.ReadUInt32();

                if (format != BaseDataBufferFormat.Structured)
                {
                    bufferStride = HwBuffer.GetStrideForFormat(format);
                }

                buffer.Buffer = HwBuffer.FromData(reader, gameType, format, streamingMode, bufferStride, bufferElementCount);
            }

            return(buffer);
        }