当前位置: 首页>>代码示例>>C#>>正文


C# MemoryStream.ReadFloat方法代码示例

本文整理汇总了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 = "";
            }
开发者ID:ostapus,项目名称:WoW2Mesh,代码行数:10,代码来源:wmo_model.cs

示例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!");
            }
        }
开发者ID:CHiiLD,项目名称:net-toolkit,代码行数:13,代码来源:StreamExtensionsTest.cs

示例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);
 }
开发者ID:ostapus,项目名称:WoW2Mesh,代码行数:34,代码来源:Adt.cs

示例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;
        }
开发者ID:ostapus,项目名称:WoW2Mesh,代码行数:44,代码来源:Adt.cs

示例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;
 }
开发者ID:ostapus,项目名称:WoW2Mesh,代码行数:12,代码来源:WmoGroup.cs

示例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);
        }
开发者ID:ostapus,项目名称:WoW2Mesh,代码行数:86,代码来源:m2.cs

示例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;
 }
开发者ID:ostapus,项目名称:WoW2Mesh,代码行数:10,代码来源:wmo.cs


注:本文中的System.IO.MemoryStream.ReadFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。