MaterialsOptimizer.Parser.ReadFloat C# (CSharp) Method

ReadFloat() public method

public ReadFloat ( ) : float
return float
        public float ReadFloat()
        {
            if ( !SkipSpaces() )
                return 0.0f;
            int	StartIndex = m_Index;
            while ( OK && (IsNumeric() || IsChar( '-' ) || IsChar( '.' )) ) {
                m_Index++;
            }

            string	Number = m_Content.Substring( StartIndex, m_Index-StartIndex );
            float	Result = float.Parse( Number );
            return Result;
        }

Usage Example

Example #1
0
        public float4   ReadFloat4(string _block)
        {
            Parser P = new Parser(_block);

            float4 Result = new float4();

            int coordinateIndex = 0;

            while (P.OK)
            {
                float value = P.ReadFloat();
                P.ReadString();                 // Skip separator

                switch (coordinateIndex)
                {
                case 0: Result.x = value; break;

                case 1: Result.y = value; break;

                case 2: Result.z = value; break;

                case 3: Result.w = value; break;

                default: Error("Unexpected coordinate!"); break;
                }

                coordinateIndex++;
            }
            return(Result);
        }
All Usage Examples Of MaterialsOptimizer.Parser::ReadFloat