diff options
Diffstat (limited to 'src/modelinfo')
-rw-r--r-- | src/modelinfo/BaseModelInfo.cpp | 16 | ||||
-rw-r--r-- | src/modelinfo/BaseModelInfo.h | 48 | ||||
-rw-r--r-- | src/modelinfo/ClumpModelInfo.cpp | 61 | ||||
-rw-r--r-- | src/modelinfo/ClumpModelInfo.h | 14 | ||||
-rw-r--r-- | src/modelinfo/MloModelInfo.cpp | 4 | ||||
-rw-r--r-- | src/modelinfo/ModelIndices.h | 728 | ||||
-rw-r--r-- | src/modelinfo/ModelInfo.cpp | 102 | ||||
-rw-r--r-- | src/modelinfo/ModelInfo.h | 19 | ||||
-rw-r--r-- | src/modelinfo/PedModelInfo.cpp | 290 | ||||
-rw-r--r-- | src/modelinfo/PedModelInfo.h | 43 | ||||
-rw-r--r-- | src/modelinfo/SimpleModelInfo.cpp | 59 | ||||
-rw-r--r-- | src/modelinfo/SimpleModelInfo.h | 32 | ||||
-rw-r--r-- | src/modelinfo/TimeModelInfo.h | 3 | ||||
-rw-r--r-- | src/modelinfo/VehicleModelInfo.cpp | 300 | ||||
-rw-r--r-- | src/modelinfo/VehicleModelInfo.h | 51 | ||||
-rw-r--r-- | src/modelinfo/WeaponModelInfo.cpp | 53 | ||||
-rw-r--r-- | src/modelinfo/WeaponModelInfo.h | 23 | ||||
-rw-r--r-- | src/modelinfo/XtraCompsModelInfo.h | 13 |
18 files changed, 949 insertions, 910 deletions
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp index 7137c604..709420fd 100644 --- a/src/modelinfo/BaseModelInfo.cpp +++ b/src/modelinfo/BaseModelInfo.cpp @@ -4,12 +4,13 @@ #include "TxdStore.h" #include "2dEffect.h" #include "BaseModelInfo.h" +#include "ModelInfo.h" #include "ColModel.h" CBaseModelInfo::CBaseModelInfo(ModelInfoType type) { m_colModel = nil; - m_twodEffects = nil; + m_2dEffectsID = -1; m_objectId = -1; m_refCount = 0; m_txdSlot = -1; @@ -23,9 +24,10 @@ CBaseModelInfo::Shutdown(void) { DeleteCollisionModel(); DeleteRwObject(); - m_twodEffects = nil; + m_2dEffectsID = -1; m_num2dEffects = 0; m_txdSlot = -1; + m_objectId = -1; } void @@ -76,17 +78,17 @@ CBaseModelInfo::RemoveTexDictionaryRef(void) void CBaseModelInfo::Init2dEffects(void) { - m_twodEffects = nil; + m_2dEffectsID = -1; m_num2dEffects = 0; } void CBaseModelInfo::Add2dEffect(C2dEffect *fx) { - if(m_twodEffects) + if(m_2dEffectsID >= 0) m_num2dEffects++; else{ - m_twodEffects = fx; + m_2dEffectsID = CModelInfo::Get2dEffectStore().GetIndex(fx); m_num2dEffects = 1; } } @@ -94,8 +96,8 @@ CBaseModelInfo::Add2dEffect(C2dEffect *fx) C2dEffect* CBaseModelInfo::Get2dEffect(int n) { - if(m_twodEffects) - return &m_twodEffects[n]; + if(m_2dEffectsID >= 0) + return CModelInfo::Get2dEffectStore().GetItem(m_2dEffectsID+n); else return nil; } diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index f46cea84..2d1dc8ac 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -2,18 +2,20 @@ struct CColModel; -#define MAX_MODEL_NAME (24) +#define MAX_MODEL_NAME (21) enum ModelInfoType { - MITYPE_NA = 0, - MITYPE_SIMPLE = 1, - MITYPE_MLO = 2, - MITYPE_TIME = 3, - MITYPE_CLUMP = 4, - MITYPE_VEHICLE = 5, - MITYPE_PED = 6, - MITYPE_XTRACOMPS = 7, + MITYPE_NA, + MITYPE_SIMPLE, + MITYPE_MLO, // unused but still in enum + MITYPE_TIME, + MITYPE_WEAPON, + MITYPE_CLUMP, + MITYPE_VEHICLE, + MITYPE_PED, + MITYPE_XTRACOMPS, // unused but still in enum + MITYPE_HAND // xbox and mobile }; class C2dEffect; @@ -22,22 +24,14 @@ class CBaseModelInfo { protected: char m_name[MAX_MODEL_NAME]; + uint8 m_type; + uint8 m_num2dEffects; + bool m_bOwnsColModel; CColModel *m_colModel; - C2dEffect *m_twodEffects; + int16 m_2dEffectsID; int16 m_objectId; uint16 m_refCount; int16 m_txdSlot; - uint8 m_type; - uint8 m_num2dEffects; - bool m_bOwnsColModel; -#ifdef EXTRA_MODEL_FLAGS -public: - // from mobile - bool m_bIsDoubleSided; - bool m_bIsTree; - bool m_bCanBeIgnored; // for low-end devices - bool RenderDoubleSided(void) { return m_bIsDoubleSided || m_bIsTree; } -#endif public: CBaseModelInfo(ModelInfoType type); @@ -47,13 +41,15 @@ public: virtual RwObject *CreateInstance(void) = 0; virtual RwObject *CreateInstance(RwMatrix *) = 0; virtual RwObject *GetRwObject(void) = 0; + virtual void SetAnimFile(const char *file) {} + virtual void ConvertAnimFileIndex(void) {} + virtual int GetAnimFileIndex(void) { return -1; } // one day it becomes virtual uint8 GetModelType() const { return m_type; } - bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; } - bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE || - m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck - } + bool IsBuilding(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; } + bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME || m_type == MITYPE_WEAPON; } + bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE; } char *GetModelName(void) { return m_name; } void SetModelName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); } void SetColModel(CColModel *col, bool owns = false){ @@ -76,5 +72,3 @@ public: uint8 GetNum2dEffects() const { return m_num2dEffects; } uint16 GetNumRefs() const { return m_refCount; } }; - -VALIDATE_SIZE(CBaseModelInfo, 0x30); diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp index 44a62afb..ba18bfa7 100644 --- a/src/modelinfo/ClumpModelInfo.cpp +++ b/src/modelinfo/ClumpModelInfo.cpp @@ -5,7 +5,7 @@ #include "NodeName.h" #include "VisibilityPlugins.h" #include "ModelInfo.h" -#include "ModelIndices.h" +#include "AnimManager.h" void CClumpModelInfo::DeleteRwObject(void) @@ -14,17 +14,17 @@ CClumpModelInfo::DeleteRwObject(void) RpClumpDestroy(m_clump); m_clump = nil; RemoveTexDictionaryRef(); + if(GetAnimFileIndex() != -1) + CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex()); } } -#ifdef PED_SKIN static RpAtomic* SetHierarchyForSkinAtomic(RpAtomic *atomic, void *data) { RpSkinAtomicSetHAnimHierarchy(atomic, (RpHAnimHierarchy*)data); return nil; } -#endif RwObject* CClumpModelInfo::CreateInstance(void) @@ -32,24 +32,17 @@ CClumpModelInfo::CreateInstance(void) if(m_clump == nil) return nil; RpClump *clone = RpClumpClone(m_clump); -#ifdef PED_SKIN if(IsClumpSkinned(clone)){ RpHAnimHierarchy *hier; RpHAnimAnimation *anim; hier = GetAnimHierarchyFromClump(clone); assert(hier); - // This seems dangerous as only the first atomic will get a hierarchy - // can we guarantee this if hands and head are also in the clump? RpClumpForAllAtomics(clone, SetHierarchyForSkinAtomic, hier); anim = HAnimAnimationCreateForHierarchy(hier); RpHAnimHierarchySetCurrentAnim(hier, anim); RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); - // the rest is xbox only: - // RpSkinGetNumBones(RpSkinGeometryGetSkin(RpAtomicGetGeometry(IsClumpSkinned(clone)))); - RpHAnimHierarchyUpdateMatrices(hier); } -#endif return (RwObject*)clone; } @@ -77,27 +70,18 @@ CClumpModelInfo::SetClump(RpClump *clump) m_clump = clump; CVisibilityPlugins::SetClumpModelInfo(m_clump, this); AddTexDictionaryRef(); - RpClumpForAllAtomics(clump, SetAtomicRendererCB, nil); - -#ifdef PED_SKIN + if(GetAnimFileIndex() != -1) + CAnimManager::AddAnimBlockRef(GetAnimFileIndex()); if(IsClumpSkinned(clump)){ int i; RpHAnimHierarchy *hier; RpAtomic *skinAtomic; RpSkin *skin; - // mobile: -// hier = nil; -// RwFrameForAllChildren(RpClumpGetFrame(clump), GetHierarchyFromChildNodesCB, &hier); -// assert(hier); -// RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier); -// skinAtomic = GetFirstAtomic(clump); - - // xbox: hier = GetAnimHierarchyFromClump(clump); assert(hier); - RpSkinAtomicSetHAnimHierarchy(IsClumpSkinned(clump), hier); - skinAtomic = IsClumpSkinned(clump); + RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier); + skinAtomic = GetFirstAtomic(clump); assert(skinAtomic); skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(skinAtomic)); @@ -112,17 +96,27 @@ CClumpModelInfo::SetClump(RpClump *clump) } RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); } - if(strcmp(GetModelName(), "playerh") == 0){ - // playerh is incompatible with the xbox player skin - // so check if player model is skinned and only apply skin to head if it isn't - CPedModelInfo *body = (CPedModelInfo*)CModelInfo::GetModelInfo(MI_PLAYER); - if(!(body->m_clump && IsClumpSkinned(body->m_clump))) - RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); +} + +void +CClumpModelInfo::SetAnimFile(const char *file) +{ + if(strcasecmp(file, "null") == 0) + return; + + m_animFileName = new char[strlen(file)+1]; + strcpy(m_animFileName, file); +} + +void +CClumpModelInfo::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; } -#else - if(strcmp(GetModelName(), "playerh") == 0) - RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); -#endif } void @@ -154,6 +148,7 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data) return assoc->frame ? nil : frame; } +// unused RwFrame* CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data) { diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h index 58b6de11..0113d340 100644 --- a/src/modelinfo/ClumpModelInfo.h +++ b/src/modelinfo/ClumpModelInfo.h @@ -30,9 +30,13 @@ class CClumpModelInfo : public CBaseModelInfo { public: RpClump *m_clump; + union { + int32 m_animFileIndex; + char *m_animFileName; + }; - CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {} - CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {} + CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) { m_animFileIndex = -1; } + CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) { m_animFileIndex = -1; } ~CClumpModelInfo() {} void DeleteRwObject(void); RwObject *CreateInstance(void); @@ -40,6 +44,9 @@ public: RwObject *GetRwObject(void) { return (RwObject*)m_clump; } virtual void SetClump(RpClump *); + virtual void SetAnimFile(const char *file); + virtual void ConvertAnimFileIndex(void); + virtual int GetAnimFileIndex(void) { return m_animFileIndex; } static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data); void SetFrameIds(RwObjectNameIdAssocation *assocs); @@ -50,5 +57,4 @@ public: static RwFrame *FillFrameArrayCB(RwFrame *frame, void *data); static RwFrame *GetFrameFromId(RpClump *clump, int32 id); }; - -VALIDATE_SIZE(CClumpModelInfo, 0x34); +//static_assert(sizeof(CClumpModelInfo) == 0x34, "CClumpModelInfo: error"); diff --git a/src/modelinfo/MloModelInfo.cpp b/src/modelinfo/MloModelInfo.cpp index 7535e6c5..fa12b900 100644 --- a/src/modelinfo/MloModelInfo.cpp +++ b/src/modelinfo/MloModelInfo.cpp @@ -3,6 +3,7 @@ #include "VisibilityPlugins.h" #include "ModelInfo.h" +/* void CMloModelInfo::ConstructClump() { @@ -36,4 +37,5 @@ CMloModelInfo::ConstructClump() RpClumpDestroy(m_clump); m_clump = nil; } -}
\ No newline at end of file +} +*/
\ No newline at end of file diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index c0f01929..836c4092 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -1,13 +1,9 @@ #pragma once +#include "ModelInfo.h" + #define MODELINDICES \ X("fire_hydrant", MI_FIRE_HYDRANT) \ - X("bagelstnd02", MI_BAGELSTAND2) \ - X("fish01", MI_FISHSTALL01) \ - X("fishstall02", MI_FISHSTALL02) \ - X("fishstall03", MI_FISHSTALL03) \ - X("fishstall04", MI_FISHSTALL04) \ - X("taxisign", MI_TAXISIGN) \ X("phonesign", MI_PHONESIGN) \ X("noparkingsign1", MI_NOPARKINGSIGN1) \ X("bussign1", MI_BUSSIGN1) \ @@ -20,97 +16,62 @@ X("wastebin", MI_WASTEBIN) \ X("phonebooth1", MI_PHONEBOOTH1) \ X("parkingmeter", MI_PARKINGMETER) \ + X("parkingmeterg", MI_PARKINGMETER2) \ + X("mall_fans", MI_MALLFAN) \ + X("htl_fan_rotate_nt", MI_HOTELFAN_NIGHT) \ + X("htl_fan_rotate_dy", MI_HOTELFAN_DAY) \ + X("hotroomfan", MI_HOTROOMFAN) \ X("trafficlight1", MI_TRAFFICLIGHTS) \ + X("MTraffic4", MI_TRAFFICLIGHTS_VERTICAL) \ + X("MTraffic1", MI_TRAFFICLIGHTS_MIAMI) \ + X("MTraffic2", MI_TRAFFICLIGHTS_TWOVERTICAL) \ X("lamppost1", MI_SINGLESTREETLIGHTS1) \ X("lamppost2", MI_SINGLESTREETLIGHTS2) \ X("lamppost3", MI_SINGLESTREETLIGHTS3) \ X("doublestreetlght1", MI_DOUBLESTREETLIGHTS) \ - X("rd_Road2A10", MI_ROADSFORROADBLOCKSSTART) \ - X("rd_Road1A30", MI_ROADSFORROADBLOCKSEND) \ - X("veg_tree1", MI_TREE1) \ + X("Streetlamp1", MI_STREETLAMP1) \ + X("Streetlamp2", MI_STREETLAMP2) \ X("veg_tree3", MI_TREE2) \ X("veg_treea1", MI_TREE3) \ - X("veg_treenew01", MI_TREE4) \ - X("veg_treenew05", MI_TREE5) \ X("veg_treeb1", MI_TREE6) \ - X("veg_treenew10", MI_TREE7) \ X("veg_treea3", MI_TREE8) \ - X("veg_treenew09", MI_TREE9) \ - X("veg_treenew08", MI_TREE10) \ - X("veg_treenew03", MI_TREE11) \ - X("veg_treenew16", MI_TREE12) \ - X("veg_treenew17", MI_TREE13) \ - X("veg_treenew06", MI_TREE14) \ - X("doc_crane_cab", MODELID_CRANE_1) \ - X("cranetopb", MODELID_CRANE_2) \ - X("cranetopa", MODELID_CRANE_3) \ + X("doc_crane_cab0", MODELID_CRANE_1) \ + X("doc_crane_cab01", MODELID_CRANE_2) \ + X("doc_crane_cab02", MODELID_CRANE_3) \ + X("doc_crane_cab03", MODELID_CRANE_4) \ + X("boatcranelg0", MODELID_CRANE_5) \ + X("LODnetopa0", MODELID_CRANE_6) \ X("package1", MI_COLLECTABLE1) \ X("Money", MI_MONEY) \ X("barrel1", MI_CARMINE) \ - X("oddjgaragdoor", MI_GARAGEDOOR1) \ - X("bombdoor", MI_GARAGEDOOR2) \ - X("door_bombshop", MI_GARAGEDOOR3) \ - X("vheistlocdoor", MI_GARAGEDOOR4) \ - X("door2_garage", MI_GARAGEDOOR5) \ - X("ind_slidedoor", MI_GARAGEDOOR6) \ - X("bankjobdoor", MI_GARAGEDOOR7) \ - X("door_jmsgrage", MI_GARAGEDOOR9) \ - X("jamesgrge_kb", MI_GARAGEDOOR10) \ - X("door_sfehousegrge", MI_GARAGEDOOR11) \ - X("shedgaragedoor", MI_GARAGEDOOR12) \ - X("door4_garage", MI_GARAGEDOOR13) \ - X("door_col_compnd_01", MI_GARAGEDOOR14) \ - X("door_col_compnd_02", MI_GARAGEDOOR15) \ - X("door_col_compnd_03", MI_GARAGEDOOR16) \ - X("door_col_compnd_04", MI_GARAGEDOOR17) \ - X("door_col_compnd_05", MI_GARAGEDOOR18) \ - X("impex_door", MI_GARAGEDOOR19) \ - X("SalvGarage", MI_GARAGEDOOR20) \ - X("door3_garage", MI_GARAGEDOOR21) \ - X("leveldoor2", MI_GARAGEDOOR22) \ - X("double_garage_dr", MI_GARAGEDOOR23) \ - X("amcogaragedoor", MI_GARAGEDOOR24) \ - X("towergaragedoor1", MI_GARAGEDOOR25) \ - X("towergaragedoor2", MI_GARAGEDOOR26) \ - X("towergaragedoor3", MI_GARAGEDOOR27) \ - X("plysve_gragedoor", MI_GARAGEDOOR28) \ - X("impexpsubgrgdoor", MI_GARAGEDOOR29) \ - X("Sub_sprayshopdoor", MI_GARAGEDOOR30) \ - X("ind_plyrwoor", MI_GARAGEDOOR31) \ - X("8ballsuburbandoor", MI_GARAGEDOOR32) \ + X("dk_paynspraydoor", MI_GARAGEDOOR2) \ + X("dk_waretankdoor1", MI_GARAGEDOOR3) \ + X("hav_garagedoor1", MI_GARAGEDOOR4) \ + X("hav_garagedoor02", MI_GARAGEDOOR5) \ + X("hav_garagedoor03", MI_GARAGEDOOR6) \ + X("hav_garagedoor04", MI_GARAGEDOOR7) \ + X("lh_showdoor03", MI_GARAGEDOOR9) \ + X("lh_showdoor1", MI_GARAGEDOOR10) \ + X("lhtankdoor", MI_GARAGEDOOR11) \ + X("nbtgardoor", MI_GARAGEDOOR12) \ + X("dk_camjonesdoor", MI_GARAGEDOOR13) \ + X("nbtgardoor02", MI_GARAGEDOOR14) \ + X("dt_savedra", MI_GARAGEDOOR15) \ + X("dt_savedrb", MI_GARAGEDOOR16) \ + X("dk_bombdoor", MI_GARAGEDOOR18) \ + X("haiwshpnsdoor", MI_GARAGEDOOR19) \ + X("wshpnsdoor", MI_GARAGEDOOR20) \ + X("nbecpnsdoor", MI_GARAGEDOOR21) \ + X("nbtgardoor03", MI_GARAGEDOOR22) \ + X("dt_savedrc", MI_GARAGEDOOR23) \ + X("dt_savedrd", MI_GARAGEDOOR24) \ + X("man_frntstepGD", MI_GARAGEDOOR25) \ + X("svegrgedoor", MI_GARAGEDOOR26) \ X("barrel2", MI_NAUTICALMINE) \ - X("crushercrush", MI_CRUSHERBODY) \ - X("crushertop", MI_CRUSHERLID) \ - X("donkeymag", MI_DONKEYMAG) \ - X("bullion", MI_BULLION) \ - X("floatpackge1", MI_FLOATPACKAGE1) \ X("briefcase", MI_BRIEFCASE) \ - X("chinabanner1", MI_CHINABANNER1) \ - X("chinabanner2", MI_CHINABANNER2) \ - X("chinabanner3", MI_CHINABANNER3) \ - X("chinabanner4", MI_CHINABANNER4) \ - X("iten_chinatown5", MI_CHINABANNER5) \ - X("iten_chinatown7", MI_CHINABANNER6) \ - X("iten_chinatown3", MI_CHINABANNER7) \ - X("iten_chinatown2", MI_CHINABANNER8) \ - X("iten_chinatown4", MI_CHINABANNER9) \ - X("iten_washline01", MI_CHINABANNER10) \ - X("iten_washline02", MI_CHINABANNER11) \ - X("iten_washline03", MI_CHINABANNER12) \ - X("chinalanterns", MI_CHINALANTERN) \ - X("glassfx1", MI_GLASS1) \ - X("glassfx2", MI_GLASS2) \ - X("glassfx3", MI_GLASS3) \ - X("glassfx4", MI_GLASS4) \ - X("glassfx55", MI_GLASS5) \ - X("glassfxsub1", MI_GLASS6) \ - X("glassfxsub2", MI_GLASS7) \ + X("wglasssmash", MI_GLASS1) \ X("glassfx_composh", MI_GLASS8) \ - X("bridge_liftsec", MI_BRIDGELIFT) \ - X("bridge_liftweight", MI_BRIDGEWEIGHT) \ - X("subbridge_lift", MI_BRIDGEROADSEGMENT) \ X("barrel4", MI_EXPLODINGBARREL) \ - X("flagsitaly", MI_ITALYBANNER1) \ X("adrenaline", MI_PICKUP_ADRENALINE) \ X("bodyarmour", MI_PICKUP_BODYARMOUR) \ X("info", MI_PICKUP_INFO) \ @@ -119,44 +80,65 @@ X("bribe", MI_PICKUP_BRIBE) \ X("killfrenzy", MI_PICKUP_KILLFRENZY) \ X("camerapickup", MI_PICKUP_CAMERA) \ + X("bigdollar", MI_PICKUP_REVENUE) \ + X("pickupsave", MI_PICKUP_SAVEGAME) \ + X("property_locked", MI_PICKUP_PROPERTY) \ + X("property_fsale", MI_PICKUP_PROPERTY_FORSALE) \ + X("clothesp", MI_PICKUP_CLOTHES) \ X("bollardlight", MI_BOLLARDLIGHT) \ - X("magnet", MI_MAGNET) \ - X("streetlamp1", MI_STREETLAMP1) \ - X("streetlamp2", MI_STREETLAMP2) \ - X("railtrax_lo4b", MI_RAILTRACKS) \ X("bar_barrier10", MI_FENCE) \ X("bar_barrier12", MI_FENCE2) \ X("petrolpump", MI_PETROLPUMP) \ - X("bodycast", MI_BODYCAST) \ - X("backdoor", MI_BACKDOOR) \ - X("coffee", MI_COFFEE) \ + X("washgaspump", MI_PETROLPUMP2) \ X("bouy", MI_BUOY) \ X("parktable1", MI_PARKTABLE) \ - X("sbwy_tunl_start", MI_SUBWAY1) \ - X("sbwy_tunl_bit", MI_SUBWAY2) \ - X("sbwy_tunl_bend", MI_SUBWAY3) \ - X("sbwy_tunl_cstm6", MI_SUBWAY4) \ - X("sbwy_tunl_cstm7", MI_SUBWAY5) \ - X("sbwy_tunl_cstm8", MI_SUBWAY6) \ - X("sbwy_tunl_cstm10", MI_SUBWAY7) \ - X("sbwy_tunl_cstm9", MI_SUBWAY8) \ - X("sbwy_tunl_cstm11", MI_SUBWAY9) \ - X("sbwy_tunl_cstm1", MI_SUBWAY10) \ - X("sbwy_tunl_cstm2", MI_SUBWAY11) \ - X("sbwy_tunl_cstm4", MI_SUBWAY12) \ - X("sbwy_tunl_cstm3", MI_SUBWAY13) \ - X("sbwy_tunl_cstm5", MI_SUBWAY14) \ - X("subplatform_n2", MI_SUBWAY15) \ - X("suby_tunl_start", MI_SUBWAY16) \ - X("sbwy_tunl_start2", MI_SUBWAY17) \ - X("indy_tunl_start", MI_SUBWAY18) \ - X("indsubway03", MI_SUBPLATFORM_IND) \ - X("comerside_subway", MI_SUBPLATFORM_COMS) \ - X("subplatform", MI_SUBPLATFORM_COMS2) \ - X("subplatform_n", MI_SUBPLATFORM_COMN) \ - X("Otherside_subway", MI_SUBPLATFORM_SUB) \ - X("subplatform_sub", MI_SUBPLATFORM_SUB2) \ - X("files", MI_FILES) + X("lamppost1", MI_LAMPPOST1) \ + X("veg_palm04", MI_VEG_PALM01) \ + X("veg_palwee02", MI_VEG_PALM02) \ + X("veg_palmkbb11", MI_VEG_PALM03) \ + X("veg_palmkb4", MI_VEG_PALM04) \ + X("veg_palm02", MI_VEG_PALM05) \ + X("veg_palmkb3", MI_VEG_PALM06) \ + X("veg_palmbig14", MI_VEG_PALM07) \ + X("veg_palm01", MI_VEG_PALM08) \ + X("mlamppost", MI_MLAMPPOST) \ + X("roadworkbarrier1", MI_BARRIER1) \ + X("littleha_police", MI_LITTLEHA_POLICE) \ + X("telgrphpole02", MI_TELPOLE02) \ + X("trafficlight1", MI_TRAFFICLIGHT01) \ + X("parkbench1", MI_PARKBENCH) \ + X("plc_stinger", MI_PLC_STINGER) \ + X("od_lightbeam", MI_LIGHTBEAM) \ + X("ap_radar1_01", MI_AIRPORTRADAR) \ + X("rcbomb", MI_RCBOMB) \ + X("beachball", MI_BEACHBALL) \ + X("sandcastle1", MI_SANDCASTLE1) \ + X("sandcastle2", MI_SANDCASTLE2) \ + X("jellyfish", MI_JELLYFISH) \ + X("jellyfish01", MI_JELLYFISH01) \ + X("fish1single", MI_FISH1SINGLE) \ + X("fish1s", MI_FISH1S) \ + X("fish2single", MI_FISH2SINGLE) \ + X("fish2s", MI_FISH2S) \ + X("fish3single", MI_FISH3SINGLE) \ + X("fish3s", MI_FISH3S) \ + X("turtle", MI_TURTLE) \ + X("dolphin", MI_DOLPHIN) \ + X("shark", MI_SHARK) \ + X("submarine", MI_SUBMARINE) \ + X("Esc_step", MI_ESCALATORSTEP) \ + X("lounge_wood_up", MI_LOUNGE_WOOD_UP) \ + X("lounge_towel_up", MI_LOUNGE_TOWEL_UP) \ + X("lounge_wood_dn", MI_LOUNGE_WOOD_DN) \ + X("lotion", MI_LOTION) \ + X("beachtowel01", MI_BEACHTOWEL01) \ + X("beachtowel02", MI_BEACHTOWEL02) \ + X("beachtowel03", MI_BEACHTOWEL03) \ + X("beachtowel04", MI_BEACHTOWEL04) \ + X("blimp_night", MI_BLIMP_NIGHT) \ + X("blimp_day", MI_BLIMP_DAY) \ + X("yt_main_body", MI_YT_MAIN_BODY) \ + X("yt_main_body2", MI_YT_MAIN_BODY2) #define X(name, var) extern int16 var; MODELINDICES @@ -174,88 +156,131 @@ enum MI_MEDIC, MI_FIREMAN, MI_MALE01, - MI_TAXI_D, - MI_PIMP, - MI_GANG01, - MI_GANG02, - MI_GANG03, - MI_GANG04, - MI_GANG05, - MI_GANG06, - MI_GANG07, - MI_GANG08, - MI_GANG09, - MI_GANG10, - MI_GANG11, - MI_GANG12, - MI_GANG13, - MI_GANG14, - MI_CRIMINAL01, - MI_CRIMINAL02, - MI_SPECIAL01, + + MI_HFYST = 9, + MI_HFOST, + MI_HMYST, + MI_HMOST, + MI_HFYRI, + MI_HFORI, + MI_HMYRI, + MI_HMORI, + MI_HFYBE, + MI_HFOBE, + MI_HMYBE, + MI_HMOBE, + MI_HFYBU, + MI_HFYMD, + MI_HFYCG, + MI_HFYPR, + MI_HFOTR, + MI_HMOTR, + MI_HMYAP, + MI_HMOCA, + MI_TAXI_D = MI_HMOCA, + MI_BMODK, + MI_BMYKR, + MI_BFYST, + MI_BFOST, + MI_BMYST, + MI_BMOST, + MI_BFYRI, + MI_BFORI, + MI_BMYRI, + MI_BFYBE, + MI_BMYBE, + MI_BFOBE, + MI_BMOBE, + MI_BMYBU, + MI_BFYPR, + MI_BFOTR, + MI_BMOTR, + MI_BMYPI, + MI_BMYBB, + MI_WMYCR, + MI_WFYST, + MI_WFOST, + MI_WMYST, + MI_WMOST, + MI_WFYRI, + MI_WFORI, + MI_WMYRI, + MI_WMORI, + MI_WFYBE, + MI_WMYBE, + MI_WFOBE, + MI_WMOBE, + MI_WMYCW, + MI_WMYGO, + MI_WFOGO, + MI_WMOGO, + MI_WFYLG, + MI_WMYLG, + MI_WFYBU, + MI_WMYBU, + MI_WMOBU, + MI_WFYPR, + MI_WFOTR, + MI_WMOTR, + MI_WMYPI, + MI_WMOCA, + MI_WFYJG, + MI_WMYJG, + MI_WFYSK, + MI_WMYSK, + MI_WFYSH, + MI_WFOSH, + MI_JFOTO, + MI_JMOTO, + + MI_CBA,// = 83, + MI_CBB, + MI_HNA, + MI_HNB, + MI_SGA, + MI_SGB, + MI_CLA, + MI_CLB, + MI_GDA, + MI_GDB, + MI_BKA, + MI_BKB, + MI_PGA, + MI_PGB, + MI_VICE1, + MI_VICE2, + MI_VICE3, + MI_VICE4, + MI_VICE5, + MI_VICE6, + MI_VICE7, + MI_VICE8, + MI_WFYG1, + MI_WFYG2,// = 106, // last regular ped + // three more peds possible + MI_SPECIAL01 = 109, MI_SPECIAL02, MI_SPECIAL03, MI_SPECIAL04, - MI_MALE02, - MI_MALE03, - MI_FATMALE01, - MI_FATMALE02, - MI_FEMALE01, - MI_FEMALE02, - MI_FEMALE03, - MI_FATFEMALE01, - MI_FATFEMALE02, - MI_PROSTITUTE, - MI_PROSTITUTE2, - MI_P_MAN1, - MI_P_MAN2, - MI_P_WOM1, - MI_P_WOM2, - MI_CT_MAN1, - MI_CT_MAN2, - MI_CT_WOM1, - MI_CT_WOM2, - MI_LI_MAN1, - MI_LI_MAN2, - MI_LI_WOM1, - MI_LI_WOM2, - MI_DOCKER1, - MI_DOCKER2, - MI_SCUM_MAN, - MI_SCUM_WOM, - MI_WORKER1, - MI_WORKER2, - MI_B_MAN1, - MI_B_MAN2, - MI_B_MAN3, - MI_B_WOM1, - MI_B_WOM2, - MI_B_WOM3, - MI_MOD_MAN, - MI_MOD_WOM, - MI_ST_MAN, - MI_ST_WOM, - MI_FAN_MAN1, - MI_FAN_MAN2, - MI_FAN_WOM, - MI_HOS_MAN, - MI_HOS_WOM, - MI_CONST1, - MI_CONST2, - MI_SHOPPER1, - MI_SHOPPER2, - MI_SHOPPER3, - MI_STUD_MAN, - MI_STUD_WOM, - MI_CAS_MAN, - MI_CAS_WOM, - MI_BUSKER1, - MI_BUSKER2, - MI_BUSKER3, - MI_BUSKER4, - // three more peds possible + MI_SPECIAL05, + MI_SPECIAL06, + MI_SPECIAL07, + MI_SPECIAL08, + MI_SPECIAL09, + MI_SPECIAL10, + MI_SPECIAL11, + MI_SPECIAL12, + MI_SPECIAL13, + MI_SPECIAL14, + MI_SPECIAL15, + MI_SPECIAL16, + MI_SPECIAL17, + MI_SPECIAL18, + MI_SPECIAL19, + MI_SPECIAL20, + MI_SPECIAL21,// = 129, - MI_LAST_PED = 89, + MI_LAST_PED = MI_SPECIAL21, MI_FIRST_VEHICLE, MI_LANDSTAL = MI_FIRST_VEHICLE, @@ -264,13 +289,13 @@ enum MI_LINERUN, MI_PEREN, MI_SENTINEL, - MI_PATRIOT, + MI_RIO, MI_FIRETRUCK, MI_TRASH, MI_STRETCH, MI_MANANA, MI_INFERNUS, - MI_BLISTA, + MI_VOODOO, MI_PONY, MI_MULE, MI_CHEETAH, @@ -279,11 +304,11 @@ enum MI_MOONBEAM, MI_ESPERANT, MI_TAXI, - MI_KURUMA, + MI_WASHING, MI_BOBCAT, MI_MRWHOOP, MI_BFINJECT, - MI_CORPSE, + MI_HUNTER, MI_POLICE, MI_ENFORCER, MI_SECURICA, @@ -292,77 +317,159 @@ enum MI_BUS, MI_RHINO, MI_BARRACKS, - MI_TRAIN, + MI_CUBAN, MI_CHOPPER, - MI_DODO, + MI_ANGEL, MI_COACH, MI_CABBIE, MI_STALLION, MI_RUMPO, MI_RCBANDIT, - MI_BELLYUP, - MI_MRWONGS, - MI_MAFIA, - MI_YARDIE, - MI_YAKUZA, - MI_DIABLOS, - MI_COLUMB , - MI_HOODS, + MI_ROMERO, + MI_PACKER, + MI_SENTXS, + MI_ADMIRAL, + MI_SQUALO, + MI_SEASPAR, + MI_PIZZABOY, + MI_GANGBUR, MI_AIRTRAIN, MI_DEADDODO, MI_SPEEDER, MI_REEFER, - MI_PANLANT, + MI_TROPIC, MI_FLATBED, MI_YANKEE, - MI_ESCAPE, - MI_BORGNINE, - MI_TOYZ, - MI_GHOST, - - // leftovers on PC - MI_MIAMI_RCBARON = 154, - MI_MIAMI_RCRAIDER = 155, - MI_MIAMI_SPARROW = 159, - - MI_GRENADE = 170, - MI_AK47, + MI_CADDY, + MI_ZEBRA, + MI_TOPFUN, + MI_SKIMMER, + MI_PCJ600, + MI_FAGGIO, + MI_FREEWAY, + MI_RCBARON, + MI_RCRAIDER, + MI_GLENDALE, + MI_OCEANIC, + MI_SANCHEZ, + MI_SPARROW, + MI_PATRIOT, + MI_LOVEFIST, + MI_COASTG, + MI_DINGHY, + MI_HERMES, + MI_SABRE, + MI_SABRETUR, + MI_PHEONIX, + MI_WALTON, + MI_REGINA, + MI_COMET, + MI_DELUXO, + MI_BURRITO, + MI_SPAND, + MI_MARQUIS, + MI_BAGGAGE, + MI_KAUFMAN, + MI_MAVERICK, + MI_VCNMAV, + MI_RANCHER, + MI_FBIRANCH, + MI_VIRGO, + MI_GREENWOO, + MI_JETMAX, + MI_HOTRING, + MI_SANDKING, + MI_BLISTAC, + MI_POLMAV, + MI_BOXVILLE, + MI_BENSON, + MI_MESA, + MI_RCGOBLIN, + MI_HOTRINA, + MI_HOTRINB, + MI_BLOODRA, + MI_BLOODRB, + MI_VICECHEE, + + // HACK + MI_TRAIN = -1, + MI_DODO = -2, + + MI_LAST_VEHICLE = MI_VICECHEE, + + MI_WHEEL_RIM, + MI_WHEEL_OFFROAD, + MI_WHEEL_TRUCK, + + MI_CAR_DOOR,// = 240, + MI_CAR_BUMPER, + MI_CAR_PANEL, + MI_CAR_BONNET, + MI_CAR_BOOT, + MI_CAR_WHEEL, + MI_BODYPARTA, + MI_BODYPARTB, + + MI_WHEEL_SPORT = 250, + MI_WHEEL_SALOON, + MI_WHEEL_LIGHTVAN, + MI_WHEEL_CLASSIC, + MI_WHEEL_ALLOY, + MI_WHEEL_LIGHTTRUCK, + MI_WHEEL_SMALLCAR, + + MI_AIRTRAIN_VLO, // = 257, + MI_MOBILE, + + MI_BRASS_KNUCKLES, // 259 + MI_SCREWDRIVER, + MI_GOLFCLUB, + MI_NIGHTSTICK, + MI_KNIFE, MI_BASEBALL_BAT, - MI_COLT, + MI_HAMMER, + MI_MEAT_CLEAVER, + MI_MACHETE, + MI_KATANA, + MI_CHAINSAW, + MI_GRENADE, + MI_TEARGAS, MI_MOLOTOV, - MI_ROCKETLAUNCHER, + MI_MISSILE, + MI_COLT45, + MI_PYTHON, + MI_RUGER, MI_SHOTGUN, - MI_SNIPER, + MI_SPAS12_SHOTGUN, + MI_STUBBY_SHOTGUN, + MI_M4, + MI_TEC9, MI_UZI, - MI_MISSILE, - MI_M16, + MI_SILENCEDINGRAM, + MI_MP5, + MI_SNIPERRIFLE, + MI_LASERSCOPE, + MI_ROCKETLAUNCHER, MI_FLAMETHROWER, + MI_M60, + MI_MINIGUN, MI_BOMB, + MI_CAMERA, MI_FINGERS, + MI_MINIGUN2, - MI_CUTOBJ01 = 185, + MI_CUTOBJ01,// = 295, MI_CUTOBJ02, MI_CUTOBJ03, MI_CUTOBJ04, MI_CUTOBJ05, - MI_CAR_DOOR = 190, - MI_CAR_BUMPER, - MI_CAR_PANEL, - MI_CAR_BONNET, - MI_CAR_BOOT, - MI_CAR_WHEEL, - MI_BODYPARTA, - MI_BODYPARTB, - - MI_AIRTRAIN_VLO = 198, - MI_LOPOLYGUY, - NUM_DEFAULT_MODELS + NUM_DEFAULT_MODELS,// = 300 }; enum{ - NUM_OF_SPECIAL_CHARS = 4, + NUM_OF_SPECIAL_CHARS = 21, NUM_OF_CUTSCENE_OBJECTS = 5 }; @@ -373,18 +480,21 @@ void TestModelIndices(void); inline bool IsGlass(int16 id) { - return id == MI_GLASS1 || - id == MI_GLASS2 || - id == MI_GLASS3 || - id == MI_GLASS4 || - id == MI_GLASS5 || - id == MI_GLASS6 || - id == MI_GLASS7 || - id == MI_GLASS8; + CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(id); + return mi->IsBuilding() && (mi->m_isCodeGlass || mi->m_isArtistGlass); +} + +inline bool +IsTrafficLight(int16 id) +{ + return id == MI_TRAFFICLIGHTS || + id == MI_TRAFFICLIGHTS_VERTICAL || + id == MI_TRAFFICLIGHTS_MIAMI || + id == MI_TRAFFICLIGHTS_TWOVERTICAL; } inline bool -IsStreetLight(int16 id) +IsLightWithoutShift(int16 id) { return id == MI_TRAFFICLIGHTS || id == MI_SINGLESTREETLIGHTS1 || @@ -394,86 +504,87 @@ IsStreetLight(int16 id) } inline bool -IsBodyPart(int16 id) +IsLightWithPreRenderEffects(int16 id) { - return id == MI_BODYPARTA || id == MI_BODYPARTB; + return IsTrafficLight(id) || + id == MI_SINGLESTREETLIGHTS1 || + id == MI_SINGLESTREETLIGHTS2 || + id == MI_SINGLESTREETLIGHTS3 || + id == MI_DOUBLESTREETLIGHTS; } -// This is bad and should perhaps not be used inline bool -IsBoatModel(int16 id) +IsLightThatNeedsRepositioning(int16 id) { - return id == MI_PREDATOR || - id == MI_REEFER || - id == MI_SPEEDER || - id == MI_GHOST; + return id == MI_SINGLESTREETLIGHTS1 || + id == MI_SINGLESTREETLIGHTS2 || + id == MI_SINGLESTREETLIGHTS3 || + id == MI_TRAFFICLIGHTS_MIAMI || + id == MI_TRAFFICLIGHTS_TWOVERTICAL || + id == MI_MLAMPPOST || + id == MI_STREETLAMP1 || + id == MI_STREETLAMP2; } inline bool -IsPedModel(int16 id) +IsLightObject(int16 id) { - return id >= MI_PLAYER && id <= MI_LAST_PED; + return id == MI_TRAFFICLIGHTS_MIAMI || + id == MI_MLAMPPOST || + id == MI_SINGLESTREETLIGHTS1 || + id == MI_SINGLESTREETLIGHTS2 || + id == MI_SINGLESTREETLIGHTS3 || + id == MI_DOUBLESTREETLIGHTS || + id == MI_TRAFFICLIGHTS_TWOVERTICAL; } inline bool -IsTreeModel(int16 id) +IsLampPost(int16 id) { - return id == MI_TREE1 || - id == MI_TREE2 || - id == MI_TREE3 || - id == MI_TREE4 || - id == MI_TREE5 || - id == MI_TREE6 || - id == MI_TREE7 || - id == MI_TREE8 || - id == MI_TREE9 || - id == MI_TREE10 || - id == MI_TREE11 || - id == MI_TREE12 || - id == MI_TREE13 || - id == MI_TREE14; + return id == MI_SINGLESTREETLIGHTS1 || + id == MI_SINGLESTREETLIGHTS2 || + id == MI_SINGLESTREETLIGHTS3 || + id == MI_BOLLARDLIGHT || + id == MI_MLAMPPOST || + id == MI_STREETLAMP1 || + id == MI_STREETLAMP2 || + id == MI_TELPOLE02 || + id == MI_TRAFFICLIGHTS_MIAMI || + id == MI_TRAFFICLIGHTS_TWOVERTICAL; } inline bool -IsBannerModel(int16 id) +IsBodyPart(int16 id) +{ + return id == MI_BODYPARTA || id == MI_BODYPARTB; +} + +inline bool +IsPedModel(int16 id) +{ + return id >= MI_PLAYER && id <= MI_LAST_PED; +} +inline bool +IsPalmTreeModel(int16 id) { - return id == MI_CHINABANNER1 || - id == MI_CHINABANNER2 || - id == MI_CHINABANNER3 || - id == MI_CHINABANNER4 || - id == MI_CHINABANNER5 || - id == MI_CHINABANNER6 || - id == MI_CHINABANNER7 || - id == MI_CHINABANNER8 || - id == MI_CHINABANNER9 || - id == MI_CHINABANNER10 || - id == MI_CHINABANNER11 || - id == MI_CHINABANNER12 || - id == MI_ITALYBANNER1 || - id == MI_CHINALANTERN; + return id == MI_VEG_PALM01 || + id == MI_VEG_PALM02 || + id == MI_VEG_PALM03 || + id == MI_VEG_PALM04 || + id == MI_VEG_PALM05 || + id == MI_VEG_PALM06 || + id == MI_VEG_PALM07 || + id == MI_VEG_PALM08; } + inline bool -IsPickupModel(int16 id) +IsTreeModel(int16 id) { - return id == MI_GRENADE || - id == MI_AK47 || - id == MI_BASEBALL_BAT || - id == MI_COLT || - id == MI_MOLOTOV || - id == MI_ROCKETLAUNCHER || - id == MI_SHOTGUN || - id == MI_SNIPER || - id == MI_UZI || - id == MI_M16 || - id == MI_FLAMETHROWER || - id == MI_PICKUP_ADRENALINE || - id == MI_PICKUP_BODYARMOUR || - id == MI_PICKUP_INFO || - id == MI_PICKUP_HEALTH || - id == MI_PICKUP_BONUS || - id == MI_PICKUP_BRIBE || - id == MI_PICKUP_KILLFRENZY || - id == MI_PICKUP_CAMERA; + return id == MI_TREE2 || + id == MI_TREE3 || + id == MI_TREE6 || + id == MI_TREE8 || + IsPalmTreeModel(id); } inline bool @@ -498,7 +609,8 @@ inline bool IsExplosiveThingModel(int16 id) { return id == MI_EXPLODINGBARREL || - id == MI_PETROLPUMP; + id == MI_PETROLPUMP || + id == MI_PETROLPUMP2; } inline bool @@ -506,4 +618,4 @@ IsFence(int16 id) { return id == MI_FENCE || id == MI_FENCE2; -}
\ No newline at end of file +} diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp index 7aa5fc8b..41515e20 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -4,18 +4,15 @@ #include "TempColModels.h" #include "ModelIndices.h" #include "ModelInfo.h" -#include "Frontend.h" CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE]; CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore; -CStore<CMloModelInfo, MLOMODELSIZE> CModelInfo::ms_mloModelStore; -CStore<CInstance, MLOINSTANCESIZE> CModelInfo::ms_mloInstanceStore; CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore; +CStore<CWeaponModelInfo, WEAPONMODELSIZE> CModelInfo::ms_weaponModelStore; CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore; CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore; CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore; -CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> CModelInfo::ms_xtraCompsModelStore; CStore<C2dEffect, TWODFXSIZE> CModelInfo::ms_2dEffectStore; void @@ -24,14 +21,20 @@ CModelInfo::Initialise(void) int i; CSimpleModelInfo *m; + debug("sizeof SimpleModelStore %d\n", sizeof(ms_simpleModelStore)); + debug("sizeof TimeModelStore %d\n", sizeof(ms_timeModelStore)); + debug("sizeof WeaponModelStore %d\n", sizeof(ms_weaponModelStore)); + debug("sizeof ClumpModelStore %d\n", sizeof(ms_clumpModelStore)); + debug("sizeof VehicleModelStore %d\n", sizeof(ms_vehicleModelStore)); + debug("sizeof PedModelStore %d\n", sizeof(ms_pedModelStore)); + debug("sizeof 2deffectsModelStore %d\n", sizeof(ms_2dEffectStore)); + for(i = 0; i < MODELINFOSIZE; i++) ms_modelInfoPtrs[i] = nil; ms_2dEffectStore.Clear(); - ms_mloInstanceStore.Clear(); - ms_xtraCompsModelStore.Clear(); ms_simpleModelStore.Clear(); ms_timeModelStore.Clear(); - ms_mloModelStore.Clear(); + ms_weaponModelStore.Clear(); ms_clumpModelStore.Clear(); ms_pedModelStore.Clear(); ms_vehicleModelStore.Clear(); @@ -91,29 +94,23 @@ CModelInfo::ShutDown(void) int i; for(i = 0; i < ms_simpleModelStore.allocPtr; i++) ms_simpleModelStore.store[i].Shutdown(); - for(i = 0; i < ms_mloInstanceStore.allocPtr; i++) - ms_mloInstanceStore.store[i].Shutdown(); for(i = 0; i < ms_timeModelStore.allocPtr; i++) ms_timeModelStore.store[i].Shutdown(); + for(i = 0; i < ms_weaponModelStore.allocPtr; i++) + ms_weaponModelStore.store[i].Shutdown(); for(i = 0; i < ms_clumpModelStore.allocPtr; i++) ms_clumpModelStore.store[i].Shutdown(); for(i = 0; i < ms_vehicleModelStore.allocPtr; i++) ms_vehicleModelStore.store[i].Shutdown(); for(i = 0; i < ms_pedModelStore.allocPtr; i++) ms_pedModelStore.store[i].Shutdown(); - for(i = 0; i < ms_xtraCompsModelStore.allocPtr; i++) - ms_xtraCompsModelStore.store[i].Shutdown(); - for(i = 0; i < ms_mloInstanceStore.allocPtr; i++) - ms_mloInstanceStore.store[i].Shutdown(); for(i = 0; i < ms_2dEffectStore.allocPtr; i++) ms_2dEffectStore.store[i].Shutdown(); ms_2dEffectStore.Clear(); ms_simpleModelStore.Clear(); - ms_mloInstanceStore.Clear(); - ms_mloModelStore.Clear(); - ms_xtraCompsModelStore.Clear(); ms_timeModelStore.Clear(); + ms_weaponModelStore.Clear(); ms_pedModelStore.Clear(); ms_clumpModelStore.Clear(); ms_vehicleModelStore.Clear(); @@ -129,23 +126,21 @@ CModelInfo::AddSimpleModel(int id) return modelinfo; } -CMloModelInfo * -CModelInfo::AddMloModel(int id) +CTimeModelInfo* +CModelInfo::AddTimeModel(int id) { - CMloModelInfo *modelinfo; - modelinfo = CModelInfo::ms_mloModelStore.Alloc(); + CTimeModelInfo *modelinfo; + modelinfo = CModelInfo::ms_timeModelStore.Alloc(); CModelInfo::ms_modelInfoPtrs[id] = modelinfo; - modelinfo->m_clump = nil; - modelinfo->firstInstance = 0; - modelinfo->lastInstance = 0; + modelinfo->Init(); return modelinfo; } -CTimeModelInfo* -CModelInfo::AddTimeModel(int id) +CWeaponModelInfo* +CModelInfo::AddWeaponModel(int id) { - CTimeModelInfo *modelinfo; - modelinfo = CModelInfo::ms_timeModelStore.Alloc(); + CWeaponModelInfo *modelinfo; + modelinfo = CModelInfo::ms_weaponModelStore.Alloc(); CModelInfo::ms_modelInfoPtrs[id] = modelinfo; modelinfo->Init(); return modelinfo; @@ -201,6 +196,21 @@ CModelInfo::GetModelInfo(const char *name, int *id) return nil; } +CBaseModelInfo* +CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex) +{ + if (minIndex > maxIndex) + return 0; + + CBaseModelInfo *modelinfo; + for(int i = minIndex; i <= maxIndex; i++){ + modelinfo = CModelInfo::ms_modelInfoPtrs[i]; + if(modelinfo && !CGeneral::faststricmp(modelinfo->GetModelName(), name)) + return modelinfo; + } + return nil; +} + bool CModelInfo::IsBoatModel(int32 id) { @@ -215,31 +225,25 @@ CModelInfo::IsBikeModel(int32 id) ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE; } -void -CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level) -{ - ISLAND_LOADING_IS(LOW) - { - int i; - CBaseModelInfo *mi; - CColModel *colmodel; - - for (i = 0; i < MODELINFOSIZE; i++) { - mi = GetModelInfo(i); - if (mi) { - colmodel = mi->GetColModel(); - if (colmodel && colmodel->level != LEVEL_GENERIC && colmodel->level != level) - colmodel->RemoveCollisionVolumes(); - } - } - } +bool +CModelInfo::IsCarModel(int32 id) +{ + return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE && + ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_CAR; } -void -CModelInfo::ConstructMloClumps() +bool +CModelInfo::IsHeliModel(int32 id) +{ + return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE && + ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_HELI; +} + +bool +CModelInfo::IsPlaneModel(int32 id) { - for (int i = 0; i < ms_mloModelStore.allocPtr; i++) - ms_mloModelStore.store[i].ConstructClump(); + return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE && + ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_PLANE; } void diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h index 4d24e78f..a0ee0015 100644 --- a/src/modelinfo/ModelInfo.h +++ b/src/modelinfo/ModelInfo.h @@ -1,55 +1,52 @@ #pragma once #include "2dEffect.h" -#include "BaseModelInfo.h" #include "SimpleModelInfo.h" #include "MloModelInfo.h" #include "TimeModelInfo.h" +#include "WeaponModelInfo.h" #include "ClumpModelInfo.h" #include "PedModelInfo.h" #include "VehicleModelInfo.h" -#include "XtraCompsModelInfo.h" -#include "Instance.h" -#include "Game.h" +#include "templates.h" class CModelInfo { static CBaseModelInfo *ms_modelInfoPtrs[MODELINFOSIZE]; static CStore<CSimpleModelInfo, SIMPLEMODELSIZE> ms_simpleModelStore; - static CStore<CMloModelInfo, MLOMODELSIZE> ms_mloModelStore; - static CStore<CInstance, MLOINSTANCESIZE> ms_mloInstanceStore; static CStore<CTimeModelInfo, TIMEMODELSIZE> ms_timeModelStore; + static CStore<CWeaponModelInfo, WEAPONMODELSIZE> ms_weaponModelStore; static CStore<CClumpModelInfo, CLUMPMODELSIZE> ms_clumpModelStore; static CStore<CPedModelInfo, PEDMODELSIZE> ms_pedModelStore; static CStore<CVehicleModelInfo, VEHICLEMODELSIZE> ms_vehicleModelStore; static CStore<C2dEffect, TWODFXSIZE> ms_2dEffectStore; - static CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> ms_xtraCompsModelStore; public: static void Initialise(void); static void ShutDown(void); static CSimpleModelInfo *AddSimpleModel(int id); - static CMloModelInfo *AddMloModel(int id); static CTimeModelInfo *AddTimeModel(int id); + static CWeaponModelInfo *AddWeaponModel(int id); static CClumpModelInfo *AddClumpModel(int id); static CPedModelInfo *AddPedModel(int id); static CVehicleModelInfo *AddVehicleModel(int id); static CStore<C2dEffect, TWODFXSIZE> &Get2dEffectStore(void) { return ms_2dEffectStore; } - static CStore<CInstance, MLOINSTANCESIZE> &GetMloInstanceStore(void) { return ms_mloInstanceStore; } static CBaseModelInfo *GetModelInfo(const char *name, int *id); static CBaseModelInfo *GetModelInfo(int id){ return ms_modelInfoPtrs[id]; } + static CBaseModelInfo *GetModelInfo(const char *name, int minIndex, int maxIndex); static CColModel *GetColModel(int id){ return ms_modelInfoPtrs[id]->GetColModel(); } static bool IsBoatModel(int32 id); static bool IsBikeModel(int32 id); - static void RemoveColModelsFromOtherLevels(eLevelName level); - static void ConstructMloClumps(); + static bool IsCarModel(int32 id); + static bool IsHeliModel(int32 id); + static bool IsPlaneModel(int32 id); static void ReInit2dEffects(); }; diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp index 2cce48f4..25b260d3 100644 --- a/src/modelinfo/PedModelInfo.cpp +++ b/src/modelinfo/PedModelInfo.cpp @@ -13,33 +13,13 @@ void CPedModelInfo::DeleteRwObject(void) { + CClumpModelInfo::DeleteRwObject(); if(m_hitColModel) delete m_hitColModel; m_hitColModel = nil; -#ifdef PED_SKIN - RwFrame *frame; - if(m_head){ - frame = RpAtomicGetFrame(m_head); - RpAtomicDestroy(m_head); - RwFrameDestroy(frame); - m_head = nil; - } - if(m_lhand){ - frame = RpAtomicGetFrame(m_lhand); - RpAtomicDestroy(m_lhand); - RwFrameDestroy(frame); - m_lhand = nil; - } - if(m_rhand){ - frame = RpAtomicGetFrame(m_rhand); - RpAtomicDestroy(m_rhand); - RwFrameDestroy(frame); - m_rhand = nil; - } -#endif - CClumpModelInfo::DeleteRwObject(); // PC calls this first } +// leftover... RwObjectNameIdAssocation CPedModelInfo::m_pPedIds[PED_NODE_MAX] = { { "Smid", PED_MID, 0, }, // that is strange... { "Shead", PED_HEAD, 0, }, @@ -55,133 +35,19 @@ RwObjectNameIdAssocation CPedModelInfo::m_pPedIds[PED_NODE_MAX] = { { nil, 0, 0, }, }; -#ifdef PED_SKIN -struct LimbCBarg -{ - CPedModelInfo *mi; - RpClump *clump; - int32 frameIDs[3]; -}; - -RpAtomic* -CPedModelInfo::findLimbsCb(RpAtomic *atomic, void *data) -{ - LimbCBarg *limbs = (LimbCBarg*)data; - RwFrame *frame = RpAtomicGetFrame(atomic); - const char *name = GetFrameNodeName(frame); - if(CGeneral::faststricmp(name, "Shead01") == 0){ - limbs->frameIDs[0] = RpHAnimFrameGetID(frame); - limbs->mi->m_head = atomic; - RpClumpRemoveAtomic(limbs->clump, atomic); - RwFrameRemoveChild(frame); - }else if(CGeneral::faststricmp(name, "SLhand01") == 0){ - limbs->frameIDs[1] = RpHAnimFrameGetID(frame); - limbs->mi->m_lhand = atomic; - RpClumpRemoveAtomic(limbs->clump, atomic); - RwFrameRemoveChild(frame); - }else if(CGeneral::faststricmp(name, "SRhand01") == 0){ - limbs->frameIDs[2] = RpHAnimFrameGetID(frame); - limbs->mi->m_rhand = atomic; - RpClumpRemoveAtomic(limbs->clump, atomic); - RwFrameRemoveChild(frame); - } - return atomic; -} -#endif - void CPedModelInfo::SetClump(RpClump *clump) { #ifdef EXTENDED_PIPELINES CustomPipes::AttachRimPipe(clump); #endif -#ifdef PED_SKIN - // CB has to be set here before atomics are detached from clump - if(strcmp(GetModelName(), "player") == 0) - RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); - if(IsClumpSkinned(clump)){ - LimbCBarg limbs = { this, clump, { 0, 0, 0 } }; - RpClumpForAllAtomics(clump, findLimbsCb, &limbs); - } CClumpModelInfo::SetClump(clump); - SetFrameIds(m_pPedIds); - if(m_hitColModel == nil && !IsClumpSkinned(clump)) - CreateHitColModel(); - // And again because CClumpModelInfo resets it - if(strcmp(GetModelName(), "player") == 0) - RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); - else if(IsClumpSkinned(clump)) - // skinned peds have no low detail version, so they don't have the right render Cb - RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPedCB); -#else - CClumpModelInfo::SetClump(clump); - SetFrameIds(m_pPedIds); + SetFrameIds(m_pPedIds); // not needed in VC actually if(m_hitColModel == nil) - CreateHitColModel(); + CreateHitColModelSkinned(clump); + RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPedCB); if(strcmp(GetModelName(), "player") == 0) RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); -#endif -} - -RpAtomic* -CountAtomicsCB(RpAtomic *atomic, void *data) -{ - (*(int32*)data)++; - return atomic; -} - -RpAtomic* -GetAtomicListCB(RpAtomic *atomic, void *data) -{ - **(RpAtomic***)data = atomic; - (*(RpAtomic***)data)++; - return atomic; -} - -RwFrame* -FindPedFrameFromNameCB(RwFrame *frame, void *data) -{ - RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data; - - if(CGeneral::faststricmp(GetFrameNodeName(frame)+1, assoc->name+1)){ - RwFrameForAllChildren(frame, FindPedFrameFromNameCB, assoc); - return assoc->frame ? nil : frame; - }else{ - assoc->frame = frame; - return nil; - } -} - -void -CPedModelInfo::SetLowDetailClump(RpClump *lodclump) -{ - RpAtomic *atomics[16]; - RpAtomic **pAtm; - int32 numAtm, numLodAtm; - int i; - RwObjectNameAssociation assoc; - - numAtm = 0; - numLodAtm = 0; - RpClumpForAllAtomics(m_clump, CountAtomicsCB, &numAtm); // actually unused - RpClumpForAllAtomics(lodclump, CountAtomicsCB, &numLodAtm); - - RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPedHiDetailCB); - RpClumpForAllAtomics(lodclump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPedLowDetailCB); - - pAtm = atomics; - RpClumpForAllAtomics(lodclump, GetAtomicListCB, &pAtm); - - for(i = 0; i < numLodAtm; i++){ - assoc.name = GetFrameNodeName(RpAtomicGetFrame(atomics[i])); - assoc.frame = nil; - RwFrameForAllChildren(RpClumpGetFrame(m_clump), FindPedFrameFromNameCB, &assoc); - if(assoc.frame){ - RpAtomicSetFrame(atomics[i], assoc.frame); - RpClumpRemoveAtomic(lodclump, atomics[i]); - RpClumpAddAtomic(m_clump, atomics[i]); - } - } } struct ColNodeInfo @@ -193,117 +59,20 @@ struct ColNodeInfo float radius; }; -#define NUMPEDINFONODES 8 +#define NUMPEDINFONODES 10 ColNodeInfo m_pColNodeInfos[NUMPEDINFONODES] = { - { nil, PED_HEAD, PEDPIECE_HEAD, 0.0f, 0.05f, 0.2f }, - { "Storso", 0, PEDPIECE_TORSO, 0.0f, 0.15f, 0.2f }, - { "Storso", 0, PEDPIECE_TORSO, 0.0f, -0.05f, 0.3f }, - { nil, PED_MID, PEDPIECE_MID, 0.0f, -0.07f, 0.3f }, - { nil, PED_UPPERARML, PEDPIECE_LEFTARM, 0.07f, -0.1f, 0.2f }, - { nil, PED_UPPERARMR, PEDPIECE_RIGHTARM, -0.07f, -0.1f, 0.2f }, - { "Slowerlegl", 0, PEDPIECE_LEFTLEG, 0.0f, 0.07f, 0.25f }, - { nil, PED_LOWERLEGR, PEDPIECE_RIGHTLEG, 0.0f, 0.07f, 0.25f }, + { nil, PED_HEAD, PEDPIECE_HEAD, 0.0f, 0.05f, 0.15f }, + { nil, PED_MID, PEDPIECE_TORSO, 0.0f, 0.15f, 0.2f }, + { nil, PED_MID, PEDPIECE_TORSO, 0.0f, -0.05f, 0.25f }, + { nil, PED_MID, PEDPIECE_MID, 0.0f, -0.25f, 0.25f }, + { nil, PED_UPPERARML, PEDPIECE_LEFTARM, 0.03f, -0.05f, 0.16f }, + { nil, PED_UPPERARMR, PEDPIECE_RIGHTARM, -0.03f, -0.05f, 0.16f }, + { nil, PED_LOWERLEGL, PEDPIECE_LEFTLEG, 0.0f, 0.15f, 0.2f }, + { nil, PED_LOWERLEGR, PEDPIECE_RIGHTLEG, 0.0f, 0.15f, 0.2f }, + { nil, PED_FOOTL, PEDPIECE_LEFTLEG, 0.0f, 0.15f, 0.15f }, + { nil, PED_FOOTR, PEDPIECE_RIGHTLEG, 0.0f, 0.15f, 0.15f }, }; -RwObject* -FindHeadRadiusCB(RwObject *object, void *data) -{ - RpAtomic *atomic = (RpAtomic*)object; - *(float*)data = RpAtomicGetBoundingSphere(atomic)->radius; - return nil; -} - -void -CPedModelInfo::CreateHitColModel(void) -{ - RwObjectNameAssociation nameAssoc; - RwObjectIdAssociation idAssoc; - RwFrame *nodeFrame; - CColModel *colmodel = new CColModel; - CColSphere *spheres = (CColSphere*)RwMalloc(NUMPEDINFONODES*sizeof(CColSphere)); - RwFrame *root = RpClumpGetFrame(m_clump); - RwMatrix *mat = RwMatrixCreate(); - for(int i = 0; i < NUMPEDINFONODES; i++){ - nodeFrame = nil; - if(m_pColNodeInfos[i].name){ - nameAssoc.name = m_pColNodeInfos[i].name; - nameAssoc.frame = nil; - RwFrameForAllChildren(root, FindFrameFromNameCB, &nameAssoc); - nodeFrame = nameAssoc.frame; - }else{ - idAssoc.id = m_pColNodeInfos[i].pedNode; - idAssoc.frame = nil; - RwFrameForAllChildren(root, FindFrameFromIdCB, &idAssoc); - nodeFrame = idAssoc.frame; - } - if(nodeFrame){ - float radius = m_pColNodeInfos[i].radius; - if(m_pColNodeInfos[i].pieceType == PEDPIECE_HEAD) - RwFrameForAllObjects(nodeFrame, FindHeadRadiusCB, &radius); - RwMatrixTransform(mat, RwFrameGetMatrix(nodeFrame), rwCOMBINEREPLACE); - const char *name = GetFrameNodeName(nodeFrame); - for(nodeFrame = RwFrameGetParent(nodeFrame); - nodeFrame; - nodeFrame = RwFrameGetParent(nodeFrame)){ - name = GetFrameNodeName(nodeFrame); - RwMatrixTransform(mat, RwFrameGetMatrix(nodeFrame), rwCOMBINEPOSTCONCAT); - if(RwFrameGetParent(nodeFrame) == root) - break; - } - spheres[i].center = mat->pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); - spheres[i].radius = radius; - spheres[i].surface = SURFACE_PED; - spheres[i].piece = m_pColNodeInfos[i].pieceType; - } - } - RwMatrixDestroy(mat); - colmodel->spheres = spheres; - colmodel->numSpheres = NUMPEDINFONODES; - colmodel->boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0); - colmodel->boundingBox.Set(CVector(-0.5f, -0.5f, -1.2f), CVector(0.5f, 0.5f, 1.2f), SURFACE_DEFAULT, 0); - colmodel->level = LEVEL_GENERIC; - m_hitColModel = colmodel; -} - -CColModel* -CPedModelInfo::AnimatePedColModel(CColModel* colmodel, RwFrame* frame) -{ - RwObjectNameAssociation nameAssoc; - RwObjectIdAssociation idAssoc; - RwMatrix* mat = RwMatrixCreate(); - CColSphere* spheres = colmodel->spheres; - - for (int i = 0; i < NUMPEDINFONODES; i++) { - RwFrame* f = nil; - if (m_pColNodeInfos[i].name) { - nameAssoc.name = m_pColNodeInfos[i].name; - nameAssoc.frame = nil; - RwFrameForAllChildren(frame, FindFrameFromNameCB, &nameAssoc); - f = nameAssoc.frame; - } - else { - idAssoc.id = m_pColNodeInfos[i].pedNode; - idAssoc.frame = nil; - RwFrameForAllChildren(frame, FindFrameFromIdCB, &idAssoc); - f = idAssoc.frame; - } - if (f) { - RwMatrixCopy(mat, RwFrameGetMatrix(f)); - - for (f = RwFrameGetParent(f); f; f = RwFrameGetParent(f)) { - RwMatrixTransform(mat, RwFrameGetMatrix(f), rwCOMBINEPOSTCONCAT); - if (RwFrameGetParent(f) == frame) - break; - } - - spheres[i].center = mat->pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); - } - } - - return colmodel; -} - -#ifdef PED_SKIN void CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) { @@ -317,6 +86,7 @@ CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) for(int i = 0; i < NUMPEDINFONODES; i++){ *mat = *invmat; + // From LCS. Otherwise gives FPE #ifdef FIX_BUGS spheres[i].center = CVector(0.0f, 0.0f, 0.0f); @@ -339,8 +109,8 @@ CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) RwMatrixDestroy(mat); colmodel->spheres = spheres; colmodel->numSpheres = NUMPEDINFONODES; - colmodel->boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0); - colmodel->boundingBox.Set(CVector(-0.5f, -0.5f, -1.2f), CVector(0.5f, 0.5f, 1.2f), SURFACE_DEFAULT, 0); + colmodel->boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f)); + colmodel->boundingBox.Set(CVector(-0.5f, -0.5f, -1.2f), CVector(0.5f, 0.5f, 1.2f)); colmodel->level = LEVEL_GENERIC; m_hitColModel = colmodel; } @@ -375,4 +145,24 @@ CPedModelInfo::AnimatePedColModelSkinned(RpClump *clump) return m_hitColModel; } -#endif +CColModel* +CPedModelInfo::AnimatePedColModelSkinnedWorld(RpClump *clump) +{ + if(m_hitColModel == nil) + CreateHitColModelSkinned(clump); + CColSphere *spheres = m_hitColModel->spheres; + RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump); + RwMatrix *mat; + + for(int i = 0; i < NUMPEDINFONODES; i++){ + int id = ConvertPedNode2BoneTag(m_pColNodeInfos[i].pedNode); + int idx = RpHAnimIDGetIndex(hier, id); + + mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; + RwV3d pos = { 0.0f, 0.0f, 0.0f }; + RwV3dTransformPoints(&pos, &pos, 1, mat); + + spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); + } + return m_hitColModel; +} diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h index 26ab3c3f..79bd7eaa 100644 --- a/src/modelinfo/PedModelInfo.h +++ b/src/modelinfo/PedModelInfo.h @@ -5,8 +5,8 @@ #include "PedType.h" enum PedNode { - PED_TORSO, - PED_MID, // Smid on PS2/PC, Storso on mobile/xbox + PED_TORSO = 0, // has no bone! + PED_MID, PED_HEAD, PED_UPPERARML, PED_UPPERARMR, @@ -17,7 +17,15 @@ enum PedNode { PED_FOOTL, PED_FOOTR, PED_LOWERLEGR, - PED_NODE_MAX// Not valid: PED_LOWERLEGL + PED_LOWERLEGL, + + PED_FOREARML, + PED_FOREARMR, + PED_CLAVICLEL, + PED_CLAVICLER, + PED_NECK, + + PED_NODE_MAX }; class CPedModelInfo : public CClumpModelInfo @@ -28,40 +36,17 @@ public: ePedStats m_pedStatType; uint32 m_carsCanDrive; CColModel *m_hitColModel; -#ifdef PED_SKIN - RpAtomic *m_head; - RpAtomic *m_lhand; - RpAtomic *m_rhand; -#endif + int8 radio1, radio2; static RwObjectNameIdAssocation m_pPedIds[PED_NODE_MAX]; - CPedModelInfo(void) : CClumpModelInfo(MITYPE_PED) { - m_hitColModel = nil; -#ifdef PED_SKIN - m_head = nil; - m_lhand = nil; - m_rhand = nil; -#endif - } + CPedModelInfo(void) : CClumpModelInfo(MITYPE_PED) { m_hitColModel = nil; } ~CPedModelInfo(void) { delete m_hitColModel; } void DeleteRwObject(void); void SetClump(RpClump *); - void SetLowDetailClump(RpClump*); - void CreateHitColModel(void); void CreateHitColModelSkinned(RpClump *clump); CColModel *GetHitColModel(void) { return m_hitColModel; } - static CColModel *AnimatePedColModel(CColModel* colmodel, RwFrame* frame); CColModel *AnimatePedColModelSkinned(RpClump *clump); - -#ifdef PED_SKIN - static RpAtomic *findLimbsCb(RpAtomic *atomic, void *data); - RpAtomic *getHead(void) { return m_head; } - RpAtomic *getLeftHand(void) { return m_lhand; } - RpAtomic *getRightHand(void) { return m_rhand; } -#endif + CColModel *AnimatePedColModelSkinnedWorld(RpClump *clump); }; -#ifndef PED_SKIN -VALIDATE_SIZE(CPedModelInfo, 0x48); -#endif
\ No newline at end of file diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp index 9fc0dd6e..18eb7e5f 100644 --- a/src/modelinfo/SimpleModelInfo.cpp +++ b/src/modelinfo/SimpleModelInfo.cpp @@ -4,6 +4,7 @@ #include "Camera.h" #include "Renderer.h" #include "ModelInfo.h" +#include "AnimManager.h" #include "custompipes.h" void @@ -18,6 +19,8 @@ CSimpleModelInfo::DeleteRwObject(void) RwFrameDestroy(f); m_atomics[i] = nil; RemoveTexDictionaryRef(); + if(GetAnimFileIndex() != -1) + CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex()); } } @@ -55,7 +58,7 @@ CSimpleModelInfo::Init(void) m_atomics[2] = nil; m_numAtomics = 0; m_firstDamaged = 0; - m_normalCull = 0; + m_wetRoadReflection = 0; m_isDamaged = 0; m_isBigBuilding = 0; m_noFade = 0; @@ -64,6 +67,10 @@ CSimpleModelInfo::Init(void) m_isSubway = 0; m_ignoreLight = 0; m_noZwrite = 0; + m_noShadows = 0; + m_ignoreDrawDist = 0; + m_isCodeGlass = 0; + m_isArtistGlass = 0; } void @@ -71,13 +78,20 @@ CSimpleModelInfo::SetAtomic(int n, RpAtomic *atomic) { AddTexDictionaryRef(); m_atomics[n] = atomic; - if(m_ignoreLight){ - RpGeometry *geo = RpAtomicGetGeometry(atomic); + if(GetAnimFileIndex() != -1) + CAnimManager::AddAnimBlockRef(GetAnimFileIndex()); + RpGeometry *geo = RpAtomicGetGeometry(atomic); + if(m_ignoreLight) RpGeometrySetFlags(geo, RpGeometryGetFlags(geo) & ~rpGEOMETRYLIGHT); - } + if(RpGeometryGetFlags(geo) & rpGEOMETRYNORMALS && + RpGeometryGetNumTriangles(geo) > 200) + debug("%s has %d polys\n", m_name, RpGeometryGetNumTriangles(geo)); #ifdef EXTENDED_PIPELINES - CustomPipes::AttachWorldPipe(atomic); + if(m_wetRoadReflection) + CustomPipes::AttachGlossPipe(atomic); + else + CustomPipes::AttachWorldPipe(atomic); #endif } @@ -134,12 +148,20 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist) return nil; } +RpAtomic* +CSimpleModelInfo::GetFirstAtomicFromDistance(float dist) +{ + if(dist < m_lodDistances[0] * TheCamera.LODDistMultiplier) + return m_atomics[0]; + return nil; +} + void -CSimpleModelInfo::FindRelatedModel(void) +CSimpleModelInfo::FindRelatedModel(int32 minID, int32 maxID) { int i; CBaseModelInfo *mi; - for(i = 0; i < MODELINFOSIZE; i++){ + for(i = minID; i <= maxID; i++){ mi = CModelInfo::GetModelInfo(i); if(mi && mi != this && !CGeneral::faststrcmp(GetModelName()+3, mi->GetModelName()+3)){ @@ -150,24 +172,23 @@ CSimpleModelInfo::FindRelatedModel(void) } } +#define NEAR_DRAW_DIST 0.0f // 100.0f in liberty city + void -CSimpleModelInfo::SetupBigBuilding(void) +CSimpleModelInfo::SetupBigBuilding(int32 minID, int32 maxID) { CSimpleModelInfo *related; if(m_lodDistances[0] > LOD_DISTANCE && GetRelatedModel() == nil){ m_isBigBuilding = 1; - FindRelatedModel(); + FindRelatedModel(minID, maxID); related = GetRelatedModel(); - if(related) + if(related){ m_lodDistances[2] = related->GetLargestLodDistance()/TheCamera.LODDistMultiplier; - else -#ifdef FIX_BUGS - if(toupper(m_name[0]) == 'L' && toupper(m_name[1]) == 'O' && toupper(m_name[2]) == 'D') - m_lodDistances[2] = 100.0f; - else - m_lodDistances[2] = 0.0f; -#else - m_lodDistances[2] = 100.0f; -#endif + if(m_drawLast){ + m_drawLast = false; + debug("%s was draw last\n", GetModelName()); + } + }else + m_lodDistances[2] = NEAR_DRAW_DIST; } } diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h index 94e55a2f..986cb886 100644 --- a/src/modelinfo/SimpleModelInfo.h +++ b/src/modelinfo/SimpleModelInfo.h @@ -11,30 +11,25 @@ public: float m_lodDistances[3]; uint8 m_numAtomics; uint8 m_alpha; - /* // For reference, PS2 has: - uint8 m_firstDamaged; - uint8 m_normalCull : 1; - uint8 m_isDamaged : 1; - uint8 m_isBigBuilding : 1; - uint8 m_noFade : 1; - uint8 m_drawLast : 1; - uint8 m_additive : 1; - uint8 m_isSubway : 1; - uint8 m_ignoreLight : 1; - // m_noZwrite is missing because not needed - */ uint16 m_firstDamaged : 2; // 0: no damage model // 1: 1 and 2 are damage models // 2: 2 is damage model - uint16 m_normalCull : 1; + uint16 m_wetRoadReflection : 1; uint16 m_isDamaged : 1; + uint16 m_isBigBuilding : 1; uint16 m_noFade : 1; uint16 m_drawLast : 1; uint16 m_additive : 1; + uint16 m_isSubway : 1; uint16 m_ignoreLight : 1; uint16 m_noZwrite : 1; + uint16 m_noShadows : 1; + + uint16 m_ignoreDrawDist : 1; + uint16 m_isCodeGlass : 1; + uint16 m_isArtistGlass : 1; CSimpleModelInfo(void) : CBaseModelInfo(MITYPE_SIMPLE) {} CSimpleModelInfo(ModelInfoType id) : CBaseModelInfo(id) {} @@ -44,16 +39,18 @@ public: RwObject *CreateInstance(RwMatrix *); RwObject *GetRwObject(void) { return (RwObject*)m_atomics[0]; } + virtual void SetAtomic(int n, RpAtomic *atomic); + void Init(void); void IncreaseAlpha(void); - void SetAtomic(int n, RpAtomic *atomic); void SetLodDistances(float *dist); float GetLodDistance(int i); float GetNearDistance(void); float GetLargestLodDistance(void); RpAtomic *GetAtomicFromDistance(float dist); - void FindRelatedModel(void); - void SetupBigBuilding(void); + RpAtomic *GetFirstAtomicFromDistance(float dist); + void FindRelatedModel(int32 minID, int32 maxID); + void SetupBigBuilding(int32 minID, int32 maxID); void SetNumAtomics(int n) { m_numAtomics = n; } CSimpleModelInfo *GetRelatedModel(void){ @@ -61,5 +58,4 @@ public: void SetRelatedModel(CSimpleModelInfo *m){ m_atomics[2] = (RpAtomic*)m; } }; - -VALIDATE_SIZE(CSimpleModelInfo, 0x4C); +//static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: error"); diff --git a/src/modelinfo/TimeModelInfo.h b/src/modelinfo/TimeModelInfo.h index 73b6ab26..6e3c64fb 100644 --- a/src/modelinfo/TimeModelInfo.h +++ b/src/modelinfo/TimeModelInfo.h @@ -17,5 +17,4 @@ public: void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; } CTimeModelInfo *FindOtherTimeModel(void); }; - -VALIDATE_SIZE(CTimeModelInfo, 0x58); +//static_assert(sizeof(CTimeModelInfo) == 0x58, "CTimeModelInfo: error"); diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index 685b6ef6..d31962ce 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -23,7 +23,6 @@ int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 }; int8 CVehicleModelInfo::ms_compsUsed[2]; -RwTexture *CVehicleModelInfo::ms_pEnvironmentMaps[NUM_VEHICLE_ENVMAPS]; RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256]; RwTexture *CVehicleModelInfo::ms_colourTextureTable[256]; @@ -83,9 +82,23 @@ RwObjectNameIdAssocation carIds[] = { }; RwObjectNameIdAssocation boatIds[] = { - { "boat_moving_hi", BOAT_MOVING, VEHICLE_FLAG_COLLAPSE }, - { "boat_rudder_hi", BOAT_RUDDER, VEHICLE_FLAG_COLLAPSE }, - { "windscreen", BOAT_WINDSCREEN, VEHICLE_FLAG_WINDSCREEN | VEHICLE_FLAG_COLLAPSE }, + { "boat_moving_hi", BOAT_MOVING, 0 }, + { "boat_rudder_hi", BOAT_RUDDER, 0 }, + { "boat_flap_left", BOAT_FLAP_LEFT, 0 }, + { "boat_flap_right", BOAT_FLAP_RIGHT, 0 }, + { "boat_rearflap_left", BOAT_REARFLAP_LEFT, 0 }, + { "boat_rearflap_right", BOAT_REARFLAP_RIGHT, 0 }, +#ifdef FIX_BUGS + // let's just accept both + { "windscreen", BOAT_WINDSCREEN, VEHICLE_FLAG_WINDSCREEN | VEHICLE_FLAG_DRAWLAST }, + { "windscreen_hi_ok", BOAT_WINDSCREEN, VEHICLE_FLAG_WINDSCREEN | VEHICLE_FLAG_DRAWLAST }, +#else +#ifdef GTA_PS2 + { "windscreen", BOAT_WINDSCREEN, VEHICLE_FLAG_WINDSCREEN | VEHICLE_FLAG_DRAWLAST }, +#else + { "windscreen_hi_ok", BOAT_WINDSCREEN, VEHICLE_FLAG_WINDSCREEN | VEHICLE_FLAG_DRAWLAST }, +#endif +#endif { "ped_frontseat", BOAT_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { nil, 0, 0 } }; @@ -128,7 +141,9 @@ RwObjectNameIdAssocation bikeIds[] = { { "wheel_front", BIKE_WHEEL_FRONT, 0 }, { "wheel_rear", BIKE_WHEEL_REAR, 0 }, { "mudguard", BIKE_MUDGUARD, 0 }, + { "handlebars", BIKE_HANDLEBARS, 0 }, { "ped_frontseat", CAR_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "ped_backseat", CAR_POS_BACKSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "headlights", CAR_POS_HEADLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "taillights", CAR_POS_TAILLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "exhaust", CAR_POS_EXHAUST, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, @@ -150,6 +165,8 @@ RwObjectNameIdAssocation *CVehicleModelInfo::ms_vehicleDescs[] = { bikeIds }; +bool gbBlackCars; +bool gbPinkCars; CVehicleModelInfo::CVehicleModelInfo(void) : CClumpModelInfo(MITYPE_VEHICLE) @@ -161,6 +178,7 @@ CVehicleModelInfo::CVehicleModelInfo(void) m_positions[i].z = 0.0f; } m_numColours = 0; + m_animFileIndex = -1; } void @@ -191,7 +209,7 @@ CVehicleModelInfo::CreateInstance(void) clumpframe = RpClumpGetFrame(clump); comp1 = ChooseComponent(); - if(comp1 != -1){ + if(comp1 != -1 && m_comps[comp1]){ atomic = RpAtomicClone(m_comps[comp1]); f = RwFrameCreate(); RwFrameTransform(f, @@ -204,7 +222,7 @@ CVehicleModelInfo::CreateInstance(void) ms_compsUsed[0] = comp1; comp2 = ChooseSecondComponent(); - if(comp2 != -1){ + if(comp2 != -1 && m_comps[comp2]){ atomic = RpAtomicClone(m_comps[comp2]); f = RwFrameCreate(); RwFrameTransform(f, @@ -230,10 +248,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) { @@ -301,7 +339,7 @@ CVehicleModelInfo::SetAtomicRendererCB(RpAtomic *atomic, void *data) }else if(strstr(name, "_lo")){ RpClumpRemoveAtomic(clump, atomic); RpAtomicDestroy(atomic); - return atomic; // BUG: not done by gta + return atomic; // BUG: nil in gta }else if(strstr(name, "_vlo")) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB); else @@ -364,21 +402,31 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(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(strcmp(name, "boat_hi") == 0 || !CGeneral::faststrncmp(name, "extra", 5)) CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB_Boat); - else if(strstr(name, "_hi")) - CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB); - else if(strstr(name, "_lo")){ + else if(strstr(name, "_hi")){ + if(alpha) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat); + 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_BigVehicle); - else - CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil); + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLoDetailCB_Boat); + else{ + if(alpha) + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat); + else + CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil); + } HideDamagedAtomicCB(atomic, nil); return atomic; } @@ -386,30 +434,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") || !CGeneral::faststrncmp(name, "extra", 5)) { + 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: nil in 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((tVehicleType)m_handlingId)->Flags & HANDLING_IS_HELI) + RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_RealHeli, m_clump); + else RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, m_clump); - break; - } } RwObject* @@ -606,6 +692,17 @@ 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: +#ifdef FIX_BUGS + return CGeneral::GetRandomNumberInRange(0, 6); +#else + return CGeneral::GetRandomNumberInRange(0, 5); +#endif } return -1; } @@ -732,6 +829,9 @@ CVehicleModelInfo::GetEditableMaterialListCB(RpAtomic *atomic, void *data) return atomic; } +static int maxFirstMaterials; +static int maxSecondMaterials; + void CVehicleModelInfo::FindEditableMaterialList(void) { @@ -746,6 +846,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; } @@ -754,35 +856,26 @@ void CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2) { RwRGBA col, *colp; - RwTexture *coltex; RpMaterial **matp; if(c1 != m_currentColour1){ col = ms_vehicleColourTable[c1]; - coltex = ms_colourTextureTable[c1]; for(matp = m_materials1; *matp; matp++){ - if(RpMaterialGetTexture(*matp) && RwTextureGetName(RpMaterialGetTexture(*matp))[0] != '@'){ - colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const - colp->red = col.red; - colp->green = col.green; - colp->blue = col.blue; - }else - RpMaterialSetTexture(*matp, coltex); + colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const + colp->red = col.red; + colp->green = col.green; + colp->blue = col.blue; } m_currentColour1 = c1; } if(c2 != m_currentColour2){ col = ms_vehicleColourTable[c2]; - coltex = ms_colourTextureTable[c2]; for(matp = m_materials2; *matp; matp++){ - if(RpMaterialGetTexture(*matp) && RwTextureGetName(RpMaterialGetTexture(*matp))[0] != '@'){ - colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const - colp->red = col.red; - colp->green = col.green; - colp->blue = col.blue; - }else - RpMaterialSetTexture(*matp, coltex); + colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const + colp->red = col.red; + colp->green = col.green; + colp->blue = col.blue; } m_currentColour2 = c2; } @@ -791,9 +884,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]; @@ -816,18 +912,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; + } } +// unused RwTexture* CreateCarColourTexture(uint8 r, uint8 g, uint8 b) { @@ -916,7 +1021,7 @@ CVehicleModelInfo::LoadVehicleColours(void) if(section == NONE){ if(line[start] == 'c' && line[start + 1] == 'o' && line[start + 2] == 'l') section = COLOURS; - else if(line[start] == 'c' && line[start + 1] == 'a' && line[start + 2] == 'r') + if(line[start] == 'c' && line[start + 1] == 'a' && line[start + 2] == 'r') section = CARS; }else if(line[start] == 'e' && line[start + 1] == 'n' && line[start + 2] == 'd'){ section = NONE; @@ -927,7 +1032,6 @@ CVehicleModelInfo::LoadVehicleColours(void) ms_vehicleColourTable[numCols].green = g; ms_vehicleColourTable[numCols].blue = b; ms_vehicleColourTable[numCols].alpha = 0xFF; - ms_colourTextureTable[numCols] = CreateCarColourTexture(r, g, b); numCols++; }else if(section == CARS){ n = sscanf(&line[start], // BUG: games doesn't add start @@ -962,63 +1066,49 @@ CVehicleModelInfo::DeleteVehicleColourTextures(void) for(i = 0; i < 256; i++){ if(ms_colourTextureTable[i]){ RwTextureDestroy(ms_colourTextureTable[i]); -#if GTA_VERSION >= GTA3_PC_11 ms_colourTextureTable[i] = nil; -#endif } } } 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; - *(bool*)data = true; + *(int*)data = RpMatFXMaterialGetEffects(material); return nil; } RpMaterial* -CVehicleModelInfo::SetEnvironmentMapCB(RpMaterial *material, void *data) +CVehicleModelInfo::SetDefaultEnvironmentMapCB(RpMaterial *material, void *data) { - float spec; - - spec = RpMaterialGetSurfaceProperties(material)->specular; - if(spec <= 0.0f) - RpMatFXMaterialSetEffects(material, rpMATFXEFFECTNULL); - else{ + if(RpMatFXMaterialGetEffects(material) == rpMATFXEFFECTENVMAP){ + RpMatFXMaterialSetEnvMapFrame(material, pMatFxIdentityFrame); if(RpMaterialGetTexture(material) == nil) RpMaterialSetTexture(material, gpWhiteTexture); RpMatFXMaterialSetEffects(material, rpMATFXEFFECTENVMAP); #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 - RpMatFXMaterialSetupEnvMap(material, (RwTexture*)data, pMatFxIdentityFrame, false, spec); } return material; } -bool initialised; - RpAtomic* CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data) { - bool hasSpec; + int fx; RpGeometry *geo; geo = RpAtomicGetGeometry(atomic); - hasSpec = 0; - RpGeometryForAllMaterials(geo, HasSpecularMaterialCB, &hasSpec); - if(hasSpec){ - RpGeometryForAllMaterials(geo, SetEnvironmentMapCB, data); - RpGeometrySetFlags(geo, RpGeometryGetFlags(geo) | rpGEOMETRYMODULATEMATERIALCOLOR); + fx = rpMATFXEFFECTNULL; + RpGeometryForAllMaterials(geo, GetMatFXEffectMaterialCB, &fx); + if(fx != rpMATFXEFFECTNULL){ RpMatFXAtomicEnableEffects(atomic); -#ifdef GTA_PS2 - if(!initialised){ - SetupPS2ManagerLightingCallback(RpAtomicGetInstancePipeline(atomic)); - initialised = true; - } -#endif + RpGeometryForAllMaterials(geo, SetDefaultEnvironmentMapCB, data); } return atomic; } @@ -1030,20 +1120,18 @@ CVehicleModelInfo::SetEnvironmentMap(void) int32 i; if(pMatFxIdentityFrame == nil){ + RwV3d axis = { 1.0f, 0.0f, 0.0f }; pMatFxIdentityFrame = RwFrameCreate(); - RwMatrixSetIdentity(RwFrameGetMatrix(pMatFxIdentityFrame)); + RwMatrixRotate(RwFrameGetMatrix(pMatFxIdentityFrame), &axis, 60.0f, rwCOMBINEREPLACE); RwFrameUpdateObjects(pMatFxIdentityFrame); RwFrameGetLTM(pMatFxIdentityFrame); } - if(m_envMap != ms_pEnvironmentMaps[0]){ - m_envMap = ms_pEnvironmentMaps[0]; - RpClumpForAllAtomics(m_clump, SetEnvironmentMapCB, m_envMap); - if(m_wheelId != -1){ - wheelmi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(m_wheelId); - for(i = 0; i < wheelmi->m_numAtomics; i++) - SetEnvironmentMapCB(wheelmi->m_atomics[i], m_envMap); - } + RpClumpForAllAtomics(m_clump, SetEnvironmentMapCB, nil); + if(m_wheelId != -1){ + wheelmi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(m_wheelId); + for(i = 0; i < wheelmi->m_numAtomics; i++) + SetEnvironmentMapCB(wheelmi->m_atomics[i], nil); } #ifdef EXTENDED_PIPELINES @@ -1054,24 +1142,11 @@ CVehicleModelInfo::SetEnvironmentMap(void) void CVehicleModelInfo::LoadEnvironmentMaps(void) { - const char *texnames[] = { - "reflection01", // only one used - "reflection02", - "reflection03", - "reflection04", - "reflection05", - "reflection06", - }; int32 txdslot; - int32 i; txdslot = CTxdStore::FindTxdSlot("particle"); CTxdStore::PushCurrentTxd(); 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){ gpWhiteTexture = RwTextureRead("white", nil); RwTextureGetName(gpWhiteTexture)[0] = '@'; @@ -1083,14 +1158,8 @@ CVehicleModelInfo::LoadEnvironmentMaps(void) void CVehicleModelInfo::ShutdownEnvironmentMaps(void) { - int32 i; - - // ignoring "initialised" as that's a PS2 thing only RwTextureDestroy(gpWhiteTexture); gpWhiteTexture = nil; - for(i = 0; i < NUM_VEHICLE_ENVMAPS; i++) - if(ms_pEnvironmentMaps[i]) - RwTextureDestroy(ms_pEnvironmentMaps[i]); RwFrameDestroy(pMatFxIdentityFrame); pMatFxIdentityFrame = nil; } @@ -1107,12 +1176,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; diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index e6ba576d..c7a41126 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -3,10 +3,9 @@ #include "ClumpModelInfo.h" enum { - NUM_FIRST_MATERIALS = 26, - NUM_SECOND_MATERIALS = 26, + NUM_FIRST_MATERIALS = 24, + NUM_SECOND_MATERIALS = 20, NUM_VEHICLE_COLOURS = 8, - NUM_VEHICLE_ENVMAPS = 1 }; enum { @@ -41,13 +40,6 @@ enum eCarPositions CAR_POS_TAILLIGHTS, CAR_POS_FRONTSEAT, CAR_POS_BACKSEAT, - // these are unused so we don't know the actual values - CAR_POS_REVERSELIGHTS, - CAR_POS_BRAKELIGHTS, - CAR_POS_INDICATORS_FRONT, - CAR_POS_INDICATORS_BACK, - CAR_POS_STEERWHEEL, - // CAR_POS_EXHAUST }; @@ -73,7 +65,7 @@ enum ePlanePositions }; enum { - NUM_VEHICLE_POSITIONS = 10 + NUM_VEHICLE_POSITIONS = 5 }; class CVehicleModelInfo : public CClumpModelInfo @@ -81,17 +73,19 @@ class CVehicleModelInfo : public CClumpModelInfo public: uint8 m_lastColour1; uint8 m_lastColour2; - char m_gameName[32]; + char m_gameName[10]; int32 m_vehicleType; + float m_wheelScale; union { - int32 m_wheelId; - int32 m_planeLodId; + int16 m_wheelId; + int16 m_planeLodId; }; - float m_wheelScale; - int32 m_numDoors; - int32 m_handlingId; - int32 m_vehicleClass; - int32 m_level; + 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; float m_bikeSteerAngle; @@ -103,13 +97,15 @@ public: uint8 m_lastColorVariation; uint8 m_currentColour1; uint8 m_currentColour2; - RwTexture *m_envMap; RpAtomic *m_comps[6]; - int32 m_numComps; + // This is stupid, CClumpModelInfo already has it! + union { + int32 m_animFileIndex; + char *m_animFileName; + }; static int8 ms_compsToUse[2]; static int8 ms_compsUsed[2]; - static RwTexture *ms_pEnvironmentMaps[NUM_VEHICLE_ENVMAPS]; static RwRGBA ms_vehicleColourTable[256]; static RwTexture *ms_colourTextureTable[256]; static RwObjectNameIdAssocation *ms_vehicleDescs[NUM_VEHICLE_TYPES]; @@ -118,6 +114,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); @@ -130,6 +129,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); @@ -152,8 +152,8 @@ public: static void DeleteVehicleColourTextures(void); static RpAtomic *SetEnvironmentMapCB(RpAtomic *atomic, void *data); - static RpMaterial *SetEnvironmentMapCB(RpMaterial *material, void *data); - static RpMaterial *HasSpecularMaterialCB(RpMaterial *material, void *data); + static RpMaterial *SetDefaultEnvironmentMapCB(RpMaterial *material, void *data); + static RpMaterial *GetMatFXEffectMaterialCB(RpMaterial *material, void *data); void SetEnvironmentMap(void); static void LoadEnvironmentMaps(void); static void ShutdownEnvironmentMaps(void); @@ -162,4 +162,5 @@ public: static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; } }; -VALIDATE_SIZE(CVehicleModelInfo, 0x1F8); +extern bool gbBlackCars; +extern bool gbPinkCars; diff --git a/src/modelinfo/WeaponModelInfo.cpp b/src/modelinfo/WeaponModelInfo.cpp new file mode 100644 index 00000000..d9294c3f --- /dev/null +++ b/src/modelinfo/WeaponModelInfo.cpp @@ -0,0 +1,53 @@ +#include "common.h" + +#include "ModelInfo.h" +#include "AnimManager.h" +#include "VisibilityPlugins.h" + +void +CWeaponModelInfo::SetAnimFile(const char *file) +{ + if(strcasecmp(file, "null") == 0) + return; + + m_animFileName = new char[strlen(file)+1]; + strcpy(m_animFileName, file); +} + +void +CWeaponModelInfo::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; + } +} + +void +CWeaponModelInfo::Init(void) +{ + CSimpleModelInfo::Init(); + SetWeaponInfo(0); +} + +void +CWeaponModelInfo::SetWeaponInfo(int32 weaponId) +{ + m_atomics[2] = (RpAtomic*)weaponId; +} + +eWeaponType +CWeaponModelInfo::GetWeaponInfo(void) +{ + return (eWeaponType)(uintptr)m_atomics[2]; +} + +void +CWeaponModelInfo::SetAtomic(int n, RpAtomic *atomic) +{ + CSimpleModelInfo::SetAtomic(n, atomic); + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderWeaponCB); +} + diff --git a/src/modelinfo/WeaponModelInfo.h b/src/modelinfo/WeaponModelInfo.h new file mode 100644 index 00000000..548bf8a6 --- /dev/null +++ b/src/modelinfo/WeaponModelInfo.h @@ -0,0 +1,23 @@ +#pragma once + +#include "SimpleModelInfo.h" +#include "WeaponType.h" + +class CWeaponModelInfo : public CSimpleModelInfo +{ + union { + int32 m_animFileIndex; + char *m_animFileName; + }; +public: + CWeaponModelInfo(void) : CSimpleModelInfo(MITYPE_WEAPON) { m_animFileIndex = -1; } + + virtual void SetAnimFile(const char *file); + virtual void ConvertAnimFileIndex(void); + virtual int GetAnimFileIndex(void) { return m_animFileIndex; } + virtual void SetAtomic(int n, RpAtomic *atomic); + + void Init(void); + void SetWeaponInfo(int32 weaponId); + eWeaponType GetWeaponInfo(void); +}; diff --git a/src/modelinfo/XtraCompsModelInfo.h b/src/modelinfo/XtraCompsModelInfo.h deleted file mode 100644 index ab308a8a..00000000 --- a/src/modelinfo/XtraCompsModelInfo.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "ClumpModelInfo.h" - -class CXtraCompsModelInfo : public CClumpModelInfo -{ - int field_34; -public: - CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; } - void Shutdown(void) {}; - RwObject *CreateInstance(void) { return nil; } - void SetClump(RpClump*) {}; -};
\ No newline at end of file |