Fixes #222 (more skinning targets) Added support for driver skins, like in TRB1 Silber RB1LT

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3368 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 9fff20ff795bcdb009c0d21f7c9c120242f5334e
Former-commit-id: 216899289edd7808e2ec8adb58392969397aad2d
This commit is contained in:
pouillot 2011-02-16 22:52:53 +00:00
parent 1530ed6c98
commit 806e7a2d67
4 changed files with 60 additions and 11 deletions

View file

@ -98,12 +98,14 @@ typedef struct {
- RM_CAR_SKIN_TARGET_3D_WHEELS
- RM_CAR_SKIN_TARGET_INTERIOR
- RM_CAR_SKIN_TARGET_BOARD
- RM_CAR_SKIN_TARGET_DRIVER
- RM_CAR_SKIN_TARGET_PIT_DOOR
*/
#define RM_CAR_SKIN_TARGET_WHOLE_LIVERY 0x00000001 /**< The whole car external livery */
#define RM_CAR_SKIN_TARGET_3D_WHEELS 0x00000002 /**< The 3D wheels */
#define RM_CAR_SKIN_TARGET_INTERIOR 0x00000010 /**< The car interior */
#define RM_CAR_SKIN_TARGET_BOARD 0x00000020 /**< The interior instrument board */
#define RM_CAR_SKIN_TARGET_DRIVER 0x00000040 /**< The driver */
#define RM_CAR_SKIN_TARGET_PIT_DOOR 0x00000100 /**< The pit door logo */
} tInitCar;

View file

@ -239,13 +239,13 @@ void GfDrivers::print() const
// GfDriverSkin class ---------------------------------------------------------------
GfDriverSkin::GfDriverSkin(const std::string& strName) : _strName(strName), _nTargets(0)
GfDriverSkin::GfDriverSkin(const std::string& strName) : _strName(strName), _bfTargets(0)
{
}
int GfDriverSkin::getTargets() const
{
return _nTargets;
return _bfTargets;
}
const std::string& GfDriverSkin::getName() const
@ -258,14 +258,14 @@ const std::string& GfDriverSkin::getCarPreviewFileName() const
return _strCarPreviewFileName;
}
void GfDriverSkin::setTargets(int nTargets)
void GfDriverSkin::setTargets(int bfTargets)
{
_nTargets = nTargets;
_bfTargets = bfTargets;
}
void GfDriverSkin::addTargets(int nTargets)
void GfDriverSkin::addTargets(int bfTargets)
{
_nTargets |= nTargets;
_bfTargets |= bfTargets;
}
void GfDriverSkin::setName(const std::string& strName)
@ -459,6 +459,8 @@ static const char* pszLiveryTexExt = ".png";
static const char* pszPreviewTexSufx = "-preview.jpg";
static const char* pszInteriorTexExt = ".png";
static const char* pszInteriorTexSufx = "-int";
static const char* pszDriverTexName = "driver"; // Warning: Must be consistent with <car>.ac/acc
static const char* pszDriverTexExt = ".png";
static const char* pszLogoTexName = "logo"; // Warning: Must be consistent with grscene.cpp
static const char* pszLogoTexExt = ".png";
static const char* pszWheel3DTexName = "wheel3d"; // Warning: Must be consistent with wheel<i>.ac/acc
@ -641,7 +643,7 @@ void GfDriver::getPossibleSkinsInFolder(const std::string& strCarId,
pCurWheel3DFile = pCurWheel3DFile->next;
// Extract the skin name from the 3D wheel texture file name.
const int nSkinNameLen = // Expecting "logo-<skin name>.png"
const int nSkinNameLen = // Expecting "wheel3d-<skin name>.png"
strlen(pCurWheel3DFile->name) - strlen(pszWheel3DTexName)
- 1 - strlen(pszWheel3DTexExt);
if (nSkinNameLen > 0)
@ -664,6 +666,41 @@ void GfDriver::getPossibleSkinsInFolder(const std::string& strCarId,
}
GfDirFreeList(pWheel3DFileList, NULL);
// Search for skinned driver files if any.
tFList *pDriverFileList =
GfDirGetListFiltered(strFolderPath.c_str(), pszDriverTexName, pszDriverTexExt);
if (pDriverFileList)
{
tFList *pCurDriverFile = pDriverFileList;
do
{
pCurDriverFile = pCurDriverFile->next;
// Extract the skin name from the 3D wheel texture file name.
const int nSkinNameLen = // Expecting "driver-<skin name>.png"
strlen(pCurDriverFile->name) - strlen(pszDriverTexName)
- 1 - strlen(pszDriverTexExt);
if (nSkinNameLen > 0)
{
const std::string strSkinName =
std::string(pCurDriverFile->name)
.substr(strlen(pszDriverTexName) + 1, nSkinNameLen);
// If a skin with such name already exists in the list, update it.
std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName);
if (itSkin != vecPossSkins.end())
{
itSkin->addTargets(RM_CAR_SKIN_TARGET_DRIVER);
GfLogDebug(" Found %s-skinned driver (targets:%x)\n",
strSkinName.c_str(), itSkin->getTargets());
}
}
}
while (pCurDriverFile != pDriverFileList);
}
GfDirFreeList(pDriverFileList, NULL);
}
std::vector<GfDriverSkin> GfDriver::getPossibleSkins(const std::string& strAltCarId) const

View file

@ -45,14 +45,14 @@ public:
const std::string& getName() const;
const std::string& getCarPreviewFileName() const;
void setTargets(int nTargets); // Overwrite any previous target.
void setTargets(int bfTargets); // Overwrite any previous target.
void addTargets(int nTargets); // Bit-or.
void setName(const std::string& strName);
void setCarPreviewFileName(const std::string& strFileName);
protected:
int _nTargets; // Skin targets bit-field (see car.h for possible values)
int _bfTargets; // Skin targets bit-field (see car.h for possible values)
std::string _strName; // Skin name (empty if standard skin)
std::string _strCarPreviewFileName; // Car preview for this skin name (empty if none)
};

View file

@ -599,10 +599,20 @@ grInitCar(tCarElt *car)
GfLogTrace("Using skinned interior %s\n", strTgtTexName.c_str());
}
/* 3) 3D wheels if present */
/* 3) driver if present */
if (bCustomSkin && car->_skinTargets & RM_CAR_SKIN_TARGET_DRIVER)
{
strSrcTexName = "driver"; // Warning: Must be consistent with wheel<i>.ac/.acc contents
strTgtTexName = strSrcTexName + '-' + car->_skinName + pszTexFileExt;
strSrcTexName += pszTexFileExt;
options.addTextureMapping(strSrcTexName.c_str(), strTgtTexName.c_str());
GfLogTrace("Using skinned driver %s\n", strTgtTexName.c_str());
}
/* 4) 3D wheels if present */
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 <car>.ac/.acc contents
strTgtTexName = strSrcTexName + '-' + car->_skinName + pszTexFileExt;
strSrcTexName += pszTexFileExt;
options.addTextureMapping(strSrcTexName.c_str(), strTgtTexName.c_str());