本文整理汇总了C#中IReader.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# IReader.ReadUInt16方法的具体用法?C# IReader.ReadUInt16怎么用?C# IReader.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader.ReadUInt16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTagAddress
public static uint GetTagAddress(IReader memoryReader, ushort index, uint exeBase)
{
//uint newcountaddr = MaxTagCountAddress;
// Read the tag count and validate the tag index
memoryReader.SeekTo(MaxTagCountAddress + exeBase);
var maxIndex = memoryReader.ReadUInt16();
if (index >= maxIndex)
return 0;
// Read the tag index table to get the index of the tag in the address table
memoryReader.SeekTo(TagIndexArrayPointerAddress + exeBase);
var tagIndexTableAddress = memoryReader.ReadUInt32();
if (tagIndexTableAddress == 0)
return 0;
memoryReader.SeekTo(tagIndexTableAddress + index * 4);
var addressIndex = memoryReader.ReadInt32();
if (addressIndex < 0)
return 0;
// Read the tag's address in the address table
memoryReader.SeekTo(TagAddressArrayPointerAddress + exeBase);
var tagAddressTableAddress = memoryReader.ReadUInt32();
if (tagAddressTableAddress == 0)
return 0;
memoryReader.SeekTo(tagAddressTableAddress + addressIndex * 4);
return memoryReader.ReadUInt32();
}
示例2: ReadIndexBuffer
/// <summary>
/// Reads an index buffer from a stream.
/// </summary>
/// <param name="reader">The stream to read from.</param>
/// <param name="count">The number of indices to read.</param>
/// <returns>The index buffer that was read.</returns>
public static ushort[] ReadIndexBuffer(IReader reader, int count)
{
ushort[] indices = new ushort[count];
for (int i = 0; i < count; i++)
indices[i] = reader.ReadUInt16();
return indices;
}
示例3: ReadResourcePage
private static ResourcePage ReadResourcePage(IReader reader, byte version)
{
if (version > 1)
throw new InvalidOperationException("Unrecognized \"rspg\" block version");
var page = new ResourcePage();
page.Index = reader.ReadInt32();
if (version > 0)
page.Salt = reader.ReadUInt16();
page.Flags = reader.ReadByte();
page.FilePath = reader.ReadAscii();
if (page.FilePath.Length == 0)
page.FilePath = null;
page.Offset = reader.ReadInt32();
page.UncompressedSize = reader.ReadInt32();
page.CompressionMethod = (ResourcePageCompression) reader.ReadByte();
page.CompressedSize = reader.ReadInt32();
page.Checksum = reader.ReadUInt32();
page.Hash1 = ReadByteArray(reader);
page.Hash2 = ReadByteArray(reader);
page.Hash3 = ReadByteArray(reader);
page.Unknown1 = reader.ReadInt32();
page.Unknown2 = reader.ReadInt32();
page.Unknown3 = reader.ReadInt32();
return page;
}
示例4: ReadElement
/// <summary>
/// Reads a vertex element from a stream and sends it to an IVertexProcessor.
/// </summary>
/// <param name="reader">The stream to read from. It should be positioned at the start of the element.</param>
/// <param name="element">The layout of the element to read.</param>
/// <param name="boundingBox">The bounding box to transform the element with. Can be null.</param>
/// <param name="processor">The IVertexProcessor to send the element to.</param>
private static void ReadElement(IReader reader, VertexElementLayout element, BoundingBox boundingBox,
IVertexProcessor processor)
{
// EW EW EW
// TODO: Implement everything, this is just enough to load some Reach vertices for now...
float x = 0, y = 0, z = 0, w = 1;
uint value;
switch (element.Type)
{
case VertexElementType.Float2:
x = reader.ReadFloat();
y = reader.ReadFloat();
break;
case VertexElementType.Float3:
x = reader.ReadFloat();
y = reader.ReadFloat();
z = reader.ReadFloat();
break;
case VertexElementType.Float4:
x = reader.ReadFloat();
y = reader.ReadFloat();
z = reader.ReadFloat();
w = reader.ReadFloat();
break;
case VertexElementType.UByte4:
x = reader.ReadByte();
y = reader.ReadByte();
z = reader.ReadByte();
w = reader.ReadByte();
break;
case VertexElementType.UByte4N:
x = reader.ReadByte()/255.0f;
y = reader.ReadByte()/255.0f;
z = reader.ReadByte()/255.0f;
w = reader.ReadByte()/255.0f;
break;
case VertexElementType.Byte4N:
x = reader.ReadSByte()/127.0f;
y = reader.ReadSByte()/127.0f;
z = reader.ReadSByte()/127.0f;
w = reader.ReadSByte()/127.0f;
break;
case VertexElementType.Float16_2:
x = Half.ToHalf(reader.ReadUInt16());
y = Half.ToHalf(reader.ReadUInt16());
break;
case VertexElementType.Float16_4:
x = Half.ToHalf(reader.ReadUInt16());
y = Half.ToHalf(reader.ReadUInt16());
z = Half.ToHalf(reader.ReadUInt16());
w = Half.ToHalf(reader.ReadUInt16());
break;
case VertexElementType.UShort2:
x = reader.ReadUInt16();
y = reader.ReadUInt16();
break;
case VertexElementType.UShort2N:
x = reader.ReadUInt16()/65535.0f;
y = reader.ReadUInt16()/65535.0f;
break;
case VertexElementType.UShort4N:
x = reader.ReadUInt16()/65535.0f;
y = reader.ReadUInt16()/65535.0f;
z = reader.ReadUInt16()/65535.0f;
w = reader.ReadUInt16()/65535.0f;
break;
case VertexElementType.Short4N:
x = reader.ReadInt16()/32767.0f;
y = reader.ReadInt16()/32767.0f;
z = reader.ReadInt16()/32767.0f;
w = reader.ReadInt16()/32767.0f;
break;
case VertexElementType.D3DColor:
w = reader.ReadByte()/255.0f; // W is set here because alpha comes first but ends up last in the vector
y = reader.ReadByte()/255.0f;
z = reader.ReadByte()/255.0f;
x = reader.ReadByte()/255.0f;
break;
case VertexElementType.DHen3N:
value = reader.ReadUInt32();
//.........这里部分代码省略.........