- bugfix for lighting of tileset objects, when rotated objects had weird lighting causing random light patterns to show on them.
This commit is contained in:
parent
f8630e086e
commit
e2fcf9ed94
|
@ -1004,6 +1004,34 @@ void Renderer::setupLighting() {
|
|||
assertGl();
|
||||
}
|
||||
|
||||
void Renderer::setupLightingForRotatedModel() {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const World *world= game->getWorld();
|
||||
const GameCamera *gameCamera= game->getGameCamera();
|
||||
const TimeFlow *timeFlow= world->getTimeFlow();
|
||||
float time= timeFlow->getTime();
|
||||
|
||||
assertGl();
|
||||
|
||||
//sun/moon light
|
||||
Vec3f lightColor= timeFlow->computeLightColor();
|
||||
Vec3f fogColor= world->getTileset()->getFogColor();
|
||||
Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time);
|
||||
//nearestLightPos= lightPos;
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, lightPos.ptr());
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, Vec4f(lightColor*lightAmbFactor, 1.f).ptr());
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, Vec4f(lightColor, 1.f).ptr());
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, Vec4f(0.0f, 0.0f, 0.f, 1.f).ptr());
|
||||
|
||||
glFogfv(GL_FOG_COLOR, Vec4f(fogColor*lightColor, 1.f).ptr());
|
||||
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void Renderer::loadGameCameraMatrix() {
|
||||
const GameCamera *gameCamera= game->getGameCamera();
|
||||
|
||||
|
@ -4508,6 +4536,10 @@ void Renderer::renderObjects(const int renderFps) {
|
|||
glTranslatef(v.x, v.y, v.z);
|
||||
glRotatef(o->getRotation(), 0.f, 1.f, 0.f);
|
||||
|
||||
if(o->getRotation() != 0.0) {
|
||||
setupLightingForRotatedModel();
|
||||
}
|
||||
|
||||
//objModel->updateInterpolationData(0.f, true);
|
||||
objModel->updateInterpolationData(o->getAnimProgress(), true);
|
||||
modelRenderer->render(objModel);
|
||||
|
|
|
@ -460,6 +460,7 @@ public:
|
|||
|
||||
//lights and camera
|
||||
void setupLighting();
|
||||
void setupLightingForRotatedModel();
|
||||
void loadGameCameraMatrix();
|
||||
void loadCameraMatrix(const Camera *camera);
|
||||
void computeVisibleQuad();
|
||||
|
|
|
@ -261,8 +261,11 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
|
|||
}
|
||||
}
|
||||
|
||||
//rotationAllowed
|
||||
if(modelNode->hasChild("rotationAllowed")){
|
||||
//rotationAllowed
|
||||
if(modelNode->hasAttribute("rotationAllowed") == true) {
|
||||
tmt->setRotationAllowed(modelNode->getAttribute("rotationAllowed")->getBoolValue());
|
||||
}
|
||||
else if(modelNode->hasChild("rotationAllowed")){
|
||||
const XmlNode *rotationAllowedNode= modelNode->getChild("rotationAllowed");
|
||||
tmt->setRotationAllowed(rotationAllowedNode->getAttribute("value")->getBoolValue());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue