コード例 #1
0
        public override bool Parse(string text)
        {
            idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            idToken token;
            string  tokenValue;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenValue = token.ToString().ToLower();

                if (tokenValue == "}")
                {
                    break;
                }

                if (tokenValue == "audio")
                {
                    _audio = lexer.ReadToken().ToString();
                    idE.DeclManager.FindSound(_audio);
                }
                else if (tokenValue == "info")
                {
                    _info = lexer.ReadToken().ToString();
                }
                else if (tokenValue == "name")
                {
                    _videoName = lexer.ReadToken().ToString();
                }
                else if (tokenValue == "preview")
                {
                    _preview = lexer.ReadToken().ToString();
                }
                else if (tokenValue == "video")
                {
                    _video = lexer.ReadToken().ToString();
                    idE.DeclManager.FindMaterial(_video);
                }
            }

            if (lexer.HadError == true)
            {
                lexer.Warning("Video decl '{0}' had a parse error", this.Name);
                return(false);
            }

            return(true);
        }
コード例 #2
0
ファイル: idDeclFX.cs プロジェクト: PEMantis/idtech4.net
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            idToken token;
            string  tokenValue;

            idConsole.Warning("TODO: actual fx parsing, we only step over the block");

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenValue = token.ToString().ToLower();

                if (tokenValue == "}")
                {
                    break;
                }

                if (tokenValue == "bindto")
                {
                    token = lexer.ReadToken();

                    idConsole.Warning("TODO: FX: joint = token;");
                }
                else if (tokenValue == "{")
                {
                    idConsole.Warning("TODO: FX: idFXSingleAction action;");
                    ParseSingleAction(lexer /*, action*/);
                    // events.Append(action);
                    continue;
                }
            }

            if (lexer.HadError == true)
            {
                lexer.Warning("FX decl '{0}' had a parse error", this.Name);
                return(false);
            }
            return(true);
        }
コード例 #3
0
ファイル: idDeclSkin.cs プロジェクト: iainmckay/idtech4.net
		public override bool Parse(string text)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idLexer lexer = new idLexer(idDeclFile.LexerOptions);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			List<SkinMapping> mappings = new List<SkinMapping>();
			List<string> associatedModels = new List<string>();

			idToken token, token2;
			string tokenLower;

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenLower = token.ToString().ToLower();

				if(tokenLower == "}")
				{
					break;
				}
				else if((token2 = lexer.ReadToken()) == null)
				{
					lexer.Warning("Unexpected end of file");
					MakeDefault();

					break;
				}
				else if(tokenLower == "model")
				{
					associatedModels.Add(token2.ToString());
					continue;
				}

				SkinMapping map = new SkinMapping();
				map.To = idE.DeclManager.FindMaterial(token2.ToString());

				if(tokenLower == "*")
				{
					// wildcard.
					map.From = null;
				}
				else
				{
					map.From = idE.DeclManager.FindMaterial(token.ToString());
				}
				
				mappings.Add(map);
			}

			_mappings = mappings.ToArray();
			_associatedModels = associatedModels.ToArray();

			return false;
		}
コード例 #4
0
        /// <summary>
        /// This is used during both the initial load, and any reloads.
        /// </summary>
        /// <returns></returns>
        public int LoadAndParse()
        {
            // load the text
            idConsole.DeveloperWriteLine("...loading '{0}'", this.FileName);

            byte[] data = idE.FileSystem.ReadFile(this.FileName);

            if (data == null)
            {
                idConsole.FatalError("couldn't load {0}", this.FileName);
                return(0);
            }

            string  content = UTF8Encoding.UTF8.GetString(data);
            idLexer lexer   = new idLexer();

            lexer.Options = LexerOptions;

            if (lexer.LoadMemory(content, this.FileName) == false)
            {
                idConsole.Error("Couldn't parse {0}", this.FileName);
                return(0);
            }

            // mark all the defs that were from the last reload of this file
            foreach (idDecl decl in _decls)
            {
                decl.RedefinedInReload = false;
            }

            // TODO: checksum = MD5_BlockChecksum( buffer, length );

            _fileSize = content.Length;

            int      startMarker, sourceLine;
            int      size;
            string   name;
            bool     reparse;
            idToken  token;
            idDecl   newDecl;
            DeclType identifiedType;

            string tokenValue;

            // scan through, identifying each individual declaration
            while (true)
            {
                startMarker = lexer.FileOffset;
                sourceLine  = lexer.LineNumber;

                // parse the decl type name
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenValue = token.ToString();

                // get the decl type from the type name
                identifiedType = idE.DeclManager.GetDeclTypeFromName(tokenValue);

                if (identifiedType == DeclType.Unknown)
                {
                    if (tokenValue == "{")
                    {
                        // if we ever see an open brace, we somehow missed the [type] <name> prefix
                        lexer.Warning("Missing decl name");
                        lexer.SkipBracedSection(false);

                        continue;
                    }
                    else
                    {
                        if (this.DefaultType == DeclType.Unknown)
                        {
                            lexer.Warning("No type");
                            continue;
                        }

                        lexer.UnreadToken = token;

                        // use the default type
                        identifiedType = this.DefaultType;
                    }
                }

                // now parse the name
                if ((token = lexer.ReadToken()) == null)
                {
                    lexer.Warning("Type without definition at the end of file");
                    break;
                }

                tokenValue = token.ToString();

                if (tokenValue == "{")
                {
                    // if we ever see an open brace, we somehow missed the [type] <name> prefix
                    lexer.Warning("Missing decl name");
                    lexer.SkipBracedSection(false);

                    continue;
                }

                // FIXME: export decls are only used by the model exporter, they are skipped here for now
                if (identifiedType == DeclType.ModelExport)
                {
                    lexer.SkipBracedSection();
                    continue;
                }

                name = tokenValue;

                // make sure there's a '{'
                if ((token = lexer.ReadToken()) == null)
                {
                    lexer.Warning("Type without definition at end of file");
                    break;
                }

                tokenValue = token.ToString();

                if (tokenValue != "{")
                {
                    lexer.Warning("Expecting '{{' but found '{0}'", tokenValue);
                    continue;
                }

                lexer.UnreadToken = token;

                // now take everything until a matched closing brace
                lexer.SkipBracedSection();
                size = lexer.FileOffset - startMarker;

                // look it up, possibly getting a newly created default decl
                reparse = false;
                newDecl = idE.DeclManager.FindTypeWithoutParsing(identifiedType, name, false);

                if (newDecl != null)
                {
                    // update the existing copy
                    if ((newDecl.SourceFile != this) || (newDecl.RedefinedInReload == true))
                    {
                        lexer.Warning("{0} '{1}' previously defined at {2}:{3}", identifiedType.ToString().ToLower(), name, newDecl.FileName, newDecl.LineNumber);
                        continue;
                    }

                    if (newDecl.State != DeclState.Unparsed)
                    {
                        reparse = true;
                    }
                }
                else
                {
                    // allow it to be created as a default, then add it to the per-file list
                    newDecl = idE.DeclManager.FindTypeWithoutParsing(identifiedType, name, true);

                    if (newDecl == null)
                    {
                        lexer.Warning("could not instanciate decl '{0}' with name '{1}'", identifiedType.ToString().ToLower(), name);
                        continue;
                    }

                    _decls.Add(newDecl);
                }

                newDecl.RedefinedInReload = true;
                newDecl.SourceText        = content.Substring(startMarker, size);
                newDecl.SourceFile        = this;
                newDecl.SourceTextOffset  = startMarker;
                newDecl.SourceTextLength  = size;
                newDecl.SourceLine        = sourceLine;
                newDecl.State             = DeclState.Unparsed;

                // if it is currently in use, reparse it immedaitely
                if (reparse)
                {
                    newDecl.ParseLocal();
                }
            }

            _lineCount = lexer.LineNumber;

            // any defs that weren't redefinedInReload should now be defaulted
            foreach (idDecl decl in _decls)
            {
                if (decl.RedefinedInReload == false)
                {
                    decl.MakeDefault();
                    decl.SourceTextOffset = decl.SourceFile.FileSize;
                    decl.SourceTextLength = 0;
                    decl.SourceLine       = decl.SourceFile.LineCount;
                }
            }

            return(_checksum);
        }
