forked from speed-dreams/speed-dreams-code
- Removed skyversion
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6164 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: e1f5ddba6dc74c2a472c7217de6b490923e26f4d Former-commit-id: b6ac19bcbe9e96a859ba428c6e18af7939012c4f
This commit is contained in:
parent
94b5b303d5
commit
141a551654
7 changed files with 105 additions and 131 deletions
|
@ -42,7 +42,6 @@
|
|||
#define TRK_ATT_SURF "surface"
|
||||
#define TRK_ATT_NAME "name"
|
||||
#define TRK_ATT_VERSION "version"
|
||||
#define TRK_ATT_SKY_VERSION "sky version"
|
||||
#define TRK_ATT_AUTHOR "author"
|
||||
#define TRK_ATT_DESCR "description"
|
||||
#define TRK_ATT_CAT "category"
|
||||
|
@ -65,7 +64,6 @@
|
|||
#define TRK_SECT_GRAPH "Graphic"
|
||||
|
||||
#define TRK_ATT_3DDESC "3d description"
|
||||
#define TRK_ATT_3DDESC2 "3d osg"
|
||||
|
||||
#define TRK_ATT_BKGRND "background image"
|
||||
#define TRK_ATT_BGTYPE "background type"
|
||||
|
@ -646,7 +644,6 @@ typedef struct Track
|
|||
const char *subcategory; /**< used for the moment for long/short speedway */
|
||||
int nseg; /**< Number of segments */
|
||||
int version; /**< Version of the track type */
|
||||
int skyversion; /**< Version of the "Sky dome" feature */
|
||||
tdble length; /**< main track length */
|
||||
tdble width; /**< main track width */
|
||||
tTrackPitInfo pits; /**< Pits information */
|
||||
|
|
|
@ -761,7 +761,7 @@ void SDRender::UpdateSky(double currentTime, double accelTime)
|
|||
|
||||
if (!bInitialized)
|
||||
{
|
||||
if (SDSkyDomeDistance && SDTrack->skyversion > 0)
|
||||
if ( SDSkyDomeDistance )
|
||||
{
|
||||
// Ensure the sun and moon positions are reset
|
||||
const int timeOfDay = (int)SDTrack->local.timeofday;
|
||||
|
|
|
@ -66,140 +66,114 @@ SDScenery::~SDScenery(void)
|
|||
|
||||
void SDScenery::LoadScene(tTrack *track)
|
||||
{
|
||||
void *hndl = grTrackHandle;
|
||||
const char *acname;
|
||||
const char *osgname;
|
||||
char buf[256];
|
||||
void *hndl = grTrackHandle;
|
||||
const char *acname;
|
||||
const char *osgname;
|
||||
char buf[256];
|
||||
|
||||
GfOut("Initialisation class SDScenery\n");
|
||||
GfOut("Initialisation class SDScenery\n");
|
||||
|
||||
m_background = new SDBackground;
|
||||
//m_pit = new SDPit;
|
||||
_scenery = new osg::Group;
|
||||
SDTrack = track;
|
||||
m_background = new SDBackground;
|
||||
//m_pit = new SDPit;
|
||||
_scenery = new osg::Group;
|
||||
SDTrack = track;
|
||||
|
||||
// Load graphics options.
|
||||
LoadGraphicsOptions();
|
||||
// Load graphics options.
|
||||
LoadGraphicsOptions();
|
||||
|
||||
if(grHandle == NULL)
|
||||
{
|
||||
snprintf(buf, 256, "%s%s", GetLocalDir(), GR_PARAM_FILE);
|
||||
grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_REREAD);
|
||||
}//if grHandle
|
||||
if(grHandle == NULL)
|
||||
{
|
||||
snprintf(buf, 256, "%s%s", GetLocalDir(), GR_PARAM_FILE);
|
||||
grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_REREAD);
|
||||
}//if grHandle
|
||||
|
||||
/* Determine the world limits */
|
||||
grWrldX = (int)(SDTrack->max.x - SDTrack->min.x + 1);
|
||||
grWrldY = (int)(SDTrack->max.y - SDTrack->min.y + 1);
|
||||
grWrldZ = (int)(SDTrack->max.z - SDTrack->min.z + 1);
|
||||
grWrldMaxSize = (int)(MAX(MAX(grWrldX, grWrldY), grWrldZ));
|
||||
/* Determine the world limits */
|
||||
grWrldX = (int)(SDTrack->max.x - SDTrack->min.x + 1);
|
||||
grWrldY = (int)(SDTrack->max.y - SDTrack->min.y + 1);
|
||||
grWrldZ = (int)(SDTrack->max.z - SDTrack->min.z + 1);
|
||||
grWrldMaxSize = (int)(MAX(MAX(grWrldX, grWrldY), grWrldZ));
|
||||
|
||||
if (strcmp(SDTrack->category, "speedway") == 0)
|
||||
{
|
||||
_speedWay = true;
|
||||
if (strcmp(SDTrack->subcategory, "long") == 0)
|
||||
_speedWayLong = true;
|
||||
else
|
||||
_speedWayLong = false;
|
||||
}
|
||||
else
|
||||
_speedWay = false;
|
||||
if (strcmp(SDTrack->category, "speedway") == 0)
|
||||
{
|
||||
_speedWay = true;
|
||||
if (strcmp(SDTrack->subcategory, "long") == 0)
|
||||
_speedWayLong = true;
|
||||
else
|
||||
_speedWayLong = false;
|
||||
}
|
||||
else
|
||||
_speedWay = false;
|
||||
|
||||
GfOut("SpeedWay = %d - SubCategorie = %d\n", _speedWay, _speedWayLong);
|
||||
GfOut("SpeedWay = %d - SubCategorie = %d\n", _speedWay, _speedWayLong);
|
||||
|
||||
acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
||||
osgname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC2, "track.osg");
|
||||
GfOut("ACname = %s\n", acname);
|
||||
GfOut("OsgName = %s\n", osgname);
|
||||
acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
||||
|
||||
if (strlen(acname) == 0)
|
||||
{
|
||||
GfLogError("No specified track 3D model file\n");
|
||||
}
|
||||
GfOut("ACname = %s\n", acname);
|
||||
|
||||
std::string PathTmp = GetDataDir();
|
||||
if (strlen(acname) == 0)
|
||||
{
|
||||
GfLogError("No specified track 3D model file\n");
|
||||
}
|
||||
|
||||
if (_SkyDomeDistance > 0 && SDTrack->skyversion > 0)
|
||||
{
|
||||
_bgsky = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, GR_ATT_BGSKY_DISABLED), GR_ATT_BGSKY_ENABLED) == 0;
|
||||
if (_bgsky)
|
||||
{
|
||||
_bgtype = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKYTYPE, GR_ATT_BGSKY_RING), GR_ATT_BGSKY_LAND) == 0;
|
||||
std::string strPath = PathTmp;
|
||||
snprintf(buf, 256, "tracks/%s/%s/", SDTrack->category, SDTrack->internalname);
|
||||
strPath += buf;
|
||||
m_background->build(_bgtype, grWrldX, grWrldY, grWrldZ, strPath);
|
||||
GfOut("Background loaded\n");
|
||||
}
|
||||
}
|
||||
std::string PathTmp = GetDataDir();
|
||||
|
||||
std::string strPath = GetDataDir();
|
||||
snprintf(buf, 256, "tracks/%s/%s/", SDTrack->category, SDTrack->internalname);
|
||||
_bgsky = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, GR_ATT_BGSKY_DISABLED), GR_ATT_BGSKY_ENABLED) == 0;
|
||||
if (_bgsky)
|
||||
{
|
||||
_bgtype = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKYTYPE, GR_ATT_BGSKY_RING), GR_ATT_BGSKY_LAND) == 0;
|
||||
std::string strPath = PathTmp;
|
||||
snprintf(buf, 256, "tracks/%s/%s/", SDTrack->category, SDTrack->internalname);
|
||||
strPath += buf;
|
||||
m_background->build(_bgtype, grWrldX, grWrldY, grWrldZ, strPath);
|
||||
GfOut("Background loaded\n");
|
||||
}
|
||||
|
||||
std::string ext = osgDB::getFileExtension(acname);
|
||||
std::string strPath = GetDataDir();
|
||||
snprintf(buf, 256, "tracks/%s/%s/", SDTrack->category, SDTrack->internalname);
|
||||
|
||||
if (strcmp(osgname, "track.osg") == 0)
|
||||
{
|
||||
if (ext == "acc")
|
||||
{
|
||||
GfOut("Load 3D Model Scene ACC\n");
|
||||
strPath+=buf;
|
||||
_strTexturePath = strPath;
|
||||
strPath+=acname;
|
||||
std::string ext = osgDB::getFileExtension(acname);
|
||||
|
||||
LoadTrack(strPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath+=buf;
|
||||
if (ext == "acc")
|
||||
{
|
||||
GfOut("Load 3D Model Scene ACC\n");
|
||||
strPath+=buf;
|
||||
_strTexturePath = strPath;
|
||||
strPath+=acname;
|
||||
|
||||
std::string strTPath = GetDataDir();
|
||||
snprintf(buf, 256, "data/textures/");
|
||||
strTPath += buf;
|
||||
osgDB::FilePathList pathList = osgDB::Registry::instance()->getDataFilePathList();
|
||||
pathList.push_back(strPath);
|
||||
pathList.push_back(strTPath+"data/objects/");
|
||||
pathList.push_back(strTPath+"data/textures/");
|
||||
osgDB::Registry::instance()->setDataFilePathList(pathList);
|
||||
osg::ref_ptr<osg::Node> pTrack = osgDB::readNodeFile(acname);
|
||||
LoadTrack(strPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath+=buf;
|
||||
|
||||
if (ext =="ac")
|
||||
{
|
||||
osg::ref_ptr<osg::MatrixTransform> rot = new osg::MatrixTransform;
|
||||
osg::Matrix mat( 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
rot->setMatrix(mat);
|
||||
rot->addChild(pTrack);
|
||||
_scenery->addChild(rot.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
_scenery->addChild(pTrack.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GfOut("OSG MODEL 3D = %s\n", osgname);
|
||||
strPath+=buf;
|
||||
std::string strTPath = GetDataDir();
|
||||
snprintf(buf, 256, "data/textures/");
|
||||
strTPath += buf;
|
||||
std::string strTPath = GetDataDir();
|
||||
snprintf(buf, 256, "data/textures/");
|
||||
strTPath += buf;
|
||||
osgDB::FilePathList pathList = osgDB::Registry::instance()->getDataFilePathList();
|
||||
pathList.push_back(strPath);
|
||||
pathList.push_back(strTPath+"data/objects/");
|
||||
pathList.push_back(strTPath+"data/textures/");
|
||||
osgDB::Registry::instance()->setDataFilePathList(pathList);
|
||||
osg::ref_ptr<osg::Node> pTrack = osgDB::readNodeFile(acname);
|
||||
|
||||
osgDB::FilePathList pathList = osgDB::Registry::instance()->getDataFilePathList();
|
||||
pathList.push_back(strPath);
|
||||
pathList.push_back(strTPath+"data/objects/");
|
||||
pathList.push_back(strTPath+"data/textures/");
|
||||
osgDB::Registry::instance()->setDataFilePathList(pathList);
|
||||
osg::ref_ptr<osg::Node> pTrack = osgDB::readNodeFile( osgname );
|
||||
_scenery->addChild(pTrack.get());
|
||||
if (ext =="ac")
|
||||
{
|
||||
osg::ref_ptr<osg::MatrixTransform> rot = new osg::MatrixTransform;
|
||||
osg::Matrix mat( 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
rot->setMatrix(mat);
|
||||
rot->addChild(pTrack);
|
||||
_scenery->addChild(rot.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
_scenery->addChild(pTrack.get());
|
||||
}
|
||||
}
|
||||
|
||||
//m_pit->build(strPath);
|
||||
//_scenery->addChild(m_pit->getPit());
|
||||
}
|
||||
|
||||
osgDB::Registry::instance()->clearObjectCache();
|
||||
osgDB::Registry::instance()->clearObjectCache();
|
||||
}
|
||||
|
||||
void SDScenery::LoadSkyOptions()
|
||||
|
|
|
@ -119,7 +119,7 @@ grInitBackground()
|
|||
|
||||
// If no realistic sky dome requested, or if the track skyversion doesn't support it,
|
||||
// we set up a static - texture-based - background
|
||||
if (!grSkyDomeDistance || grTrack->skyversion < 1)
|
||||
if (!grSkyDomeDistance )
|
||||
{
|
||||
GfLogInfo("Setting up static background (mono-texture sky and landscape)\n");
|
||||
|
||||
|
@ -448,7 +448,7 @@ grLoadBackground()
|
|||
// Load static background if no sky dome.
|
||||
const tTrackGraphicInfo *graphic = &grTrack->graphic;
|
||||
TheBackground = 0;
|
||||
if (!grSkyDomeDistance || grTrack->skyversion < 1)
|
||||
if (!grSkyDomeDistance )
|
||||
{
|
||||
GfLogInfo("Loading static background (type %d)\n", graphic->bgtype);
|
||||
|
||||
|
@ -769,7 +769,7 @@ grLoadBackground()
|
|||
GfLogTrace("Loading sky shadow mapping image :\n");
|
||||
grEnvShadowState = 0;
|
||||
int nEnvShadowIndex = -1; // Default = not depending on weather conds.
|
||||
if (!grSkyDomeDistance || grTrack->skyversion < 1)
|
||||
if (!grSkyDomeDistance )
|
||||
{
|
||||
// Static / texture-based sky case.
|
||||
if (grTrack->local.rain > 0) // Rain => full cloud cover.
|
||||
|
@ -860,7 +860,7 @@ grPreDrawSky(tSituation* s, float fogStart, float fogEnd)
|
|||
static const double sqrt_m_log01 = sqrt( m_log01 );
|
||||
GLbitfield clear_mask;
|
||||
|
||||
if (grSkyDomeDistance && grTrack->skyversion > 0)
|
||||
if (grSkyDomeDistance )
|
||||
{
|
||||
const GLfloat fog_exp2_density = sqrt_m_log01 / TheSky->getVisibility();
|
||||
glEnable(GL_FOG);
|
||||
|
@ -904,7 +904,7 @@ grDrawStaticBackground(cGrCamera *cam, cGrBackgroundCam *bgCam)
|
|||
void
|
||||
grPostDrawSky(void)
|
||||
{
|
||||
if (grSkyDomeDistance && grTrack->skyversion > 0)
|
||||
if (grSkyDomeDistance )
|
||||
TheSky->postDraw(grSkyDomeDistance);
|
||||
}//grPostDrawSky
|
||||
|
||||
|
@ -919,7 +919,7 @@ grUpdateSky(double currentTime, double accelTime)
|
|||
|
||||
// Nothing to do if static sky dome, or race not started.
|
||||
//if (!grDynamicSkyDome) //TODO(kilo): find some meaning for this variable
|
||||
if (!grSkyDomeDistance || grTrack->skyversion < 1)
|
||||
if (!grSkyDomeDistance )
|
||||
return;
|
||||
|
||||
if (currentTime < 0) {
|
||||
|
@ -929,7 +929,8 @@ grUpdateSky(double currentTime, double accelTime)
|
|||
|
||||
if (!bInitialized)
|
||||
{
|
||||
if (grSkyDomeDistance && grTrack->skyversion > 0) {
|
||||
if (grSkyDomeDistance )
|
||||
{
|
||||
// Ensure the sun and moon positions are reset
|
||||
const int timeOfDay = (int)grTrack->local.timeofday;
|
||||
GLfloat sunAscension = grTrack->local.sunascension;
|
||||
|
|
|
@ -219,7 +219,7 @@ grLoadScene(tTrack *track)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (grSkyDomeDistance > 0 && grTrack->skyversion > 0)
|
||||
if ( grSkyDomeDistance > 0 )
|
||||
{
|
||||
grBGSky = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, GR_ATT_BGSKY_DISABLED), GR_ATT_BGSKY_ENABLED) == 0;
|
||||
if (grBGSky)
|
||||
|
|
|
@ -304,7 +304,8 @@ void cGrScreen::camDraw(tSituation *s)
|
|||
|
||||
// Draw the static background.
|
||||
// Exclude this when sky dome enabled, because it is then actually invisible.
|
||||
if (dispCam->getDrawBackground() && (grSkyDomeDistance == 0 || grTrack->skyversion == 0)) {
|
||||
if (dispCam->getDrawBackground() && (grSkyDomeDistance == 0))
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
@ -343,7 +344,8 @@ void cGrScreen::camDraw(tSituation *s)
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// Draw the sky dome if enabled (first part)
|
||||
if (dispCam->getDrawBackground() && grSkyDomeDistance > 0 && grTrack->skyversion > 0) {
|
||||
if (dispCam->getDrawBackground() && grSkyDomeDistance > 0 )
|
||||
{
|
||||
grPreDrawSky(s, dispCam->getFogStart(), dispCam->getFogEnd());
|
||||
}
|
||||
|
||||
|
@ -351,7 +353,8 @@ void cGrScreen::camDraw(tSituation *s)
|
|||
grDrawScene();
|
||||
|
||||
// Draw the sky dome if enabled (last part)
|
||||
if (dispCam->getDrawBackground() && grSkyDomeDistance > 0 && grTrack->skyversion > 0) {
|
||||
if (dispCam->getDrawBackground() && grSkyDomeDistance > 0 )
|
||||
{
|
||||
grPostDrawSky();
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,6 @@ GetTrackHeader(void *TrackHandle) {
|
|||
theTrack->name = GfParmGetStr(TrackHandle, TRK_SECT_HDR, TRK_ATT_NAME, "no name");
|
||||
theTrack->descr = GfParmGetStr(TrackHandle, TRK_SECT_HDR, TRK_ATT_DESCR, "no description");
|
||||
theTrack->version = (int)GfParmGetNum(TrackHandle, TRK_SECT_HDR, TRK_ATT_VERSION, (char*)NULL, 0);
|
||||
theTrack->skyversion = (int)GfParmGetNum(TrackHandle, TRK_SECT_HDR, TRK_ATT_SKY_VERSION, (char*)NULL, 0);
|
||||
theTrack->width = GfParmGetNum(TrackHandle, TRK_SECT_MAIN, TRK_ATT_WIDTH, (char*)NULL, 15.0);
|
||||
theTrack->authors = GfParmGetStr(TrackHandle, TRK_SECT_HDR, TRK_ATT_AUTHOR, "none");
|
||||
theTrack->category = GfParmGetStr(TrackHandle, TRK_SECT_HDR, TRK_ATT_CAT, "road");
|
||||
|
|
Loading…
Reference in a new issue