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


C# EndianBinaryReader.ReadSingle方法代码示例

本文整理汇总了C#中EndianBinaryReader.ReadSingle方法的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryReader.ReadSingle方法的具体用法?C# EndianBinaryReader.ReadSingle怎么用?C# EndianBinaryReader.ReadSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EndianBinaryReader的用法示例。


在下文中一共展示了EndianBinaryReader.ReadSingle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: read

		public void read(EndianBinaryReader r) {
			Time = r.ReadSingle();
			Measure = r.ReadInt16();
			Beat = r.ReadInt16();
			PhraseIteration = r.ReadInt32();
			Mask = r.ReadInt32();
		}
开发者ID:aequitas,项目名称:rocksmith-custom-song-toolkit,代码行数:7,代码来源:Sng2014HSL.cs

示例2: txt1

 public txt1(EndianBinaryReader er)
     : base(er)
 {
     long baseoffset = er.BaseStream.Position - 0x4C;
     NrCharacters = er.ReadUInt16();
     NrCharacters2 = er.ReadUInt16();
     MaterialId = er.ReadUInt16();
     FontId = er.ReadUInt16();
     PositionType = er.ReadByte();
     TextAlignment = er.ReadByte();
     TextFlags = er.ReadByte();
     Padding = er.ReadByte();
     StringOffset = er.ReadUInt32();
     TopColor = er.ReadColor8();
     BottomColor = er.ReadColor8();
     FontSize = er.ReadVector2();
     CharSpace = er.ReadSingle();
     LineSpace = er.ReadSingle();
     er.BaseStream.Position = baseoffset + StringOffset;
     Text = er.ReadStringNT(Encoding.Unicode);
     er.BaseStream.Position = baseoffset + SectionSize;
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:22,代码来源:txt1.cs

示例3: VertexStreamCtr

 public VertexStreamCtr(EndianBinaryReader er)
     : base(er)
 {
     BufferObject = er.ReadUInt32();
     LocationFlag = er.ReadUInt32();
     VertexStreamLength = er.ReadUInt32();
     VertexStreamOffset = er.ReadUInt32();
     LocationAddress = er.ReadUInt32();
     MemoryArea = er.ReadUInt32();
     FormatType = (DataType)er.ReadUInt32();
     NrComponents = er.ReadUInt32();
     Scale = er.ReadSingle();
     Offset = er.ReadUInt32();
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:14,代码来源:CMDL.cs

示例4: hfzReadHeader

        private HfzHeader hfzReadHeader(EndianBinaryReader reader)
        {
            HfzHeader fh = new HfzHeader();

            string heading = UTF8Encoding.UTF8.GetString(reader.ReadBytes(4));
            if (heading.Equals("HF2"))
            {
                throw new Exception("Invalid file format heading HF2 not found");
            }

            ushort fileVersion = reader.ReadUInt16();
            fh.FileVersionNo = fileVersion;

            UInt32 nx = reader.ReadUInt32();
            fh.nx = nx;

            UInt32 ny = reader.ReadUInt32();
            fh.ny = ny;

            ushort tileSize = reader.ReadUInt16();
            fh.TileSize = tileSize;

            float Precis = reader.ReadSingle();
            fh.Precis = Precis;

            float HorizScale = reader.ReadSingle();
            fh.HorizScale = HorizScale;

            UInt32 ExtHeaderLength = reader.ReadUInt32();
            fh.ExtHeaderLength = ExtHeaderLength;

            if (ExtHeaderLength > 0)
            {
                fh = decodeExtHeaderBuf(fh, reader);
            }

            return fh;
        }
开发者ID:Celludriel,项目名称:L3DT_Filemanager,代码行数:38,代码来源:HfzManager.cs

示例5: readWmfHeader

        private WmfHeader readWmfHeader(EndianBinaryReader reader)
        {
            validateFile(reader);

            ushort dataOffset = reader.ReadUInt16();
            uint width = reader.ReadUInt32();
            uint height = reader.ReadUInt32();
            byte dataSize = reader.ReadByte();
            bool floatingPointFlag = reader.ReadByte() == 1 ? true : false;
            float verticalScale = reader.ReadSingle();
            float verticalOffset = reader.ReadSingle();
            float horizontalScale = reader.ReadSingle();
            ushort tileSize = reader.ReadUInt16();
            bool wrapFlag = reader.ReadByte() == 1 ? true : false;
            byte reserved = reader.ReadByte();

            if (reserved != 0)
            {
                throw new Exception("Reserved should be 0 for a WMF");
            }

            ushort auxDataType = reader.ReadUInt16();
            byte auxDataSize = reader.ReadByte();
            byte[] auxReserved = reader.ReadBytes(dataOffset - 45);

            return new WmfHeader(dataOffset, width, height, dataSize, floatingPointFlag, verticalScale,
                verticalOffset, horizontalScale, tileSize, wrapFlag, auxDataType, auxDataSize, auxReserved);
        }
开发者ID:Celludriel,项目名称:L3DT_Filemanager,代码行数:28,代码来源:WmfManager.cs

示例6: Read

        public void Read(Stream inStream, MesgDefinition defnMesg)
        {
            inStream.Position = 1;
             EndianBinaryReader mesgReader = new EndianBinaryReader(inStream, defnMesg.IsBigEndian);

             LocalNum = defnMesg.LocalMesgNum;

             foreach (FieldDefinition fieldDef in defnMesg.GetFields())
             {
            // It's possible the field type found in the field definition may
            // not agree with the type defined in the profile.  The profile
            // type will be preferred for decode.
            Field field = GetField(fieldDef.Num);
            if (field == null)
            {
               // We normally won't have fields attached to our skeleton message,
               // as we add values we need to add the fields too based on the mesg,field
               // combo in the profile.  Must derive from the profile so the scale etc
               // is correct
               field = new Field(Profile.GetMesg(this.Num).GetField(fieldDef.Num));
               if (field.Num == Fit.FieldNumInvalid)
               {
                  // If there was no info in the profile the FieldNum will get set to invalid
                  // so preserve the unknown fields info while we know it
                  field.Num = fieldDef.Num;
                  field.Type = fieldDef.Type;
               }
               SetField(field);
            }

            object value;

            // strings may be an array and are of variable length
            if ((field.Type & Fit.BaseTypeNumMask) == Fit.String)
            {
               List<byte> utf8Bytes = new List<byte>();
               byte b = new byte();

               for (int i=0; i<fieldDef.Size; i++)
               {
                  b = mesgReader.ReadByte();
                  if (b == 0x00)
                  {
                     field.AddValue(utf8Bytes.ToArray());
                     utf8Bytes.Clear();
                  }
                  else
                  {
                     utf8Bytes.Add(b);
                  }
               }
               if (utf8Bytes.Count != 0)
               {
                  field.AddValue(utf8Bytes.ToArray());
                  utf8Bytes.Clear();
               }
            }
            else
            {
               int numElements = (int)fieldDef.Size / Fit.BaseType[field.Type & Fit.BaseTypeNumMask].size;
               for (int i=0; i < numElements; i++)
               {
                  switch (field.Type & Fit.BaseTypeNumMask)
                  {
                     case Fit.Enum:
                     case Fit.Byte:
                     case Fit.UInt8:
                     case Fit.UInt8z:
                        value = mesgReader.ReadByte();
                        break;

                     case Fit.SInt8:
                        value = mesgReader.ReadSByte();
                        break;

                     case Fit.SInt16:
                        value = mesgReader.ReadInt16();
                        break;

                     case Fit.UInt16:
                     case Fit.UInt16z:
                        value = mesgReader.ReadUInt16();
                        break;

                     case Fit.SInt32:
                        value = mesgReader.ReadInt32();
                        break;

                     case Fit.UInt32:
                     case Fit.UInt32z:
                        value = mesgReader.ReadUInt32();
                        break;

                     case Fit.Float32:
                        value = mesgReader.ReadSingle();
                        break;

                     case Fit.Float64:
                        value = mesgReader.ReadDouble();
                        break;
//.........这里部分代码省略.........
开发者ID:LightningBugalugs,项目名称:Fickle-Frostbite,代码行数:101,代码来源:Mesg.cs

示例7: read

 public void read(EndianBinaryReader r)
 {
     Time = r.ReadSingle();
     DnaId = r.ReadInt32();
 }
开发者ID:cozy1,项目名称:rocksmith-custom-song-toolkit,代码行数:5,代码来源:Sng2014HSL.cs

示例8: ReadVertexBlock

        private void ReadVertexBlock(EndianBinaryReader reader, CModel currentModel)
        {
            currentModel.VertexBaseIndex = _models._vertexPositions.Count;
            currentModel.VertexCount = reader.ReadInt32();

            for (int i = 0; i < currentModel.VertexCount; i++)
            {
                Vector3 vertex = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                _models._vertexPositions.Add(vertex);
            }
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:11,代码来源:DatFile.cs

示例9: ReadTextureMapBlock

 private void ReadTextureMapBlock(EndianBinaryReader reader, CModel currentModel)
 {
     currentModel.TextureMapCount = reader.ReadInt32();
     for (int i = 0; i < currentModel.TextureMapCount; i++)
     {
         float tU = reader.ReadSingle();
         float tV = reader.ReadSingle();
         _models._vertexTextureMap.Add(new Vector2(tU, tV));
     }
 }
开发者ID:sikora507,项目名称:OpenC1,代码行数:10,代码来源:DatFile.cs

示例10: Read

        public void Read(EndianBinaryReader reader, string type, List<EntityTemplate> templates)
        {
            ChunkType = type;

            if (ChunkType == "RTBL")
            {
            }

            DisplayName = ChunkType;

            Fields = new List<ElementProperty>();

            string searchID = ChunkType.Remove(ChunkType.Length - 1);

            EntityTemplate template = templates.Find(x => x.ChunkID.Contains(searchID));

            Geometry = template.Geometry;

            ActualColor = template.Color;

            DisplayColor = ActualColor;

            foreach (ElementProperty prop in template.Properties)
            {
                switch (prop.Type)
                {
                    case FieldType.Byte:
                        prop.Data = reader.ReadByte();
                        break;
                    case FieldType.Short:
                        prop.Data = reader.ReadInt16();
                        break;
                    case FieldType.Integer:
                        prop.Data = reader.ReadInt32();
                        break;
                    case FieldType.Float:
                        prop.Data = reader.ReadSingle();
                        break;
                    case FieldType.Vector2:
                        prop.Data = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                        break;
                    case FieldType.Vector3:
                        prop.Data = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                        if (prop.Name == "Position")
                        {
                            Position = (Vector3)prop.Data;
                        }
                        break;
                    case FieldType.String:
                        string test = reader.ReadString((uint)prop.Length).Trim('\0');
                        prop.Data = test;
                        DisplayName = (string)prop.Data;
                        break;
                    case FieldType.ListByte:
                        List<byte> byteList = new List<byte>();

                        int readerOffsetStorage = (int)reader.BaseStream.Position;

                        if (ChunkType == "RTBL")
                        {
                            int roomListOffset = (int)template.Properties.Find(x => x.Name == "Room List Offset").Data;

                            readerOffsetStorage = (int)reader.BaseStream.Position;

                            reader.BaseStream.Position = roomListOffset;

                            prop.Length = Convert.ToInt32(template.Properties.Find(x => x.Name == "Room Count").Data);
                        }

                        for (int i = 0; i < prop.Length; i++)
                        {
                            byteList.Add(reader.ReadByte());
                        }

                        prop.Data = byteList;

                        if (ChunkType == "RTBL")
                        {
                            reader.BaseStream.Position = readerOffsetStorage;
                        }
                        break;
                    case FieldType.ListShort:
                        List<short> shortList = new List<short>();

                        for (int i = 0; i < prop.Length; i++)
                        {
                            shortList.Add(reader.ReadInt16());
                        }

                        prop.Data = shortList;
                        break;
                    case FieldType.ListRPPN:
                        List<Chunk> rppnList = new List<Chunk>();

                        prop.Data = rppnList;
                        break;
                    case FieldType.Color:
                        Color color = Color.FromArgb((int)reader.ReadByte(), (int)reader.ReadByte(), (int)reader.ReadByte());

//.........这里部分代码省略.........
开发者ID:Sage-of-Mirrors,项目名称:DZxEditor-TWW-Entity-Editor,代码行数:101,代码来源:Main.cs

示例11: Load

        public void Load(EndianBinaryReader reader)
        {
            int numVerts = reader.ReadInt32();

            int vertsOffset = reader.ReadInt32();

            int numFaces = reader.ReadInt32();

            int facesOffset = reader.ReadInt32();

            reader.BaseStream.Position = vertsOffset;

            List<Vector3> vertsList = new List<Vector3>();

            for (int i = 0; i < numVerts; i++)
            {
                vertsList.Add(new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()));
            }

            Vertexes = vertsList.ToArray();

            reader.BaseStream.Position = facesOffset;

            List<int> facesList = new List<int>();

            for (int i = 0; i < numFaces; i++)
            {
                facesList.Add(reader.ReadInt16());

                facesList.Add(reader.ReadInt16());

                facesList.Add(reader.ReadInt16());

                reader.Skip(4);
            }

            Meshes = facesList.ToArray();

            //Generate a buffer on the GPU and get the ID to it
            GL.GenBuffers(1, out _glVbo);

            //This "binds" the buffer. Once a buffer is bound, all actions are relative to it until another buffer is bound.
            GL.BindBuffer(BufferTarget.ArrayBuffer, _glVbo);

            //This uploads data to the currently bound buffer from the CPU -> GPU. This only needs to be done with the data changes (ie: you edited a vertexes position on the cpu side)
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Vertexes.Length * Vector3.SizeInBytes), Vertexes,
                BufferUsageHint.StaticDraw);

            //Now we're going to repeat the same process for the Element buffer, which is what OpenGL calls indicies. (Notice how it's basically identical?)
            GL.GenBuffers(1, out _glEbo);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, _glEbo);
            GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(Meshes.Length * 4), Meshes,
                BufferUsageHint.StaticDraw);
        }
开发者ID:Sage-of-Mirrors,项目名称:DZxEditor-TWW-Entity-Editor,代码行数:54,代码来源:Main.cs

示例12: Bone

                public Single[] WorldMatrix; //4x3

                #endregion Fields

                #region Constructors

                public Bone(EndianBinaryReader er)
                {
                    NameOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
                    Flags = (BoneFlags)er.ReadUInt32();
                    JointID = er.ReadUInt32();
                    ParentID = er.ReadInt32();
                    if (ParentID == -1) ParentOffset = er.ReadUInt32();
                    else ParentOffset = (UInt32)(er.BaseStream.Position + er.ReadInt32());
                    ChildOffset = er.ReadUInt32();
                    if (ChildOffset != 0) ChildOffset += (UInt32)(er.BaseStream.Position - 4);
                    PreviousSiblingOffset = er.ReadUInt32();
                    if (PreviousSiblingOffset != 0) PreviousSiblingOffset += (UInt32)(er.BaseStream.Position - 4);
                    NextSiblingOffset = er.ReadUInt32();
                    if (NextSiblingOffset != 0) NextSiblingOffset += (UInt32)(er.BaseStream.Position - 4);
                    Scale = new Vector3(er.ReadSingle(), er.ReadSingle(), er.ReadSingle());
                    Rotation = new Vector3(er.ReadSingle(), er.ReadSingle(), er.ReadSingle());
                    Translation = new Vector3(er.ReadSingle(), er.ReadSingle(), er.ReadSingle());
                    LocalMatrix = er.ReadSingles(4 * 3);
                    WorldMatrix = er.ReadSingles(4 * 3);
                    InverseBaseMatrix = er.ReadSingles(4 * 3);
                    BillboardMode = (BBMode)er.ReadUInt32();
                    Unknown6 = er.ReadUInt32();
                    Unknown7 = er.ReadUInt32();

                    long curpos = er.BaseStream.Position;
                    er.BaseStream.Position = NameOffset;
                    Name = er.ReadStringNT(Encoding.ASCII);
                    er.BaseStream.Position = curpos;
                }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:35,代码来源:CMDL.cs

示例13: VertexParamAttributeCtr

 public VertexParamAttributeCtr(EndianBinaryReader er)
     : base(er)
 {
     FormatType = (DataType)er.ReadUInt32();
     NrComponents = er.ReadUInt32();
     Scale = er.ReadSingle();
     NrAttributes = er.ReadUInt32();
     AttributeArrayOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
     long curpos = er.BaseStream.Position;
     er.BaseStream.Position = AttributeArrayOffset;
     Attributes = er.ReadSingles((int)NrAttributes);
     er.BaseStream.Position = curpos;
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:13,代码来源:CMDL.cs

示例14: LoadMapEntityFromStream

        private RawMapEntity LoadMapEntityFromStream(string chunkFourCC, EndianBinaryReader reader, MapEntityDataDescriptor template)
        {
            RawMapEntity obj = new RawMapEntity();
            obj.Fields = new PropertyCollection();
            obj.FourCC = chunkFourCC;

            // We're going to examine the Template's properties and load based on the current template type.
            for (int i = 0; i < template.Fields.Count; i++)
            {
                var templateProperty = template.Fields[i];
                string propertyName = templateProperty.FieldName;
                PropertyType type = templateProperty.FieldType;
                object value = null;

                switch (type)
                {
                    case PropertyType.FixedLengthString:
                        value = reader.ReadString(templateProperty.Length).Trim(new[] { '\0' });
                        break;

                    case PropertyType.String:
                        value = reader.ReadStringUntil('\0');
                        break;

                    case PropertyType.Byte:
                        value = reader.ReadByte();
                        break;

                    case PropertyType.Short:
                        value = reader.ReadInt16();
                        break;

                    case PropertyType.Int32BitField:
                    case PropertyType.Int32:
                        value = reader.ReadInt32();
                        break;

                    case PropertyType.Float:
                        value = reader.ReadSingle();
                        break;

                    case PropertyType.Vector3:
                        value = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                        break;

                    case PropertyType.Vector2:
                        value = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                        break;

                    case PropertyType.Enum:
                        byte enumIndexBytes = reader.ReadByte(); // ToDo: Resolve to actual Enum later.
                        value = enumIndexBytes;
                        break;

                    case PropertyType.ObjectReference:
                        // When we first resolve them, we're going to keep the value as the reference byte,
                        // and then when they are post-processed they'll be turned into a proper type.
                        value = (int)reader.ReadByte();
                        break;

                    case PropertyType.ObjectReferenceShort:
                        // When we first resolve them, we're going to keep the value as the reference byte,
                        // and then when they are post-processed they'll be turned into a proper type.
                        value = (int)reader.ReadUInt16();
                        break;

                    case PropertyType.ObjectReferenceArray:
                        // When we first resolve them, we're going to keep the value as the reference byte,
                        // and then when they are post-processed they'll be turned into a proper type.
                        var refList = new BindingList<object>();
                        for (int refArray = 0; refArray < templateProperty.Length; refArray++)
                        {
                            refList.Add((int)reader.ReadByte());
                        }
                        value = refList;
                        break;

                    case PropertyType.XYRotation:
                        {
                            Vector3 eulerAngles = new Vector3();
                            for (int f = 0; f < 2; f++)
                                eulerAngles[f] = (reader.ReadInt16() * (180 / 32786f));

                            Quaternion xAxis = Quaternion.FromAxisAngle(new Vector3(1, 0, 0), eulerAngles.X * MathE.Deg2Rad);
                            Quaternion yAxis = Quaternion.FromAxisAngle(new Vector3(0, 1, 0), eulerAngles.Y * MathE.Deg2Rad);

                            // Swizzling to the ZYX order seems to be the right one.
                            Quaternion finalRot = yAxis * xAxis;
                            value = finalRot;
                        }
                        break;

                    case PropertyType.XYZRotation:
                        {
                            Vector3 eulerAngles = new Vector3();
                            for (int f = 0; f < 3; f++)
                                eulerAngles[f] = (reader.ReadInt16() * (180 / 32786f));

                            Quaternion xAxis = Quaternion.FromAxisAngle(new Vector3(1, 0, 0), eulerAngles.X * MathE.Deg2Rad);
                            Quaternion yAxis = Quaternion.FromAxisAngle(new Vector3(0, 1, 0), eulerAngles.Y * MathE.Deg2Rad);
//.........这里部分代码省略.........
开发者ID:CryZe,项目名称:WindEditor2,代码行数:101,代码来源:MapEntityLoader.cs

示例15: readValueFromReader

        private float readValueFromReader(EndianBinaryReader reader, WmfHeader header, uint xLocation, uint yLocation)
        {
            float value;

            if (header.floatingPointFlag)
            {
                float readSingleValue = reader.ReadSingle();
                debugLine("v: " + readSingleValue);
                value = header.verticalScale * readSingleValue + header.verticalOffset;
                debugLine("cv: " + value);
            }
            else
            {
                switch (header.waterLevelDataSize)
                {
                    case 2:
                        ushort readShortValue = reader.ReadUInt16();
                        debugLine("v: " + readShortValue);
                        value = header.verticalScale * readShortValue + header.verticalOffset;
                        debugLine("cv: " + value);
                        break;
                    default: throw new Exception("Invalid pixel data at x: " + xLocation + ", y: " + yLocation);
                }
            }
            return value;
        }
开发者ID:Celludriel,项目名称:L3DT_Filemanager,代码行数:26,代码来源:WmfManager.cs


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