Merge pull request #191 from erorcun/erorcun

AnimViewer!
This commit is contained in:
aap 2019-08-15 17:06:03 +02:00 committed by GitHub
commit b246274d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 581 additions and 21 deletions

View File

@ -61,7 +61,7 @@ WRAPPER void CCarCtrl::PickNextNodeAccordingStrategy(CVehicle*) { EAXJMP(0x41BA5
WRAPPER void CCarCtrl::DragCarToPoint(CVehicle*, CVector*) { EAXJMP(0x41D450); } WRAPPER void CCarCtrl::DragCarToPoint(CVehicle*, CVector*) { EAXJMP(0x41D450); }
WRAPPER void CCarCtrl::SlowCarDownForCarsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float) { EAXJMP(0x419B40); } WRAPPER void CCarCtrl::SlowCarDownForCarsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float) { EAXJMP(0x419B40); }
WRAPPER void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float) { EAXJMP(0x419300); } WRAPPER void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float) { EAXJMP(0x419300); }
WRAPPER void CCarCtrl::Init(void) { EAXJMP(0x41D280); }
void void
CCarCtrl::GenerateRandomCars() CCarCtrl::GenerateRandomCars()
{ {

View File

@ -61,7 +61,7 @@ public:
static float FindMaximumSpeedForThisCarInTraffic(CVehicle*); static float FindMaximumSpeedForThisCarInTraffic(CVehicle*);
static void SlowCarDownForCarsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float); static void SlowCarDownForCarsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float);
static void SlowCarDownForPedsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float); static void SlowCarDownForPedsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float);
static void Init(void);
static float GetOffsetOfLaneFromCenterOfRoad(int8 lane, CCarPathLink* pLink) static float GetOffsetOfLaneFromCenterOfRoad(int8 lane, CCarPathLink* pLink)
{ {

419
src/core/AnimViewer.cpp Normal file
View File

@ -0,0 +1,419 @@
#include "common.h"
#include "patcher.h"
#include "Font.h"
#include "Pad.h"
#include "Text.h"
#include "main.h"
#include "Timer.h"
#include "DMAudio.h"
#include "FileMgr.h"
#include "Streaming.h"
#include "TxdStore.h"
#include "General.h"
#include "Camera.h"
#include "Vehicle.h"
#include "PlayerSkin.h"
#include "PlayerInfo.h"
#include "World.h"
#include "Renderer.h"
#include "AnimManager.h"
#include "AnimViewer.h"
#include "PlayerPed.h"
#include "Pools.h"
#include "References.h"
#include "PathFind.h"
#include "HandlingMgr.h"
#include "TempColModels.h"
#include "Particle.h"
#include "CdStream.h"
#include "Messages.h"
#include "CarCtrl.h"
#include "FileLoader.h"
#include "ModelIndices.h"
#include "Clock.h"
#include "Timecycle.h"
#include "RpAnimBlend.h"
#include "Shadows.h"
int CAnimViewer::animTxdSlot = 0;
CEntity *CAnimViewer::pTarget = nil;
void
CAnimViewer::Render(void) {
if (pTarget)
{
// pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
if (pTarget)
{
pTarget->Render();
CRenderer::RenderOneNonRoad(pTarget);
}
}
}
void
CAnimViewer::Initialise(void) {
LoadingScreen("Loading the ModelViewer", "", GetRandomSplashScreen());
animTxdSlot = CTxdStore::AddTxdSlot("generic");
CTxdStore::Create(animTxdSlot);
int hudSlot = CTxdStore::AddTxdSlot("hud");
CTxdStore::LoadTxd(hudSlot, "MODELS/HUD.TXD");
int particleSlot = CTxdStore::AddTxdSlot("particle");
CTxdStore::LoadTxd(particleSlot, "MODELS/PARTICLE.TXD");
CTxdStore::SetCurrentTxd(animTxdSlot);
CPools::Initialise();
CReferences::Init();
TheCamera.Init();
TheCamera.SetRwCamera(Scene.camera);
// I didn't get which camera og code selects.
for (int i = 0; i < 3; i++) {
TheCamera.Cams[i].Distance = 5.0f;
}
gbModelViewer = true;
ThePaths.Init();
ThePaths.AllocatePathFindInfoMem(4500);
CCollision::Init();
CWorld::Initialise();
mod_HandlingManager.Initialise();
CTempColModels::Initialise();
CAnimManager::Initialise();
CModelInfo::Initialise();
CParticle::Initialise();
CCarCtrl::Init();
CPedStats::Initialise();
CMessages::Init();
CdStreamAddImage("MODELS\\GTA3.IMG");
CFileLoader::LoadLevel("DATA\\ANIMVIEWER.DAT");
CStreaming::Init();
CStreaming::LoadInitialPeds();
CStreaming::RequestSpecialModel(MI_PLAYER, "player", STREAMFLAGS_DONT_REMOVE);
CStreaming::LoadAllRequestedModels(false);
CRenderer::Init();
CVehicleModelInfo::LoadVehicleColours();
CAnimManager::LoadAnimFiles();
CWorld::PlayerInFocus = 0;
CWeapon::InitialiseWeapons();
CShadows::Init();
CPed::Initialise();
CTimer::Initialise();
CClock::Initialise(60000);
CTimeCycle::Initialise();
CCarCtrl::Init();
CPlayerPed *player = new CPlayerPed();
player->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
CWorld::Players[0].m_pPed = player;
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
int fd = CFileMgr::OpenFile("DATA\\SPECIAL.TXT", "r");
char animGroup[32], modelName[32];
if (fd)
{
for (int lineId = 0; lineId < NUM_OF_SPECIAL_CHARS; lineId++) {
if (!CFileMgr::ReadLine(fd, gString, 255))
break;
sscanf(gString, "%s %s", &modelName, &animGroup);
int groupId;
for (groupId = 0; groupId < NUM_ANIM_ASSOC_GROUPS; groupId++)
{
if (!strcmp(animGroup, CAnimManager::GetAnimGroupName((AssocGroupId)groupId)))
break;
}
if (groupId != NUM_ANIM_ASSOC_GROUPS)
((CPedModelInfo*)CModelInfo::GetModelInfo(MI_SPECIAL01 + lineId))->m_animGroup = groupId;
CStreaming::RequestSpecialChar(lineId, modelName, STREAMFLAGS_DONT_REMOVE);
}
CFileMgr::CloseFile(fd);
} else {
// From xbox
CStreaming::RequestSpecialChar(0, "luigi", STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestSpecialChar(1, "joey", STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestSpecialChar(2, "tony", STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestSpecialChar(3, "curly", STREAMFLAGS_DONT_REMOVE);
}
}
int
LastPedModelId(int modelId)
{
CBaseModelInfo *model;
for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i);
if (model->m_type == MITYPE_PED)
return i;
}
return modelId;
}
int
LastVehicleModelId(int modelId)
{
CBaseModelInfo* model;
for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i);
if (model->m_type == MITYPE_VEHICLE)
return i;
}
return modelId;
}
// It's me that named this.
int
FindMeAModelID(int modelId, int wantedChange)
{
// Max. 2 trials wasn't here, it's me that added it.
int tryCount = 2;
int ogModelId = modelId;
while(tryCount != 0)
{
modelId += wantedChange;
if (modelId < 0 || modelId >= MODELINFOSIZE)
{
tryCount--;
wantedChange = -wantedChange;
}
else if (modelId != 5 && modelId != 6 && modelId != 405)
{
CBaseModelInfo *model = CModelInfo::GetModelInfo(modelId);
if (model)
{
//int type = model->m_type;
return modelId;
}
}
}
return ogModelId;
}
void
PlayAnimation(RpClump *clump, AssocGroupId animGroup, AnimationId anim)
{
CAnimBlendAssociation *currentAssoc = RpAnimBlendClumpGetAssociation(clump, anim);
if (currentAssoc && currentAssoc->IsPartial())
delete currentAssoc;
RpAnimBlendClumpSetBlendDeltas(clump, ASSOC_PARTIAL, -8.0f);
CAnimBlendAssociation *animAssoc = CAnimManager::BlendAnimation(clump, animGroup, anim, 8.0f);
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
animAssoc->SetCurrentTime(0.0f);
animAssoc->SetRun();
}
void
CAnimViewer::Update(void)
{
static int modelId = 0;
static int animId = 0;
// Please don't make this bool, static bool's are problematic on my side.
static int reloadIFP = 0;
AssocGroupId animGroup = ASSOCGRP_STD;
int nextModelId = modelId;
CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId);
CEntity *entity = nil;
if (modelInfo->m_type == MITYPE_PED)
{
int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup;
if (animId > ANIM_IDLE_STANCE)
animGroup = ASSOCGRP_STD;
if (reloadIFP)
{
if (pTarget)
{
CWorld::Remove(pTarget);
if (pTarget)
delete pTarget;
}
pTarget = nil;
// These calls were inside of LoadIFP function.
CAnimManager::Shutdown();
CAnimManager::Initialise();
CAnimManager::LoadAnimFiles();
reloadIFP = 0;
}
}
else
{
animGroup = ASSOCGRP_STD;
}
CPad::UpdatePads();
CPad* pad = CPad::GetPad(0);
CStreaming::UpdateForAnimViewer();
CStreaming::RequestModel(modelId, 0);
if (CStreaming::HasModelLoaded(modelId))
{
if (!pTarget)
{
if (modelInfo->m_type == MITYPE_VEHICLE)
{
CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo;
if (veh->m_vehicleType != VEHICLE_TYPE_CAR)
{
// Not ready yet
/* if (veh->m_vehicleType == VEHICLE_TYPE_BOAT)
{
v33 = (CBoat*)CVehicle::operator new((CVehicle*)0x488, v6);
CBoat::CBoat(v33, modelId, 1u);
entity = (int)v33;
pTarget = (int)v33;
}
else
{
*/ entity = pTarget = new CObject(modelId, true);
if (!modelInfo->GetColModel())
{
modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1);
}
// }
}
else
{
entity = pTarget = new CAutomobile(modelId, RANDOM_VEHICLE);
entity->m_status = STATUS_ABANDONED;
}
entity->bIsStuck = true;
}
else if (modelInfo->m_type == MITYPE_PED)
{
pTarget = entity = new CPed(PEDTYPE_CIVMALE);
entity->SetModelIndex(modelId);
}
else
{
entity = pTarget = new CObject(modelId, true);
if (!modelInfo->GetColModel())
{
modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1);
}
entity->bIsStuck = true;
}
entity->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
CWorld::Add(entity);
TheCamera.TakeControl(pTarget, 9, 2, 1);
}
if (entity &&
(entity->m_type == ENTITY_TYPE_VEHICLE || entity->m_type == ENTITY_TYPE_PED || entity->m_type == ENTITY_TYPE_OBJECT))
{
// Maybe m_vecMoveSpeed or something else? Some structs are different on mobile.
((CPhysical*)pTarget)->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
}
pTarget->GetPosition().z = 0.0f;
if (modelInfo->m_type != MITYPE_PED)
{
if (modelInfo->m_type == MITYPE_VEHICLE)
{
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1)
{
nextModelId = LastPedModelId(modelId);
}
else
{
// Start in mobile
if (pad->NewState.Square && !pad->OldState.Square)
CVehicleModelInfo::LoadVehicleColours();
}
}
}
else
{
((CPed*)pTarget)->bKindaStayInSamePlace = true;
// Triangle in mobile
if (pad->NewState.Square && !pad->OldState.Square) {
reloadIFP = 1;
} else if (pad->NewState.Cross && !pad->OldState.Cross)
{
PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId);
}
else if (pad->NewState.Circle && !pad->OldState.Circle)
{
PlayAnimation(pTarget->GetClump(), animGroup, ANIM_IDLE_STANCE);
}
else if (pad->NewState.DPadUp && pad->OldState.DPadUp == 0)
{
animId--;
if (animId < 0)
{
animId = NUM_ANIMS - 1;
}
PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId);
}
else if (pad->NewState.DPadDown && !pad->OldState.DPadDown)
{
animId = (animId == (NUM_ANIMS - 1) ? 0 : animId + 1);
PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId);
}
else
{
if (pad->NewState.Start && !pad->OldState.Start)
{
} else {
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) {
nextModelId = LastVehicleModelId(modelId);
} else {
// if (CPad::GetPad(1)->NewState.LeftShoulder2)
// CPedModelInfo::AnimatePedColModelSkinned(CModelInfo::ms_modelInfoPtrs[(pTarget + 96)], pTarget->GetClump()));
}
}
}
}
}
if (pad->NewState.DPadLeft && pad->OldState.DPadLeft == 0)
{
nextModelId = FindMeAModelID(modelId, -1);
} else if (pad->NewState.DPadRight && pad->OldState.DPadRight == 0)
{
nextModelId = FindMeAModelID(modelId, 1);
}
if (nextModelId != modelId)
{
modelId = nextModelId;
if (pTarget)
{
CWorld::Remove(pTarget);
if (pTarget)
delete pTarget;
}
pTarget = nil;
return;
}
CTimeCycle::Update();
CWorld::Process();
if (pTarget)
TheCamera.Process();
}
void
CAnimViewer::Shutdown(void)
{
if (CWorld::Players[0].m_pPed)
delete CWorld::Players[0].m_pPed;
CWorld::ShutDown();
CModelInfo::ShutDown();
CAnimManager::Shutdown();
CTimer::Shutdown();
CStreaming::Shutdown();
CTxdStore::RemoveTxdSlot(animTxdSlot);
}

