ReadSingle() public method

public ReadSingle ( ) : float
return float
 internal override void ReadFrom(BinaryReader reader)
 {
     Id = reader.ReadInt32();
     float x = reader.ReadSingle();
     float y = reader.ReadSingle();
     Position = new Vector2(x, y);
 }
Example #2
0
 private Point3D ReadPoint(BinaryReader reader)
 {
     var x = reader.ReadSingle();
     var y = reader.ReadSingle();
     var z = reader.ReadSingle();
     return new Point3D(x, y, z);
 }
        public IList<IFace> Read(BinaryReader reader)
        {
            int numFaces = reader.ReadInt32();

            for (int i = 0; i < numFaces; i++)
            {
                float materialRotation = reader.ReadSingle();
                float u = reader.ReadSingle();
                float v = reader.ReadSingle();
                float uScale = reader.ReadSingle();
                float vScale = reader.ReadSingle();
                int unknown = reader.ReadInt32();
                int materialIndex = reader.ReadInt32();
                int unknown2 = reader.ReadInt32();

                int numVertices = reader.ReadInt32();

                for (int j = 0; j < numVertices; j++)
                {
                    int unknown3 = reader.ReadInt32();
                    int indice = reader.ReadInt32();
                }

                IFace face = new Face();
                face.MaterialRotation =
                face.U = u;
            }
        }
 public void RestoreState(BinaryReader reader)
 {
     var curName = reader.ReadString();
     if (curName != "")
     {
         var loop = reader.ReadBoolean();
         current = new LinearSequence(anims[curName], loop)
                       {
                           Speed = reader.ReadSingle(),
                           Time = reader.ReadSingle()
                       };
     }
     var backupName = reader.ReadString();
     if (backupName != "")
     {
         var loop = reader.ReadBoolean();
         backup = new LinearSequence(anims[backupName], loop)
         {
             Speed = reader.ReadSingle(),
             Time = reader.ReadSingle()
         };
     }
     fadeLeft = reader.ReadSingle();
     fadeTime = reader.ReadSingle();
 }
Example #5
0
        public static Image Read(BinaryReader Reader)
        {
            Image I = new Image();

              I.m_Width = Reader.ReadInt32();
              I.m_Height = Reader.ReadInt32();

              Reader.ReadSingle();
              Reader.ReadSingle();

              Reader.ReadSingle();
              Reader.ReadSingle();

              I.m_HorizontalFieldOfView = Reader.ReadSingle();
              I.m_VerticalFieldOfView = Reader.ReadSingle();
              long l = Reader.ReadInt64();
              I.m_AquiredOn = DateTime.Now; //= new DateTime(l);
              I.m_SequenceNumber = Reader.ReadInt32();

              I.m_RawPixels = Reader.ReadBytes(I.m_Width * I.m_Height * 3);

              I.m_Pixels = new Color[I.m_Width * I.m_Height];
              for (int i = 0; i < I.m_Pixels.Length; i++)
            I.m_Pixels[i] = Color.FromArgb(I.m_RawPixels[3 * i], I.m_RawPixels[3 * i+1], I.m_RawPixels[3 * i + 2]);

              return I;
        }
        public override void parse(BinaryReader br, ChunkMap chkMap, Boolean dbg, int chunkLength)
        {
            if (dbg) Console.Out.WriteLine("|-----|" + ChunkHeader.W3D_CHUNK_DEFORM_DATA);

            HeaderID = (int)ChunkHeader.W3D_CHUNK_DEFORM_DATA;
            HeaderName = ChunkHeader.W3D_CHUNK_DEFORM_DATA.ToString();

            for (int i = 0; i < chunkLength / 28; i++)
            {
                vertex_index = br.ReadInt32();
                position = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());

                int R = br.ReadByte();
                int G = br.ReadByte();
                int B = br.ReadByte();
                int A = br.ReadByte();

                color = Color.FromArgb(A, R, G, B);

                //reserved
                for (int i2 = 0; i2 < 2; i2++)
                {
                    reserved[i2] = br.ReadInt32();
                }
            }
        }
Example #7
0
 /// <summary>
 /// </summary>
 /// <param name="stream">
 /// </param>
 public void ReadFromStream(Stream stream)
 {
     BinaryReader br = new BinaryReader(stream);
     this.X = br.ReadSingle();
     this.Y = br.ReadSingle();
     this.Z = br.ReadSingle();
 }
        /// <summary>
        /// Deserialisiert Update Daten.
        /// </summary>
        public override void DeserializeUpdate(BinaryReader reader)
        {
            base.DeserializeUpdate(reader);

            // Velocity wieder deserialisieren
            Velocity = new Vector2(reader.ReadSingle(), reader.ReadSingle());
        }
Example #9
0
 /// <summary>
 /// Reads object data from given BinaryReader.
 /// </summary>
 public void Read(BinaryReader br)
 {
     R = br.ReadSingle();
     G = br.ReadSingle();
     B = br.ReadSingle();
     A = br.ReadSingle();
 }
Example #10
0
        private static GameObject BuildObject(Scene scene, BinaryReader reader)
        {
            var id = reader.ReadUInt32();
            var position = new Vector2f(reader.ReadSingle(), reader.ReadSingle());

            return ObjectsManager.Build(id, position);
        }
        public override void parse(BinaryReader br, ChunkMap chkMap, Boolean dbg, int chunkLength)
        {
            if (dbg) Console.Out.WriteLine("|----| " + ChunkHeader.W3D_CHUNK_STAGE_TEXCOORDS);

            HeaderID = (int)ChunkHeader.W3D_CHUNK_STAGE_TEXCOORDS;
            HeaderName = ChunkHeader.W3D_CHUNK_STAGE_TEXCOORDS.ToString();

            int NumTexCoords = chunkLength / 8;
            object[] uv = new object[2];
            tex_coord_data = new object[NumTexCoords][];

            for (int i = 0; i < NumTexCoords; i++)
            {
                uv[0] = br.ReadSingle();
                uv[1] = br.ReadSingle();

                tex_coord_data[i] = uv;

                if (dbg)
                {
                    Console.Out.WriteLine("\t Tex Coord #" + i);
                    Console.Out.WriteLine("\t U: " + uv[0] + " V: " + uv[1]);
                }
            }
        }
