- add new options in graphic config
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4735 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: e417b80e42c7bb394bbe596eb89afe1ccd33d166 Former-commit-id: 169d9bda387afc75b5d39f76162f319bb871b08e
This commit is contained in:
parent
750c241a2f
commit
110e0e8eb0
5 changed files with 80 additions and 25 deletions
|
@ -69,7 +69,9 @@
|
|||
#define GR_ATT_DYNAMICSKYDOME_ENABLED "enabled"
|
||||
#define GR_ATT_DYNAMICSKYDOME_DISABLED "disabled"
|
||||
#define GR_ATT_PRECIPDENSITY "precipitation density"
|
||||
#define GR_ATT_VISIBILITY "visibility"
|
||||
#define GR_ATT_BGSKY "background skydome"
|
||||
#define GR_ATT_BGSKYTYPE "background type"
|
||||
#define GR_ATT_BGSKY_RING "background"
|
||||
#define GR_ATT_BGSKY_LAND "land"
|
||||
#define GR_ATT_BGSKY_DISABLED "disabled"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
<!DOCTYPE params SYSTEM "../../../libs/tgf/params.dtd">
|
||||
|
||||
<params name="graph" type="param" mode="mw" version="1.7">
|
||||
<params name="graph" type="param" mode="mw" version="1.8">
|
||||
<section name="Graphic">
|
||||
<attnum name="smoke value" val="300"/>
|
||||
<attnum name="smoke interval" val="0.01"/>
|
||||
|
@ -31,6 +31,12 @@
|
|||
<attnum name="precipitation density" unit="%" val="100"/>
|
||||
<attnum name="cloudlayer" val="1"/>
|
||||
<attstr name="background skydome" val="enabled"/>
|
||||
<attstr name="background type" val="background"/>
|
||||
<attnum name="visibility" val="12000"/>
|
||||
<attstr name="spectator LOD" val="none"/>
|
||||
<attstr name="forest LOD" val="none"/>
|
||||
<attstr name="tree LOD" val="none"/>
|
||||
<attstr name="parking LOD" val="none"/>
|
||||
</section>
|
||||
|
||||
<section name="Playable Cameras Distance of Views">
|
||||
|
|
|
@ -263,14 +263,18 @@ grInitBackground()
|
|||
|
||||
cloudLayers[0] = TheSky->addCloud(buf, grSkyDomeDistance, 650,
|
||||
400 / domeSizeRatio, 400 / domeSizeRatio);
|
||||
cloudLayers[0]->setSpeed(100);
|
||||
cloudLayers[0]->setDirection(60);
|
||||
}
|
||||
else if (grNbCloudLayers == 1)
|
||||
{
|
||||
GfLogInfo(" Cloud cover : 3 layers\n");
|
||||
|
||||
int wind = (rand() % 60) + 40;
|
||||
|
||||
cloudLayers[0] = TheSky->addCloud(buf, grSkyDomeDistance, 2550,
|
||||
100 / domeSizeRatio, 100 / domeSizeRatio);
|
||||
cloudLayers[0]->setSpeed(60);
|
||||
cloudLayers[0]->setSpeed(wind);
|
||||
cloudLayers[0]->setDirection(45);
|
||||
|
||||
GfLogInfo(" * layer 1 : speed=60, direction=45, texture=%s\n", buf);
|
||||
|
@ -304,7 +308,8 @@ grInitBackground()
|
|||
snprintf(buf, sizeof(buf), "data/textures/scattered%d.rgba", 1);
|
||||
cloudLayers[0] = TheSky->addCloud(buf, grSkyDomeDistance, 3000,
|
||||
100 / domeSizeRatio, 100 / domeSizeRatio);
|
||||
cloudLayers[0]->setSpeed(30);
|
||||
int wind = (rand() % 40) + 60;
|
||||
cloudLayers[0]->setSpeed(wind);
|
||||
cloudLayers[0]->setDirection(40);
|
||||
|
||||
GfLogInfo(" * layer 1 : speed=30, direction=40, texture=%s\n", buf);
|
||||
|
@ -333,7 +338,6 @@ grInitBackground()
|
|||
|
||||
// Initialize the whole sky dome.
|
||||
sgVec3 viewPos;
|
||||
//sgSetVec3(viewPos, (track->max.x)/2, 0, (track->max.z)/2);
|
||||
sgSetVec3(viewPos,grWrldX/2, grWrldY/2, 0);
|
||||
TheSky->repositionFlat(viewPos, 0, 0);
|
||||
|
||||
|
@ -344,7 +348,7 @@ grInitBackground()
|
|||
{
|
||||
case TR_RAIN_NONE:
|
||||
//visibility = 0.0f;
|
||||
visibility = 2500.0;
|
||||
visibility = 12000.0f;
|
||||
break;
|
||||
case TR_RAIN_LITTLE:
|
||||
//visibility = 400.0f;
|
||||
|
@ -880,8 +884,8 @@ void grLoadBackgroundSky(void)
|
|||
desc2 = grssgLoadAC3D(bgsky, NULL);
|
||||
BackSkyAnchor->addKid(desc2);
|
||||
|
||||
// move backgroundsky in scene center
|
||||
sgCoord BackSkypos;
|
||||
//sgSetCoord ( &backskypos, double(grWrldX/2), 0.0f, double(grWrldZ/2));
|
||||
sgSetCoord(&BackSkypos, grWrldX/2, grWrldY/2, 0, 0, 0, 0);
|
||||
BackSkyLoc->setTransform(&BackSkypos);
|
||||
}
|
||||
|
@ -966,7 +970,6 @@ grUpdateSky(double currentTime, double accelTime)
|
|||
// At each call, update possibly high speed objects of the sky dome : the clouds.
|
||||
sgVec3 viewPos;
|
||||
sgSetVec3(viewPos, grWrldX/2, grWrldY/2, 0);
|
||||
//sgSetVec3(viewPos, 0, 0, 0);
|
||||
TheSky->repositionFlat(viewPos, 0, currentTime - lastTimeHighSpeed);
|
||||
|
||||
// Now, we are done for high speed objects.
|
||||
|
@ -974,28 +977,31 @@ grUpdateSky(double currentTime, double accelTime)
|
|||
|
||||
// Check if time to update low speed objects : sun and moon (once every minute).
|
||||
int nextTimeLowSpeed = 60 * (int)floor((accelTime + 60.0) / 60.0);
|
||||
if (nextTimeLowSpeed == lastTimeLowSpeed)
|
||||
return;
|
||||
/*if (nextTimeLowSpeed == lastTimeLowSpeed)
|
||||
return;*/
|
||||
const float deltaTimeLowSpeed = (float)(nextTimeLowSpeed - lastTimeLowSpeed);
|
||||
lastTimeLowSpeed = nextTimeLowSpeed;
|
||||
//lastTimeLowSpeed = nextTimeLowSpeed;
|
||||
|
||||
// Update sun and moon, and thus global lighting / coloring parameters of the scene.
|
||||
//GfLogDebug("%f : Updating slow objects of the dynamic sky dome (sun and moon)\n", currentTime);
|
||||
if (nextTimeLowSpeed != lastTimeLowSpeed)
|
||||
{
|
||||
// 1) Update sun position
|
||||
const float deltaDecl = deltaTimeLowSpeed * 360.0f / (24.0f * 60.0f * 60.0f);
|
||||
grSunDeclination += deltaDecl;
|
||||
if (grSunDeclination >= 360.0f)
|
||||
grSunDeclination -= 360.0f;
|
||||
|
||||
// 1) Update sun position
|
||||
const float deltaDecl = deltaTimeLowSpeed * 360.0f / (24.0f * 60.0f * 60.0f);
|
||||
grSunDeclination += deltaDecl;
|
||||
if (grSunDeclination >= 360.0f)
|
||||
grSunDeclination -= 360.0f;
|
||||
|
||||
TheCelestBodies[eCBSun]->setDeclination ( DEG2RAD(grSunDeclination) );
|
||||
TheCelestBodies[eCBSun]->setDeclination ( DEG2RAD(grSunDeclination) );
|
||||
|
||||
// 2) Update moon position
|
||||
grMoonDeclination += deltaDecl;
|
||||
if (grMoonDeclination >= 360.0f)
|
||||
grMoonDeclination -= 360.0f;
|
||||
// 2) Update moon position
|
||||
grMoonDeclination += deltaDecl;
|
||||
if (grMoonDeclination >= 360.0f)
|
||||
grMoonDeclination -= 360.0f;
|
||||
|
||||
TheCelestBodies[eCBMoon]->setDeclination ( DEG2RAD(grMoonDeclination) );
|
||||
TheCelestBodies[eCBMoon]->setDeclination ( DEG2RAD(grMoonDeclination) );
|
||||
lastTimeLowSpeed = nextTimeLowSpeed;
|
||||
}
|
||||
|
||||
// 3) Update scene color and light
|
||||
const float sol_angle = (float)TheCelestBodies[eCBSun]->getAngle();
|
||||
|
|
|
@ -70,7 +70,7 @@ loadOptions()
|
|||
|
||||
BackgroundTypeIndex = 0; // Default value index, in case file value not found in list.
|
||||
const char* pszBackgroundType =
|
||||
GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, GR_ATT_BGSKY_RING);
|
||||
GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKYTYPE, GR_ATT_BGSKY_RING);
|
||||
for (int i = 0; i < NbBackgroundTypeValues; i++)
|
||||
{
|
||||
if (!strcmp(pszBackgroundType, BackgroundTypeValues[i]))
|
||||
|
@ -128,7 +128,7 @@ saveOptions()
|
|||
snprintf(buf, sizeof(buf), "%s%s", GfLocalDir(), GR_PARAM_FILE);
|
||||
void* grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
|
||||
|
||||
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, BackgroundTypeValues[BackgroundTypeIndex]);
|
||||
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKYTYPE, BackgroundTypeValues[BackgroundTypeIndex]);
|
||||
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_AGR_FOREST, ForestValues[ForestIndex]);
|
||||
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_AGR_TREE, TreeValues[TreeIndex]);
|
||||
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_AGR_PARKING, ParkingValues[ParkingIndex]);
|
||||
|
|
|
@ -43,9 +43,12 @@ static const int PrecipDensityValues[] = {0, 20, 40, 60, 80, 100};
|
|||
static const int NbPrecipDensityValues = sizeof(PrecipDensityValues) / sizeof(PrecipDensityValues[0]);
|
||||
static const int CloudLayersValues[] = {1, 2, 3};
|
||||
static const int NbCloudLayersValues = sizeof(CloudLayersValues) / sizeof(CloudLayersValues[0]);
|
||||
static const char* BackgroundLandscapeValues[] = { GR_ATT_BGSKY_DISABLED, GR_ATT_BGSKY_RING, GR_ATT_BGSKY_LAND };
|
||||
static const char* BackgroundLandscapeValues[] = { GR_ATT_BGSKY_DISABLED, GR_ATT_BGSKY_ENABLED };
|
||||
static const int NbBackgroundLandscapeValues = sizeof(BackgroundLandscapeValues) / sizeof(BackgroundLandscapeValues[0]);
|
||||
|
||||
static const int VisibilityValues[] = { 4000, 6000, 8000, 10000, 12000, 15000 };
|
||||
static const int NbVisibilityValues = sizeof(VisibilityValues) / sizeof(VisibilityValues[0]);
|
||||
|
||||
static void *ScrHandle = NULL;
|
||||
|
||||
static int FovEditId;
|
||||
|
@ -57,6 +60,7 @@ static int DynamicTimeOfDayLabelId, DynamicTimeOfDayLeftButtonId, DynamicTimeOfD
|
|||
static int PrecipDensityLabelId;
|
||||
static int CloudLayersLabelId, CloudLayersLeftButtonId, CloudLayersRightButtonId;
|
||||
static int BackgroundLandscapeLabelId, BackgroundLandscapeLeftButtonId, BackgroundLandscapeRightButtonId;
|
||||
static int VisibilityLabelId, VisibilityLeftButtonId, VisibilityRightButtonId;
|
||||
|
||||
static int FovFactorValue = 100;
|
||||
static int SmokeValue = 300;
|
||||
|
@ -67,6 +71,7 @@ static int DynamicTimeOfDayIndex = 0;
|
|||
static int PrecipDensityIndex = NbPrecipDensityValues - 1;
|
||||
static int CloudLayerIndex = 0;
|
||||
static int BackgroundLandscapeIndex = 0;
|
||||
static int VisibilityIndex = 0;
|
||||
|
||||
static char buf[512];
|
||||
|
||||
|
@ -146,6 +151,16 @@ loadOptions()
|
|||
}
|
||||
}
|
||||
|
||||
VisibilityIndex = NbVisibilityValues -1; // Default value index, in case file value not found in list.
|
||||
const int nVisibility =
|
||||
(int)(GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_VISIBILITY, NULL, 12000.0));
|
||||
for (int i = 0; i < NbVisibilityValues; i++)
|
||||
{
|
||||
if (nVisibility <= VisibilityValues[i])
|
||||
VisibilityIndex = i;
|
||||
break;
|
||||
}
|
||||
|
||||
GfParmReleaseHandle(grHandle);
|
||||
}
|
||||
|
||||
|
@ -167,6 +182,7 @@ saveOptions()
|
|||
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_PRECIPDENSITY, "%", PrecipDensityValues[PrecipDensityIndex]);
|
||||
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_CLOUDLAYER, NULL, CloudLayersValues[CloudLayerIndex]);
|
||||
GfParmSetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, BackgroundLandscapeValues[BackgroundLandscapeIndex]);
|
||||
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_VISIBILITY, NULL, VisibilityValues[VisibilityIndex]);
|
||||
|
||||
GfParmWriteFile(NULL, grHandle, "graph");
|
||||
|
||||
|
@ -175,6 +191,16 @@ saveOptions()
|
|||
|
||||
// GUI callback functions ===================================================================
|
||||
|
||||
|
||||
static void
|
||||
onChangeVisibility(void* vp)
|
||||
{
|
||||
const long delta = (long)vp;
|
||||
VisibilityIndex = (VisibilityIndex + NbVisibilityValues + delta) % NbVisibilityValues;
|
||||
snprintf(buf, sizeof(buf), "%d", VisibilityValues[VisibilityIndex]);
|
||||
GfuiLabelSetText(ScrHandle, VisibilityLabelId, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
onChangeFov(void* vp)
|
||||
{
|
||||
|
@ -294,6 +320,13 @@ onChangeSkyDomeDistance(void* vp)
|
|||
onChangeCloudLayers(0); // Display real value.
|
||||
else
|
||||
GfuiLabelSetText(ScrHandle, CloudLayersLabelId, "1");
|
||||
|
||||
GfuiEnable(ScrHandle, VisibilityLeftButtonId, bSkyDome ? GFUI_ENABLE : GFUI_DISABLE);
|
||||
GfuiEnable(ScrHandle, VisibilityRightButtonId, bSkyDome ? GFUI_ENABLE : GFUI_DISABLE);
|
||||
if (bSkyDome)
|
||||
onChangeVisibility(0); // Display Real value.
|
||||
else
|
||||
GfuiLabelSetText(ScrHandle, VisibilityLabelId, "4000");
|
||||
|
||||
// No changes of FOV if sky dome enabled
|
||||
GfuiEnable(ScrHandle, FovEditId, bSkyDome ? GFUI_DISABLE : GFUI_ENABLE);
|
||||
|
@ -320,6 +353,7 @@ onActivate(void* /* dummy */)
|
|||
onChangeSkid(0);
|
||||
onChangeSkyDomeDistance(0); // Also loads DynamicTimeOfDay, BackgroundLandscape, CloudLayers
|
||||
onChangePrecipDensity(0);
|
||||
onChangeVisibility(0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -392,6 +426,13 @@ GraphMenuInit(void* prevMenu)
|
|||
BackgroundLandscapeLabelId =
|
||||
GfuiMenuCreateLabelControl(ScrHandle, param, "bgskydomelabel");
|
||||
|
||||
VisibilityLeftButtonId =
|
||||
GfuiMenuCreateButtonControl(ScrHandle, param, "visibilityleftarrow", (void*)-1, onChangeVisibility);
|
||||
VisibilityRightButtonId =
|
||||
GfuiMenuCreateButtonControl(ScrHandle, param, "visibilityrightarrow", (void*)1, onChangeVisibility);
|
||||
VisibilityLabelId =
|
||||
GfuiMenuCreateLabelControl(ScrHandle, param, "visibilitylabel");
|
||||
|
||||
GfuiMenuCreateButtonControl(ScrHandle, param, "ApplyButton", prevMenu, onAccept);
|
||||
GfuiMenuCreateButtonControl(ScrHandle, param, "CancelButton", prevMenu, onCancel);
|
||||
|
||||
|
|
Loading…
Reference in a new issue