12
src/core/AnimViewer.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
class CAnimViewer {
public:
static int animTxdSlot;
static CEntity *pTarget;
static void Initialise();
static void Render();
static void Shutdown();
static void Update();
};

View File

@ -27,7 +27,9 @@ WRAPPER void CamShakeNoPos(CCamera*, float) { EAXJMP(0x46B100); }
WRAPPER void CCamera::TakeControl(CEntity*, int16, int16, int32) { EAXJMP(0x471500); } WRAPPER void CCamera::TakeControl(CEntity*, int16, int16, int32) { EAXJMP(0x471500); }
WRAPPER void CCamera::TakeControlNoEntity(const CVector&, int16, int32) { EAXJMP(0x4715B0); } WRAPPER void CCamera::TakeControlNoEntity(const CVector&, int16, int32) { EAXJMP(0x4715B0); }
WRAPPER void CCamera::SetCamPositionForFixedMode(const CVector&, const CVector&) { EAXJMP(0x46FCC0); } WRAPPER void CCamera::SetCamPositionForFixedMode(const CVector&, const CVector&) { EAXJMP(0x46FCC0); }
WRAPPER void CCamera::Init(void) { EAXJMP(0x46BAD0); }
WRAPPER void CCamera::SetRwCamera(RwCamera*) { EAXJMP(0x46FEC0); }
WRAPPER void CCamera::Process(void) { EAXJMP(0x46D3F0); }
bool bool
CCamera::GetFading() CCamera::GetFading()

