mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-16 10:59:01 +00:00
few changes for vehicle model info
This commit is contained in:
parent
aff89c6f5c
commit
152c7c452c
4 changed files with 50 additions and 75 deletions
2
librw
2
librw
|
@ -1 +1 @@
|
||||||
Subproject commit bdbc92d86eef28344e01c992d55a9c4f43629f84
|
Subproject commit 661feeabf4a4f0a8b0bee23b53ba557a14352d00
|
|
@ -756,6 +756,7 @@ RwCamera *RwCameraForAllClumpsNotInFrustum(RwCamera *camera, RwInt32 numClumps,
|
||||||
|
|
||||||
RwBool RpMatFXPluginAttach( void ) { registerMatFXPlugin(); return true; }
|
RwBool RpMatFXPluginAttach( void ) { registerMatFXPlugin(); return true; }
|
||||||
RpAtomic *RpMatFXAtomicEnableEffects( RpAtomic *atomic ) { MatFX::enableEffects(atomic); return atomic; }
|
RpAtomic *RpMatFXAtomicEnableEffects( RpAtomic *atomic ) { MatFX::enableEffects(atomic); return atomic; }
|
||||||
|
RpMatFXMaterialFlags RpMatFXMaterialGetEffects( const RpMaterial *material ){ return (RpMatFXMaterialFlags)MatFX::getEffects(material); }
|
||||||
RpMaterial *RpMatFXMaterialSetEffects( RpMaterial *material, RpMatFXMaterialFlags flags ) { MatFX::setEffects(material, (uint32)flags); return material; }
|
RpMaterial *RpMatFXMaterialSetEffects( RpMaterial *material, RpMatFXMaterialFlags flags ) { MatFX::setEffects(material, (uint32)flags); return material; }
|
||||||
RpMaterial *RpMatFXMaterialSetupEnvMap( RpMaterial *material, RwTexture *texture, RwFrame *frame, RwBool useFrameBufferAlpha, RwReal coef ) {
|
RpMaterial *RpMatFXMaterialSetupEnvMap( RpMaterial *material, RwTexture *texture, RwFrame *frame, RwBool useFrameBufferAlpha, RwReal coef ) {
|
||||||
MatFX *mfx = MatFX::get(material);
|
MatFX *mfx = MatFX::get(material);
|
||||||
|
@ -764,8 +765,23 @@ RpMaterial *RpMatFXMaterialSetupEnvMap( RpMaterial *material, RwTexture *texture
|
||||||
mfx->setEnvCoefficient(coef);
|
mfx->setEnvCoefficient(coef);
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
RpMaterial *RpMatFXMaterialSetEnvMapFrame( RpMaterial *material, RwFrame *frame )
|
||||||
|
{
|
||||||
|
MatFX *mfx = MatFX::get(material);
|
||||||
|
mfx->setEnvFrame(frame);
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
RpMaterial *RpMatFXMaterialSetEnvMapCoefficient( RpMaterial *material, RwReal coef )
|
||||||
|
{
|
||||||
|
MatFX *mfx = MatFX::get(material);
|
||||||
|
mfx->setEnvCoefficient(coef);
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
RwReal RpMatFXMaterialGetEnvMapCoefficient( const RpMaterial *material )
|
||||||
|
{
|
||||||
|
MatFX *mfx = MatFX::get(material);
|
||||||
|
return mfx->getEnvCoefficient();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 };
|
int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 };
|
||||||
int8 CVehicleModelInfo::ms_compsUsed[2];
|
int8 CVehicleModelInfo::ms_compsUsed[2];
|
||||||
RwTexture *CVehicleModelInfo::ms_pEnvironmentMaps[NUM_VEHICLE_ENVMAPS];
|
|
||||||
RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256];
|
RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256];
|
||||||
RwTexture *CVehicleModelInfo::ms_colourTextureTable[256];
|
RwTexture *CVehicleModelInfo::ms_colourTextureTable[256];
|
||||||
|
|
||||||
|
@ -752,35 +751,26 @@ void
|
||||||
CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2)
|
CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2)
|
||||||
{
|
{
|
||||||
RwRGBA col, *colp;
|
RwRGBA col, *colp;
|
||||||
RwTexture *coltex;
|
|
||||||
RpMaterial **matp;
|
RpMaterial **matp;
|
||||||
|
|
||||||
if(c1 != m_currentColour1){
|
if(c1 != m_currentColour1){
|
||||||
col = ms_vehicleColourTable[c1];
|
col = ms_vehicleColourTable[c1];
|
||||||
coltex = ms_colourTextureTable[c1];
|
|
||||||
for(matp = m_materials1; *matp; matp++){
|
for(matp = m_materials1; *matp; matp++){
|
||||||
if(RpMaterialGetTexture(*matp) && RwTextureGetName(RpMaterialGetTexture(*matp))[0] != '@'){
|
colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const
|
||||||
colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const
|
colp->red = col.red;
|
||||||
colp->red = col.red;
|
colp->green = col.green;
|
||||||
colp->green = col.green;
|
colp->blue = col.blue;
|
||||||
colp->blue = col.blue;
|
|
||||||
}else
|
|
||||||
RpMaterialSetTexture(*matp, coltex);
|
|
||||||
}
|
}
|
||||||
m_currentColour1 = c1;
|
m_currentColour1 = c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c2 != m_currentColour2){
|
if(c2 != m_currentColour2){
|
||||||
col = ms_vehicleColourTable[c2];
|
col = ms_vehicleColourTable[c2];
|
||||||
coltex = ms_colourTextureTable[c2];
|
|
||||||
for(matp = m_materials2; *matp; matp++){
|
for(matp = m_materials2; *matp; matp++){
|
||||||
if(RpMaterialGetTexture(*matp) && RwTextureGetName(RpMaterialGetTexture(*matp))[0] != '@'){
|
colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const
|
||||||
colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const
|
colp->red = col.red;
|
||||||
colp->red = col.red;
|
colp->green = col.green;
|
||||||
colp->green = col.green;
|
colp->blue = col.blue;
|
||||||
colp->blue = col.blue;
|
|
||||||
}else
|
|
||||||
RpMaterialSetTexture(*matp, coltex);
|
|
||||||
}
|
}
|
||||||
m_currentColour2 = c2;
|
m_currentColour2 = c2;
|
||||||
}
|
}
|
||||||
|
@ -925,7 +915,6 @@ CVehicleModelInfo::LoadVehicleColours(void)
|
||||||
ms_vehicleColourTable[numCols].green = g;
|
ms_vehicleColourTable[numCols].green = g;
|
||||||
ms_vehicleColourTable[numCols].blue = b;
|
ms_vehicleColourTable[numCols].blue = b;
|
||||||
ms_vehicleColourTable[numCols].alpha = 0xFF;
|
ms_vehicleColourTable[numCols].alpha = 0xFF;
|
||||||
ms_colourTextureTable[numCols] = CreateCarColourTexture(r, g, b);
|
|
||||||
numCols++;
|
numCols++;
|
||||||
}else if(section == CARS){
|
}else if(section == CARS){
|
||||||
n = sscanf(&line[start], // BUG: games doesn't add start
|
n = sscanf(&line[start], // BUG: games doesn't add start
|
||||||
|
@ -960,38 +949,33 @@ CVehicleModelInfo::DeleteVehicleColourTextures(void)
|
||||||
for(i = 0; i < 256; i++){
|
for(i = 0; i < 256; i++){
|
||||||
if(ms_colourTextureTable[i]){
|
if(ms_colourTextureTable[i]){
|
||||||
RwTextureDestroy(ms_colourTextureTable[i]);
|
RwTextureDestroy(ms_colourTextureTable[i]);
|
||||||
#ifdef GTA3_1_1_PATCH
|
|
||||||
ms_colourTextureTable[i] = nil;
|
ms_colourTextureTable[i] = nil;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RpMaterial*
|
RpMaterial*
|
||||||
CVehicleModelInfo::HasSpecularMaterialCB(RpMaterial *material, void *data)
|
CVehicleModelInfo::GetMatFXEffectMaterialCB(RpMaterial *material, void *data)
|
||||||
{
|
{
|
||||||
if(RpMaterialGetSurfaceProperties(material)->specular <= 0.0f)
|
if(RpMatFXMaterialGetEffects(material) == rpMATFXEFFECTNULL)
|
||||||
return material;
|
return material;
|
||||||
*(bool*)data = true;
|
*(int*)data = RpMatFXMaterialGetEffects(material);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
RpMaterial*
|
RpMaterial*
|
||||||
CVehicleModelInfo::SetEnvironmentMapCB(RpMaterial *material, void *data)
|
CVehicleModelInfo::SetDefaultEnvironmentMapCB(RpMaterial *material, void *data)
|
||||||
{
|
{
|
||||||
float spec;
|
if(RpMatFXMaterialGetEffects(material) == rpMATFXEFFECTENVMAP){
|
||||||
|
RpMatFXMaterialSetEnvMapFrame(material, pMatFxIdentityFrame);
|
||||||
spec = RpMaterialGetSurfaceProperties(material)->specular;
|
|
||||||
if(spec <= 0.0f)
|
|
||||||
RpMatFXMaterialSetEffects(material, rpMATFXEFFECTNULL);
|
|
||||||
else{
|
|
||||||
if(RpMaterialGetTexture(material) == nil)
|
if(RpMaterialGetTexture(material) == nil)
|
||||||
RpMaterialSetTexture(material, gpWhiteTexture);
|
RpMaterialSetTexture(material, gpWhiteTexture);
|
||||||
RpMatFXMaterialSetEffects(material, rpMATFXEFFECTENVMAP);
|
RpMatFXMaterialSetEffects(material, rpMATFXEFFECTENVMAP);
|
||||||
#ifndef PS2_MATFX
|
#ifndef PS2_MATFX
|
||||||
spec *= 0.5f; // Tone down a bit for PC
|
float coef = RpMatFXMaterialGetEnvMapCoefficient(material);
|
||||||
|
coef *= 0.25f; // Tone down a bit for PC
|
||||||
|
RpMatFXMaterialSetEnvMapCoefficient(material, coef);
|
||||||
#endif
|
#endif
|
||||||
RpMatFXMaterialSetupEnvMap(material, (RwTexture*)data, pMatFxIdentityFrame, false, spec);
|
|
||||||
}
|
}
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
@ -999,17 +983,15 @@ CVehicleModelInfo::SetEnvironmentMapCB(RpMaterial *material, void *data)
|
||||||
RpAtomic*
|
RpAtomic*
|
||||||
CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data)
|
CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data)
|
||||||
{
|
{
|
||||||
bool hasSpec;
|
int fx;
|
||||||
RpGeometry *geo;
|
RpGeometry *geo;
|
||||||
|
|
||||||
geo = RpAtomicGetGeometry(atomic);
|
geo = RpAtomicGetGeometry(atomic);
|
||||||
hasSpec = 0;
|
fx = 0;
|
||||||
RpGeometryForAllMaterials(geo, HasSpecularMaterialCB, &hasSpec);
|
RpGeometryForAllMaterials(geo, GetMatFXEffectMaterialCB, &fx);
|
||||||
if(hasSpec){
|
if(fx != rpMATFXEFFECTNULL){
|
||||||
RpGeometryForAllMaterials(geo, SetEnvironmentMapCB, data);
|
|
||||||
RpGeometrySetFlags(geo, RpGeometryGetFlags(geo) | rpGEOMETRYMODULATEMATERIALCOLOR);
|
|
||||||
RpMatFXAtomicEnableEffects(atomic);
|
RpMatFXAtomicEnableEffects(atomic);
|
||||||
// PS2 sets of PS2Manager lighting CB here
|
RpGeometryForAllMaterials(geo, SetDefaultEnvironmentMapCB, data);
|
||||||
}
|
}
|
||||||
return atomic;
|
return atomic;
|
||||||
}
|
}
|
||||||
|
@ -1021,44 +1003,29 @@ CVehicleModelInfo::SetEnvironmentMap(void)
|
||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
if(pMatFxIdentityFrame == nil){
|
if(pMatFxIdentityFrame == nil){
|
||||||
|
RwV3d axis = { 1.0f, 0.0f, 0.0f };
|
||||||
pMatFxIdentityFrame = RwFrameCreate();
|
pMatFxIdentityFrame = RwFrameCreate();
|
||||||
RwMatrixSetIdentity(RwFrameGetMatrix(pMatFxIdentityFrame));
|
RwMatrixRotate(RwFrameGetMatrix(pMatFxIdentityFrame), &axis, 60.0f, rwCOMBINEREPLACE);
|
||||||
RwFrameUpdateObjects(pMatFxIdentityFrame);
|
RwFrameUpdateObjects(pMatFxIdentityFrame);
|
||||||
RwFrameGetLTM(pMatFxIdentityFrame);
|
RwFrameGetLTM(pMatFxIdentityFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_envMap != ms_pEnvironmentMaps[0]){
|
RpClumpForAllAtomics(m_clump, SetEnvironmentMapCB, nil);
|
||||||
m_envMap = ms_pEnvironmentMaps[0];
|
if(m_wheelId != -1){
|
||||||
RpClumpForAllAtomics(m_clump, SetEnvironmentMapCB, m_envMap);
|
wheelmi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(m_wheelId);
|
||||||
if(m_wheelId != -1){
|
for(i = 0; i < wheelmi->m_numAtomics; i++)
|
||||||
wheelmi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(m_wheelId);
|
SetEnvironmentMapCB(wheelmi->m_atomics[i], nil);
|
||||||
for(i = 0; i < wheelmi->m_numAtomics; i++)
|
|
||||||
SetEnvironmentMapCB(wheelmi->m_atomics[i], m_envMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CVehicleModelInfo::LoadEnvironmentMaps(void)
|
CVehicleModelInfo::LoadEnvironmentMaps(void)
|
||||||
{
|
{
|
||||||
const char *texnames[] = {
|
|
||||||
"reflection01", // only one used
|
|
||||||
"reflection02",
|
|
||||||
"reflection03",
|
|
||||||
"reflection04",
|
|
||||||
"reflection05",
|
|
||||||
"reflection06",
|
|
||||||
};
|
|
||||||
int32 txdslot;
|
int32 txdslot;
|
||||||
int32 i;
|
|
||||||
|
|
||||||
txdslot = CTxdStore::FindTxdSlot("particle");
|
txdslot = CTxdStore::FindTxdSlot("particle");
|
||||||
CTxdStore::PushCurrentTxd();
|
CTxdStore::PushCurrentTxd();
|
||||||
CTxdStore::SetCurrentTxd(txdslot);
|
CTxdStore::SetCurrentTxd(txdslot);
|
||||||
for(i = 0; i < NUM_VEHICLE_ENVMAPS; i++){
|
|
||||||
ms_pEnvironmentMaps[i] = RwTextureRead(texnames[i], nil);
|
|
||||||
RwTextureSetFilterMode(ms_pEnvironmentMaps[i], rwFILTERLINEAR);
|
|
||||||
}
|
|
||||||
if(gpWhiteTexture == nil){
|
if(gpWhiteTexture == nil){
|
||||||
gpWhiteTexture = RwTextureRead("white", nil);
|
gpWhiteTexture = RwTextureRead("white", nil);
|
||||||
RwTextureGetName(gpWhiteTexture)[0] = '@';
|
RwTextureGetName(gpWhiteTexture)[0] = '@';
|
||||||
|
@ -1070,14 +1037,8 @@ CVehicleModelInfo::LoadEnvironmentMaps(void)
|
||||||
void
|
void
|
||||||
CVehicleModelInfo::ShutdownEnvironmentMaps(void)
|
CVehicleModelInfo::ShutdownEnvironmentMaps(void)
|
||||||
{
|
{
|
||||||
int32 i;
|
|
||||||
|
|
||||||
// ignoring "initialised" as that's a PS2 thing only
|
|
||||||
RwTextureDestroy(gpWhiteTexture);
|
RwTextureDestroy(gpWhiteTexture);
|
||||||
gpWhiteTexture = nil;
|
gpWhiteTexture = nil;
|
||||||
for(i = 0; i < NUM_VEHICLE_ENVMAPS; i++)
|
|
||||||
if(ms_pEnvironmentMaps[i])
|
|
||||||
RwTextureDestroy(ms_pEnvironmentMaps[i]);
|
|
||||||
RwFrameDestroy(pMatFxIdentityFrame);
|
RwFrameDestroy(pMatFxIdentityFrame);
|
||||||
pMatFxIdentityFrame = nil;
|
pMatFxIdentityFrame = nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ enum {
|
||||||
NUM_FIRST_MATERIALS = 26,
|
NUM_FIRST_MATERIALS = 26,
|
||||||
NUM_SECOND_MATERIALS = 26,
|
NUM_SECOND_MATERIALS = 26,
|
||||||
NUM_VEHICLE_COLOURS = 8,
|
NUM_VEHICLE_COLOURS = 8,
|
||||||
NUM_VEHICLE_ENVMAPS = 1
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -72,7 +71,6 @@ public:
|
||||||
|
|
||||||
static int8 ms_compsToUse[2];
|
static int8 ms_compsToUse[2];
|
||||||
static int8 ms_compsUsed[2];
|
static int8 ms_compsUsed[2];
|
||||||
static RwTexture *ms_pEnvironmentMaps[NUM_VEHICLE_ENVMAPS];
|
|
||||||
static RwRGBA ms_vehicleColourTable[256];
|
static RwRGBA ms_vehicleColourTable[256];
|
||||||
static RwTexture *ms_colourTextureTable[256];
|
static RwTexture *ms_colourTextureTable[256];
|
||||||
static RwObjectNameIdAssocation *ms_vehicleDescs[NUM_VEHICLE_TYPES];
|
static RwObjectNameIdAssocation *ms_vehicleDescs[NUM_VEHICLE_TYPES];
|
||||||
|
@ -114,8 +112,8 @@ public:
|
||||||
static void DeleteVehicleColourTextures(void);
|
static void DeleteVehicleColourTextures(void);
|
||||||
|
|
||||||
static RpAtomic *SetEnvironmentMapCB(RpAtomic *atomic, void *data);
|
static RpAtomic *SetEnvironmentMapCB(RpAtomic *atomic, void *data);
|
||||||
static RpMaterial *SetEnvironmentMapCB(RpMaterial *material, void *data);
|
static RpMaterial *SetDefaultEnvironmentMapCB(RpMaterial *material, void *data);
|
||||||
static RpMaterial *HasSpecularMaterialCB(RpMaterial *material, void *data);
|
static RpMaterial *GetMatFXEffectMaterialCB(RpMaterial *material, void *data);
|
||||||
void SetEnvironmentMap(void);
|
void SetEnvironmentMap(void);
|
||||||
static void LoadEnvironmentMaps(void);
|
static void LoadEnvironmentMaps(void);
|
||||||
static void ShutdownEnvironmentMaps(void);
|
static void ShutdownEnvironmentMaps(void);
|
||||||
|
|
Loading…
Reference in a new issue