public ColorValue GetSaturate() { ColorValue r = this; r.Saturate(); return(r); }
public void Saturate() { Color.Saturate(); if (Power < 0) { Power = 0; } else if (Power > 1) { Power = 1; } }
///// <summary>Utility method which returns the count of values in a given type.</summary> ///// <param name="type">The element type.</param> ///// <returns>The types count.</returns> //public static int GetTypeCount( VertexElementTypes type ) //{ // switch( type ) // { // case VertexElementTypes.Color: // case VET_COLOUR_ABGR: // case VET_COLOUR_ARGB: // return 1; // case VET_FLOAT1: // return 1; // case VET_FLOAT2: // return 2; // case VET_FLOAT3: // return 3; // case VET_FLOAT4: // return 4; // case VET_SHORT1: // return 1; // case VET_SHORT2: // return 2; // case VET_SHORT3: // return 3; // case VET_SHORT4: // return 4; // case VET_UBYTE4: // return 4; // } // //OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid type", // // "VertexElement::getTypeCount"); // return 0; //} ///// <summary> ///// Simple converter function which will turn a single-value type into a ///// multi-value type based on a parameter. ///// </summary> ///// <param name="baseType">The base type.</param> ///// <param name="count">The count.</param> ///// <returns>The element type.</returns> //public static VertexElementTypes MultiplyTypeCount( VertexElementTypes baseType, int count ) //{ // unsafe // { // return OgreVertexElement.multiplyTypeCount( baseType, count ); // } //} ///// <summary> ///// Simple converter function which will a type into it's single-value ///// equivalent - makes switches on type easier. ///// </summary> ///// <param name="multiType">The multi type.</param> ///// <returns>The element type.</returns> //public static VertexElementTypes GetBaseType( VertexElementTypes multiType ) //{ // unsafe // { // return OgreVertexElement.getBaseType( multiType ); // } //} /// <summary>Utility method for converting color to a packed 32-bit color type.</summary> /// <param name="color">The source color.</param> /// <param name="destinationType">The destination type.</param> /// <returns>The packed color type.</returns> public static uint ConvertColorValue(ColorValue color, VertexElementType destinationType) { //fix parameters color.Saturate(); if (destinationType != VertexElementType.ColorARGB && destinationType != VertexElementType.ColorABGR) { //!!!!Windows? not D3D? RenderSystem.ConvertColorValue if (SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows || SystemSettings.CurrentPlatform == SystemSettings.Platform.UWP) { destinationType = VertexElementType.ColorARGB; } else { destinationType = VertexElementType.ColorABGR; } } if (destinationType == VertexElementType.ColorARGB) { byte val8; uint val32 = 0; val8 = (byte)(color.Alpha * 255); val32 = (uint)val8 << 24; val8 = (byte)(color.Red * 255); val32 += (uint)val8 << 16; val8 = (byte)(color.Green * 255); val32 += (uint)val8 << 8; val8 = (byte)(color.Blue * 255); val32 += (uint)val8; return(val32); } else //if( destinationType == VertexElementTypes.ColorABGR ) { byte val8; uint val32 = 0; val8 = (byte)(color.Alpha * 255); val32 = (uint)val8 << 24; val8 = (byte)(color.Blue * 255); val32 += (uint)val8 << 16; val8 = (byte)(color.Green * 255); val32 += (uint)val8 << 8; val8 = (byte)(color.Red * 255); val32 += (uint)val8; return(val32); } //return ConvertColorValue( ref color, destinationType ); }