View File

@ -476,6 +476,10 @@ int m_iModeObbeCamIsInForCar;
void SetCamPositionForFixedMode(const CVector&, const CVector&); void SetCamPositionForFixedMode(const CVector&, const CVector&);
bool GetFading(); bool GetFading();
void Init();
void SetRwCamera(RwCamera*);
void Process();
void dtor(void) { this->CCamera::~CCamera(); } void dtor(void) { this->CCamera::~CCamera(); }
}; };
static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error"); static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error");
@ -488,4 +492,4 @@ static_assert(offsetof(CCamera, Cams) == 0x1A4, "CCamera: error");
static_assert(sizeof(CCamera) == 0xE9D8, "CCamera: wrong size"); static_assert(sizeof(CCamera) == 0xE9D8, "CCamera: wrong size");
extern CCamera &TheCamera; extern CCamera &TheCamera;
void CamShakeNoPos(CCamera*, float); void CamShakeNoPos(CCamera*, float);

View File

@ -14,7 +14,7 @@ WRAPPER void CMessages::AddMessage(wchar* key, uint32 time, uint16 pos) { EAXJMP
WRAPPER void CMessages::AddMessageJumpQ(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529A10); } WRAPPER void CMessages::AddMessageJumpQ(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529A10); }
WRAPPER void CMessages::AddMessageSoon(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529AF0); } WRAPPER void CMessages::AddMessageSoon(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529AF0); }
WRAPPER void CMessages::ClearMessages() { EAXJMP(0x529CE0); } WRAPPER void CMessages::ClearMessages() { EAXJMP(0x529CE0); }
WRAPPER void CMessages::Init() { EAXJMP(0x529310); }
tPreviousBrief *CMessages::PreviousBriefs = (tPreviousBrief *)0x713C08; tPreviousBrief *CMessages::PreviousBriefs = (tPreviousBrief *)0x713C08;
tMessage *CMessages::BriefMessages = (tMessage *)0x8786E0; tMessage *CMessages::BriefMessages = (tMessage *)0x8786E0;
tBigMessage *CMessages::BIGMessages = (tBigMessage *)0x773628; tBigMessage *CMessages::BIGMessages = (tBigMessage *)0x773628;

