/// <summary>
        /// Function to return the number of elements within a field.
        /// </summary>
        /// <param name="type">Type of this field.</param>
        /// <returns>The number of elements within a field.</returns>
        static public int FieldElementCount(VertexFieldType type)
        {
            switch (type)
            {
            case VertexFieldType.Float1:
                return(1);

            case VertexFieldType.Float2:
                return(2);

            case VertexFieldType.Float3:
                return(3);

            case VertexFieldType.Float4:
                return(4);

            case VertexFieldType.Short1:
                return(1);

            case VertexFieldType.Short2:
                return(2);

            case VertexFieldType.Short3:
                return(3);

            case VertexFieldType.Short4:
                return(4);

            case VertexFieldType.Color:
                return(1);

            case VertexFieldType.UByte4:
                return(4);
            }

            throw new Exception("Vertex field type '" + type.ToString() + "' is not recognized.");
        }
        /// <summary>
        /// Function to return the size in bytes of a vertex field.
        /// </summary>
        /// <param name="type">Type of the field to evaluate.</param>
        /// <returns>Size of the field in bytes.</returns>
        static public int SizeOf(VertexFieldType type)
        {
            switch (type)
            {
            case VertexFieldType.Float1:
                return(sizeof(float));

            case VertexFieldType.Float2:
                return(sizeof(float) * 2);

            case VertexFieldType.Float3:
                return(sizeof(float) * 3);

            case VertexFieldType.Float4:
                return(sizeof(float) * 4);

            case VertexFieldType.Short1:
                return(sizeof(short));

            case VertexFieldType.Short2:
                return(sizeof(short) * 2);

            case VertexFieldType.Short3:
                return(sizeof(short) * 3);

            case VertexFieldType.Short4:
                return(sizeof(short) * 4);

            case VertexFieldType.Color:
                return(sizeof(int));

            case VertexFieldType.UByte4:
                return(sizeof(byte) * 4);
            }

            throw new Exception("Vertex field type '" + type.ToString() + "' is not recognized.");
        }
Exemplo n.º 3
0
		/// <summary>
		/// Function to return the number of elements within a field.
		/// </summary>
		/// <param name="type">Type of this field.</param>
		/// <returns>The number of elements within a field.</returns>
		static public int FieldElementCount(VertexFieldType type)
		{
			switch(type)
			{
				case VertexFieldType.Float1:
					return 1;
				case VertexFieldType.Float2:
					return 2;
				case VertexFieldType.Float3:
					return 3;
				case VertexFieldType.Float4:
					return 4;
				case VertexFieldType.Short1:
					return 1;
				case VertexFieldType.Short2:
					return 2;
				case VertexFieldType.Short3:
					return 3;
				case VertexFieldType.Short4:
					return 4;
				case VertexFieldType.Color:
					return 1;
				case VertexFieldType.UByte4:
					return 4;
			}

			throw new Exception( "Vertex field type '" + type.ToString() + "' is not recognized.");
		}
Exemplo n.º 4
0
		/// <summary>
		/// Function to return the size in bytes of a vertex field.
		/// </summary>
		/// <param name="type">Type of the field to evaluate.</param>
		/// <returns>Size of the field in bytes.</returns>
		static public int SizeOf(VertexFieldType type)
		{
			switch(type)
			{
				case VertexFieldType.Float1:
					return sizeof(float);
				case VertexFieldType.Float2:
					return sizeof(float) * 2;
				case VertexFieldType.Float3:
					return sizeof(float) * 3;
				case VertexFieldType.Float4:
					return sizeof(float) * 4;
				case VertexFieldType.Short1:
					return sizeof(short);
				case VertexFieldType.Short2:
					return sizeof(short) * 2;
				case VertexFieldType.Short3:
					return sizeof(short) * 3;
				case VertexFieldType.Short4:
					return sizeof(short) * 4;
				case VertexFieldType.Color:
					return sizeof(int);
				case VertexFieldType.UByte4:
					return sizeof(byte) * 4;
			}

			throw new Exception( "Vertex field type '" + type.ToString() + "' is not recognized.");
		}