本文整理汇总了C#中BinaryReaderEx.ReadSingle方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReaderEx.ReadSingle方法的具体用法?C# BinaryReaderEx.ReadSingle怎么用?C# BinaryReaderEx.ReadSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryReaderEx
的用法示例。
在下文中一共展示了BinaryReaderEx.ReadSingle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSection
public override void LoadSection(BinaryReaderEx reader)
{
base.LoadSection(reader);
this.NumElements = reader.ReadInt32();
reader.BaseStream.Seek(12, System.IO.SeekOrigin.Current); // Skip 12 bytes
this.ElementOffsets = new List<ElementOffsetData>();
for (var i = 0; i < this.NumElements; i++)
{
var thing = new ElementOffsetData();
thing.BoneNameOffset = reader.ReadInt32();
thing.NameOffset = reader.ReadInt32();
thing.OffsetX = reader.ReadSingle();
thing.OffsetY = reader.ReadSingle();
thing.OffsetZ = reader.ReadSingle();
thing.Unused1 = reader.ReadInt32();
thing.Unused2 = reader.ReadInt32();
thing.Unused3 = reader.ReadInt32();
this.ElementOffsets.Add(thing);
}
foreach (var el in this.ElementOffsets)
{
reader.BaseStream.Position = this.SectionStart + el.BoneNameOffset;
el.BoneName = reader.ReadNullTerminatedString();
reader.BaseStream.Position = this.SectionStart + el.NameOffset;
el.Name = reader.ReadNullTerminatedString();
}
}
示例2: LoadData
public override void LoadData(BinaryReaderEx reader)
{
base.LoadData(reader);
shapOffset = reader.BaseStream.Position;
this.ShapHeader = new ShapHeader();
this.ShapHeader.NumThings = reader.ReadInt32(Endianness.BigEndian);
this.ShapHeader.ThingOffset = reader.ReadInt32(Endianness.BigEndian);
this.ShapHeader.NumThings2 = reader.ReadInt32(Endianness.BigEndian);
this.ShapHeader.Thing2Offset = reader.ReadInt32(Endianness.BigEndian);
this.ShapHeader.NameOffset = reader.ReadInt32(Endianness.BigEndian);
this.ShapHeader.Unknown = reader.ReadInt32(Endianness.BigEndian);
reader.BaseStream.Position = shapOffset + this.ShapHeader.ThingOffset;
this.Things = new List<ShapThing1>();
for (var i = 0; i < this.ShapHeader.NumThings; i++)
{
ShapThing1 t = new ShapThing1();
t.Unk1 = reader.ReadInt16(Endianness.BigEndian);
t.Unk2 = reader.ReadInt16(Endianness.BigEndian);
this.Things.Add(t);
}
reader.BaseStream.Position = shapOffset + this.ShapHeader.Thing2Offset;
this.Things2 = new List<ShapThing2>();
for (var j = 0; j < this.ShapHeader.NumThings2; j++)
{
ShapThing2 t = new ShapThing2();
t.Unk1 = reader.ReadSingle(Endianness.BigEndian);
t.Unk2 = reader.ReadSingle(Endianness.BigEndian);
t.Unk3 = reader.ReadSingle(Endianness.BigEndian);
this.Things2.Add(t);
}
reader.BaseStream.Position = shapOffset + this.ShapHeader.NameOffset;
this.Name = reader.ReadNullTerminatedString();
this.DisplayName = String.Format("SHAP [{0}]", this.Name);
}
示例3: LoadBones
private void LoadBones(BinaryReaderEx reader)
{
reader.BaseStream.Position = this.BasePosition;
this.Bones = new List<Skeleton.SkeletonBone>(this.BoneCount);
this.Children = new List<INavigable>(this.BoneCount);
for (var i = 0; i < this.BoneCount; i++)
{
Skeleton.SkeletonBone bone = new Skeleton.SkeletonBone();
bone.Parent = this;
bone.StringIndex = reader.ReadInt32();
bone.Unknown1 = reader.ReadInt32();
bone.Unknown2 = reader.ReadInt32();
bone.Unknown3 = reader.ReadInt32();
bone.Translation.X = reader.ReadSingle();
bone.Translation.Y = reader.ReadSingle();
bone.Translation.Z = reader.ReadSingle();
bone.Rotation.X = reader.ReadSingle();
bone.Rotation.Y = reader.ReadSingle();
bone.Rotation.Z = reader.ReadSingle();
bone.Rotation.W = reader.ReadSingle();
bone.Scale.X = reader.ReadSingle();
bone.Scale.Y = reader.ReadSingle();
bone.Scale.Z = reader.ReadSingle();
bone.ParentBoneIndex = reader.ReadInt32();
bone.ChildBoneIndex = reader.ReadInt32();
bone.SiblingBoneIndex = reader.ReadInt32();
bone.BoneIndex = reader.ReadInt32();
bone.Unknown4 = reader.ReadInt32();
bone.Unknown5 = reader.ReadInt32();
bone.Stuff = reader.ReadBytes(96);
this.Bones.Add(bone);
this.Children.Add(bone);
bone.Name = this.StringTable[bone.StringIndex];
}
}
示例4: LoadData
public override void LoadData(BinaryReaderEx reader)
{
base.LoadData(reader);
this.boundingBox.Minimum.X = reader.ReadSingle(Endianness.BigEndian);
this.boundingBox.Minimum.Y = reader.ReadSingle(Endianness.BigEndian);
this.boundingBox.Minimum.Z = reader.ReadSingle(Endianness.BigEndian);
this.boundingBox.Maximum.X = reader.ReadSingle(Endianness.BigEndian);
this.boundingBox.Maximum.Y = reader.ReadSingle(Endianness.BigEndian);
this.boundingBox.Maximum.Z = reader.ReadSingle(Endianness.BigEndian);
this.DisplayName = "AABB";
}
示例5: Load
public override void Load(BinaryReaderEx reader)
{
Type = reader.ReadInt16();
Unk1 = reader.ReadInt16();
Unk2 = reader.ReadInt32();
Float1 = reader.ReadSingle();
Float2 = reader.ReadSingle();
Float3 = reader.ReadSingle();
Float4 = reader.ReadSingle();
Float5 = reader.ReadSingle();
Float6 = reader.ReadSingle();
}
示例6: CreateConstantCurve
private static Curves.ConstantCurve CreateConstantCurve(BinaryReaderEx reader, AnimatedComponent component, short count)
{
if (count != 1) { throw new InvalidOperationException("Unexpected count " + count + " for ConstantCurve"); }
var val = reader.ReadSingle(Endianness.BigEndian);
var result = new Curves.ConstantCurve(component, val);
return result;
}
示例7: CreateCompressedLinearCurve
private static Curves.LinearCurve CreateCompressedLinearCurve(BinaryReaderEx reader, AnimatedComponent component, short count)
{
var result = new Curves.LinearCurve(component);
bool flag = (count & 0x8000) != 0;
int numValues = count & 0x7FFF;
float offset = reader.ReadSingle(Endianness.BigEndian);
float scale = reader.ReadSingle(Endianness.BigEndian);
var lengths = reader.ReadBytes(numValues);
for (var i = 0; i < numValues; i++)
{
var length = lengths[i];
if (length == 0) { length = 1; }
var indices = reader.ReadBytes(length);
if (flag)
{
for (var j = 0; j < length; j++)
{
ushort sval = reader.ReadUInt16(Endianness.BigEndian);
bool isNeg = (sval & 0x8000) != 0;
float val = (sval & 0x7FFF) / 32767.0f;
if (isNeg) { val = -val; }
val = val * scale + offset;
Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue()
{
Time = (float)(indices[j] + 256*i),
Value = val
};
result.Values.Add(curveVal);
}
}
else
{
for (var j = 0; j < length; j++)
{
byte sval = reader.ReadByte();
bool isNeg = (sval & 0x80) != 0;
float val = (sval & 0x7F) / 127.0f;
if (isNeg) { val = -val; }
val = val * scale + offset;
Curves.LinearCurveValue curveVal = new Curves.LinearCurveValue()
{
Time = (float)(indices[j] + 256 * i),
Value = val
};
result.Values.Add(curveVal);
}
}
}
// Align reader position to 4-byte boundary
reader.BaseStream.Position = (reader.BaseStream.Position + 3) & 0x7FFFFFFFFFFFFFFC;
return result;
}
示例8: Load
public override void Load(BinaryReaderEx reader)
{
base.Load(reader);
Float1 = reader.ReadSingle();
AnimationLength = reader.ReadSingle();
Bones = reader.ReadInt16();
NumIndices = reader.ReadInt16();
Flags = reader.ReadByte();
reader.BaseStream.Seek(3, System.IO.SeekOrigin.Current);
for (var i = 0; i < NumIndices; i++)
{
int val = reader.ReadInt32();
ChunkIndex idx = new ChunkIndex();
idx.Index = val & 0x7FFFFFFF;
idx.Flag = (val & 0x80000000) == 0x80000000;
this.Offsets.Add(idx);
}
}
示例9: FloatToFloat
private static float FloatToFloat(BinaryReaderEx src)
{
return src.ReadSingle(Endianness.BigEndian);
}