View File

@ -46,4 +46,5 @@ public:
static void AddMessageJumpQ(wchar* key, uint32 time, uint16 pos); static void AddMessageJumpQ(wchar* key, uint32 time, uint16 pos);
static void AddMessageSoon(wchar* key, uint32 time, uint16 pos); static void AddMessageSoon(wchar* key, uint32 time, uint16 pos);
static void ClearMessages(); static void ClearMessages();
static void Init();
}; };

View File

@ -25,4 +25,4 @@ public:
bool IsWithinArea(float x1, float y1, float x2, float y2); bool IsWithinArea(float x1, float y1, float x2, float y2);
bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2); bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2);
}; };
static_assert(sizeof(CPlaceable) == 0x4C, "CPlaceable: error"); static_assert(sizeof(CPlaceable) == 0x4C, "CPlaceable: error");

View File

@ -1,4 +1,5 @@
#include "common.h" #include "common.h"
#include "patcher.h"
#include "Pools.h" #include "Pools.h"
CCPtrNodePool *&CPools::ms_pPtrNodePool = *(CCPtrNodePool**)0x943044; CCPtrNodePool *&CPools::ms_pPtrNodePool = *(CCPtrNodePool**)0x943044;
@ -11,6 +12,9 @@ CObjectPool *&CPools::ms_pObjectPool = *(CObjectPool**)0x880E28;
CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18; CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18;
CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C; CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C;
WRAPPER void CPools::Initialise(void) { EAXJMP(0x4A1770); }
#if 0
void void
CPools::Initialise(void) CPools::Initialise(void)
{ {
@ -26,6 +30,7 @@ CPools::Initialise(void)
ms_pDummyPool = new CDummyPool(NUMDUMMIES); ms_pDummyPool = new CDummyPool(NUMDUMMIES);
ms_pAudioScriptObjectPool = new CAudioScriptObjectPool(NUMAUDIOSCRIPTOBJECTS); ms_pAudioScriptObjectPool = new CAudioScriptObjectPool(NUMAUDIOSCRIPTOBJECTS);
} }
#endif
int32 CPools::GetPedRef(CPed *ped) { return ms_pPedPool->GetIndex(ped); } int32 CPools::GetPedRef(CPed *ped) { return ms_pPedPool->GetIndex(ped); }
CPed *CPools::GetPed(int32 handle) { return ms_pPedPool->GetAt(handle); } CPed *CPools::GetPed(int32 handle) { return ms_pPedPool->GetAt(handle); }

