public Vector4f Read(BinaryReader reader, ref int offset)
{
Vector4f value;
int size;
if (Offset != offset)
throw new Exception();
switch (Format) {
case ModelVertexFormat.Vector3f:
size = 12;
value.X = reader.ReadSingle();
value.Y = reader.ReadSingle();
value.Z = reader.ReadSingle();
value.W = 1;
break;
case ModelVertexFormat.Vector4abgr:
size = 4;
value.W = reader.ReadByte() / 255f;
value.Z = reader.ReadByte() / 255f;
value.Y = reader.ReadByte() / 255f;
value.X = reader.ReadByte() / 255f;
break;
case ModelVertexFormat.Vector4b:
size = 4;
value.X = reader.ReadByte();
value.Y = reader.ReadByte();
value.Z = reader.ReadByte();
value.W = reader.ReadByte();
break;
case ModelVertexFormat.Vector4nsb:
case ModelVertexFormat.Vector4nsb2:
size = 4;
value.X = reader.ReadSByte() / 127f;
value.Y = reader.ReadSByte() / 127f;
value.Z = reader.ReadSByte() / 127f;
value.W = reader.ReadSByte() / 127f;
break;
case ModelVertexFormat.Vector2ns1024:
size = 4;
value.X = reader.ReadInt16() / 1024f;
value.Y = reader.ReadInt16() / 1024f;
value.Z = value.W = 0;
break;
case ModelVertexFormat.Vector4ns1024:
size = 8;
value.X = reader.ReadInt16() / 1024f;
value.Y = reader.ReadInt16() / 1024f;
value.Z = reader.ReadInt16() / 1024f;
value.W = reader.ReadInt16() / 1024f;
break;
case ModelVertexFormat.Vector4ns:
size = 8;
value.X = reader.ReadInt16() / 32767f;
value.Y = reader.ReadInt16() / 32767f;
value.Z = reader.ReadInt16() / 32767f;
value.W = reader.ReadInt16() / 32767f;
break;
default:
throw new NotImplementedException("Format " + Format + " is not implemented.");
}
offset += size;
return value;
}