コード例 #5
0
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            idToken token;

            _text = string.Empty;

            string tokenLower;
            string tokenValue;

            // scan through, identifying each individual parameter
            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenValue = token.ToString();
                tokenLower = tokenValue.ToLower();

                if (tokenValue == "}")
                {
                    break;
                }
                else if (tokenLower == "subject")
                {
                    _subject = lexer.ReadToken().ToString();
                }
                else if (tokenLower == "to")
                {
                    _to = lexer.ReadToken().ToString();
                }
                else if (tokenLower == "from")
                {
                    _from = lexer.ReadToken().ToString();
                }
                else if (tokenLower == "date")
                {
                    _date = lexer.ReadToken().ToString();
                }
                else if (tokenLower == "text")
                {
                    token      = lexer.ReadToken();
                    tokenValue = token.ToString();

                    if (tokenValue != "{")
                    {
                        lexer.Warning("Email dec '{0}' had a parse error", this.Name);
                        return(false);
                    }

                    while (((token = lexer.ReadToken()) != null) && (token.ToString() != "}"))
                    {
                        _text += token.ToString();
                    }
                }
                else if (tokenLower == "image")
                {
                    _image = lexer.ReadToken().ToString();
                }
            }

            if (lexer.HadError == true)
            {
                lexer.Warning("Email decl '{0}' had a parse error", this.Name);
                return(false);
            }

            return(true);
        }
コード例 #6
0
ファイル: idDeclPDA.cs プロジェクト: PEMantis/idtech4.net
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idToken token;
            string  tokenLower;

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenLower = token.ToString().ToLower();

                if (tokenLower == "}")
                {
                    break;
                }
                else if (tokenLower == "name")
                {
                    token    = lexer.ReadToken();
                    _pdaName = (token != null) ? token.ToString() : string.Empty;
                }
                else if (tokenLower == "fullname")
                {
                    token     = lexer.ReadToken();
                    _fullName = (token != null) ? token.ToString() : string.Empty;
                }
                else if (tokenLower == "icon")
                {
                    token = lexer.ReadToken();
                    _icon = (token != null) ? token.ToString() : string.Empty;
                }
                else if (tokenLower == "id")
                {
                    token = lexer.ReadToken();
                    _id   = (token != null) ? token.ToString() : string.Empty;
                }
                else if (tokenLower == "post")
                {
                    token = lexer.ReadToken();
                    _post = (token != null) ? token.ToString() : string.Empty;
                }
                else if (tokenLower == "title")
                {
                    token  = lexer.ReadToken();
                    _title = (token != null) ? token.ToString() : string.Empty;
                }
                else if (tokenLower == "security")
                {
                    token     = lexer.ReadToken();
                    _security = (token != null) ? token.ToString() : string.Empty;
                }
                else if (tokenLower == "pda_email")
                {
                    token = lexer.ReadToken();
                    _emailList.Add(token.ToString());

                    idE.DeclManager.FindType(DeclType.Email, token.ToString());
                }
                else if (tokenLower == "pda_audio")
                {
                    token = lexer.ReadToken();
                    _audioList.Add(token.ToString());

                    idE.DeclManager.FindType(DeclType.Audio, token.ToString());
                }
                else if (tokenLower == "pda_video")
                {
                    token = lexer.ReadToken();
                    _videoList.Add(token.ToString());

                    idE.DeclManager.FindType(DeclType.Video, token.ToString());
                }
            }

            if (lexer.HadError == true)
            {
                lexer.Warning("PDA decl '{0}' had a parse error", this.Name);
                return(false);
            }

            _originalVideoCount = _videoList.Count;
            _originalEmailCount = _emailList.Count;

            return(true);
        }
コード例 #7
0
ファイル: idDeclFX.cs プロジェクト: PEMantis/idtech4.net
        private void ParseSingleAction(idLexer lexer /*idFXSingleAction& FXAction*/)
        {
            idToken token;
            string  tokenValue;

            /*FXAction.type = -1;
             * FXAction.sibling = -1;
             *
             * FXAction.data = "<none>";
             * FXAction.name = "<none>";
             * FXAction.fire = "<none>";
             *
             * FXAction.delay = 0.0f;
             * FXAction.duration = 0.0f;
             * FXAction.restart = 0.0f;
             * FXAction.size = 0.0f;
             * FXAction.fadeInTime = 0.0f;
             * FXAction.fadeOutTime = 0.0f;
             * FXAction.shakeTime = 0.0f;
             * FXAction.shakeAmplitude = 0.0f;
             * FXAction.shakeDistance = 0.0f;
             * FXAction.shakeFalloff = false;
             * FXAction.shakeImpulse = 0.0f;
             * FXAction.shakeIgnoreMaster = false;
             * FXAction.lightRadius = 0.0f;
             * FXAction.rotate = 0.0f;
             * FXAction.random1 = 0.0f;
             * FXAction.random2 = 0.0f;
             *
             * FXAction.lightColor = vec3_origin;
             * FXAction.offset = vec3_origin;
             * FXAction.axis = mat3_identity;
             *
             * FXAction.bindParticles = false;
             * FXAction.explicitAxis = false;
             * FXAction.noshadows = false;
             * FXAction.particleTrackVelocity = false;
             * FXAction.trackOrigin = false;
             * FXAction.soundStarted = false;*/

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenValue = token.ToString().ToLower();

                if (tokenValue == "}")
                {
                    break;
                }
                else if (tokenValue == "shake")
                {
                    /*FXAction.type = FX_SHAKE;*/
                    /*FXAction.shakeTime = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.shakeAmplitude = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.shakeDistance = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.shakeFalloff = */ lexer.ParseBool();
                    lexer.ExpectTokenString(",");
                    /*FXAction.shakeImpulse = */ lexer.ParseFloat();
                }
                else if (tokenValue == "noshadows")
                {
                    // TODO: FXAction.noshadows = true;
                }
                else if (tokenValue == "name")
                {
                    token = lexer.ReadToken();
                    // TODO: FXAction.name = token;
                }
                else if (tokenValue == "fire")
                {
                    token = lexer.ReadToken();
                    // TODO: FXAction.fire = token;
                }
                else if (tokenValue == "random")
                {
                    /*FXAction.random1 = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.random2 = */ lexer.ParseFloat();
                    // FXAction.delay = 0.0f;		// check random
                }
                else if (tokenValue == "delay")
                {
                    /*FXAction.delay = */ lexer.ParseFloat();
                }
                else if (tokenValue == "rotate")
                {
                    /*FXAction.rotate = */ lexer.ParseFloat();
                }
                else if (tokenValue == "duration")
                {
                    /*FXAction.duration = */ lexer.ParseFloat();
                }
                else if (tokenValue == "trackorigin")
                {
                    /*FXAction.trackOrigin = */ lexer.ParseBool();
                }
                else if (tokenValue == "restart")
                {
                    /*FXAction.restart = */ lexer.ParseFloat();
                }
                else if (tokenValue == "fadein")
                {
                    /*FXAction.fadeInTime = */ lexer.ParseFloat();
                }
                else if (tokenValue == "fadeout")
                {
                    /*FXAction.fadeOutTime = */ lexer.ParseFloat();
                }
                else if (tokenValue == "size")
                {
                    /*FXAction.size = */ lexer.ParseFloat();
                }
                else if (tokenValue == "offset")
                {
                    /*FXAction.offset.x = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.offset.y = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.offset.z = */ lexer.ParseFloat();
                }
                else if (tokenValue == "axis")
                {
                    /*idVec3 v;*/
                    /*v.x = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*v.y = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*v.z = */ lexer.ParseFloat();

                    /*v.Normalize();
                     * FXAction.axis = v.ToMat3();
                     * FXAction.explicitAxis = true;*/
                }
                else if (tokenValue == "angle")
                {
                    /*idAngles a;*/
                    /*a[0] = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*a[1] = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*a[2] = */ lexer.ParseFloat();

                    /*FXAction.axis = a.ToMat3();
                     * FXAction.explicitAxis = true;*/
                }
                else if (tokenValue == "uselight")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * for( int i = 0; i < events.Num(); i++ ) {
                     *      if ( events[i].name.Icmp( FXAction.data ) == 0 ) {
                     *              FXAction.sibling = i;
                     *              FXAction.lightColor = events[i].lightColor;
                     *              FXAction.lightRadius = events[i].lightRadius;
                     *      }
                     * }
                     * FXAction.type = FX_LIGHT;
                     *
                     * // precache the light material
                     * declManager->FindMaterial( FXAction.data );*/
                }
                else if (tokenValue == "attachlight")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_ATTACHLIGHT;
                     *
                     * // precache it
                     * declManager->FindMaterial( FXAction.data );*/
                }
                else if (tokenValue == "attachentity")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_ATTACHENTITY;
                     *
                     * // precache the model
                     * renderModelManager->FindModel( FXAction.data );*/
                }
                else if (tokenValue == "launch")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_LAUNCH;
                     *
                     * // precache the entity def
                     * declManager->FindType( DECL_ENTITYDEF, FXAction.data );*/
                }
                else if (tokenValue == "usemodel")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * for( int i = 0; i < events.Num(); i++ ) {
                     *      if ( events[i].name.Icmp( FXAction.data ) == 0 ) {
                     *              FXAction.sibling = i;
                     *      }
                     * }
                     * FXAction.type = FX_MODEL;
                     *
                     * // precache the model
                     * renderModelManager->FindModel( FXAction.data );*/
                }
                else if (tokenValue == "light")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;*/
                    lexer.ExpectTokenString(",");
                    /*FXAction.lightColor[0] = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.lightColor[1] = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.lightColor[2] = */ lexer.ParseFloat();
                    lexer.ExpectTokenString(",");
                    /*FXAction.lightRadius = */ lexer.ParseFloat();

                    /*FXAction.type = FX_LIGHT;
                     *
                     * // precache the light material
                     * declManager->FindMaterial( FXAction.data );*/
                }
                else if (tokenValue == "model")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_MODEL;
                     *
                     * // precache it
                     * renderModelManager->FindModel( FXAction.data );*/
                }
                else if (tokenValue == "particle")                // FIXME: now the same as model
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_PARTICLE;
                     *
                     * // precache it
                     * renderModelManager->FindModel( FXAction.data );*/
                }
                else if (tokenValue == "decal")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_DECAL;
                     *
                     * // precache it
                     * declManager->FindMaterial( FXAction.data );*/
                }
                else if (tokenValue == "particletrackvelocity")
                {
                    // TODO: FXAction.particleTrackVelocity = true;
                }
                else if (tokenValue == "sound")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_SOUND;
                     *
                     * // precache it
                     * declManager->FindSound( FXAction.data );*/
                }
                else if (tokenValue == "ignoremaster")
                {
                    /*FXAction.shakeIgnoreMaster = true;*/
                }
                else if (tokenValue == "shockwave")
                {
                    token = lexer.ReadToken();

                    /*FXAction.data = token;
                     * FXAction.type = FX_SHOCKWAVE;
                     *
                     * // precache the entity def
                     * declManager->FindType( DECL_ENTITYDEF, FXAction.data );*/
                }
                else
                {
                    lexer.Warning("FX File: bad token");
                }
            }
        }
