Merge branch 'master' of https://git.teknik.io/scuti/reflex2q3
This commit is contained in:
commit
7747fd32fb
@ -639,7 +639,8 @@ EntityConverter::convertPointLight(const std::vector<std::string> &lines) const
|
|||||||
float green;
|
float green;
|
||||||
float blue;
|
float blue;
|
||||||
// Convert 32bit hex value into RGB values
|
// Convert 32bit hex value into RGB values
|
||||||
hexToRGB(color, red, green, blue);
|
float backgroundColor = 0.5; //!! Just a guess
|
||||||
|
hexToRGB(color, backgroundColor, red, green, blue);
|
||||||
colorStream << "\"_color\" \"" << red << " " << green << " " << blue << "\"" << std::endl;
|
colorStream << "\"_color\" \"" << red << " " << green << " " << blue << "\"" << std::endl;
|
||||||
convertedLines.push_back (colorStream.str() );
|
convertedLines.push_back (colorStream.str() );
|
||||||
}
|
}
|
||||||
@ -740,17 +741,24 @@ EntityConverter::offset(const std::string &value, const float amount) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EntityConverter::hexToRGB(const std::string &hex, float &r, float &g, float &b) const
|
EntityConverter::hexToRGB(const std::string &hex, float background, float &r, float &g, float &b) const
|
||||||
{
|
{
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::hex << hex;
|
ss << std::hex << hex;
|
||||||
ss >> value;
|
ss >> value;
|
||||||
|
|
||||||
// get the necessary components from the top 3 bytes
|
// BYTE ORDER IS ARGB
|
||||||
r = ((value >> 16) & 0xFF) / 255.0;
|
// Get each value and normalize
|
||||||
g = ((value >> 8) & 0xFF) / 255.0;
|
float sourceAlpha = ((value >> 24) & 0xFF) / 255.0;
|
||||||
b = ((value) & 0xFF) / 255.0;
|
float sourceRed = ((value >> 16) & 0xFF) / 255.0;
|
||||||
|
float sourceGreen = ((value >> 8) & 0xFF) / 255.0;
|
||||||
|
float sourceBlue = ((value) & 0xFF) / 255.0;
|
||||||
|
|
||||||
|
// Convert RGB value close to something close to the source RGBA value
|
||||||
|
r = ((1 - sourceAlpha) * background) + (sourceAlpha * sourceRed);
|
||||||
|
g = ((1 - sourceAlpha) * background) + (sourceAlpha * sourceGreen);
|
||||||
|
b = ((1 - sourceAlpha) * background) + (sourceAlpha * sourceBlue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,13 +199,14 @@ class EntityConverter
|
|||||||
* Class: EntityConverter
|
* Class: EntityConverter
|
||||||
* Method: EntityConverter :: hexToRGB
|
* Method: EntityConverter :: hexToRGB
|
||||||
* Description: Convert 8 digit hex value into separate red, green, and blue values
|
* Description: Convert 8 digit hex value into separate red, green, and blue values
|
||||||
* Parameter: string hex, inputted hex value
|
* Parameter: string hex, inputted hex RGBA value (leftmost byte is alpha, then RGB)
|
||||||
|
* Parameter: float background, background color
|
||||||
* Parameter: float r, RETURN BY REFERENCE: converted red value
|
* Parameter: float r, RETURN BY REFERENCE: converted red value
|
||||||
* Parameter: float g, RETURN BY REFERENCE: converted green value
|
* Parameter: float g, RETURN BY REFERENCE: converted green value
|
||||||
* Parameter: float b, RETURN BY REFERENCE: converted blue value
|
* Parameter: float b, RETURN BY REFERENCE: converted blue value
|
||||||
*--------------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void hexToRGB(const std::string &hex, float &r, float &g, float &b) const;
|
void hexToRGB(const std::string &hex, const float background, float &r, float &g, float &b) const;
|
||||||
/*
|
/*
|
||||||
*--------------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------------
|
||||||
* Class: EntityConverter
|
* Class: EntityConverter
|
||||||
|
Loading…
Reference in New Issue
Block a user