本文整理汇总了C#中Stream.ReadFloat方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadFloat方法的具体用法?C# Stream.ReadFloat怎么用?C# Stream.ReadFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.ReadFloat方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFrom
public void ReadFrom(Stream stream)
{
Seed = stream.ReadInt32();
Radius = stream.ReadFloat();
DeviationScale = stream.ReadFloat();
Diameter = Radius * 2.0f;
AveragePlanetRadius = stream.ReadFloat();
}
示例2: ReadFrom
public void ReadFrom(Stream stream)
{
int numMaterials = stream.ReadInt32();
Layers = new MyMaterialLayer[numMaterials];
for (int i = 0; i < numMaterials; ++i)
{
Layers[i] = new MyMaterialLayer();
Layers[i].StartHeight = stream.ReadFloat();
Layers[i].EndHeight = stream.ReadFloat();
Layers[i].StartAngle = stream.ReadFloat();
Layers[i].EndAngle = stream.ReadFloat();
Layers[i].HeightStartDeviation = stream.ReadFloat();
Layers[i].AngleStartDeviation = stream.ReadFloat();
Layers[i].HeightEndDeviation = stream.ReadFloat();
Layers[i].AngleEndDeviation = stream.ReadFloat();
Layers[i].MaterialDefinition = MyDefinitionManager.Static.GetVoxelMaterialDefinition(stream.ReadString());
}
int numOreProbabilities = stream.ReadInt32();
OreProbabilities = new MyOreProbability[numOreProbabilities];
for (int i = 0; i < numOreProbabilities; ++i)
{
OreProbabilities[i] = new MyOreProbability();
OreProbabilities[i].CummulativeProbability = stream.ReadFloat();
OreProbabilities[i].OreName = stream.ReadString();
}
OreStartDepth = stream.ReadFloat();
OreEndDepth = stream.ReadFloat();
}
示例3: HvaReader
public HvaReader(Stream s)
{
// Index swaps for transposing a matrix
var ids = new byte[]{0,4,8,12,1,5,9,13,2,6,10,14};
s.Seek(16, SeekOrigin.Begin);
FrameCount = s.ReadUInt32();
LimbCount = s.ReadUInt32();
// Skip limb names
s.Seek(16*LimbCount, SeekOrigin.Current);
Transforms = new float[16*FrameCount*LimbCount];
for (var j = 0; j < FrameCount; j++)
for (var i = 0; i < LimbCount; i++)
{
// Convert to column-major matrices and add the final matrix row
var c = 16*(LimbCount*j + i);
Transforms[c + 3] = 0;
Transforms[c + 7] = 0;
Transforms[c + 11] = 0;
Transforms[c + 15] = 1;
for (var k = 0; k < 12; k++)
Transforms[c + ids[k]] = s.ReadFloat();
}
}
示例4: HvaReader
public HvaReader(Stream s, string fileName)
{
// Index swaps for transposing a matrix
var ids = new byte[] { 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14 };
s.Seek(16, SeekOrigin.Begin);
FrameCount = s.ReadUInt32();
LimbCount = s.ReadUInt32();
// Skip limb names
s.Seek(16 * LimbCount, SeekOrigin.Current);
Transforms = new float[16 * FrameCount * LimbCount];
var testMatrix = new float[16];
for (var j = 0; j < FrameCount; j++)
for (var i = 0; i < LimbCount; i++)
{
// Convert to column-major matrices and add the final matrix row
var c = 16 * (LimbCount * j + i);
Transforms[c + 3] = 0;
Transforms[c + 7] = 0;
Transforms[c + 11] = 0;
Transforms[c + 15] = 1;
for (var k = 0; k < 12; k++)
Transforms[c + ids[k]] = s.ReadFloat();
Array.Copy(Transforms, 16 * (LimbCount * j + i), testMatrix, 0, 16);
if (Util.MatrixInverse(testMatrix) == null)
throw new InvalidDataException(
"The transformation matrix for HVA file `{0}` section {1} frame {2} is invalid because it is not invertible!"
.F(fileName, i, j));
}
}
示例5: MyMaterialLayer
void IMyStorageDataProvider.ReadFrom(ref MyOctreeStorage.ChunkHeader header, Stream stream, ref bool isOldFormat)
{
m_state.Version = stream.ReadUInt32();
if (m_state.Version != CURRENT_VERSION)
{
// Making sure this gets saved in new format and serialized cache holding old format is discarded.
isOldFormat = true;
}
m_state.Generator = stream.ReadInt32();
m_state.Seed = stream.ReadInt32();
m_state.Size = stream.ReadFloat();
if (m_state.Version == VERSION_WITHOUT_PLANETS)
{
m_state.IsPlanet = 0;
}
else
{
m_state.IsPlanet = stream.ReadUInt32();
}
if (m_state.IsPlanet != 0)
{
int numMaterials = stream.ReadInt32();
m_materialLayers = new MyMaterialLayer[numMaterials];
for (int i = 0; i < numMaterials; ++i)
{
m_materialLayers[i] = new MyMaterialLayer();
m_materialLayers[i].StartHeight = stream.ReadFloat();
m_materialLayers[i].EndHeight = stream.ReadFloat();
m_materialLayers[i].MaterialName = stream.ReadString();
m_materialLayers[i].StartAngle = stream.ReadFloat();
m_materialLayers[i].EndAngle = stream.ReadFloat();
m_materialLayers[i].HeightStartDeviation = stream.ReadFloat();
m_materialLayers[i].AngleStartDeviation = stream.ReadFloat();
m_materialLayers[i].HeightEndDeviation = stream.ReadFloat();
m_materialLayers[i].AngleEndDeviation = stream.ReadFloat();
}
m_shapeAttributes.Seed = stream.ReadInt32();
m_shapeAttributes.Radius = stream.ReadFloat();
m_shapeAttributes.NoiseFrequency = stream.ReadFloat();
m_shapeAttributes.DeviationScale = stream.ReadFloat();
m_shapeAttributes.NormalNoiseFrequency = stream.ReadFloat();
m_shapeAttributes.LayerDeviationNoiseFreqeuncy = stream.ReadFloat();
m_shapeAttributes.LayerDeviationSeed = stream.ReadInt32();
m_hillAttributes.BlendTreshold = stream.ReadFloat();
m_hillAttributes.Treshold = stream.ReadFloat();
m_hillAttributes.SizeRatio = stream.ReadFloat();
m_hillAttributes.NumNoises = stream.ReadInt32();
m_hillAttributes.Frequency = stream.ReadFloat();
m_canyonAttributes.BlendTreshold = stream.ReadFloat();
m_canyonAttributes.Treshold = stream.ReadFloat();
m_canyonAttributes.SizeRatio = stream.ReadFloat();
m_canyonAttributes.NumNoises = stream.ReadInt32();
m_canyonAttributes.Frequency = stream.ReadFloat();
MyCompositeShapes.PlanetGenerators[m_state.Generator](ref m_shapeAttributes,ref m_hillAttributes, ref m_canyonAttributes, m_materialLayers, out m_data);
}
else
{
MyCompositeShapes.AsteroidGenerators[m_state.Generator](m_state.Seed, m_state.Size, out m_data);
}
m_state.Version = CURRENT_VERSION;
}
示例6: ReadFromStream
public override void ReadFromStream(Stream aStream)
{
A = aStream.ReadFloat ();
B = aStream.ReadFloat ();
C = aStream.ReadBoolean ();
D = aStream.ReadBoolean ();
E = aStream.ReadFloat ();
F = aStream.ReadFloat ();
}
示例7: InvalidBranchException
void IMyStorageDataProvider.ReadFrom(ref MyOctreeStorage.ChunkHeader header, Stream stream, ref bool isOldFormat)
{
m_state.Version = stream.ReadUInt32();
if (m_state.Version != CURRENT_VERSION)
{
// Making sure this gets saved in new format and serialized cache holding old format is discarded.
isOldFormat = true;
}
m_state.Generator = stream.ReadInt32();
m_state.Seed = stream.ReadInt32();
m_state.Size = stream.ReadFloat();
if (m_state.Version == VERSION_WITHOUT_PLANETS)
{
m_state.UnusedCompat = 0;
}
else
{
m_state.UnusedCompat = stream.ReadUInt32();
if (m_state.UnusedCompat == 1)
{
Debug.Fail("This storage is from a prototype version of planets and is no longer supported.");
throw new InvalidBranchException();
}
}
var gen = MyCompositeShapes.AsteroidGenerators[m_state.Generator];
gen(m_state.Seed, m_state.Size, out m_data);
m_state.Version = CURRENT_VERSION;
}
示例8:
void IMyStorageDataProvider.ReadFrom(ref MyOctreeStorage.ChunkHeader header, Stream stream, ref bool isOldFormat)
{
m_state.Version = stream.ReadUInt32();
if (m_state.Version != CURRENT_VERSION)
{
// Making sure this gets saved in new format and serialized cache holding old format is discarded.
isOldFormat = true;
m_state.Version = CURRENT_VERSION;
}
m_state.Generator = stream.ReadInt32();
m_state.Seed = stream.ReadInt32();
m_state.Size = stream.ReadFloat();
MyCompositeShapes.AsteroidGenerators[m_state.Generator](m_state.Seed, m_state.Size, out m_data);
}
示例9: VxlReader
public VxlReader(Stream s)
{
if (!s.ReadASCII(16).StartsWith("Voxel Animation"))
throw new InvalidDataException("Invalid vxl header");
s.ReadUInt32();
LimbCount = s.ReadUInt32();
s.ReadUInt32();
BodySize = s.ReadUInt32();
s.Seek(770, SeekOrigin.Current);
// Read Limb headers
Limbs = new VxlLimb[LimbCount];
for (var i = 0; i < LimbCount; i++)
{
Limbs[i] = new VxlLimb();
Limbs[i].Name = s.ReadASCII(16);
s.Seek(12, SeekOrigin.Current);
}
// Skip to the Limb footers
s.Seek(802 + 28*LimbCount + BodySize, SeekOrigin.Begin);
var LimbDataOffset = new uint[LimbCount];
for (var i = 0; i < LimbCount; i++)
{
LimbDataOffset[i] = s.ReadUInt32();
s.Seek(8, SeekOrigin.Current);
Limbs[i].Scale = s.ReadFloat();
s.Seek(48, SeekOrigin.Current);
Limbs[i].Bounds = new float[6];
for (var j = 0; j < 6; j++)
Limbs[i].Bounds[j] = s.ReadFloat();
Limbs[i].Size = s.ReadBytes(3);
Limbs[i].Type = (NormalType)s.ReadByte();
}
for (var i = 0; i < LimbCount; i++)
{
s.Seek(802 + 28*LimbCount + LimbDataOffset[i], SeekOrigin.Begin);
ReadVoxelData(s, Limbs[i]);
}
}
示例10: ReadAsBinary
/// <summary>
/// Populate this instance from the given <see cref="Stream"/> as a binary <see cref="KeyValue"/>.
/// </summary>
/// <param name="input">The input <see cref="Stream"/> to read from.</param>
/// <returns><c>true</c> if the read was successful; otherwise, <c>false</c>.</returns>
public bool ReadAsBinary( Stream input )
{
this.Children = new List<KeyValue>();
while ( true )
{
var type = ( Type )input.ReadByte();
if ( type == Type.End )
{
break;
}
var current = new KeyValue();
current.Name = input.ReadNullTermString( Encoding.UTF8 );
try
{
switch ( type )
{
case Type.None:
{
current.ReadAsBinary( input );
break;
}
case Type.String:
{
current.Value = input.ReadNullTermString( Encoding.UTF8 );
break;
}
case Type.WideString:
{
throw new InvalidDataException( "wstring is unsupported" );
}
case Type.Int32:
case Type.Color:
case Type.Pointer:
{
current.Value = Convert.ToString( input.ReadInt32() );
break;
}
case Type.UInt64:
{
current.Value = Convert.ToString( input.ReadUInt64() );
break;
}
case Type.Float32:
{
current.Value = Convert.ToString( input.ReadFloat() );
break;
}
default:
{
throw new InvalidDataException( "Unknown KV type encountered." );
}
}
}
catch ( InvalidDataException ex )
{
throw new InvalidDataException( string.Format( "An exception ocurred while reading KV '{0}'", current.Name ), ex );
}
this.Children.Add( current );
}
return input.Position == input.Length;
}
示例11:
void IMyStorageDataProvider.ReadFrom(ref MyOctreeStorage.ChunkHeader header, Stream stream, ref bool isOldFormat)
{
m_state.Version = stream.ReadUInt32();
if (m_state.Version != CURRENT_VERSION)
{
// Making sure this gets saved in new format and serialized cache holding old format is discarded.
isOldFormat = true;
}
m_state.Generator = stream.ReadInt32();
m_state.Seed = stream.ReadInt32();
m_state.Size = stream.ReadFloat();
if (m_state.Version == VERSION_WITHOUT_PLANETS)
{
m_state.IsPlanet = 0;
}
else
{
m_state.IsPlanet = stream.ReadUInt32();
}
if (m_state.IsPlanet != 0)
{
m_materialAttributes.ReadFrom(stream);
m_shapeAttributes.ReadFrom(stream);
m_hillAttributes.ReadFrom(stream);
m_canyonAttributes.ReadFrom(stream);
MyCompositeShapes.PlanetGenerators[m_state.Generator](ref m_shapeAttributes, ref m_hillAttributes, ref m_canyonAttributes, ref m_materialAttributes, out m_data);
}
else
{
MyCompositeShapes.AsteroidGenerators[m_state.Generator](m_state.Seed, m_state.Size, out m_data);
}
m_state.Version = CURRENT_VERSION;
}