コード例 #8
0
        public void Parse(idLexer lexer, idJointMatrix[] joints)
        {
            lexer.ExpectTokenString("{");

            //
            // parse name
            //
            if (lexer.CheckTokenString("name") == true)
            {
                lexer.ReadToken();
            }

            //
            // parse shader
            //
            lexer.ExpectTokenString("shader");

            idToken token        = lexer.ReadToken();
            string  materialName = token.ToString();

            _material = idE.DeclManager.FindMaterial(materialName);

            //
            // parse texture coordinates
            //
            lexer.ExpectTokenString("numverts");
            int count = lexer.ParseInt();

            if (count < 0)
            {
                lexer.Error("Invalid size: {0}", token.ToString());
            }

            _texCoords = new Vector2[count];

            int[] firstWeightForVertex = new int[count];
            int[] weightCountForVertex = new int[count];
            int   maxWeight            = 0;
            int   coordCount           = _texCoords.Length;

            _weightCount = 0;

            for (int i = 0; i < coordCount; i++)
            {
                lexer.ExpectTokenString("vert");
                lexer.ParseInt();

                float[] tmp = lexer.Parse1DMatrix(2);

                _texCoords[i] = new Vector2(tmp[0], tmp[1]);

                firstWeightForVertex[i] = lexer.ParseInt();
                weightCountForVertex[i] = lexer.ParseInt();

                if (weightCountForVertex[i] == 0)
                {
                    lexer.Error("Vertex without any joint weights.");
                }

                _weightCount += weightCountForVertex[i];

                if ((weightCountForVertex[i] + firstWeightForVertex[i]) > maxWeight)
                {
                    maxWeight = weightCountForVertex[i] + firstWeightForVertex[i];
                }
            }

            //
            // parse tris
            //
            lexer.ExpectTokenString("numtris");
            _triangleCount = lexer.ParseInt();

            if (_triangleCount < 0)
            {
                lexer.Error("Invalid size: {0}", _triangleCount);
            }

            int[] tris = new int[_triangleCount * 3];

            for (int i = 0; i < _triangleCount; i++)
            {
                lexer.ExpectTokenString("tri");
                lexer.ParseInt();

                tris[i * 3 + 0] = lexer.ParseInt();
                tris[i * 3 + 1] = lexer.ParseInt();
                tris[i * 3 + 2] = lexer.ParseInt();
            }

            //
            // parse weights
            //
            lexer.ExpectTokenString("numweights");
            count = lexer.ParseInt();

            if (count < 0)
            {
                lexer.Error("Invalid size: {0}", count);
            }

            if (maxWeight > count)
            {
                lexer.Warning("Vertices reference out of range weights in model ({0} of {1} weights).", maxWeight, count);
            }

            VertexWeight[] tempWeights = new VertexWeight[count];

            for (int i = 0; i < count; i++)
            {
                lexer.ExpectTokenString("weight");
                lexer.ParseInt();

                int jointIndex = lexer.ParseInt();

                if ((jointIndex < 0) || (jointIndex >= joints.Length))
                {
                    lexer.Error("Joint index out of range({0}): {1}", joints.Length, jointIndex);
                }

                tempWeights[i].JointIndex  = jointIndex;
                tempWeights[i].JointWeight = lexer.ParseFloat();

                float[] tmp = lexer.Parse1DMatrix(3);

                tempWeights[i].Offset = new Vector3(tmp[0], tmp[1], tmp[2]);
            }

            // create pre-scaled weights and an index for the vertex/joint lookup
            _scaledWeights = new Vector4[_weightCount];
            _weightIndex   = new int[_weightCount * 2];

            count      = 0;
            coordCount = _texCoords.Length;

            for (int i = 0; i < coordCount; i++)
            {
                int num         = firstWeightForVertex[i];
                int weightCount = weightCountForVertex[i];

                for (int j = 0; j < weightCount; j++, num++, count++)
                {
                    Vector3 tmp = tempWeights[num].Offset * tempWeights[num].JointWeight;

                    _scaledWeights[count].X = tmp.X;
                    _scaledWeights[count].Y = tmp.Y;
                    _scaledWeights[count].Z = tmp.Z;
                    _scaledWeights[count].W = tempWeights[num].JointWeight;

                    _weightIndex[count * 2 + 0] = tempWeights[num].JointIndex;
                }

                _weightIndex[count * 2 - 1] = 1;
            }

            lexer.ExpectTokenString("}");

            // update counters
            idConsole.Warning("TODO: idRenderModel_MD5 update counters");

            /*c_numVerts += texCoords.Num();
             * c_numWeights += numWeights;
             * c_numWeightJoints++;
             * for ( i = 0; i < numWeights; i++ ) {
             *      c_numWeightJoints += weightIndex[i*2+1];
             * }*/

            //
            // build the information that will be common to all animations of this mesh:
            // silhouette edge connectivity and normal / tangent generation information
            //
            Vertex[] verts     = new Vertex[_texCoords.Length];
            int      vertCount = verts.Length;

            for (int i = 0; i < vertCount; i++)
            {
                verts[i].TextureCoordinates = _texCoords[i];
            }

            TransformVertices(verts, joints);

            idConsole.Warning("TODO: idMD5Mesh Deform");
            //_deformInfo = idE.RenderSystem.BuildDeformInformation(verts, tris, _material.UseUnsmoothedTangents);
        }
