public float3 ReadFloat3(float3 _InitialValue) { string Block = ReadBlock(); Parser P = new Parser(Block); float3 Result = _InitialValue; string coord = P.ReadString(); while (P.OK) { P.ConsumeString("= "); float value = P.ReadFloat(); P.ConsumeString(";"); switch (coord) { case "x": Result.x = value; break; case "y": Result.y = value; break; case "z": Result.z = value; break; default: Error("Unexpected coordinate!"); break; } coord = P.ReadString(); } return(Result); }
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 ParseModel(string _Model) { Parser P = new Parser(_Model); P.ConsumeString("model = "); string ModelFileName = RebaseFileName(P.ReadString(true, true), "T:/generated/model/", ".bmodel"); m_Model = new Model(ModelFileName); }
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); } } } }
public bool Parse(string _Block) { Parser P = new Parser(_Block); P.ConsumeString("entityDef"); m_Name = P.ReadString(); string entityDef = P.ReadBlock(); return(ParseEntityDef(entityDef)); }
private bool ParseEntityDef(string _Block) { Parser P = new Parser(_Block); P.ConsumeString("inherit ="); string inherit = P.ReadString(true, true); if (inherit == "func/static") { m_Type = TYPE.MODEL; } else if (inherit == "player/start") { m_Type = TYPE.PLAYER_START; } else if (inherit == "blacksparrow/probe") { m_Type = TYPE.PROBE; } else if (inherit == "func/reference") { m_Type = TYPE.REF_MAP; } if (m_Type == TYPE.UNKNOWN) { return(false); } P.ConsumeString("editorVars"); P.ReadBlock(); P.ConsumeString("edit ="); string Content = P.ReadBlock(); ParseContent(Content); return(true); }
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 ParseModel( string _Model ) { Parser P = new Parser( _Model ); P.ConsumeString( "model = " ); string ModelFileName = RebaseFileName( P.ReadString( true, true ), "T:/generated/model/", ".bmodel" ); m_Model = new Model( ModelFileName ); }
private bool ParseEntityDef( string _Block ) { Parser P = new Parser( _Block ); P.ConsumeString( "inherit =" ); string inherit = P.ReadString( true, true ); if ( inherit == "func/static" ) { m_Type = TYPE.MODEL; } else if ( inherit == "player/start" ) { m_Type = TYPE.PLAYER_START; } else if ( inherit == "blacksparrow/probe" ) { m_Type = TYPE.PROBE; } else if ( inherit == "func/reference" ) { m_Type = TYPE.REF_MAP; } if ( m_Type == TYPE.UNKNOWN ) return false; P.ConsumeString( "editorVars" ); P.ReadBlock(); P.ConsumeString( "edit =" ); string Content = P.ReadBlock(); ParseContent( Content ); return true; }
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(); } }
public bool Parse( string _Block ) { Parser P = new Parser( _Block ); P.ConsumeString( "entityDef" ); m_Name = P.ReadString(); string entityDef = P.ReadBlock(); return ParseEntityDef( entityDef ); }
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(); } }
public float3 ReadFloat3( float3 _InitialValue) { string Block = ReadBlock(); Parser P = new Parser( Block ); float3 Result = _InitialValue; string coord = P.ReadString(); while ( P.OK ) { P.ConsumeString( "= " ); float value = P.ReadFloat(); P.ConsumeString( ";" ); switch ( coord ) { case "x": Result.x = value; break; case "y": Result.y = value; break; case "z": Result.z = value; break; default: Error( "Unexpected coordinate!" ); break; } coord = P.ReadString(); } return Result; }