Example #1
0
        private Bitmap mTextureImage; // the bitmap image file.

        /// <summary>
        /// Constructs from parsing the command file.
        /// DO NOT change the parser loop unless you know what you are doing.
        /// </summary>
        /// <param name="parser"></param>
        public RTTextureType_Color(CommandFileParser parser)
        {
            while (!parser.IsEndElement("texture"))
            {
                if (parser.IsElement() && (!parser.IsElement("texture")))
                {
                    if (parser.IsElement("filename"))
                    {
                        String name = parser.ReadString();
                        name = parser.FullPath() + "\\" + name;
                        if (System.IO.File.Exists(name))
                        {
                            mTextureImage = new Bitmap(name, true);
                        }
                        else
                        {
                            parser.ParserError("TextureType_Color filename");
                        }
                    }
                    else
                    {
                        parser.ParserError("TextureType_Color");
                    }
                }
                else
                {
                    parser.ParserRead();
                }
            }
        }
        private Bitmap mTextureImage; // the bitmap image file.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructs from parsing the command file.
        /// DO NOT change the parser loop unless you know what you are doing.
        /// </summary>
        /// <param name="parser"></param>
        public RTTextureType_Bump(CommandFileParser parser)
        {
            mGain = 1.0f;

            while (!parser.IsEndElement("texture"))
            {
                if (parser.IsElement() && (!parser.IsElement("texture")))
                {
                    if (parser.IsElement("filename")) {
                        String name = parser.ReadString();
                        name = parser.FullPath() + "\\" + name;
                        if (System.IO.File.Exists(name))
                            mTextureImage = new Bitmap(name, true);
                        else
                            parser.ParserError("TextureType_Bump filename");
                    }
                    else if (parser.IsElement("gain"))
                        mGain = parser.ReadFloat();
                    else
                        parser.ParserError("TextureType_Bump");
                }
                else
                    parser.ParserRead();
            }
            mInvWidth = 1f / (float)(mTextureImage.Width - 1);
            mInvHeight = 1f / (float)(mTextureImage.Height - 1);
        }
        private Bitmap mTextureImage; // the bitmap image file.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructs from parsing the command file.
        /// DO NOT change the parser loop unless you know what you are doing.
        /// </summary>
        /// <param name="parser"></param>
        public RTTextureType_Color(CommandFileParser parser)
        {
            while (!parser.IsEndElement("texture"))
            {
                if (parser.IsElement() && (!parser.IsElement("texture")))
                {
                    if (parser.IsElement("filename")) {
                        String name = parser.ReadString();
                        name = parser.FullPath() + "\\" + name;
                        if (System.IO.File.Exists(name))
                            mTextureImage = new Bitmap(name, true);
                        else
                            parser.ParserError("TextureType_Color filename");
                    }
                    else
                        parser.ParserError("TextureType_Color");
                }
                else
                    parser.ParserRead();
            }
        }
        /// <summary>
        /// Constructs from parsing the command file.
        /// DO NOT change the parser loop unless you know what you are doing.
        /// </summary>
        /// <param name="parser"></param>
        public RTTextureType_Bump(CommandFileParser parser)
        {
            mGain = 1.0f;

            while (!parser.IsEndElement("texture"))
            {
                if (parser.IsElement() && (!parser.IsElement("texture")))
                {
                    if (parser.IsElement("filename"))
                    {
                        String name = parser.ReadString();
                        name = parser.FullPath() + "\\" + name;
                        if (System.IO.File.Exists(name))
                        {
                            mTextureImage = new Bitmap(name, true);
                        }
                        else
                        {
                            parser.ParserError("TextureType_Bump filename");
                        }
                    }
                    else if (parser.IsElement("gain"))
                    {
                        mGain = parser.ReadFloat();
                    }
                    else
                    {
                        parser.ParserError("TextureType_Bump");
                    }
                }
                else
                {
                    parser.ParserRead();
                }
            }
            mInvWidth  = 1f / (float)(mTextureImage.Width - 1);
            mInvHeight = 1f / (float)(mTextureImage.Height - 1);
        }