コード例 #9
0
        private bool ParseMaterial(idLexer lexer)
        {
            _parameters.MinDistance = 1;
            _parameters.MaxDistance = 10;
            _parameters.Volume      = 1;

            _speakerMask = 0;
            _altSound    = null;

            idToken token;
            string  tokenValue;
            int     sampleCount = 0;

            while (true)
            {
                if ((token = lexer.ExpectAnyToken()) == null)
                {
                    return(false);
                }

                tokenValue = token.ToString().ToLower();

                if (tokenValue == "}")
                {
                    break;
                }
                // minimum number of sounds
                else if (tokenValue == "minsamples")
                {
                    sampleCount = lexer.ParseInt();
                }
                else if (tokenValue == "description")
                {
                    _description = lexer.ReadTokenOnLine().ToString();
                }
                else if (tokenValue == "mindistance")
                {
                    _parameters.MinDistance = lexer.ParseFloat();
                }
                else if (tokenValue == "maxdistance")
                {
                    _parameters.MaxDistance = lexer.ParseFloat();
                }
                else if (tokenValue == "shakes")
                {
                    token = lexer.ExpectAnyToken();

                    if (token.Type == TokenType.Number)
                    {
                        _parameters.Shakes = token.ToFloat();
                    }
                    else
                    {
                        lexer.UnreadToken  = token;
                        _parameters.Shakes = 1.0f;
                    }
                }
                else if (tokenValue == "reverb")
                {
                    float reg0 = lexer.ParseFloat();

                    if (lexer.ExpectTokenString(",") == false)
                    {
                        return(false);
                    }

                    float reg1 = lexer.ParseFloat();
                    // no longer supported
                }
                else if (tokenValue == "volume")
                {
                    _parameters.Volume = lexer.ParseFloat();
                }
                // leadinVolume is used to allow light breaking leadin sounds to be much louder than the broken loop
                else if (tokenValue == "leadinvolume")
                {
                    _leadInVolume = lexer.ParseFloat();
                }
                else if (tokenValue == "mask_center")
                {
                    _speakerMask |= 1 << (int)Speakers.Center;
                }
                else if (tokenValue == "mask_left")
                {
                    _speakerMask |= 1 << (int)Speakers.Left;
                }
                else if (tokenValue == "mask_right")
                {
                    _speakerMask |= 1 << (int)Speakers.Right;
                }
                else if (tokenValue == "mask_backright")
                {
                    _speakerMask |= 1 << (int)Speakers.BackRight;
                }
                else if (tokenValue == "mask_backleft")
                {
                    _speakerMask |= 1 << (int)Speakers.BackLeft;
                }
                else if (tokenValue == "mask_lfe")
                {
                    _speakerMask |= 1 << (int)Speakers.Lfe;
                }
                else if (tokenValue == "soundclass")
                {
                    _parameters.SoundClass = lexer.ParseInt();

                    if (_parameters.SoundClass < 0)
                    {
                        lexer.Warning("SoundClass out of range");
                        return(false);
                    }
                }
                else if (tokenValue == "altsound")
                {
                    if ((token = lexer.ExpectAnyToken()) == null)
                    {
                        return(false);
                    }

                    _altSound = idE.DeclManager.FindSound(token.ToString());
                }
                else if (tokenValue == "ordered")
                {
                    // no longer supported
                }
                else if (tokenValue == "no_dups")
                {
                    _parameters.Flags |= SoundMaterialFlags.NoDuplicates;
                }
                else if (tokenValue == "no_flicker")
                {
                    _parameters.Flags |= SoundMaterialFlags.NoFlicker;
                }
                else if (tokenValue == "plain")
                {
                    // no longer supported
                }
                else if (tokenValue == "looping")
                {
                    _parameters.Flags |= SoundMaterialFlags.Looping;
                }
                else if (tokenValue == "no_occlusion")
                {
                    _parameters.Flags |= SoundMaterialFlags.NoOcclusion;
                }
                else if (tokenValue == "private")
                {
                    _parameters.Flags |= SoundMaterialFlags.PrivateSound;
                }
                else if (tokenValue == "antiprivate")
                {
                    _parameters.Flags |= SoundMaterialFlags.AntiPrivateSound;
                }
                else if (tokenValue == "playonce")
                {
                    _parameters.Flags |= SoundMaterialFlags.PlayOnce;
                }
                else if (tokenValue == "global")
                {
                    _parameters.Flags |= SoundMaterialFlags.Global;
                }
                else if (tokenValue == "unclamped")
                {
                    _parameters.Flags |= SoundMaterialFlags.Unclamped;
                }
                else if (tokenValue == "omnidirectional")
                {
                    _parameters.Flags |= SoundMaterialFlags.OmniDirectional;
                }
                // onDemand can't be a parms, because we must track all references and overrides would confuse it
                else if (tokenValue == "ondemand")
                {
                    // no longer loading sounds on demand
                    // _onDemand = true;
                }
                // the wave files
                else if (tokenValue == "leadin")
                {
                    // add to the leadin list
                    if ((token = lexer.ReadToken()) == null)
                    {
                        lexer.Warning("Expected sound after leadin");
                        return(false);
                    }

                    idConsole.Warning("TODO: leadin");

                    /*if(soundSystemLocal.soundCache && numLeadins < maxSamples)
                     * {
                     *      leadins[numLeadins] = soundSystemLocal.soundCache->FindSound(token.c_str(), onDemand);
                     *      numLeadins++;
                     * }*/
                }
                else if ((tokenValue.EndsWith(".wav") == true) || (tokenValue.EndsWith(".ogg") == true))
                {
                    idConsole.Warning("TODO: .wav|.ogg");

                    /*// add to the wav list
                     * if(soundSystemLocal.soundCache && numEntries < maxSamples)
                     * {
                     *      token.BackSlashesToSlashes();
                     *      idStr lang = cvarSystem->GetCVarString("sys_lang");
                     *      if(lang.Icmp("english") != 0 && token.Find("sound/vo/", false) >= 0)
                     *      {
                     *              idStr work = token;
                     *              work.ToLower();
                     *              work.StripLeading("sound/vo/");
                     *              work = va("sound/vo/%s/%s", lang.c_str(), work.c_str());
                     *              if(fileSystem->ReadFile(work, NULL, NULL) > 0)
                     *              {
                     *                      token = work;
                     *              }
                     *              else
                     *              {
                     *                      // also try to find it with the .ogg extension
                     *                      work.SetFileExtension(".ogg");
                     *                      if(fileSystem->ReadFile(work, NULL, NULL) > 0)
                     *                      {
                     *                              token = work;
                     *                      }
                     *              }
                     *      }
                     *      entries[numEntries] = soundSystemLocal.soundCache->FindSound(token.c_str(), onDemand);
                     *      numEntries++;
                     * }*/
                }
                else
                {
                    lexer.Warning("unknown token '{0}'", token.ToString());
                    return(false);
                }
            }

            if (_parameters.Shakes > 0.0f)
            {
                idConsole.Warning("TODO: CheckShakesAndOgg()");
            }

            return(true);
        }
コード例 #10
0
ファイル: idDeclFX.cs プロジェクト: iainmckay/idtech4.net
		public override bool Parse(string text)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idLexer lexer = new idLexer(idDeclFile.LexerOptions);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			idToken token;
			string tokenValue;

			idConsole.Warning("TODO: actual fx parsing, we only step over the block");

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenValue = token.ToString().ToLower();

				if(tokenValue == "}")
				{
					break;
				}

				if(tokenValue == "bindto")
				{
					token = lexer.ReadToken();

					idConsole.Warning("TODO: FX: joint = token;");
				}
				else if(tokenValue == "{")
				{
					idConsole.Warning("TODO: FX: idFXSingleAction action;");
					ParseSingleAction(lexer/*, action*/);
					// events.Append(action);
					continue;
				}
			}

			if(lexer.HadError == true)
			{
				lexer.Warning("FX decl '{0}' had a parse error", this.Name);
				return false;
			}
			return true;
		}
