本文整理汇总了C#中System.IO.MemoryStream.ReadFloat方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.ReadFloat方法的具体用法?C# MemoryStream.ReadFloat怎么用?C# MemoryStream.ReadFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.ReadFloat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public void Read(MemoryStream ms)
{
id = (uint)ms.ReadInt32();
position.X = ms.ReadFloat(); position.Y = ms.ReadFloat(); position.Z = ms.ReadFloat();
rotation.X = ms.ReadFloat(); rotation.Y = ms.ReadFloat(); rotation.Z = ms.ReadFloat(); rotation.W = ms.ReadFloat();
scale = ms.ReadFloat();
color = (uint) ms.ReadInt32();
file = "";
}
示例2: TestStreamfloat
public void TestStreamfloat()
{
float obj = 100;
using (MemoryStream ms = new MemoryStream())
{
ms.WriteFloat(obj);
ms.Seek(0, SeekOrigin.Begin);
float res = ms.ReadFloat();
Assert.IsTrue(obj.Equals(res), "Streaming failed!");
}
}
示例3: Read
public void Read(MemoryStream ms)
{
base.Read(ms, "MCNK");
flags = (uint) ms.ReadInt32();
indexX = (uint)ms.ReadInt32();
indexY = (uint)ms.ReadInt32();
numLayers = (uint)ms.ReadInt32();
numDoodads = (uint)ms.ReadInt32();
mcvtOff = (uint)ms.ReadInt32();
mcnrOff = (uint)ms.ReadInt32();
mclyOff = (uint)ms.ReadInt32();
mcrfOff = (uint)ms.ReadInt32();
mcalOff = (uint)ms.ReadInt32();
mcalSize = (uint)ms.ReadInt32();
mcshOff = (uint)ms.ReadInt32();
mcshSize = (uint)ms.ReadInt32();
areaId = (uint)ms.ReadInt32();
numWmos = (uint)ms.ReadInt32();
holes = (uint)ms.ReadInt32();
texmap0 = (ulong)ms.ReadInt64();
texmap1 = (ulong)ms.ReadInt64();
predTex = (uint)ms.ReadInt32();
noEffectDoodad = (uint)ms.ReadInt32();
msceOff = (uint)ms.ReadInt32();
numSoundEmitters = (uint)ms.ReadInt32();
mclqOff = (uint)ms.ReadInt32();
mclqSize = (uint)ms.ReadInt32();
float x = ms.ReadFloat();
float y = ms.ReadFloat();
float z = ms.ReadFloat();
position = new Vector3(x, y, z);
mccvOff = (uint)ms.ReadInt32();
ms.Read(pad, 0, pad.Length);
}
示例4: parseMcnkChunk
public McnkChunk_s parseMcnkChunk(MemoryStream ms, Terrain_s terrain)
{
long mcnk_off = ms.Position;
McnkChunk_s mcnk_chunk = new McnkChunk_s();
mcnk_chunk.Read(ms);
// set stream position to MCVT chunk
ms.Position = mcnk_off + mcnk_chunk.mcvtOff;
McvtChunk_s mcvt_chunk = new McvtChunk_s();
mcvt_chunk.Read(ms, "MCVT");
// read all height values
uint num_heights = mcvt_chunk.size / sizeof(float);
HeightMap_t height_map = terrain.heightMap;
height_map.Capacity = (int) num_heights;
for (int i = 0; i < num_heights; i++)
{
height_map.Add(ms.ReadFloat());
}
// set stream position to MCNR chunk
McnrChunk_s mcnr_chunk = new McnrChunk_s();
ms.Position = mcnk_off + mcnk_chunk.mcnrOff;
mcnr_chunk.Read(ms);
// read all normal values
//int num_normals = mcnr_chunk.size / sizeof( char ); // size is wrong
Normals_t normals = terrain.normals;
normals.Capacity = (int) num_heights;
byte normal;
for (int i = 0; i < num_heights; i++)
{
Vector3 v = new Vector3();
normal = (byte) ms.ReadByte();
v.X = normal * 0.00787401574803149606299212598425f;
normal = (byte)ms.ReadByte();
v.Z = normal * 0.00787401574803149606299212598425f;
normal = (byte)ms.ReadByte();
v.Y = normal * 0.00787401574803149606299212598425f;
normals.Add(v);
}
ms.Position = mcnk_off + 0x8 + mcnk_chunk.size;
return mcnk_chunk;
}
示例5: Read
public uint Read(MemoryStream ms)
{
base.Read(ms, "MOVT");
long end_chunk = ms.Position + size;
while (ms.Position < end_chunk)
{
Vector3 v;
v.X = ms.ReadFloat(); v.Y = ms.ReadFloat(); v.Z = ms.ReadFloat();
vertices.Add(v);
}
return size;
}
示例6: M2
public M2(mpq.Wrapper mpq_h, string name)
{
MemoryStream ms = new MemoryStream(mpq_h.GetFile(name));
// read in chunk by chunk
ms.Read(id, 0, id.Length);
ms.Read(version, 0, id.Length);
nameLength = (uint) ms.ReadInt32();
nameOff = (uint)ms.ReadInt32();
flags = (uint)ms.ReadInt32();
ms.Read(pad0, 0, pad0.Length);
numVertices = (uint) ms.ReadInt32();
verticesOff = (uint)ms.ReadInt32();
ms.Read(pad1, 0, pad1.Length);
numBoundingTriangles = (uint)ms.ReadInt32();
boundingTriangleOff = (uint)ms.ReadInt32();
numBoundingVertices = (uint)ms.ReadInt32();
boundingVerticesOff = (uint)ms.ReadInt32();
numBoundingNormals = (uint)ms.ReadInt32();
boundingNormalsOff = (uint)ms.ReadInt32();
isCollide = numBoundingTriangles > 0;
// ignore non collidable M2s
if (!isCollide)
return;
// get M2 model name
ms.Position = nameOff;
byte[] _b = new byte[nameLength];
ms.Read(_b, 0, (int) nameLength);
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
_m2name = enc.GetString(_b);
if (numVertices > 0)
{
ms.Position = verticesOff;
for (int i = 0; i < numVertices; i++)
{
Vector3 v;
v.X = ms.ReadFloat(); v.Y = ms.ReadFloat(); v.Z = ms.ReadFloat();
_vertices.Add(v);
}
}
// get bounding triangles
if (numBoundingTriangles > 0)
{
ms.Position = boundingTriangleOff;
for (int i = 0; i < numBoundingTriangles; i++)
{
// in the file those are 16bit, so read short
_boundingIndices.Add(ms.ReadShort());
}
}
// get bounding vertices
if (numBoundingVertices > 0)
{
ms.Position = boundingVerticesOff;
for (int i = 0; i < numBoundingVertices; i++)
{
Vector3 v;
v.X = ms.ReadFloat(); v.Y = ms.ReadFloat(); v.Z = ms.ReadFloat();
_boundingVertices.Add(v);
}
}
// get bounding normals
if (numBoundingNormals > 0)
{
ms.Position = boundingNormalsOff;
for (int i = 0; i < numBoundingNormals; i++)
{
Vector3 v;
v.X = ms.ReadFloat(); v.Y = ms.ReadFloat(); v.Z = ms.ReadFloat();
_boundingNormals.Add(v);
}
}
bbox = BoundingBox.CreateFromPoints(_boundingVertices);
}
示例7: Read
public uint Read(MemoryStream ms)
{
id = (uint)ms.ReadInt32();
uid = (uint)ms.ReadInt32();
pos.X = ms.ReadFloat(); pos.Y = ms.ReadFloat(); pos.Z = ms.ReadFloat();
rot.X = ms.ReadFloat(); rot.Y = ms.ReadFloat(); rot.Z = ms.ReadFloat();
scale = (ushort)ms.ReadShort();
flags = (ushort)ms.ReadShort();
return 0;
}