implement special case for shadow and connect it into SetActorShadowValid lua opcode

This commit is contained in:
Pawel Kolodziejski 2008-07-12 17:12:38 +00:00
parent cae978e7aa
commit 321112a248
3 changed files with 12 additions and 5 deletions

View File

@ -63,6 +63,7 @@ Actor::Actor(const char *name) :
for (int i = 0; i < 5; i++) {
_shadowArray[i].active = false;
_shadowArray[i].dontNegate = false;
_shadowArray[i].shadowMask = NULL;
}
@ -669,10 +670,10 @@ void Actor::setActiveShadow(int shadowId) {
}
void Actor::setShadowValid(int valid) {
/* if (valid == -1)
_shadowArray[_activeShadowSlot].active = false;
if (valid == -1)
_shadowArray[_activeShadowSlot].dontNegate = true;
else
_shadowArray[_activeShadowSlot].active = true;*/
_shadowArray[_activeShadowSlot].dontNegate = false;
}
void Actor::setActivateShadow(int shadowId, bool state) {

View File

@ -48,6 +48,7 @@ struct Shadow {
SectorListType planeList;
byte *shadowMask;
bool active;
bool dontNegate;
};
class Actor {

View File

@ -185,7 +185,7 @@ bool DriverTinyGL::isHardwareAccelerated() {
return false;
}
void tglShadowProjection(Vector3d light, Vector3d plane, Vector3d normal) {
void tglShadowProjection(Vector3d light, Vector3d plane, Vector3d normal, bool dontNegate) {
// Based on GPL shadow projection example by
// (c) 2002-2003 Phaetos <phaetos@gaffga.de>
float d, c;
@ -196,6 +196,11 @@ void tglShadowProjection(Vector3d light, Vector3d plane, Vector3d normal) {
nx = -normal.x();
ny = -normal.y();
nz = -normal.z();
if (dontNegate) {
nx = -nx;
ny = -ny;
nz = -nz;
}
lx = light.x();
ly = light.y();
lz = light.z();
@ -239,7 +244,7 @@ void DriverTinyGL::startActorDraw(Vector3d pos, float yaw, float pitch, float ro
tglSetShadowMaskBuf(_currentShadowArray->shadowMask);
SectorListType::iterator i = _currentShadowArray->planeList.begin();
Sector *shadowSector = *i;
tglShadowProjection(_currentShadowArray->pos, shadowSector->getVertices()[0], shadowSector->getNormal());
tglShadowProjection(_currentShadowArray->pos, shadowSector->getVertices()[0], shadowSector->getNormal(), _currentShadowArray->dontNegate);
}
tglTranslatef(pos.x(), pos.y(), pos.z());
tglRotatef(yaw, 0, 0, 1);