コード例 #11
0
ファイル: idDeclFX.cs プロジェクト: iainmckay/idtech4.net
		private void ParseSingleAction(idLexer lexer /*idFXSingleAction& FXAction*/) 
		{
			idToken token;
			string tokenValue;
			
			/*FXAction.type = -1;
			FXAction.sibling = -1;

			FXAction.data = "<none>";
			FXAction.name = "<none>";
			FXAction.fire = "<none>";

			FXAction.delay = 0.0f;
			FXAction.duration = 0.0f;
			FXAction.restart = 0.0f;
			FXAction.size = 0.0f;
			FXAction.fadeInTime = 0.0f;
			FXAction.fadeOutTime = 0.0f;
			FXAction.shakeTime = 0.0f;
			FXAction.shakeAmplitude = 0.0f;
			FXAction.shakeDistance = 0.0f;
			FXAction.shakeFalloff = false;
			FXAction.shakeImpulse = 0.0f;
			FXAction.shakeIgnoreMaster = false;
			FXAction.lightRadius = 0.0f;
			FXAction.rotate = 0.0f;
			FXAction.random1 = 0.0f;
			FXAction.random2 = 0.0f;

			FXAction.lightColor = vec3_origin;
			FXAction.offset = vec3_origin;
			FXAction.axis = mat3_identity;

			FXAction.bindParticles = false;
			FXAction.explicitAxis = false;
			FXAction.noshadows = false;
			FXAction.particleTrackVelocity = false;
			FXAction.trackOrigin = false;
			FXAction.soundStarted = false;*/

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenValue = token.ToString().ToLower();

				if(tokenValue == "}")
				{
					break;
				}
				else if(tokenValue == "shake")
				{
					/*FXAction.type = FX_SHAKE;*/
					/*FXAction.shakeTime = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.shakeAmplitude = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.shakeDistance = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.shakeFalloff = */lexer.ParseBool();
					lexer.ExpectTokenString(",");
					/*FXAction.shakeImpulse = */lexer.ParseFloat();
				}
				else if(tokenValue == "noshadows")
				{
					// TODO: FXAction.noshadows = true;
				}
				else if(tokenValue == "name")
				{
					token = lexer.ReadToken();
					// TODO: FXAction.name = token;
				}
				else if(tokenValue == "fire")
				{
					token = lexer.ReadToken();
					// TODO: FXAction.fire = token;
				}
				else if(tokenValue == "random")
				{
					/*FXAction.random1 = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.random2 = */lexer.ParseFloat();
					// FXAction.delay = 0.0f;		// check random
				}
				else if(tokenValue == "delay")
				{
					/*FXAction.delay = */lexer.ParseFloat();
				}
				else if(tokenValue == "rotate")
				{
					/*FXAction.rotate = */lexer.ParseFloat();
				}
				else if(tokenValue == "duration")
				{
					/*FXAction.duration = */lexer.ParseFloat();
				}
				else if(tokenValue == "trackorigin")
				{
					/*FXAction.trackOrigin = */lexer.ParseBool();
				}
				else if(tokenValue == "restart")
				{
					/*FXAction.restart = */lexer.ParseFloat();
				}
				else if(tokenValue == "fadein")
				{
					/*FXAction.fadeInTime = */lexer.ParseFloat();
				}
				else if(tokenValue == "fadeout")
				{
					/*FXAction.fadeOutTime = */lexer.ParseFloat();
				}
				else if(tokenValue == "size")
				{
					/*FXAction.size = */lexer.ParseFloat();
				}
				else if(tokenValue == "offset")
				{
					/*FXAction.offset.x = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.offset.y = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.offset.z = */lexer.ParseFloat();
				}
				else if(tokenValue == "axis")
				{
					/*idVec3 v;*/
					/*v.x = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*v.y = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*v.z = */lexer.ParseFloat();
					/*v.Normalize();
					FXAction.axis = v.ToMat3();
					FXAction.explicitAxis = true;*/
				}
				else if(tokenValue == "angle")
				{
					/*idAngles a;*/
					/*a[0] = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*a[1] = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*a[2] = */lexer.ParseFloat();
					/*FXAction.axis = a.ToMat3();
					FXAction.explicitAxis = true;*/
				}
				else if(tokenValue == "uselight")
				{
					token = lexer.ReadToken();
			
					/*FXAction.data = token;
					for( int i = 0; i < events.Num(); i++ ) {
						if ( events[i].name.Icmp( FXAction.data ) == 0 ) {
							FXAction.sibling = i;
							FXAction.lightColor = events[i].lightColor;
							FXAction.lightRadius = events[i].lightRadius;
						}
					}
					FXAction.type = FX_LIGHT;

					// precache the light material
					declManager->FindMaterial( FXAction.data );*/	
				}
				else if(tokenValue == "attachlight")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_ATTACHLIGHT;

					// precache it
					declManager->FindMaterial( FXAction.data );*/
				}
				else if(tokenValue == "attachentity")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_ATTACHENTITY;

					// precache the model
					renderModelManager->FindModel( FXAction.data );*/
				}
				else if(tokenValue == "launch")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_LAUNCH;

					// precache the entity def
					declManager->FindType( DECL_ENTITYDEF, FXAction.data );*/
				}
				else if(tokenValue == "usemodel")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					for( int i = 0; i < events.Num(); i++ ) {
						if ( events[i].name.Icmp( FXAction.data ) == 0 ) {
							FXAction.sibling = i;
						}
					}
					FXAction.type = FX_MODEL;

					// precache the model
					renderModelManager->FindModel( FXAction.data );*/
				}
				else if(tokenValue == "light")
				{
					token = lexer.ReadToken();
					
					/*FXAction.data = token;*/
					lexer.ExpectTokenString(",");
					/*FXAction.lightColor[0] = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.lightColor[1] = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.lightColor[2] = */lexer.ParseFloat();
					lexer.ExpectTokenString(",");
					/*FXAction.lightRadius = */lexer.ParseFloat();
					/*FXAction.type = FX_LIGHT;

					// precache the light material
					declManager->FindMaterial( FXAction.data );*/
				}
				else if(tokenValue == "model")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_MODEL;

					// precache it
					renderModelManager->FindModel( FXAction.data );*/
				}
				else if(tokenValue == "particle") // FIXME: now the same as model
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_PARTICLE;

					// precache it
					renderModelManager->FindModel( FXAction.data );*/
				}
				else if(tokenValue == "decal")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_DECAL;

					// precache it
					declManager->FindMaterial( FXAction.data );*/
				}
				else if(tokenValue == "particletrackvelocity")
				{
					// TODO: FXAction.particleTrackVelocity = true;
				}
				else if(tokenValue == "sound")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_SOUND;

					// precache it
					declManager->FindSound( FXAction.data );*/
				}
				else if(tokenValue == "ignoremaster")
				{
					/*FXAction.shakeIgnoreMaster = true;*/
				}
				else if(tokenValue == "shockwave")
				{
					token = lexer.ReadToken();

					/*FXAction.data = token;
					FXAction.type = FX_SHOCKWAVE;

					// precache the entity def
					declManager->FindType( DECL_ENTITYDEF, FXAction.data );*/
				}
				else
				{
					lexer.Warning("FX File: bad token");
				}
			}
		}
コード例 #12
0
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idToken token;
            string  tokenLower;

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            List <idParticleStage> stages = new List <idParticleStage>();

            _depthHack = 0.0f;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenLower = token.ToString().ToLower();

                if (tokenLower == "}")
                {
                    break;
                }
                else if (tokenLower == "{")
                {
                    idParticleStage stage = ParseParticleStage(lexer);

                    if (stage == null)
                    {
                        lexer.Warning("Particle stage parse failed");
                        MakeDefault();

                        return(false);
                    }

                    stages.Add(stage);
                }
                else if (tokenLower == "depthhack")
                {
                    _depthHack = lexer.ParseFloat();
                }
                else
                {
                    lexer.Warning("bad token {0}", token.ToString());
                    MakeDefault();

                    return(false);
                }
            }

            _stages = stages.ToArray();

            //
            // calculate the bounds
            //
            _bounds.Clear();

            int count = _stages.Length;

            for (int i = 0; i < count; i++)
            {
                idConsole.Warning("TODO: GetStageBounds");
                // TODO: GetStageBounds(stages[i]);
                _bounds += _stages[i].Bounds;
            }

            if (_bounds.Volume <= 0.1f)
            {
                _bounds = idBounds.Expand(idBounds.Zero, 8.0f);
            }

            return(true);
        }