View File

@ -26,6 +26,7 @@
#include "CutsceneMgr.h" #include "CutsceneMgr.h"
#include "CdStream.h" #include "CdStream.h"
#include "Streaming.h" #include "Streaming.h"
#include "main.h"
bool &CStreaming::ms_disableStreaming = *(bool*)0x95CD6E; bool &CStreaming::ms_disableStreaming = *(bool*)0x95CD6E;
bool &CStreaming::ms_bLoadingBigModel = *(bool*)0x95CDB0; bool &CStreaming::ms_bLoadingBigModel = *(bool*)0x95CDB0;
@ -2427,6 +2428,19 @@ CStreaming::MemoryCardLoad(uint8 *buffer, uint32 length)
ms_aInfoForModel[i].m_flags = buffer[i]; ms_aInfoForModel[i].m_flags = buffer[i];
} }
void
CStreaming::UpdateForAnimViewer(void)
{
if (CStreaming::ms_channelError == -1) {
CStreaming::AddModelsToRequestList(CVector(0.0f, 0.0f, 0.0f));
CStreaming::LoadRequestedModels();
sprintf(gString, "Requested %d, memory size %dK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed);
}
else {
CStreaming::RetryLoadFile(CStreaming::ms_channelError);
}
}
STARTPATCHES STARTPATCHES
InjectHook(0x406430, CStreaming::Init, PATCH_JUMP); InjectHook(0x406430, CStreaming::Init, PATCH_JUMP);
InjectHook(0x406C80, CStreaming::Shutdown, PATCH_JUMP); InjectHook(0x406C80, CStreaming::Shutdown, PATCH_JUMP);

View File

@ -185,4 +185,6 @@ public:
static void MemoryCardSave(uint8 *buffer, uint32 *length); static void MemoryCardSave(uint8 *buffer, uint32 *length);
static void MemoryCardLoad(uint8 *buffer, uint32 length); static void MemoryCardLoad(uint8 *buffer, uint32 length);
static void UpdateForAnimViewer(void);
}; };

View File

@ -15,3 +15,5 @@ CColModel &CTempColModels::ms_colModelPedGroundHit = *(CColModel*)0x880480;
CColModel &CTempColModels::ms_colModelBoot1 = *(CColModel*)0x880670; CColModel &CTempColModels::ms_colModelBoot1 = *(CColModel*)0x880670;
CColModel &CTempColModels::ms_colModelDoor1 = *(CColModel*)0x880850; CColModel &CTempColModels::ms_colModelDoor1 = *(CColModel*)0x880850;
CColModel &CTempColModels::ms_colModelBonnet1 = *(CColModel*)0x8808A8; CColModel &CTempColModels::ms_colModelBonnet1 = *(CColModel*)0x8808A8;
WRAPPER void CTempColModels::Initialise(void) { EAXJMP(0x412160); }

