Re #222 (more skinning targets) Added skinnability for *-int.png interior textures + improved gr traces
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3074 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: ff9f2cc028b131f2e598b9105f131a4805f8363d Former-commit-id: 16bb55deac8a8547a868c6de3b48349be6971ba2
This commit is contained in:
parent
6c3d791577
commit
f2ad2b3524
5 changed files with 87 additions and 35 deletions
|
@ -39,12 +39,12 @@ const char* rmdStdSkinName = "standard";
|
||||||
|
|
||||||
static const char* pszSkinFileExt = ".png";
|
static const char* pszSkinFileExt = ".png";
|
||||||
static const char* pszPreviewFileSuffix = "-preview.jpg";
|
static const char* pszPreviewFileSuffix = "-preview.jpg";
|
||||||
|
static const char* pszSkinIntFileSuffix = "-int";
|
||||||
static const char* pszLogoFileName = "logo"; // Warning: Must be consistent with grscene.cpp
|
static const char* pszLogoFileName = "logo"; // Warning: Must be consistent with grscene.cpp
|
||||||
static const char* pszWheel3DFileName = "wheel3d"; // Warning: Must be consistent with wheel<i>.ac/acc
|
static const char* pszWheel3DFileName = "wheel3d"; // Warning: Must be consistent with wheel<i>.ac/acc
|
||||||
|
|
||||||
static const char* apszExcludedSkinFileSuffixes[] =
|
static const char* apszExcludedSkinNamePrefixes[] = { "rpm", "speed", "int" };
|
||||||
{ "rpm.png", "speed.png", "int.png" };
|
static const int nExcludedSkinNamePrefixes = sizeof(apszExcludedSkinNamePrefixes) / sizeof(char*);
|
||||||
static const int nExcludedSkinFileSuffixes = sizeof(apszExcludedSkinFileSuffixes) / sizeof(char*);
|
|
||||||
|
|
||||||
|
|
||||||
int rmdDriverMatchesFilters(const trmdDrvElt *drv, const char* carCat, const char* drvTyp,
|
int rmdDriverMatchesFilters(const trmdDrvElt *drv, const char* carCat, const char* drvTyp,
|
||||||
|
@ -88,7 +88,7 @@ void rmdGetCarSkinsInFolder(const char* pszCarName, const char* pszFolderPath,
|
||||||
{
|
{
|
||||||
//GfLogDebug(" rmdGetCarSkinsInFolder(car=%s, path=%s) ...\n", pszCarName, pszFolderPath);
|
//GfLogDebug(" rmdGetCarSkinsInFolder(car=%s, path=%s) ...\n", pszCarName, pszFolderPath);
|
||||||
|
|
||||||
// Search for livery skin files, and asociated preview files if any.
|
// Search for skinned livery files, and associated preview files if any.
|
||||||
tFList *pSkinFileList = GfDirGetListFiltered(pszFolderPath, pszCarName, pszSkinFileExt);
|
tFList *pSkinFileList = GfDirGetListFiltered(pszFolderPath, pszCarName, pszSkinFileExt);
|
||||||
if (pSkinFileList)
|
if (pSkinFileList)
|
||||||
{
|
{
|
||||||
|
@ -97,22 +97,24 @@ void rmdGetCarSkinsInFolder(const char* pszCarName, const char* pszFolderPath,
|
||||||
{
|
{
|
||||||
pCurSkinFile = pCurSkinFile->next;
|
pCurSkinFile = pCurSkinFile->next;
|
||||||
|
|
||||||
// Ignore files with an excluded suffix.
|
// Extract the skin name from the livery file name.
|
||||||
int nExclSfxInd = 0;
|
|
||||||
for (; nExclSfxInd < nExcludedSkinFileSuffixes; nExclSfxInd++)
|
|
||||||
if (strstr(pCurSkinFile->name, apszExcludedSkinFileSuffixes[nExclSfxInd]))
|
|
||||||
break;
|
|
||||||
if (nExclSfxInd < nExcludedSkinFileSuffixes)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Extract the skin name from the skin file name.
|
|
||||||
const int nSkinNameLen = // Expecting "<car name>-<skin name>.png"
|
const int nSkinNameLen = // Expecting "<car name>-<skin name>.png"
|
||||||
strlen(pCurSkinFile->name) - strlen(pszCarName) - 1 - strlen(pszSkinFileExt);
|
strlen(pCurSkinFile->name) - strlen(pszCarName) - 1 - strlen(pszSkinFileExt);
|
||||||
std::string strSkinName;
|
std::string strSkinName;
|
||||||
if (nSkinNameLen > 0)
|
if (nSkinNameLen > 0)
|
||||||
|
{
|
||||||
strSkinName =
|
strSkinName =
|
||||||
std::string(pCurSkinFile->name)
|
std::string(pCurSkinFile->name)
|
||||||
.substr(strlen(pszCarName) + 1, nSkinNameLen);
|
.substr(strlen(pszCarName) + 1, nSkinNameLen);
|
||||||
|
|
||||||
|
// Ignore skins with an excluded prefix.
|
||||||
|
int nExclPrfxInd = 0;
|
||||||
|
for (; nExclPrfxInd < nExcludedSkinNamePrefixes; nExclPrfxInd++)
|
||||||
|
if (strSkinName.find(apszExcludedSkinNamePrefixes[nExclPrfxInd]) == 0)
|
||||||
|
break;
|
||||||
|
if (nExclPrfxInd < nExcludedSkinNamePrefixes)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else // Assuming default/standard "<car name>.png"
|
else // Assuming default/standard "<car name>.png"
|
||||||
strSkinName = rmdStdSkinName;
|
strSkinName = rmdStdSkinName;
|
||||||
|
|
||||||
|
@ -149,11 +151,47 @@ void rmdGetCarSkinsInFolder(const char* pszCarName, const char* pszFolderPath,
|
||||||
// strSkinName.c_str(), ossPreviewName.str().c_str());
|
// strSkinName.c_str(), ossPreviewName.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (pCurSkinFile != pSkinFileList);
|
}
|
||||||
|
while (pCurSkinFile != pSkinFileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
GfDirFreeList(pSkinFileList, NULL);
|
GfDirFreeList(pSkinFileList, NULL);
|
||||||
|
|
||||||
|
// Search for skinned interior files, if any.
|
||||||
|
std::string strInteriorPrefix(pszCarName);
|
||||||
|
strInteriorPrefix += pszSkinIntFileSuffix;
|
||||||
|
tFList *pIntFileList =
|
||||||
|
GfDirGetListFiltered(pszFolderPath, strInteriorPrefix.c_str(), pszSkinFileExt);
|
||||||
|
if (pIntFileList)
|
||||||
|
{
|
||||||
|
tFList *pCurSkinFile = pIntFileList;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
pCurSkinFile = pCurSkinFile->next;
|
||||||
|
|
||||||
|
// Extract the skin name from the interior file name.
|
||||||
|
const int nSkinNameLen = // Expecting "<car name>-int-<skin name>.png"
|
||||||
|
strlen(pCurSkinFile->name) - strInteriorPrefix.length()
|
||||||
|
- 1 - strlen(pszSkinFileExt);
|
||||||
|
std::string strSkinName;
|
||||||
|
if (nSkinNameLen > 0)
|
||||||
|
{
|
||||||
|
strSkinName =
|
||||||
|
std::string(pCurSkinFile->name)
|
||||||
|
.substr(strInteriorPrefix.length() + 1, nSkinNameLen);
|
||||||
|
|
||||||
|
// Add the interior to the skin targets.
|
||||||
|
if (mapSkinTargets.find(strSkinName) == mapSkinTargets.end())
|
||||||
|
mapSkinTargets[strSkinName] = 0;
|
||||||
|
mapSkinTargets[strSkinName] |= RM_CAR_SKIN_TARGET_INTERIOR;
|
||||||
|
|
||||||
|
GfLogDebug(" Found %s-skinned interior (targets:%x)\n",
|
||||||
|
strSkinName.c_str(), mapSkinTargets[strSkinName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (pCurSkinFile != pIntFileList);
|
||||||
|
}
|
||||||
|
|
||||||
// Search for skinned logo files if any.
|
// Search for skinned logo files if any.
|
||||||
tFList *pLogoFileList =
|
tFList *pLogoFileList =
|
||||||
GfDirGetListFiltered(pszFolderPath, pszLogoFileName, pszSkinFileExt);
|
GfDirGetListFiltered(pszFolderPath, pszLogoFileName, pszSkinFileExt);
|
||||||
|
@ -183,7 +221,8 @@ void rmdGetCarSkinsInFolder(const char* pszCarName, const char* pszFolderPath,
|
||||||
strSkinName.c_str(), mapSkinTargets[strSkinName]);
|
strSkinName.c_str(), mapSkinTargets[strSkinName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (pCurLogoFile != pLogoFileList);
|
}
|
||||||
|
while (pCurLogoFile != pLogoFileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
GfDirFreeList(pLogoFileList, NULL);
|
GfDirFreeList(pLogoFileList, NULL);
|
||||||
|
@ -217,7 +256,8 @@ void rmdGetCarSkinsInFolder(const char* pszCarName, const char* pszFolderPath,
|
||||||
strSkinName.c_str(), mapSkinTargets[strSkinName]);
|
strSkinName.c_str(), mapSkinTargets[strSkinName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (pCurWheel3DFile != pWheel3DFileList);
|
}
|
||||||
|
while (pCurWheel3DFile != pWheel3DFileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
GfDirFreeList(pWheel3DFileList, NULL);
|
GfDirFreeList(pWheel3DFileList, NULL);
|
||||||
|
|
|
@ -564,12 +564,12 @@ grInitCar(tCarElt *car)
|
||||||
const bool bMasterModel = strlen(car->_masterModel) != 0;
|
const bool bMasterModel = strlen(car->_masterModel) != 0;
|
||||||
const bool bCustomSkin = strlen(car->_skinName) != 0;
|
const bool bCustomSkin = strlen(car->_skinName) != 0;
|
||||||
|
|
||||||
GfLogTrace("Loading graphics for %s (driver:%s, skin:%s.%x, master model:%s)\n",
|
GfLogInfo("Loading graphics for %s (driver:%s, skin:%s.%x, master model:%s)\n",
|
||||||
car->_carName, car->_name,
|
car->_carName, car->_name,
|
||||||
bCustomSkin ? car->_skinName : "standard", car->_skinTargets,
|
bCustomSkin ? car->_skinName : "standard", car->_skinTargets,
|
||||||
bMasterModel ? car->_masterModel : "self");
|
bMasterModel ? car->_masterModel : "self");
|
||||||
|
|
||||||
/* 1) Whole livery */
|
/* 1) Whole livery : <car name>.png => <car name>-<skin name>.png */
|
||||||
std::string strSrcTexName(bMasterModel ? car->_masterModel : car->_carName);
|
std::string strSrcTexName(bMasterModel ? car->_masterModel : car->_carName);
|
||||||
std::string strTgtTexName(car->_carName);
|
std::string strTgtTexName(car->_carName);
|
||||||
if (bCustomSkin && car->_skinTargets & RM_CAR_SKIN_TARGET_WHOLE_LIVERY)
|
if (bCustomSkin && car->_skinTargets & RM_CAR_SKIN_TARGET_WHOLE_LIVERY)
|
||||||
|
@ -583,17 +583,30 @@ grInitCar(tCarElt *car)
|
||||||
strSrcTexName += pszTexFileExt;
|
strSrcTexName += pszTexFileExt;
|
||||||
strTgtTexName += pszTexFileExt;
|
strTgtTexName += pszTexFileExt;
|
||||||
options.addTextureMapping(strSrcTexName.c_str(), strTgtTexName.c_str());
|
options.addTextureMapping(strSrcTexName.c_str(), strTgtTexName.c_str());
|
||||||
GfLogDebug("Using skinned livery %s\n", strTgtTexName.c_str());
|
GfLogTrace("Using skinned livery %s\n", strTgtTexName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2) 3D wheels if present */
|
/* 2) Interior : <car name>-int.png => <car name>-int-<skin name>.png */
|
||||||
|
if (bCustomSkin && car->_skinTargets & RM_CAR_SKIN_TARGET_INTERIOR)
|
||||||
|
{
|
||||||
|
strSrcTexName = (bMasterModel ? car->_masterModel : car->_carName);
|
||||||
|
strTgtTexName = car->_carName;
|
||||||
|
strTgtTexName += "-int-";
|
||||||
|
strTgtTexName += car->_skinName;
|
||||||
|
strSrcTexName += pszTexFileExt;
|
||||||
|
strTgtTexName += pszTexFileExt;
|
||||||
|
options.addTextureMapping(strSrcTexName.c_str(), strTgtTexName.c_str());
|
||||||
|
GfLogTrace("Using skinned interior %s\n", strTgtTexName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3) 3D wheels if present */
|
||||||
if (bCustomSkin && car->_skinTargets & RM_CAR_SKIN_TARGET_3D_WHEELS)
|
if (bCustomSkin && car->_skinTargets & RM_CAR_SKIN_TARGET_3D_WHEELS)
|
||||||
{
|
{
|
||||||
strSrcTexName = "wheel3d"; // Warning: Must be consistent with wheel<i>.ac/.acc contents
|
strSrcTexName = "wheel3d"; // Warning: Must be consistent with wheel<i>.ac/.acc contents
|
||||||
strTgtTexName = strSrcTexName + '-' + car->_skinName + pszTexFileExt;
|
strTgtTexName = strSrcTexName + '-' + car->_skinName + pszTexFileExt;
|
||||||
strSrcTexName += pszTexFileExt;
|
strSrcTexName += pszTexFileExt;
|
||||||
options.addTextureMapping(strSrcTexName.c_str(), strTgtTexName.c_str());
|
options.addTextureMapping(strSrcTexName.c_str(), strTgtTexName.c_str());
|
||||||
GfLogDebug("Using skinned 3D wheels %s\n", strTgtTexName.c_str());
|
GfLogTrace("Using skinned 3D wheels %s\n", strTgtTexName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
grssgSetCurrentOptions(&options);
|
grssgSetCurrentOptions(&options);
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ ssgEntity *grssgCarLoadAC3D ( const char *fname, const grssgLoaderOptions* optio
|
||||||
t_xmin=+999999.0;
|
t_xmin=+999999.0;
|
||||||
t_ymin=+999999.0;
|
t_ymin=+999999.0;
|
||||||
|
|
||||||
GfOut("Loading %s\n", fname);
|
GfLogTrace("Loading %s\n", fname);
|
||||||
|
|
||||||
ssgEntity *obj = myssgLoadAC ( fname, options ) ;
|
ssgEntity *obj = myssgLoadAC ( fname, options ) ;
|
||||||
|
|
||||||
|
@ -1326,7 +1326,6 @@ void grssgLoaderOptions::addTextureMapping(const char* pszSrcFileName, const cha
|
||||||
{
|
{
|
||||||
_mapTextures[pszSrcFileName] = pszTgtFileName;
|
_mapTextures[pszSrcFileName] = pszTgtFileName;
|
||||||
_bTextureMapping = true;
|
_bTextureMapping = true;
|
||||||
GfTrace("grssgLoaderOptions::addTextureMapping(%s, %s)\n", pszSrcFileName, pszTgtFileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool grssgLoaderOptions::textureMapping() const
|
bool grssgLoaderOptions::textureMapping() const
|
||||||
|
|
|
@ -499,16 +499,16 @@ grLoadScene(tTrack *track)
|
||||||
grWrldMaxSize = (int)(MAX(MAX(grWrldX, grWrldY), grWrldZ));
|
grWrldMaxSize = (int)(MAX(MAX(grWrldX, grWrldY), grWrldZ));
|
||||||
|
|
||||||
RainBool = grTrack->Rain;
|
RainBool = grTrack->Rain;
|
||||||
printf("Rain = %d\n", RainBool);
|
GfLogTrace("Rain = %d\n", RainBool);
|
||||||
|
|
||||||
//acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
//acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
||||||
/*if ((grTrack->Timeday == 1) && (grTrack->skyversion > 0)) // If night in quickrace, practice or network mode
|
/*if ((grTrack->Timeday == 1) && (grTrack->skyversion > 0)) // If night in quickrace, practice or network mode
|
||||||
acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC3, "track.ac");
|
acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC3, "track.ac");
|
||||||
else*/
|
else*/
|
||||||
acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac");
|
||||||
GfOut("ACname = %s\n", acname);
|
|
||||||
if (strlen(acname) == 0)
|
if (strlen(acname) == 0)
|
||||||
{
|
{
|
||||||
|
GfLogError("No specified track 3D model file\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,14 +910,14 @@ initBackground(void) {
|
||||||
//Environment Mapping Settings
|
//Environment Mapping Settings
|
||||||
grEnvSelector = new ssgStateSelector(graphic->envnb);
|
grEnvSelector = new ssgStateSelector(graphic->envnb);
|
||||||
for (i = 0; i < graphic->envnb; i++) {
|
for (i = 0; i < graphic->envnb; i++) {
|
||||||
GfOut("Loading Environment Mapping Image %s\n", graphic->env[i]);
|
GfLogTrace("Loading %d Environment Mapping Image %s\n", i, graphic->env[i]);
|
||||||
envst = (ssgSimpleState*)grSsgLoadTexState(graphic->env[i]);
|
envst = (ssgSimpleState*)grSsgLoadTexState(graphic->env[i]);
|
||||||
// Avoid chrash with missing env.rgb files (i.e. Wheel-1)
|
// Avoid chrash with missing env.rgb files (i.e. Wheel-1)
|
||||||
if (envst == NULL) {
|
if (envst == NULL) {
|
||||||
GfOut("Try env.png instead\n");
|
GfLogWarning("Failed : trying fallback env.png\n");
|
||||||
envst = (ssgSimpleState*)grSsgLoadTexState("env.png");
|
envst = (ssgSimpleState*)grSsgLoadTexState("env.png");
|
||||||
if (envst == NULL) {
|
if (envst == NULL) {
|
||||||
GfOut("This will stop displaying graphics!\n");
|
GfLogError("No usable Environment Mapping Image for #%d : stop displaying graphics!\n", i);
|
||||||
DoNotUseEnv = true;
|
DoNotUseEnv = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -935,7 +935,7 @@ initBackground(void) {
|
||||||
grEnvState=(grMultiTexState*)grSsgEnvTexState("env.png");
|
grEnvState=(grMultiTexState*)grSsgEnvTexState("env.png");
|
||||||
else {
|
else {
|
||||||
if (DoNotUseEnv)
|
if (DoNotUseEnv)
|
||||||
GfOut("No env.png found!\n");
|
GfLogError("No env.png found!\n");
|
||||||
else
|
else
|
||||||
grEnvState=(grMultiTexState*)grSsgEnvTexState(graphic->env[0]);
|
grEnvState=(grMultiTexState*)grSsgEnvTexState(graphic->env[0]);
|
||||||
}
|
}
|
||||||
|
@ -985,7 +985,7 @@ grCustomizePits(void)
|
||||||
switch (pits->type) {
|
switch (pits->type) {
|
||||||
case TR_PIT_ON_TRACK_SIDE:
|
case TR_PIT_ON_TRACK_SIDE:
|
||||||
for(int i = 0; i < pits->nMaxPits; i++) {
|
for(int i = 0; i < pits->nMaxPits; i++) {
|
||||||
//GfOut("Pit Nbr: %d\n", i);
|
//GfLogDebug("Pit Nbr: %d\n", i);
|
||||||
ssgVertexArray *pit_vtx = new ssgVertexArray(4);
|
ssgVertexArray *pit_vtx = new ssgVertexArray(4);
|
||||||
ssgTexCoordArray *pit_tex = new ssgTexCoordArray(4);
|
ssgTexCoordArray *pit_tex = new ssgTexCoordArray(4);
|
||||||
ssgColourArray *pit_clr = new ssgColourArray(1);
|
ssgColourArray *pit_clr = new ssgColourArray(1);
|
||||||
|
@ -1017,7 +1017,7 @@ grCustomizePits(void)
|
||||||
{
|
{
|
||||||
strLogoFileName += '-';
|
strLogoFileName += '-';
|
||||||
strLogoFileName += pits->driversPits[i].car[0]->_skinName;
|
strLogoFileName += pits->driversPits[i].car[0]->_skinName;
|
||||||
GfLogDebug("Using skinned pit door logo %s\n", strLogoFileName.c_str());
|
GfLogTrace("Using skinned pit door logo %s\n", strLogoFileName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -128,7 +128,7 @@ static void grSetupState(grManagedState *st, char *buf)
|
||||||
curr->state = st;
|
curr->state = st;
|
||||||
curr->name = strdup(buf);
|
curr->name = strdup(buf);
|
||||||
|
|
||||||
GfOut("Loading %s\n", buf);
|
GfLogTrace("Loading texture %s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue