Ejemplo n.º 1
0
 public static HwBuffer FromVertexData(BinaryReader reader, GameType gameType, BaseRenderDataStreamingMode streamingMode, uint ByteStride, uint ElementCount)
 {
     return(FromData(reader, gameType, BaseDataBufferFormat.Structured, streamingMode, ByteStride, ElementCount));
 }
Ejemplo n.º 2
0
        public static HwBuffer FromIndexData(BinaryReader reader, GameType gameType, BaseIndexFormat format, BaseRenderDataStreamingMode streamingMode, uint elementCount)
        {
            var dataFormat = format switch
            {
                BaseIndexFormat.Index16 => BaseDataBufferFormat.R_UINT_16,
                BaseIndexFormat.Index32 => BaseDataBufferFormat.R_UINT_32,
                _ => throw new NotSupportedException("Unknown index buffer type"),
            };

            return(FromData(reader, gameType, dataFormat, streamingMode, GetStrideForFormat(dataFormat), elementCount));
        }
Ejemplo n.º 3
0
        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);
        }