WMO/Loading: Difference between revisions
Jump to navigation
Jump to search
(Migrating to loading page) |
No edit summary |
||
Line 1: | Line 1: | ||
== CMapObjGroup::FixColorVertexAlpha == | == Color Adjustments == | ||
=== CMapObjGroup::FixColorVertexAlpha === | |||
When loading a <tt>CMapObjGroup</tt>, if <tt>SMOHeader->flags</tt> <tt>0x8</tt> is '''not''' set, a vertex color adjustment routine called <tt>FixColorVertexAlpha</tt> is run against all vertex colors present in <tt>colorVertexList</tt>. | When loading a <tt>CMapObjGroup</tt>, if <tt>SMOHeader->flags</tt> <tt>0x8</tt> is '''not''' set, a vertex color adjustment routine called <tt>FixColorVertexAlpha</tt> is run against all vertex colors present in <tt>colorVertexList</tt>. |
Revision as of 02:35, 16 November 2017
Color Adjustments
CMapObjGroup::FixColorVertexAlpha
When loading a CMapObjGroup, if SMOHeader->flags 0x8 is not set, a vertex color adjustment routine called FixColorVertexAlpha is run against all vertex colors present in colorVertexList.
if ((this->parent->header->flags & 0x8) == 0) {
CMapObjGroup::FixColorVertexAlpha(this);
}
The logic is taken from build 3.3.5.12340. Later versions of the function may involve SMOHeader->ambColor and slightly different logic.
void CMapObjGroup::FixColorVertexAlpha(CMapObjGroup *this) {
int firstNonTransIndex;
if (this->transBatchCount > 0) {
firstNonTransIndex = this->batchList[this->transBatchCount - 1]->maxIndex + 1;
} else {
firstNonTransIndex = 0;
}
if (this->colorVertexCount) {
for (int i = 0; i < this->colorVertexCount; i++) {
CImVector *color = &this->colorVertexList[i];
// Adjust color in int or ext batch
if (i >= firstNonTransIndex) {
uint32_t r = (color->r + (((uint32_t)color->a * color->r) / 64)) / 2;
uint32_t g = (color->g + (((uint32_t)color->a * color->g) / 64)) / 2;
uint32_t b = (color->b + (((uint32_t)color->a * color->b) / 64)) / 2;
color->r = r > 255 ? 255 : r;
color->g = g > 255 ? 255 : g;
color->b = b > 255 ? 255 : b;
color->a = 255;
// Adjust color in trans batch
} else {
color->r /= 2;
color->g /= 2;
color->b /= 2;
}
}
}
}