コード例 #13
0
ファイル: idDeclPDA.cs プロジェクト: iainmckay/idtech4.net
		public override bool Parse(string text)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idToken token;
			string tokenLower;

			idLexer lexer = new idLexer(idDeclFile.LexerOptions);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenLower = token.ToString().ToLower();

				if(tokenLower == "}")
				{
					break;
				}
				else if(tokenLower == "name")
				{
					token = lexer.ReadToken();
					_pdaName = (token != null) ? token.ToString() : string.Empty;
				}
				else if(tokenLower == "fullname")
				{
					token = lexer.ReadToken();
					_fullName = (token != null) ? token.ToString() : string.Empty;
				}
				else if(tokenLower == "icon")
				{
					token = lexer.ReadToken();
					_icon = (token != null) ? token.ToString() : string.Empty;
				}
				else if(tokenLower == "id")
				{
					token = lexer.ReadToken();
					_id = (token != null) ? token.ToString() : string.Empty;
				}
				else if(tokenLower == "post")
				{
					token = lexer.ReadToken();
					_post = (token != null) ? token.ToString() : string.Empty;
				}
				else if(tokenLower == "title")
				{
					token = lexer.ReadToken();
					_title = (token != null) ? token.ToString() : string.Empty;
				}
				else if(tokenLower == "security")
				{
					token = lexer.ReadToken();
					_security = (token != null) ? token.ToString() : string.Empty;
				}
				else if(tokenLower == "pda_email")
				{
					token = lexer.ReadToken();
					_emailList.Add(token.ToString());

					idE.DeclManager.FindType(DeclType.Email, token.ToString());
				}
				else if(tokenLower == "pda_audio")
				{
					token = lexer.ReadToken();
					_audioList.Add(token.ToString());

					idE.DeclManager.FindType(DeclType.Audio, token.ToString());
				}
				else if(tokenLower == "pda_video")
				{
					token = lexer.ReadToken();
					_videoList.Add(token.ToString());

					idE.DeclManager.FindType(DeclType.Video, token.ToString());
				}
			}

			if(lexer.HadError == true)
			{
				lexer.Warning("PDA decl '{0}' had a parse error", this.Name);
				return false;
			}

			_originalVideoCount = _videoList.Count;
			_originalEmailCount = _emailList.Count;

			return true;
		}
コード例 #14
0
		public override bool Parse(string text)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idToken token;
			string tokenLower;

			idLexer lexer = new idLexer(idDeclFile.LexerOptions);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			List<idParticleStage> stages = new List<idParticleStage>();

			_depthHack = 0.0f;

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenLower = token.ToString().ToLower();

				if(tokenLower == "}")
				{
					break;
				}
				else if(tokenLower == "{")
				{
					idParticleStage stage = ParseParticleStage(lexer);

					if(stage == null)
					{
						lexer.Warning("Particle stage parse failed");
						MakeDefault();

						return false;
					}

					stages.Add(stage);
				}
				else if(tokenLower == "depthhack")
				{
					_depthHack = lexer.ParseFloat();
				}
				else
				{
					lexer.Warning("bad token {0}", token.ToString());
					MakeDefault();

					return false;
				}
			}

			_stages = stages.ToArray();

			//
			// calculate the bounds
			//
			_bounds.Clear();

			int count = _stages.Length;

			for(int i = 0; i < count; i++)
			{
				idConsole.Warning("TODO: GetStageBounds");
				// TODO: GetStageBounds(stages[i]);
				_bounds += _stages[i].Bounds;
			}

			if(_bounds.Volume <= 0.1f)
			{
				_bounds = idBounds.Expand(idBounds.Zero, 8.0f);
			}

			return true;
		}
コード例 #15
0
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            idToken token;
            idToken token2;
            string  value;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                value = token.ToString();

                if (value == "}")
                {
                    break;
                }

                if (token.Type != TokenType.String)
                {
                    lexer.Warning("Expected quoted string, but found '{0}'", value);
                    MakeDefault();

                    return(false);
                }

                if ((token2 = lexer.ReadToken()) == null)
                {
                    lexer.Warning("Unexpected end of file");
                    MakeDefault();

                    return(false);
                }

                if (_dict.ContainsKey(value) == true)
                {
                    lexer.Warning("'{0}' already defined", value);
                }

                _dict.Set(value, token2.ToString());
            }

            // we always automatically set a "classname" key to our name
            _dict.Set("classname", this.Name);

            // "inherit" keys will cause all values from another entityDef to be copied into this one
            // if they don't conflict.  We can't have circular recursions, because each entityDef will
            // never be parsed more than once

            // find all of the dicts first, because copying inherited values will modify the dict
            List <idDeclEntity> defList      = new List <idDeclEntity>();
            List <string>       keysToRemove = new List <string>();

            foreach (KeyValuePair <string, string> kvp in _dict.MatchPrefix("inherit"))
            {
                idDeclEntity copy = idE.DeclManager.FindType <idDeclEntity>(DeclType.EntityDef, kvp.Value, false);

                if (copy == null)
                {
                    lexer.Warning("Unknown entityDef '{0}' inherited by '{1}'", kvp.Value, this.Name);
                }
                else
                {
                    defList.Add(copy);
                }

                // delete this key/value pair
                keysToRemove.Add(kvp.Key);
            }

            _dict.Remove(keysToRemove.ToArray());

            // now copy over the inherited key / value pairs
            foreach (idDeclEntity def in defList)
            {
                _dict.SetDefaults(def._dict);
            }

            // precache all referenced media
            // do this as long as we arent in modview
            idE.Game.CacheDictionaryMedia(_dict);

            return(true);
        }
コード例 #16
0
ファイル: idDeclTable.cs プロジェクト: PEMantis/idtech4.net
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException("idDeclTable");
            }

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            idToken      token;
            List <float> values = new List <float>();

            string tokenLower;
            string tokenValue;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenValue = token.ToString();
                tokenLower = tokenValue.ToLower();

                if (tokenLower == "}")
                {
                    break;
                }
                else if (tokenLower == "snap")
                {
                    _snap = true;
                }
                else if (tokenLower == "clamp")
                {
                    _clamp = true;
                }
                else if (tokenLower == "{")
                {
                    while (true)
                    {
                        bool  errorFlag;
                        float v = lexer.ParseFloat(out errorFlag);

                        if (errorFlag == true)
                        {
                            // we got something non-numeric
                            MakeDefault();
                            return(false);
                        }

                        values.Add(v);

                        token      = lexer.ReadToken();
                        tokenValue = token.ToString();

                        if (tokenValue == "}")
                        {
                            break;
                        }
                        else if (tokenValue == ",")
                        {
                            continue;
                        }

                        lexer.Warning("expected comma or brace");
                        MakeDefault();

                        return(false);
                    }
                }
                else
                {
                    lexer.Warning("unknown token '{0}'", tokenValue);
                    MakeDefault();

                    return(false);
                }
            }

            // copy the 0 element to the end, so lerping doesn't
            // need to worry about the wrap case
            float val = values[0];

            values.Add(val);

            _values = values.ToArray();

            return(true);
        }
コード例 #17
0
ファイル: idDeclTable.cs プロジェクト: iainmckay/idtech4.net
		public override bool Parse(string text)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException("idDeclTable");
			}

			idLexer lexer = new idLexer(idDeclFile.LexerOptions);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			idToken token;
			List<float> values = new List<float>();

			string tokenLower;
			string tokenValue;

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenValue = token.ToString();
				tokenLower = tokenValue.ToLower();

				if(tokenLower == "}")
				{
					break;
				}
				else if(tokenLower == "snap")
				{
					_snap = true;
				}
				else if(tokenLower == "clamp")
				{
					_clamp = true;
				}
				else if(tokenLower == "{")
				{
					while(true)
					{
						bool errorFlag;
						float v = lexer.ParseFloat(out errorFlag);

						if(errorFlag == true)
						{
							// we got something non-numeric
							MakeDefault();
							return false;
						}

						values.Add(v);

						token = lexer.ReadToken();
						tokenValue = token.ToString();

						if(tokenValue == "}")
						{
							break;
						}
						else if(tokenValue == ",")
						{
							continue;
						}

						lexer.Warning("expected comma or brace");
						MakeDefault();

						return false;
					}
				}
				else
				{
					lexer.Warning("unknown token '{0}'", tokenValue);
					MakeDefault();

					return false;
				}
			}

			// copy the 0 element to the end, so lerping doesn't
			// need to worry about the wrap case
			float val = values[0];
			values.Add(val);

			_values = values.ToArray();

			return true;
		}
