From cb541dac471bf6fb9d92e6134ffd1c480c6094a6 Mon Sep 17 00:00:00 2001 From: pouillot Date: Sun, 12 Jun 2011 18:44:00 +0000 Subject: [PATCH] Restored lens flare effect when static background (not available yet for the sky dome case) git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3676 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: b7665e5faf0a3a20484002621a79f47b5d9104ee Former-commit-id: 188812137355e12dc2784e41788f19bb6e5d499e --- src/modules/graphic/ssggraph/grbackground.cpp | 46 +++++++++---------- src/modules/graphic/ssggraph/grscene.h | 1 - 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/modules/graphic/ssggraph/grbackground.cpp b/src/modules/graphic/ssggraph/grbackground.cpp index 9ad963b1f..0f0464c61 100755 --- a/src/modules/graphic/ssggraph/grbackground.cpp +++ b/src/modules/graphic/ssggraph/grbackground.cpp @@ -21,7 +21,9 @@ #include //RtXXX() #include // snprintf -#include // snprintf +#include + +#include #include "grscene.h" #include "grmain.h" @@ -64,8 +66,6 @@ grMultiTexState *grEnvState = NULL; grMultiTexState *grEnvShadowState = NULL; grMultiTexState *grEnvShadowStateOnCars = NULL; -ssgBranch *SunAnchor = NULL; - unsigned grSkyDomeDistance = 0; // Some private global variables. @@ -75,6 +75,8 @@ static int grBackgroundType = 0; static float grSunDeclination = 0.0f; static float grMoonDeclination = 0.0f; +static ssgBranch *SunAnchor = NULL; + static ssgRoot *TheBackground = NULL; static ssgTransform *TheSun = NULL; @@ -156,15 +158,14 @@ grInitBackground(void) glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); - /*if (!SUN) - { - ssgaLensFlare *sun_obj = NULL ; - sun_obj = new ssgaLensFlare () ; - TheSun = new ssgTransform ; - TheSun-> setTransform( solposn ) ; - TheSun-> addKid( sun_obj ) ; - SunAnchor-> addKid(TheSun) ; - }*/ + if (!TheSun) + { + ssgaLensFlare *sun_obj = new ssgaLensFlare(); + TheSun = new ssgTransform; + TheSun->setTransform(lightPosition); + TheSun->addKid(sun_obj); + SunAnchor->addKid(TheSun); + } } // If realistic sky dome is requested, @@ -669,12 +670,13 @@ grLoadBackground(void) GfLogError("Unsupported background type %d\n", graphic->bgtype); break; }//switch grBackgroundType + + // Lens Flares when no sky dome (realistic sky dome will use another system when ready). + SunAnchor = new ssgBranch; + TheScene->addKid(SunAnchor); + } //if (!grSkyDomeDistance || grTrack->skyversion < 1) - // Lens Flares - SunAnchor = new ssgBranch; - TheScene->addKid(SunAnchor); - // Environment Mapping Settings bool bUseEnvPng = false; // Avoid crash with missing env.rgb files (i.e. Wheel-1) bool bDoNotUseEnv = false; // Avoid crash with missing env.png @@ -876,29 +878,27 @@ grShutdownBackground(void) TheSky = 0; } - if (TheSun) { - delete TheSun; + if (TheSun) TheSun = 0; - } if (grEnvState) { ssgDeRefDelete(grEnvState); - grEnvState = NULL; + grEnvState = 0; } if (grEnvShadowState) { ssgDeRefDelete(grEnvShadowState); - grEnvShadowState = NULL; + grEnvShadowState = 0; } if (grEnvShadowStateOnCars) { ssgDeRefDelete(grEnvShadowStateOnCars); - grEnvShadowStateOnCars = NULL; + grEnvShadowStateOnCars = 0; } if(grEnvSelector) { delete grEnvSelector; - grEnvSelector = NULL; + grEnvSelector = 0; } }//grShutdownBackground diff --git a/src/modules/graphic/ssggraph/grscene.h b/src/modules/graphic/ssggraph/grscene.h index 4ff2deba8..0cb3d1442 100644 --- a/src/modules/graphic/ssggraph/grscene.h +++ b/src/modules/graphic/ssggraph/grscene.h @@ -37,7 +37,6 @@ extern int grWrldMaxSize; extern tTrack *grTrack; extern ssgRoot *TheScene; -extern ssgBranch *SunAnchor; extern ssgBranch *LandAnchor; extern ssgBranch *CarsAnchor; extern ssgBranch *ShadowAnchor;