Example #12
0
        public MagicInfo (BinaryReader reader, int version = int.MaxValue, int Customversion = int.MaxValue)
        {
            Name = reader.ReadString();
            Spell = (Spell)reader.ReadByte();
            BaseCost = reader.ReadByte();
            LevelCost = reader.ReadByte();
            Icon = reader.ReadByte();
            Level1 = reader.ReadByte();
            Level2 = reader.ReadByte();
            Level3 = reader.ReadByte();
            Need1 = reader.ReadUInt16();
            Need2 = reader.ReadUInt16();
            Need3 = reader.ReadUInt16();
            DelayBase = reader.ReadUInt32();
            DelayReduction = reader.ReadUInt32();
            PowerBase = reader.ReadUInt16();
            PowerBonus = reader.ReadUInt16();
            MPowerBase = reader.ReadUInt16();
            MPowerBonus = reader.ReadUInt16();

            if (version > 66)
                Range = reader.ReadByte();
            if (version > 70)
            {
                MultiplierBase = reader.ReadSingle();
                MultiplierBonus = reader.ReadSingle();
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="reader"></param>
 public override void FromNetwork(BinaryReader reader)
 {
     VelocityX = reader.ReadSingle();
     VelocityY = reader.ReadSingle();
     X = reader.ReadSingle();
     Y = reader.ReadSingle();
 }
Example #14
0
        public static void ReadFromFile(string file, out LineSet lineset)
        {
            Line[] lines;

            // Open the file. If it already exists, overwrite.
            using (FileStream fs = File.Open(@file, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    // Write number of lines.
                    lines = new Line[reader.ReadInt32()];

                    // Write line lengths in order.
                    for (int l = 0; l < lines.Length; ++l)
                        lines[l] = new Line() { Positions = new Vector3[reader.ReadInt32()] };

                    // Write positions.
                    float x, y, z;
                    foreach (Line line in lines)
                    {
                        for(int v = 0; v < line.Length; ++v)
                        {
                            x = reader.ReadSingle();
                            y = reader.ReadSingle();
                            z = reader.ReadSingle();
                            line[v] = new Vector3(x, y, z);
                        }
                    }

                }
            }

            lineset = new LineSet(lines);
        }
Example #15
0
 /// <inheritdoc></inheritdoc>
 public override void ReadHeader()
 {
     string location = FileIsEmbedded ? ManifestResourceString : GridFilePath;
     Name = Path.GetFileNameWithoutExtension(location);
     using (Stream str = GetStream())
     {
         if (str == null) return;
         using (BinaryReader br = new BinaryReader(str))
         {
             // read past 64 bytes of strings/nulls at start of file
             br.BaseStream.Seek(64, SeekOrigin.Begin);
             NumLambdas = br.ReadInt32();
             NumPhis = br.ReadInt32();
             br.ReadInt32(); // num z values: always 1
             PhiLam ll;
             ll.Lambda = br.ReadSingle() * DEG_TO_RAD;
             PhiLam cs;
             cs.Lambda = br.ReadSingle() * DEG_TO_RAD;
             ll.Phi = br.ReadSingle() * DEG_TO_RAD;
             LowerLeft = ll;
             cs.Phi = br.ReadSingle() * DEG_TO_RAD;
             CellSize = cs;
             Filled = false;
         }
     }
 }
Example #16
0
        public Material(SectionHeader header, Stream stream)
            : base(header, stream)
        {
            SectionHeader.Read(stream);
            var reader = new BinaryReader(stream);

            Flags = reader.ReadUInt32();
            Colour = new Color4(reader);
            reader.ReadUInt32();
            TextureCount = reader.ReadUInt32();
            Textures = new Texture[TextureCount];
            Ambient = reader.ReadSingle();
            Smoothness = reader.ReadSingle();
            Specular = 1f - reader.ReadSingle();

            for (var i = 0; i < TextureCount; ++i) {
                Textures[i] = ReadSection<Texture>();
            }

            var extensions = ReadSection<Extension>();

            var smoothness = Smoothness;
            var specular = Specular;

            extensions.ForEach<ReflectionMaterial>(x => specular = x.Intensity);
            extensions.ForEach<SpecularMaterial>(x => smoothness = x.SpecularLevel);

            Smoothness = smoothness;
            Specular = specular;
        }
Example #17
0
File: Phy.cs Project: Frassle/Ibasa
        private void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.ASCII);

            if (reader.ReadInt32() != 16)
                throw new InvalidDataException("File header is not 16.");

            Id = reader.ReadInt32();
            int solids = reader.ReadInt32();
            Checksum = reader.ReadInt32();


            for (int i = 0; i < solids; ++i)
            {
                int solidSize = reader.ReadInt32();
                string vphysics = Encoding.ASCII.GetString(reader.ReadBytes(4));
                int version = reader.ReadUInt16();
                int modelType = reader.ReadUInt16();
                int surfaceSize = reader.ReadInt32();
                Vector3f dragAxisAreas = new Vector3f(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                int axisMapSize = reader.ReadInt32();

                if (vphysics == "VPHY")
                {

                }
            }
        }
 public static CloudBallBallReplay Read(BinaryReader reader)
 {
     var ball = new CloudBallBallReplay();
     ball.X = reader.ReadSingle();
     ball.X = reader.ReadSingle();
     return ball;
 }
Example #19
0
		public static TextureInfo readTextureInfo(BinaryReader r) {
			TextureInfo t = new TextureInfo();
			t.texturePresent = r.ReadByte();
			
			if (t.texturePresent != 0) {
				t.unk1 = r.ReadByte();
				t.shaderNameIDX = r.ReadInt32();

				t.texturesCount = r.ReadByte();
				t.texturesArray = new TextureImageInfo[t.texturesCount];

				for (int i = 0; i < t.texturesCount; ++i) {
					t.texturesArray[i] = new TextureImageInfo();
					t.texturesArray[i].textureIDX = r.ReadUInt32();//String Dictionary Offset
					t.texturesArray[i].unk4 = r.ReadByte();
					t.texturesArray[i].repetition = r.ReadSingle();//Float
					t.texturesArray[i].unk6 = r.ReadInt32();
					t.texturesArray[i].unk7 = r.ReadInt32();
				}
				t.count2 = r.ReadUInt32();
				t.unk8 = new int[t.count2];
				for (int i = 0; i < t.count2; ++i) {
					t.unk8[i] = r.ReadInt32();
				}
				t.count3 = r.ReadUInt32();
				t.unk9 = new float[t.count3];
				for (int i = 0; i < t.count3; ++i) {
					t.unk9[i] = r.ReadSingle();
				}
			}
			return t;
		}
Example #20
0
 public Color(BinaryReader br)
 {
     red = br.ReadSingle();
     green = br.ReadSingle();
     blue = br.ReadSingle();
     alpha = br.ReadSingle();
 }
        public void Load()
        {
            try {
                if (File.Exists("kokororpg"))
                {
                    BinaryReader br = new BinaryReader(File.OpenRead("kokororpg"));
                    int count = br.ReadInt32();
                    int vers = br.ReadInt32();
                    if (vers == 1)
                    {
                        for (int i = 0; i < count; i++)
                        {
                            long id = br.ReadInt64();
                            float xp = br.ReadSingle();
                            int level = br.ReadInt32();
                            float hp = br.ReadSingle();
                            var plr = new KRPG_player(id);
                            plr.xp = xp;
                            plr.level = level;
                            plr.hp = hp;
                            players.Add(id, plr);
                        }
                    }

                    br.Close();
                }
            }
            catch(IOException)
            {
                Console.WriteLine("Did someone say IOException?");
            }
        }
Example #22
0
 public Plane(BinaryReader reader)
 {
     normal[0] = reader.ReadSingle();
     normal[1] = reader.ReadSingle();
     normal[2] = reader.ReadSingle();
     distance = reader.ReadSingle();
 }
Example #23
0
 public void Read(BinaryReader br)
 {
     X = br.ReadSingle();
     Y = br.ReadSingle();
     Z = br.ReadSingle();
     W = br.ReadSingle();
 }
Example #24
0
 public void LoadFromStream(BinaryReader reader)
 {
     this.R = reader.ReadSingle();
       this.G = reader.ReadSingle();
       this.B = reader.ReadSingle();
       this.A = reader.ReadSingle();
 }
Example #25
0
        public float Unknown4; //1

        public static int Deserialise(BinaryReader reader, GameObject parent)
        {
            GameObject go = new GameObject("SubSubMesh Group");
            go.isStatic = true;
            SubSubMeshGroup group = go.AddComponent<SubSubMeshGroup>();
            go.transform.SetParent(parent.transform);

            int NextOffset = reader.ReadInt32();
            reader.SkipInt32(48);
            reader.SkipInt32(); //Length
            reader.SkipInt32(0);

            group.Illumination = reader.ReadInt32();
            reader.SkipInt32(0);
            reader.SkipInt32(0);
            reader.SkipInt32(0);

            group.Unknown1 = reader.ReadSingle();
            group.Unknown2 = reader.ReadSingle();
            group.Unknown3 = reader.ReadSingle();
            group.Unknown4 = reader.ReadSingle();

            int next;
            do
            {
                next = MeshPart.Deserialise(reader, go);

            } while (next != 0);


            return NextOffset;
        }
 public List<PageItem> Process(int Flags, byte[] RecordData)
 {
     MemoryStream _ms = null;
     BinaryReader _br = null;
     MemoryStream _fs = null;
     BinaryReader _fr = null;
     try
     {
         _fs = new MemoryStream(BitConverter.GetBytes(Flags));
         _fr = new BinaryReader(_fs);
         _fr.ReadByte();
         //Byte 2 is the real flags
         byte RealFlags = _fr.ReadByte();
         // 0 1 2 3 4 5 6 7
         // X X X X X X C S                
         // if C = 1 Data int16 else float!
         bool Compressed = ((RealFlags & (int)Math.Pow(2, 6)) == (int)Math.Pow(2, 6));
         bool BrushIsARGB = ((RealFlags & (int)Math.Pow(2, 7)) == (int)Math.Pow(2, 7));
         _ms = new MemoryStream(RecordData);
         _br = new BinaryReader(_ms);
         Brush b;
         if (BrushIsARGB)
         {
             byte A, R, G, B;
             B = _br.ReadByte();
             G = _br.ReadByte();
             R = _br.ReadByte();
             A = _br.ReadByte();
             b = new SolidBrush(Color.FromArgb(A, R, G, B));
         }
         else
         {
             UInt32 BrushID = _br.ReadUInt32();
             EMFBrush EMFb = (EMFBrush)ObjectTable[(byte)BrushID];
             b = EMFb.myBrush;
         }
         Single StartAngle = _br.ReadSingle();
         Single SweepAngle = _br.ReadSingle();
         if (Compressed)
         {
             DoCompressed(StartAngle,SweepAngle, _br, b);
         }
         else
         {
             DoFloat(StartAngle,SweepAngle, _br, b);
         }
         return items;
     }
     finally
     {
         if (_br != null)
             _br.Close();
         if (_ms != null)
             _ms.Dispose();
         if (_fr != null)
             _fr.Close();
         if (_fs != null)
             _fs.Dispose();
     }
 }
Example #27
0
 internal override void DeserializeBody(BinaryReader stream)
 {
     this.mVelocityDesired = stream.ReadSingle();
     this.mIntegral = stream.ReadSingle();
     this.mAngleGain = stream.ReadSingle();
     this.mThrottle = stream.ReadSingle();
 }
Example #28
0
        /// <summary>
        /// Reads a *.anim file into this Anim instance.
        /// </summary>
        /// <param name="FileData">The filedata for the *.anim file.</param>
        public Anim(byte[] FileData)
        {
            MemoryStream MemStream = new MemoryStream(FileData);
            BinaryReader Reader = new BinaryReader(MemStream);

            m_Version = Endian.SwapUInt32(Reader.ReadUInt32());
            m_Name = Encoding.ASCII.GetString(Reader.ReadBytes(Endian.SwapInt16(Reader.ReadInt16())));
            m_Duration = Reader.ReadSingle() / 1000; //Why does this have to be divided by 1000? o_O
            m_Distance = Reader.ReadSingle();
            m_IsMoving = Reader.ReadByte();

            m_NumTranslations = Endian.SwapUInt32(Reader.ReadUInt32());
            m_TranslationsTableOffset = Reader.BaseStream.Position;

            Reader.BaseStream.Seek(m_TranslationsTableOffset + 12 * m_NumTranslations, SeekOrigin.Begin);

            m_NumRotations = Endian.SwapUInt32(Reader.ReadUInt32());
            m_RotationsTableOffset = Reader.BaseStream.Position;

            Reader.BaseStream.Seek(m_RotationsTableOffset + 16 * m_NumRotations, SeekOrigin.Begin);

            m_MotionCount = Endian.SwapUInt32(Reader.ReadUInt32());

            for (int i = 0; i < m_MotionCount; i++)
                m_Motions.Add(ReadMotion(Reader));
        }
Example #29
0
 internal override void DeserializeBody(BinaryReader stream)
 {
     this.mForward = stream.ReadSingle();
     this.mRight = stream.ReadSingle();
     this.mUpwards = stream.ReadSingle();
     this.mFrame = (LoiterCommand_Frame)stream.ReadByte();
 }
Example #30
0
 public override void Read(Stream input)
 {
     BinaryReader reader = new BinaryReader(input, Encoding.Default, true);
     X = reader.ReadSingle();
     Y = reader.ReadSingle();
     Z = reader.ReadSingle();
     W = reader.ReadSingle();
 }