コード例 #18
0
        private bool ParseAnimation(idLexer lexer, int defaultAnimCount)
        {
            List <idMD5Anim> md5anims = new List <idMD5Anim>();
            idMD5Anim        md5anim;
            idAnim           anim;
            AnimationFlags   flags = new AnimationFlags();

            idToken token;
            idToken realName = lexer.ReadToken();

            if (realName == null)
            {
                lexer.Warning("Unexpected end of file");
                MakeDefault();

                return(false);
            }

            string alias = realName.ToString();
            int    i;
            int    count = _anims.Count;

            for (i = 0; i < count; i++)
            {
                if (_anims[i].FullName.Equals(alias, StringComparison.OrdinalIgnoreCase) == true)
                {
                    break;
                }
            }

            if ((i < count) && (i >= defaultAnimCount))
            {
                lexer.Warning("Duplicate anim '{0}'", realName);
                MakeDefault();

                return(false);
            }

            if (i < defaultAnimCount)
            {
                anim = _anims[i];
            }
            else
            {
                // create the alias associated with this animation
                anim = new idAnim();
                _anims.Add(anim);
            }

            // random anims end with a number.  find the numeric suffix of the animation.
            int len = alias.Length;

            for (i = len - 1; i > 0; i--)
            {
                if (Char.IsNumber(alias[i]) == false)
                {
                    break;
                }
            }

            // check for zero length name, or a purely numeric name
            if (i <= 0)
            {
                lexer.Warning("Invalid animation name '{0}'", alias);
                MakeDefault();

                return(false);
            }

            // remove the numeric suffix
            alias = alias.Substring(0, i + 1);

            // parse the anims from the string
            do
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    lexer.Warning("Unexpected end of file");
                    MakeDefault();

                    return(false);
                }

                // lookup the animation
                md5anim = idR.AnimManager.GetAnimation(token.ToString());

                if (md5anim == null)
                {
                    lexer.Warning("Couldn't load anim '{0}'", token);
                    return(false);
                }

                md5anim.CheckModelHierarchy(_model);

                if (md5anims.Count > 0)
                {
                    // make sure it's the same length as the other anims
                    if (md5anim.Length != md5anims[0].Length)
                    {
                        lexer.Warning("Anim '{0}' does not match length of anim '{1}'", md5anim.Name, md5anims[0].Name);
                        MakeDefault();

                        return(false);
                    }
                }

                // add it to our list
                md5anims.Add(md5anim);
            }while(lexer.CheckTokenString(",") == true);

            if (md5anims.Count == 0)
            {
                lexer.Warning("No animation specified");
                MakeDefault();

                return(false);
            }

            anim.SetAnimation(this, realName.ToString(), alias, md5anims.ToArray());

            // parse any frame commands or animflags
            if (lexer.CheckTokenString("{") == true)
            {
                while (true)
                {
                    if ((token = lexer.ReadToken()) == null)
                    {
                        lexer.Warning("Unexpected end of file");
                        MakeDefault();

                        return(false);
                    }

                    string tokenValue = token.ToString();

                    if (tokenValue == "}")
                    {
                        break;
                    }
                    else if (tokenValue == "prevent_idle_override")
                    {
                        flags.PreventIdleOverride = true;
                    }
                    else if (tokenValue == "random_cycle_start")
                    {
                        flags.RandomCycleStart = true;
                    }
                    else if (tokenValue == "ai_no_turn")
                    {
                        flags.AINoTurn = true;
                    }
                    else if (tokenValue == "anim_turn")
                    {
                        flags.AnimationTurn = true;
                    }
                    else if (tokenValue == "frame")
                    {
                        // create a frame command
                        int    frameIndex;
                        string err;

                        // make sure we don't have any line breaks while reading the frame command so the error line # will be correct
                        if ((token = lexer.ReadTokenOnLine()) == null)
                        {
                            lexer.Warning("Missing frame # after 'frame'");
                            MakeDefault();

                            return(false);
                        }
                        else if ((token.Type == TokenType.Punctuation) && (token.ToString() == "-"))
                        {
                            lexer.Warning("Invalid frame # after 'frame'");
                            MakeDefault();

                            return(false);
                        }
                        else if ((token.Type != TokenType.Number) || (token.SubType == TokenSubType.Float))
                        {
                            lexer.Error("expected integer value, found '{0}'", token);
                        }

                        // get the frame number
                        frameIndex = token.ToInt32();

                        // put the command on the specified frame of the animation
                        if ((err = anim.AddFrameCommand(this, frameIndex, lexer, null)) != null)
                        {
                            lexer.Warning(err.ToString());
                            MakeDefault();

                            return(false);
                        }
                    }
                    else
                    {
                        lexer.Warning("Unknown command '{0}'", token);
                        MakeDefault();

                        return(false);
                    }
                }
            }

            // set the flags
            anim.Flags = flags;

            return(true);
        }
コード例 #19
0
ファイル: idDeclAudio.cs プロジェクト: iainmckay/idtech4.net
		public override bool Parse(string text)
		{
			idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			idToken token;
			string tokenValue;

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenValue = token.ToString().ToLower();

				if(tokenValue == "}")
				{
					break;
				}

				if(tokenValue == "audio")
				{
					_audio = lexer.ReadToken().ToString();
					idE.DeclManager.FindSound(_audio);
				}
				else if(tokenValue == "info")
				{
					_info = lexer.ReadToken().ToString();
				}
				else if(tokenValue == "name")
				{
					_audioName = lexer.ReadToken().ToString();
				}
				else if(tokenValue == "preview")
				{
					_preview = lexer.ReadToken().ToString();
				}
			}

			if(lexer.HadError == true)
			{
				lexer.Warning("Video decl '{0}' had a parse error", this.Name);
				return false;
			}

			return true;
		}
