Rendering/Lighting
Jump to navigation
Jump to search
Overview
Note: this page largely deals with how lighting worked in the WotLK era. Large chunks of this are relevant from the vanilla era through WoD.
Doodad Lighting
CMapDoodadDef::QueryInteriorLighting
void CMapDoodadDef::QueryInteriorLighting(CMapDoodadDef *this, CMapObjDef *mapObjDef, uint32_t groupIdx, uint16_t *polyIdx, const C3Vector *pos) {
CImVector color = 0;
bool lightRes;
if (polyIdx) {
C3Vector lPos;
operator*(&lPos, pos, &mapObjDef->invMat);
lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &lPos, *polyIdx, &color, (bool *)&mapObjDef + 3);
} else {
C3Vector wStart;
C3Vector lStart;
wStart.x = this->m_mat.columns[3].x;
wStart.y = this->m_mat.columns[3].y;
wStart.z = this->m_mat.columns[3].z + 1.5;
operator*(&lStart, &wStart, &mapObjDef->invMat);
C3Vector wEnd;
C3Vector lEnd;
wEnd.x = this->m_mat.columns[3].x;
wEnd.y = this->m_mat.columns[3].y;
wEnd.z = this->m_mat.columns[3].z - 1760.0;
operator*(&lEnd, &wEnd, &mapObjDef->invMat);
C3Segment seg;
seg.start = lStart;
seg.end = lEnd;
lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &seg, &color, (bool *)&mapObjDef + 3);
}
if (lightRes) {
CMapStaticEntity::AdjustLighting(&color, &this->dirColor, 0xA8u, &this->ambColor, 0x60u);
if (BYTE3(mapObjDef)) {
dnInfo = DayNightGetInfo();
if (color.a) {
CImVector::BlendRGB255(&v7->dirColor, color.a, (const CImVector *)dnInfo + 106);
CImVector::BlendRGB255(&v7->ambColor, color.a, (const CImVector *)dnInfo + 107);
}
this->dirColor.a = color.a;
this->unk3 |= 0x1000u;
} else {
this->unk3 &= 0xFFFFEFFF;
}
}
}