View File

@ -18,4 +18,6 @@ public:
static CColModel &ms_colModelBoot1; static CColModel &ms_colModelBoot1;
static CColModel &ms_colModelDoor1; static CColModel &ms_colModelDoor1;
static CColModel &ms_colModelBonnet1; static CColModel &ms_colModelBonnet1;
static void Initialise(void);
}; };

View File

@ -28,9 +28,27 @@ bool &CWorld::bSecondShift = *(bool*)0x95CD54;
bool &CWorld::bForceProcessControl = *(bool*)0x95CD6C; bool &CWorld::bForceProcessControl = *(bool*)0x95CD6C;
bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B; bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B;
bool &CWorld::bDoingCarCollisions = *(bool*)0x95CD8C;
bool &CWorld::bIncludeCarTyres = *(bool*)0x95CDAA;
WRAPPER void CWorld::Process(void) { EAXJMP(0x4B1A60); }
WRAPPER void CWorld::ShutDown(void) { EAXJMP(0x4AE450); }
WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); } WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); }
WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); } WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); }
void
CWorld::Initialise()
{
pIgnoreEntity = nil;
bDoingCarCollisions = false;
bSecondShift = false;
bNoMoreCollisionTorque = false;
bProcessCutsceneOnly = false;
bIncludeDeadPeds = false;
bForceProcessControl = false;
bIncludeCarTyres = false;
}
void void
CWorld::Add(CEntity *ent) CWorld::Add(CEntity *ent)
{ {

View File

@ -67,6 +67,8 @@ public:
static bool &bSecondShift; static bool &bSecondShift;
static bool &bForceProcessControl; static bool &bForceProcessControl;
static bool &bProcessCutsceneOnly; static bool &bProcessCutsceneOnly;
static bool &bDoingCarCollisions;
static bool &bIncludeCarTyres;
static void Remove(CEntity *entity); static void Remove(CEntity *entity);
static void Add(CEntity *entity); static void Add(CEntity *entity);
@ -111,6 +113,10 @@ public:
static int GetSectorIndexY(float f) { return (int)GetSectorY(f); } static int GetSectorIndexY(float f) { return (int)GetSectorY(f); }
static float GetWorldX(int x) { return x*SECTOR_SIZE_X + WORLD_MIN_X; } static float GetWorldX(int x) { return x*SECTOR_SIZE_X + WORLD_MIN_X; }
static float GetWorldY(int y) { return y*SECTOR_SIZE_Y + WORLD_MIN_Y; } static float GetWorldY(int y) { return y*SECTOR_SIZE_Y + WORLD_MIN_Y; }
static void Initialise();
static void ShutDown();
static void Process();
}; };
class CPlayerPed; class CPlayerPed;

View File

