mirror of
https://github.com/halpz/re3.git
synced 2025-07-22 13:29:47 +00:00
CVehicleModelInfo
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
#include "ModelIndices.h"
|
||||
#include "ModelInfo.h"
|
||||
|
||||
//--MIAMI: done
|
||||
|
||||
int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 };
|
||||
int8 CVehicleModelInfo::ms_compsUsed[2];
|
||||
RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256];
|
||||
@ -147,6 +149,8 @@ RwObjectNameIdAssocation *CVehicleModelInfo::ms_vehicleDescs[] = {
|
||||
bikeIds
|
||||
};
|
||||
|
||||
bool gbBlackCars;
|
||||
bool gbPinkCars;
|
||||
|
||||
CVehicleModelInfo::CVehicleModelInfo(void)
|
||||
: CClumpModelInfo(MITYPE_VEHICLE)
|
||||
@ -227,10 +231,30 @@ CVehicleModelInfo::SetClump(RpClump *clump)
|
||||
SetFrameIds(ms_vehicleDescs[m_vehicleType]);
|
||||
PreprocessHierarchy();
|
||||
FindEditableMaterialList();
|
||||
m_envMap = nil;
|
||||
SetEnvironmentMap();
|
||||
}
|
||||
|
||||
void
|
||||
CVehicleModelInfo::SetAnimFile(const char *file)
|
||||
{
|
||||
if(strcasecmp(file, "null") == 0)
|
||||
return;
|
||||
|
||||
m_animFileName = new char[strlen(file)+1];
|
||||
strcpy(m_animFileName, file);
|
||||
}
|
||||
|
||||
void
|
||||
CVehicleModelInfo::ConvertAnimFileIndex(void)
|
||||
{
|
||||
if(m_animFileIndex != -1){
|
||||
// we have a string pointer in that union
|
||||
int32 index = CAnimManager::GetAnimationBlockIndex(m_animFileName);
|
||||
delete[] m_animFileName;
|
||||
m_animFileIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
RwFrame*
|
||||
CVehicleModelInfo::CollapseFramesCB(RwFrame *frame, void *data)
|
||||
{
|
||||
@ -383,30 +407,68 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data)
|
||||
RpAtomic*
|
||||
CVehicleModelInfo::SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data)
|
||||
{
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
|
||||
char *name;
|
||||
|
||||
name = GetFrameNodeName(RpAtomicGetFrame(atomic));
|
||||
if(strncmp(name, "toprotor", 8) == 0)
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleRotorAlphaCB);
|
||||
else if(strncmp(name, "rearrotor", 9) == 0)
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleTailRotorAlphaCB);
|
||||
else
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
|
||||
return atomic;
|
||||
}
|
||||
|
||||
RpAtomic*
|
||||
CVehicleModelInfo::SetAtomicRendererCB_RealHeli(RpAtomic *atomic, void *data)
|
||||
{
|
||||
RpClump *clump;
|
||||
char *name;
|
||||
bool alpha;
|
||||
|
||||
clump = (RpClump*)data;
|
||||
name = GetFrameNodeName(RpAtomicGetFrame(atomic));
|
||||
alpha = false;
|
||||
RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), HasAlphaMaterialCB, &alpha);
|
||||
if(strncmp(name, "toprotor", 8) == 0)
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleRotorAlphaCB);
|
||||
else if(strncmp(name, "rearrotor", 9) == 0)
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleTailRotorAlphaCB);
|
||||
else if(strstr(name, "_hi") || strncmp(name, "extra", 5) == 0){
|
||||
if(alpha || strncmp(name, "windscreen", 10) == 0)
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB);
|
||||
else
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB);
|
||||
}else if(strstr(name, "_lo")){
|
||||
RpClumpRemoveAtomic(clump, atomic);
|
||||
RpAtomicDestroy(atomic);
|
||||
return atomic; // BUG: not done by gta
|
||||
}else if(strstr(name, "_vlo"))
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB);
|
||||
else
|
||||
CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
|
||||
HideDamagedAtomicCB(atomic, nil);
|
||||
return atomic;
|
||||
}
|
||||
|
||||
void
|
||||
CVehicleModelInfo::SetAtomicRenderCallbacks(void)
|
||||
{
|
||||
switch(m_vehicleType){
|
||||
case VEHICLE_TYPE_TRAIN:
|
||||
#ifdef GTA_TRAIN
|
||||
if(m_vehicleType == VEHICLE_TYPE_TRAIN)
|
||||
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Train, nil);
|
||||
break;
|
||||
case VEHICLE_TYPE_HELI:
|
||||
else
|
||||
#endif
|
||||
if(m_vehicleType == VEHICLE_TYPE_HELI)
|
||||
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Heli, nil);
|
||||
break;
|
||||
case VEHICLE_TYPE_PLANE:
|
||||
else if(m_vehicleType == VEHICLE_TYPE_PLANE)
|
||||
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_BigVehicle, nil);
|
||||
break;
|
||||
case VEHICLE_TYPE_BOAT:
|
||||
else if(m_vehicleType == VEHICLE_TYPE_BOAT)
|
||||
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Boat, m_clump);
|
||||
break;
|
||||
default:
|
||||
else if(mod_HandlingManager.GetHandlingData((eHandlingId)m_handlingId)->Flags & HANDLING_IS_HELI)
|
||||
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_RealHeli, m_clump);
|
||||
else
|
||||
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, m_clump);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RwObject*
|
||||
@ -603,6 +665,13 @@ ChooseComponent(int32 rule, int32 comps)
|
||||
// only valid in rain
|
||||
n = CGeneral::GetRandomNumberInRange(0, CountCompsInRule(comps));
|
||||
return COMPRULE_COMPN(comps, n);
|
||||
case 3:
|
||||
n = CGeneral::GetRandomNumberInRange(0, 1+CountCompsInRule(comps));
|
||||
if(n != 0)
|
||||
return COMPRULE_COMPN(comps, n-1);
|
||||
return -1;
|
||||
case 4:
|
||||
return CGeneral::GetRandomNumberInRange(0, 5);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -729,6 +798,9 @@ CVehicleModelInfo::GetEditableMaterialListCB(RpAtomic *atomic, void *data)
|
||||
return atomic;
|
||||
}
|
||||
|
||||
static int maxFirstMaterials;
|
||||
static int maxSecondMaterials;
|
||||
|
||||
void
|
||||
CVehicleModelInfo::FindEditableMaterialList(void)
|
||||
{
|
||||
@ -743,6 +815,8 @@ CVehicleModelInfo::FindEditableMaterialList(void)
|
||||
GetEditableMaterialListCB(m_comps[i], &cbdata);
|
||||
m_materials1[cbdata.numMats1] = nil;
|
||||
m_materials2[cbdata.numMats2] = nil;
|
||||
maxFirstMaterials = Max(maxFirstMaterials, cbdata.numMats1);
|
||||
maxSecondMaterials = Max(maxSecondMaterials, cbdata.numMats2);
|
||||
m_currentColour1 = -1;
|
||||
m_currentColour2 = -1;
|
||||
}
|
||||
@ -779,9 +853,12 @@ CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2)
|
||||
void
|
||||
CVehicleModelInfo::ChooseVehicleColour(uint8 &col1, uint8 &col2)
|
||||
{
|
||||
if(m_numColours == 0){
|
||||
if(m_numColours == 0 || gbBlackCars){
|
||||
col1 = 0;
|
||||
col2 = 0;
|
||||
}else if(gbPinkCars){
|
||||
col1 = 68;
|
||||
col2 = 68;
|
||||
}else{
|
||||
m_lastColorVariation = (m_lastColorVariation+1) % m_numColours;
|
||||
col1 = m_colours1[m_lastColorVariation];
|
||||
@ -804,18 +881,27 @@ CVehicleModelInfo::AvoidSameVehicleColour(uint8 *col1, uint8 *col2)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
if(m_numColours > 1)
|
||||
for(i = 0; i < 8; i++){
|
||||
if(*col1 != m_lastColour1 || *col2 != m_lastColour2)
|
||||
break;
|
||||
n = CGeneral::GetRandomNumberInRange(0, m_numColours);
|
||||
*col1 = m_colours1[n];
|
||||
*col2 = m_colours2[n];
|
||||
}
|
||||
m_lastColour1 = *col1;
|
||||
m_lastColour2 = *col2;
|
||||
if(gbBlackCars){
|
||||
*col1 = 0;
|
||||
*col2 = 0;
|
||||
}else if(gbPinkCars){
|
||||
*col1 = 68;
|
||||
*col2 = 68;
|
||||
}else{
|
||||
if(m_numColours > 1)
|
||||
for(i = 0; i < 8; i++){
|
||||
if(*col1 != m_lastColour1 || *col2 != m_lastColour2)
|
||||
break;
|
||||
n = CGeneral::GetRandomNumberInRange(0, m_numColours);
|
||||
*col1 = m_colours1[n];
|
||||
*col2 = m_colours2[n];
|
||||
}
|
||||
m_lastColour1 = *col1;
|
||||
m_lastColour2 = *col2;
|
||||
}
|
||||
}
|
||||
|
||||
//--MIAMI: unused
|
||||
RwTexture*
|
||||
CreateCarColourTexture(uint8 r, uint8 g, uint8 b)
|
||||
{
|
||||
@ -1055,12 +1141,15 @@ CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(int id)
|
||||
case MI_FIRETRUCK:
|
||||
n = 2;
|
||||
break;
|
||||
case MI_HUNTER:
|
||||
n = 1;
|
||||
break;
|
||||
default:
|
||||
n = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(id))->m_numDoors;
|
||||
}
|
||||
|
||||
if(n == 0)
|
||||
return id == MI_RCBANDIT ? 0 : 1;
|
||||
return id == MI_RCBANDIT || id == MI_PIZZABOY || id == MI_BAGGAGE ? 0 : 1;
|
||||
|
||||
if(id == MI_COACH)
|
||||
return 8;
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include "ClumpModelInfo.h"
|
||||
|
||||
enum {
|
||||
NUM_FIRST_MATERIALS = 26,
|
||||
NUM_SECOND_MATERIALS = 26,
|
||||
NUM_FIRST_MATERIALS = 24,
|
||||
NUM_SECOND_MATERIALS = 20,
|
||||
NUM_VEHICLE_COLOURS = 8,
|
||||
};
|
||||
|
||||
@ -43,17 +43,18 @@ class CVehicleModelInfo : public CClumpModelInfo
|
||||
public:
|
||||
uint8 m_lastColour1;
|
||||
uint8 m_lastColour2;
|
||||
char m_gameName[32];
|
||||
char m_gameName[10];
|
||||
int32 m_vehicleType;
|
||||
union {
|
||||
int32 m_wheelId;
|
||||
int32 m_planeLodId;
|
||||
};
|
||||
float m_wheelScale;
|
||||
int32 m_numDoors;
|
||||
int32 m_handlingId;
|
||||
int32 m_vehicleClass;
|
||||
int32 m_level;
|
||||
union {
|
||||
int16 m_wheelId;
|
||||
int16 m_planeLodId;
|
||||
};
|
||||
int16 m_handlingId;
|
||||
int8 m_numDoors;
|
||||
int8 m_vehicleClass;
|
||||
int8 m_level;
|
||||
int8 m_numComps;
|
||||
int16 m_frequency;
|
||||
CVector m_positions[NUM_VEHICLE_POSITIONS];
|
||||
uint32 m_compRules;
|
||||
@ -66,9 +67,11 @@ public:
|
||||
uint8 m_lastColorVariation;
|
||||
uint8 m_currentColour1;
|
||||
uint8 m_currentColour2;
|
||||
RwTexture *m_envMap;
|
||||
RpAtomic *m_comps[6];
|
||||
int32 m_numComps;
|
||||
union {
|
||||
int32 m_animFileIndex;
|
||||
char *m_animFileName;
|
||||
};
|
||||
|
||||
static int8 ms_compsToUse[2];
|
||||
static int8 ms_compsUsed[2];
|
||||
@ -80,6 +83,9 @@ public:
|
||||
void DeleteRwObject(void);
|
||||
RwObject *CreateInstance(void);
|
||||
void SetClump(RpClump *);
|
||||
void SetAnimFile(const char *file);
|
||||
void ConvertAnimFileIndex(void);
|
||||
int GetAnimFileIndex(void) { return m_animFileIndex; }
|
||||
|
||||
static RwFrame *CollapseFramesCB(RwFrame *frame, void *data);
|
||||
static RwObject *MoveObjectsCB(RwObject *object, void *data);
|
||||
@ -92,6 +98,7 @@ public:
|
||||
static RpAtomic *SetAtomicRendererCB_Train(RpAtomic *atomic, void *data);
|
||||
static RpAtomic *SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data);
|
||||
static RpAtomic *SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data);
|
||||
static RpAtomic *SetAtomicRendererCB_RealHeli(RpAtomic *atomic, void *data);
|
||||
void SetAtomicRenderCallbacks(void);
|
||||
|
||||
static RwObject *SetAtomicFlagCB(RwObject *object, void *data);
|
||||
@ -122,3 +129,6 @@ public:
|
||||
static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id);
|
||||
static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; }
|
||||
};
|
||||
|
||||
extern bool gbBlackCars;
|
||||
extern bool gbPinkCars;
|
||||
|
Reference in New Issue
Block a user