コード例 #20
0
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            int     defaultAnimationCount = 0;
            idToken token;
            idToken token2;
            string  tokenValue;
            string  fileName;
            string  extension;
            int     count;

            idMD5Joint[] md5Joints;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenValue = token.ToString();

                if (tokenValue == "}")
                {
                    break;
                }

                if (tokenValue == "inherit")
                {
                    idConsole.WriteLine("TODO: inherit");

                    /*if( !src.ReadToken( &token2 ) ) {
                     *      src.Warning( "Unexpected end of file" );
                     *      MakeDefault();
                     *      return false;
                     * }
                     *
                     * const idDeclModelDef *copy = static_cast<const idDeclModelDef *>( declManager->FindType( DECL_MODELDEF, token2, false ) );
                     * if ( !copy ) {
                     *      common->Warning( "Unknown model definition '%s'", token2.c_str() );
                     * } else if ( copy->GetState() == DS_DEFAULTED ) {
                     *      common->Warning( "inherited model definition '%s' defaulted", token2.c_str() );
                     *      MakeDefault();
                     *      return false;
                     * } else {
                     *      CopyDecl( copy );
                     *      numDefaultAnims = anims.Num();
                     * }*/
                }
                else if (tokenValue == "skin")
                {
                    if ((token2 = lexer.ReadToken()) == null)
                    {
                        lexer.Warning("Unexpected end of file");
                        MakeDefault();

                        return(false);
                    }

                    _skin = idE.DeclManager.FindSkin(token2.ToString());

                    if (_skin == null)
                    {
                        lexer.Warning("Skin '{0}' not found", token2.ToString());
                        MakeDefault();

                        return(false);
                    }
                }
                else if (tokenValue == "mesh")
                {
                    if ((token2 = lexer.ReadToken()) == null)
                    {
                        lexer.Warning("Unexpected end of file");
                        MakeDefault();

                        return(false);
                    }

                    fileName  = token2.ToString();
                    extension = Path.GetExtension(fileName);

                    if (extension != idRenderModel_MD5.MeshExtension)
                    {
                        lexer.Warning("Invalid model for MD5 mesh");
                        MakeDefault();

                        return(false);
                    }

                    _model = idE.RenderModelManager.FindModel(fileName);

                    if (_model == null)
                    {
                        lexer.Warning("Model '{0}' not found", fileName);
                        MakeDefault();

                        return(false);
                    }
                    else if (_model.IsDefault == true)
                    {
                        lexer.Warning("Model '{0}' defaulted", fileName);
                        MakeDefault();

                        return(false);
                    }

                    // get the number of joints
                    count = _model.JointCount;

                    if (count == 0)
                    {
                        lexer.Warning("Model '{0}' has no joints", fileName);
                    }

                    // set up the joint hierarchy
                    md5Joints = _model.Joints;

                    _joints           = new JointInfo[count];
                    _jointParents     = new int[count];
                    _channelJoints    = new int[(int)AnimationChannel.Count][];
                    _channelJoints[0] = new int[count];

                    for (int i = 0; i < count; i++)
                    {
                        _joints[i]         = new JointInfo();
                        _joints[i].Channel = AnimationChannel.All;
                        _joints[i].Index   = i;

                        if (md5Joints[i].Parent != null)
                        {
                            _joints[i].ParentIndex = _model.GetJointIndex(md5Joints[i].Parent);
                        }
                        else
                        {
                            _joints[i].ParentIndex = -1;
                        }

                        _jointParents[i]     = _joints[i].ParentIndex;
                        _channelJoints[0][i] = i;
                    }
                }
                else if (tokenValue == "remove")
                {
                    idConsole.Warning("TODO: remove");

                    // removes any anims whos name matches

                    /*if( !src.ReadToken( &token2 ) ) {
                     *      src.Warning( "Unexpected end of file" );
                     *      MakeDefault();
                     *      return false;
                     * }
                     * num = 0;
                     * for( i = 0; i < anims.Num(); i++ ) {
                     *      if ( ( token2 == anims[ i ]->Name() ) || ( token2 == anims[ i ]->FullName() ) ) {
                     *              delete anims[ i ];
                     *              anims.RemoveIndex( i );
                     *              if ( i >= numDefaultAnims ) {
                     *                      src.Warning( "Anim '%s' was not inherited.  Anim should be removed from the model def.", token2.c_str() );
                     *                      MakeDefault();
                     *                      return false;
                     *              }
                     *              i--;
                     *              numDefaultAnims--;
                     *              num++;
                     *              continue;
                     *      }
                     * }
                     * if ( !num ) {
                     *      src.Warning( "Couldn't find anim '%s' to remove", token2.c_str() );
                     *      MakeDefault();
                     *      return false;
                     * }*/
                }
                else if (tokenValue == "anim")
                {
                    if (_model == null)
                    {
                        lexer.Warning("Must specify mesh before defining anims");
                        MakeDefault();

                        return(false);
                    }
                    else if (ParseAnimation(lexer, defaultAnimationCount) == false)
                    {
                        MakeDefault();

                        return(false);
                    }
                }
                else if (tokenValue == "offset")
                {
                    float[] tmp = lexer.Parse1DMatrix(3);

                    if (tmp == null)
                    {
                        lexer.Warning("Expected vector following 'offset'");
                        MakeDefault();
                        return(false);
                    }

                    _offset = new Vector3(tmp[0], tmp[1], tmp[2]);
                }
                else if (tokenValue == "channel")
                {
                    if (_model == null)
                    {
                        lexer.Warning("Must specify mesh before defining channels");
                        MakeDefault();

                        return(false);
                    }

                    // set the channel for a group of joints
                    if ((token2 = lexer.ReadToken()) == null)
                    {
                        lexer.Warning("Unexpected end of file");
                        MakeDefault();

                        return(false);
                    }

                    if (lexer.CheckTokenString("(") == false)
                    {
                        lexer.Warning("Expected { after '{0}'", token2.ToString());
                        MakeDefault();

                        return(false);
                    }

                    int i;
                    int channelCount = (int)AnimationChannel.Count;

                    for (i = (int)AnimationChannel.All + 1; i < channelCount; i++)
                    {
                        if (ChannelNames[i].Equals(token2.ToString(), StringComparison.OrdinalIgnoreCase) == true)
                        {
                            break;
                        }
                    }

                    if (i >= channelCount)
                    {
                        lexer.Warning("Unknown channel '{0}'", token2.ToString());
                        MakeDefault();

                        return(false);
                    }

                    int           channel    = i;
                    StringBuilder jointNames = new StringBuilder();
                    string        token2Value;

                    while (lexer.CheckTokenString(")") == false)
                    {
                        if ((token2 = lexer.ReadToken()) == null)
                        {
                            lexer.Warning("Unexpected end of file");
                            MakeDefault();

                            return(false);
                        }

                        token2Value = token2.ToString();
                        jointNames.Append(token2Value);

                        if ((token2Value != "*") && (token2Value != "-"))
                        {
                            jointNames.Append(" ");
                        }
                    }

                    int[] jointList   = GetJointList(jointNames.ToString());
                    int   jointLength = jointList.Length;

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

                    for (count = i = 0; i < jointLength; i++)
                    {
                        int jointIndex = jointList[i];

                        if (_joints[jointIndex].Channel != AnimationChannel.All)
                        {
                            lexer.Warning("Join '{0}' assigned to multiple channels", _model.GetJointName(jointIndex));
                            continue;
                        }

                        _joints[jointIndex].Channel = (AnimationChannel)channel;
                        channelJoints.Add(jointIndex);
                    }

                    _channelJoints[channel] = channelJoints.ToArray();
                }
                else
                {
                    lexer.Warning("unknown token '{0}'", token.ToString());
                    MakeDefault();

                    return(false);
                }
            }

            return(true);
        }
コード例 #21
0
ファイル: idDeclSkin.cs プロジェクト: PEMantis/idtech4.net
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            List <SkinMapping> mappings         = new List <SkinMapping>();
            List <string>      associatedModels = new List <string>();

            idToken token, token2;
            string  tokenLower;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenLower = token.ToString().ToLower();

                if (tokenLower == "}")
                {
                    break;
                }
                else if ((token2 = lexer.ReadToken()) == null)
                {
                    lexer.Warning("Unexpected end of file");
                    MakeDefault();

                    break;
                }
                else if (tokenLower == "model")
                {
                    associatedModels.Add(token2.ToString());
                    continue;
                }

                SkinMapping map = new SkinMapping();
                map.To = idE.DeclManager.FindMaterial(token2.ToString());

                if (tokenLower == "*")
                {
                    // wildcard.
                    map.From = null;
                }
                else
                {
                    map.From = idE.DeclManager.FindMaterial(token.ToString());
                }

                mappings.Add(map);
            }

            _mappings         = mappings.ToArray();
            _associatedModels = associatedModels.ToArray();

            return(false);
        }
コード例 #22
0
ファイル: idDeclEmail.cs プロジェクト: iainmckay/idtech4.net
		public override bool Parse(string text)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idLexer lexer = new idLexer(LexerOptions.NoStringConcatination | LexerOptions.AllowPathNames | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination | LexerOptions.NoFatalErrors);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			idToken token;

			_text = string.Empty;

			string tokenLower;
			string tokenValue;

			// scan through, identifying each individual parameter
			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenValue = token.ToString();
				tokenLower = tokenValue.ToLower();

				if(tokenValue == "}")
				{
					break;
				}
				else if(tokenLower == "subject")
				{
					_subject = lexer.ReadToken().ToString();
				}
				else if(tokenLower == "to")
				{
					_to = lexer.ReadToken().ToString();
				}
				else if(tokenLower == "from")
				{
					_from = lexer.ReadToken().ToString();
				}
				else if(tokenLower == "date")
				{
					 _date = lexer.ReadToken().ToString();
				}
				else if(tokenLower == "text")
				{
					token = lexer.ReadToken();
					tokenValue = token.ToString();

					if(tokenValue != "{")
					{
						lexer.Warning("Email dec '{0}' had a parse error", this.Name);
						return false;
					}

					while(((token = lexer.ReadToken()) != null) && (token.ToString() != "}"))
					{
						_text += token.ToString();
					}
				}
				else if(tokenLower == "image")
				{
					_image = lexer.ReadToken().ToString();
				}
			}

			if(lexer.HadError == true)
			{
				lexer.Warning("Email decl '{0}' had a parse error", this.Name);
				return false;
			}

			return true;
		}