@ -47,6 +47,7 @@
#include "Text.h" #include "Text.h"
#include "RpAnimBlend.h" #include "RpAnimBlend.h"
#include "Frontend.h" #include "Frontend.h"
#include "AnimViewer.h"
#define DEFAULT_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetFOV() * 0.5f))) #define DEFAULT_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetFOV() * 0.5f)))
@ -71,9 +72,10 @@ char version_name[64];
float FramesPerSecond = 30.0f; float FramesPerSecond = 30.0f;
bool gbPrintShite = false; bool gbPrintShite = false;
bool gbModelViewer; bool &gbModelViewer = *(bool*)0x95CD93;
bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void); void DoRWStuffEndOfFrame(void);
void RenderScene(void); void RenderScene(void);
@ -104,6 +106,25 @@ InitialiseGame(void)
CGame::Initialise("DATA\\GTA3.DAT"); CGame::Initialise("DATA\\GTA3.DAT");
} }
#ifndef MASTER
void
TheModelViewer(void)
{
CAnimViewer::Update();
CTimer::Update();
SetLightsWithTimeOfDayColour(Scene.world);
CRenderer::ConstructRenderList();
DoRWStuffStartOfFrame(CTimeCycle::GetSkyTopRed(), CTimeCycle::GetSkyTopGreen(), CTimeCycle::GetSkyTopBlue(),
CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
255);
DefinedState();
CVisibilityPlugins::InitAlphaEntityList();
CAnimViewer::Render();
DoRWStuffEndOfFrame();
}
#endif
void void
Idle(void *arg) Idle(void *arg)
{ {
@ -976,6 +997,15 @@ AppEventHandler(RsEvent event, void *param)
return rsEVENTPROCESSED; return rsEVENTPROCESSED;
} }
#ifndef MASTER
case rsANIMVIEWER:
{
TheModelViewer();
return rsEVENTPROCESSED;
}
#endif
default: default:
{ {
return rsEVENTNOTPROCESSED; return rsEVENTNOTPROCESSED;

View File

@ -18,7 +18,7 @@ extern wchar *gUString;
extern wchar *gUString2; extern wchar *gUString2;
extern bool &b_FoundRecentSavedGameWantToLoad; extern bool &b_FoundRecentSavedGameWantToLoad;
extern bool gbPrintShite; extern bool gbPrintShite;
extern bool gbModelViewer; extern bool &gbModelViewer;
class CSprite2d; class CSprite2d;
@ -30,3 +30,6 @@ char *GetLevelSplashScreen(int level);
char *GetRandomSplashScreen(void); char *GetRandomSplashScreen(void);
void LittleTest(void); void LittleTest(void);
void ValidateVersion(); void ValidateVersion();
#ifndef MASTER
void TheModelViewer(void);
#endif

View File

@ -11,6 +11,7 @@ float CDraw::ms_fAspectRatio = DEFAULT_ASPECT_RATIO;
float &CDraw::ms_fNearClipZ = *(float*)0x8E2DC4; float &CDraw::ms_fNearClipZ = *(float*)0x8E2DC4;
float &CDraw::ms_fFarClipZ = *(float*)0x9434F0; float &CDraw::ms_fFarClipZ = *(float*)0x9434F0;
float &CDraw::ms_fFOV = *(float*)0x5FBC6C; float &CDraw::ms_fFOV = *(float*)0x5FBC6C;
float &CDraw::ms_fLODDistance = *(float*)0x8F2C30;
uint8 &CDraw::FadeValue = *(uint8*)0x95CD68; uint8 &CDraw::FadeValue = *(uint8*)0x95CD68;
uint8 &CDraw::FadeRed = *(uint8*)0x95CD90; uint8 &CDraw::FadeRed = *(uint8*)0x95CD90;

View File

@ -16,7 +16,8 @@ private:
static float &ms_fNearClipZ; static float &ms_fNearClipZ;
static float &ms_fFarClipZ; static float &ms_fFarClipZ;
static float &ms_fFOV; static float &ms_fFOV;
static float ms_fLODDistance; // unused public:
static float &ms_fLODDistance; // set but unused?
#ifdef ASPECT_RATIO_SCALE #ifdef ASPECT_RATIO_SCALE
// we use this variable to scale a lot of 2D elements // we use this variable to scale a lot of 2D elements
@ -24,7 +25,6 @@ private:
static float ms_fAspectRatio; static float ms_fAspectRatio;
#endif #endif
public:
static uint8 &FadeValue; static uint8 &FadeValue;
static uint8 &FadeRed; static uint8 &FadeRed;
static uint8 &FadeGreen; static uint8 &FadeGreen;

View File

@ -15,6 +15,8 @@
static RwBool DefaultVideoMode = TRUE; static RwBool DefaultVideoMode = TRUE;
bool TurnOnAnimViewer = false;
//RsGlobalType RsGlobal; //RsGlobalType RsGlobal;
RsGlobalType &RsGlobal = *(RsGlobalType*)0x8F4360; RsGlobalType &RsGlobal = *(RsGlobalType*)0x8F4360;
@ -144,7 +146,14 @@ rsPreInitCommandLine(RwChar *arg)
return TRUE; return TRUE;
} }
#ifndef MASTER
if (!strcmp(arg, RWSTRING("-animviewer")))
{
TurnOnAnimViewer = TRUE;
return TRUE;
}
#endif
return FALSE; return FALSE;
} }

View File

@ -79,8 +79,11 @@ enum RsEvent
rsPADANALOGUERIGHTRESET, rsPADANALOGUERIGHTRESET,
rsPREINITCOMMANDLINE, rsPREINITCOMMANDLINE,
rsACTIVATE, rsACTIVATE,
rsANIMVIEWER,
}; };
extern bool TurnOnAnimViewer;
typedef enum RsEvent RsEvent; typedef enum RsEvent RsEvent;
typedef RsEventStatus (*RsInputEventHandler)(RsEvent event, void *param); typedef RsEventStatus (*RsInputEventHandler)(RsEvent event, void *param);

View File

