private void Parse( string _Content ) { Parser P = new Parser( _Content ); List<Entity> Entities = new List<Entity>(); P.ConsumeString( "Version" ); int Version = P.ReadInteger(); if ( Version != 4 ) P.Error( "Unsupported file version!" ); while ( P.OK ) { P.ConsumeString( "entity" ); string Block = P.ReadBlock(); Entity E = new Entity( this ); if ( E.Parse( Block ) ) { Entities.Add( E ); } P.SkipSpaces(); } m_Entities.AddRange( Entities ); // Parse all refmaps foreach ( Entity E in Entities ) if ( E.m_Type == Entity.TYPE.REF_MAP ) { using ( StreamReader R = new FileInfo( E.m_RefMapName ).OpenText() ) { string Content = R.ReadToEnd(); Parse( Content ); } } }
private void Parse(string _Content) { Parser P = new Parser(_Content); List <Entity> Entities = new List <Entity>(); P.ConsumeString("Version"); int Version = P.ReadInteger(); if (Version != 4) { P.Error("Unsupported file version!"); } while (P.OK) { P.ConsumeString("entity"); string Block = P.ReadBlock(); Entity E = new Entity(this); if (E.Parse(Block)) { Entities.Add(E); } P.SkipSpaces(); } m_Entities.AddRange(Entities); // Parse all refmaps foreach (Entity E in Entities) { if (E.m_Type == Entity.TYPE.REF_MAP) { using (StreamReader R = new FileInfo(E.m_RefMapName).OpenText()) { string Content = R.ReadToEnd(); Parse(Content); } } } }
private void ParseOrientation(string _Orientation) { Parser P = new Parser(_Orientation); P.ConsumeString("mat = "); string Rows = P.ReadBlock(); P = new Parser(Rows); string row = P.ReadString(); while (P.OK) { P.ConsumeString("= "); switch (row) { case "mat[0]": { float3 value = P.ReadFloat3(float3.UnitX); m_Local2World.r0.Set(value, m_Local2World.r0.w); break; } case "mat[1]": { float3 value = P.ReadFloat3(float3.UnitY); m_Local2World.r1.Set(value, m_Local2World.r1.w); break; } case "mat[2]": { float3 value = P.ReadFloat3(float3.UnitZ); m_Local2World.r2.Set(value, m_Local2World.r2.w); break; } default: P.Error("Unexpected coordinate!"); break; } row = P.ReadString(); } }
private void ParseOrientation( string _Orientation ) { Parser P = new Parser( _Orientation ); P.ConsumeString( "mat = " ); string Rows = P.ReadBlock(); P = new Parser( Rows ); string row = P.ReadString(); while ( P.OK ) { P.ConsumeString( "= " ); switch ( row ) { case "mat[0]": { float3 value = P.ReadFloat3( float3.UnitX ); m_Local2World.r0.Set( value, m_Local2World.r0.w ); break; } case "mat[1]": { float3 value = P.ReadFloat3( float3.UnitY ); m_Local2World.r1.Set( value, m_Local2World.r1.w ); break; } case "mat[2]": { float3 value = P.ReadFloat3( float3.UnitZ ); m_Local2World.r2.Set( value, m_Local2World.r2.w ); break; } default: P.Error( "Unexpected coordinate!" ); break; } row = P.ReadString(); } }
private void ParseContent( string _Content ) { Parser P = new Parser( _Content ); string property = P.ReadString(); while ( P.OK ) { switch ( property ) { case "spawnPosition": P.ConsumeString( "= " ); float3 Position = P.ReadFloat3( float3.Zero ); m_Local2World.r0.w = Position.x; m_Local2World.r1.w = Position.y; m_Local2World.r2.w = Position.z; break; case "spawnOrientation": P.ConsumeString( "= " ); string Orientation = P.ReadBlock(); ParseOrientation( Orientation ); break; case "renderModelInfo": P.ConsumeString( "= ! " ); string Model = P.ReadBlock(); ParseModel( Model ); break; case "m_probe": P.ConsumeString( "= " ); string ProbeName = P.UnQuote( P.ReadToEOL(), true ); break; case "mapname": P.ConsumeString( "= " ); m_RefMapName = RebaseFileName( P.UnQuote( P.ReadToEOL(), true ), "T:/", null ); break; case "m_usedForIBL": P.ReadToEOL(); m_IBL = true; break; // Don't care... (single line) case "entityPrefix": P.ReadToEOL(); break; // Don't care... (block) case "m_bounceFactorSun": case "m_kiscule": P.ConsumeString( "= " ); P.ReadBlock(); break; case "//": // Skip comment P.ReadToEOL(); break; default: P.Error( "Unexpected property!" ); break; } property = P.ReadString(); } }
private void ParseContent(string _Content) { Parser P = new Parser(_Content); string property = P.ReadString(); while (P.OK) { switch (property) { case "spawnPosition": P.ConsumeString("= "); float3 Position = P.ReadFloat3(float3.Zero); m_Local2World.r0.w = Position.x; m_Local2World.r1.w = Position.y; m_Local2World.r2.w = Position.z; break; case "spawnOrientation": P.ConsumeString("= "); string Orientation = P.ReadBlock(); ParseOrientation(Orientation); break; case "renderModelInfo": P.ConsumeString("= ! "); string Model = P.ReadBlock(); ParseModel(Model); break; case "m_probe": P.ConsumeString("= "); string ProbeName = P.UnQuote(P.ReadToEOL(), true); break; case "mapname": P.ConsumeString("= "); m_RefMapName = RebaseFileName(P.UnQuote(P.ReadToEOL(), true), "T:/", null); break; case "m_usedForIBL": P.ReadToEOL(); m_IBL = true; break; // Don't care... (single line) case "entityPrefix": P.ReadToEOL(); break; // Don't care... (block) case "m_bounceFactorSun": case "m_kiscule": P.ConsumeString("= "); P.ReadBlock(); break; case "//": // Skip comment P.ReadToEOL(); break; default: P.Error("Unexpected property!"); break; } property = P.ReadString(); } }