@ -94,6 +94,7 @@ static psGlobalType &PsGlobal = *(psGlobalType*)0x72CF60;
#include "Game.h" #include "Game.h"
#include "PCSave.h" #include "PCSave.h"
#include "Sprite2d.h" #include "Sprite2d.h"
#include "AnimViewer.h"
VALIDATE_SIZE(psGlobalType, 0x28); VALIDATE_SIZE(psGlobalType, 0x28);
@ -976,9 +977,9 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
RECT rect; RECT rect;
/* redraw window */ /* redraw window */
if (RwInitialised && gGameState == GS_PLAYING_GAME) if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER))
{ {
RsEventHandler(rsIDLE, (void *)TRUE); RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE);
} }
/* Manually resize window */ /* Manually resize window */
@ -1917,16 +1918,23 @@ _WinMain(HINSTANCE instance,
SetErrorMode(SEM_FAILCRITICALERRORS); SetErrorMode(SEM_FAILCRITICALERRORS);
if (!TurnOnAnimViewer) {
#ifdef NO_MOVIES #ifdef NO_MOVIES
gGameState = GS_INIT_FRONTEND; gGameState = GS_INIT_FRONTEND;
TRACE("gGameState = GS_INIT_FRONTEND"); TRACE("gGameState = GS_INIT_FRONTEND");
LoadingScreen(nil, nil, "loadsc0"); LoadingScreen(nil, nil, "loadsc0");
if ( !CGame::InitialiseOnceAfterRW() ) if (!CGame::InitialiseOnceAfterRW())
RsGlobal.quit = TRUE; RsGlobal.quit = TRUE;
#endif #endif
} else {
#ifndef MASTER
CAnimViewer::Initialise();
FrontEndMenuManager.m_bGameNotLoaded = false;
gGameState = GS_ANIMVIEWER;
TurnOnAnimViewer = false;
#endif
}
while ( TRUE ) while ( TRUE )
{ {
@ -2114,6 +2122,18 @@ _WinMain(HINSTANCE instance,
} }
break; break;
} }
#ifndef MASTER
case GS_ANIMVIEWER:
{
float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
if (RwInitialised)
{
if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms)
RsEventHandler(rsANIMVIEWER, (void*)TRUE);
}
break;
}
#endif
} }
} }
else else
@ -2158,6 +2178,8 @@ _WinMain(HINSTANCE instance,
{ {
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
CTimer::Stop(); CTimer::Stop();
@ -2180,6 +2202,8 @@ _WinMain(HINSTANCE instance,
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
DMAudio.Terminate(); DMAudio.Terminate();

View File

@ -17,6 +17,7 @@ enum eGameState
GS_FRONTEND, GS_FRONTEND,
GS_INIT_PLAYING_GAME, GS_INIT_PLAYING_GAME,
GS_PLAYING_GAME, GS_PLAYING_GAME,
GS_ANIMVIEWER,
}; };
enum eWinVersion enum eWinVersion

View File

@ -11,6 +11,7 @@ WRAPPER void CWeapon::FireFromCar(CAutomobile *car, bool left) { EAXJMP(0x55C940
WRAPPER void CWeapon::AddGunshell(CEntity*, CVector const&, CVector2D const&, float) { EAXJMP(0x55F770); } WRAPPER void CWeapon::AddGunshell(CEntity*, CVector const&, CVector2D const&, float) { EAXJMP(0x55F770); }
WRAPPER void CWeapon::Update(int32 audioEntity) { EAXJMP(0x563A10); } WRAPPER void CWeapon::Update(int32 audioEntity) { EAXJMP(0x563A10); }
WRAPPER void CWeapon::DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end) { EAXJMP(0x563200); } WRAPPER void CWeapon::DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end) { EAXJMP(0x563200); }
WRAPPER void CWeapon::InitialiseWeapons(void) { EAXJMP(0x55C2D0); }
void void
CWeapon::Initialise(eWeaponType type, int ammo) CWeapon::Initialise(eWeaponType type, int ammo)

View File

@ -72,5 +72,6 @@ public:
bool IsType2Handed(void); bool IsType2Handed(void);
static void DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end); static void DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end);
bool HitsGround(CEntity* holder, CVector* firePos, CEntity* aimingTo); bool HitsGround(CEntity* holder, CVector* firePos, CEntity* aimingTo);
static void InitialiseWeapons(void);
}; };
static_assert(sizeof(CWeapon) == 0x18, "CWeapon: error"); static_assert(sizeof(CWeapon) == 0x18, "CWeapon: error");