1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-26 18:15:27 +00:00

AnimViewer fixes

This commit is contained in:
eray orçunus 2019-08-15 18:59:09 +03:00
parent 8f18f84836
commit 82dc813ab3
2 changed files with 51 additions and 86 deletions

View file

@ -40,11 +40,9 @@ CEntity *CAnimViewer::pTarget = nil;
void void
CAnimViewer::Render(void) { CAnimViewer::Render(void) {
if (pTarget) if (pTarget) {
{
// pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f); // pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
if (pTarget) if (pTarget) {
{
pTarget->Render(); pTarget->Render();
CRenderer::RenderOneNonRoad(pTarget); CRenderer::RenderOneNonRoad(pTarget);
} }
@ -110,16 +108,14 @@ CAnimViewer::Initialise(void) {
int fd = CFileMgr::OpenFile("DATA\\SPECIAL.TXT", "r"); int fd = CFileMgr::OpenFile("DATA\\SPECIAL.TXT", "r");
char animGroup[32], modelName[32]; char animGroup[32], modelName[32];
if (fd) if (fd) {
{
for (int lineId = 0; lineId < NUM_OF_SPECIAL_CHARS; lineId++) { for (int lineId = 0; lineId < NUM_OF_SPECIAL_CHARS; lineId++) {
if (!CFileMgr::ReadLine(fd, gString, 255)) if (!CFileMgr::ReadLine(fd, gString, 255))
break; break;
sscanf(gString, "%s %s", &modelName, &animGroup); sscanf(gString, "%s %s", &modelName, &animGroup);
int groupId; int groupId;
for (groupId = 0; groupId < NUM_ANIM_ASSOC_GROUPS; groupId++) for (groupId = 0; groupId < NUM_ANIM_ASSOC_GROUPS; groupId++) {
{
if (!strcmp(animGroup, CAnimManager::GetAnimGroupName((AssocGroupId)groupId))) if (!strcmp(animGroup, CAnimManager::GetAnimGroupName((AssocGroupId)groupId)))
break; break;
} }
@ -173,16 +169,12 @@ FindMeAModelID(int modelId, int wantedChange)
int tryCount = 2; int tryCount = 2;
int ogModelId = modelId; int ogModelId = modelId;
while(tryCount != 0) while(tryCount != 0) {
{
modelId += wantedChange; modelId += wantedChange;
if (modelId < 0 || modelId >= MODELINFOSIZE) if (modelId < 0 || modelId >= MODELINFOSIZE) {
{
tryCount--; tryCount--;
wantedChange = -wantedChange; wantedChange = -wantedChange;
} } else if (modelId != 5 && modelId != 6 && modelId != 405) {
else if (modelId != 5 && modelId != 6 && modelId != 405)
{
CBaseModelInfo *model = CModelInfo::GetModelInfo(modelId); CBaseModelInfo *model = CModelInfo::GetModelInfo(modelId);
if (model) if (model)
{ {
@ -223,17 +215,14 @@ CAnimViewer::Update(void)
CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId); CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId);
CEntity *entity = nil; CEntity *entity = nil;
if (modelInfo->m_type == MITYPE_PED) if (modelInfo->m_type == MITYPE_PED) {
{
int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup; int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup;
if (animId > ANIM_IDLE_STANCE) if (animId > ANIM_IDLE_STANCE)
animGroup = ASSOCGRP_STD; animGroup = ASSOCGRP_STD;
if (reloadIFP) if (reloadIFP) {
{ if (pTarget) {
if (pTarget)
{
CWorld::Remove(pTarget); CWorld::Remove(pTarget);
if (pTarget) if (pTarget)
delete pTarget; delete pTarget;
@ -247,24 +236,21 @@ CAnimViewer::Update(void)
reloadIFP = 0; reloadIFP = 0;
} }
} } else {
else
{
animGroup = ASSOCGRP_STD; animGroup = ASSOCGRP_STD;
} }
CPad::UpdatePads(); CPad::UpdatePads();
CPad* pad = CPad::GetPad(0); CPad* pad = CPad::GetPad(0);
CStreaming::UpdateForAnimViewer(); CStreaming::UpdateForAnimViewer();
CStreaming::RequestModel(modelId, 0); CStreaming::RequestModel(modelId, 0);
if (CStreaming::HasModelLoaded(modelId)) if (CStreaming::HasModelLoaded(modelId)) {
{
if (!pTarget) if (!pTarget) {
{
if (modelInfo->m_type == MITYPE_VEHICLE) if (modelInfo->m_type == MITYPE_VEHICLE) {
{
CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo; CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo;
if (veh->m_vehicleType != VEHICLE_TYPE_CAR) if (veh->m_vehicleType != VEHICLE_TYPE_CAR) {
{
// Not ready yet // Not ready yet
/* if (veh->m_vehicleType == VEHICLE_TYPE_BOAT) /* if (veh->m_vehicleType == VEHICLE_TYPE_BOAT)
{ {
@ -276,26 +262,19 @@ CAnimViewer::Update(void)
else else
{ {
*/ entity = pTarget = new CObject(modelId, true); */ entity = pTarget = new CObject(modelId, true);
if (!modelInfo->GetColModel()) if (!modelInfo->GetColModel()) {
{
modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1); modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1);
} }
// } // }
} } else {
else
{
entity = pTarget = new CAutomobile(modelId, RANDOM_VEHICLE); entity = pTarget = new CAutomobile(modelId, RANDOM_VEHICLE);
entity->m_status = STATUS_ABANDONED; entity->m_status = STATUS_ABANDONED;
} }
entity->bIsStuck = true; entity->bIsStuck = true;
} } else if (modelInfo->m_type == MITYPE_PED) {
else if (modelInfo->m_type == MITYPE_PED)
{
pTarget = entity = new CPed(PEDTYPE_CIVMALE); pTarget = entity = new CPed(PEDTYPE_CIVMALE);
entity->SetModelIndex(modelId); entity->SetModelIndex(modelId);
} } else {
else
{
entity = pTarget = new CObject(modelId, true); entity = pTarget = new CObject(modelId, true);
if (!modelInfo->GetColModel()) if (!modelInfo->GetColModel())
{ {
@ -307,63 +286,49 @@ CAnimViewer::Update(void)
CWorld::Add(entity); CWorld::Add(entity);
TheCamera.TakeControl(pTarget, 9, 2, 1); TheCamera.TakeControl(pTarget, 9, 2, 1);
} }
if (entity && if (pTarget->m_type == ENTITY_TYPE_VEHICLE || pTarget->m_type == ENTITY_TYPE_PED || pTarget->m_type == ENTITY_TYPE_OBJECT) {
(entity->m_type == ENTITY_TYPE_VEHICLE || entity->m_type == ENTITY_TYPE_PED || entity->m_type == ENTITY_TYPE_OBJECT)) ((CPhysical*)pTarget)->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
{
// 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; pTarget->GetPosition().z = 0.0f;
if (modelInfo->m_type != MITYPE_PED) if (modelInfo->m_type != MITYPE_PED) {
{
if (modelInfo->m_type == MITYPE_VEHICLE) if (modelInfo->m_type == MITYPE_VEHICLE) {
{
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) {
{
nextModelId = LastPedModelId(modelId); nextModelId = LastPedModelId(modelId);
} } else {
else
{
// Start in mobile // Start in mobile
if (pad->NewState.Square && !pad->OldState.Square) if (pad->NewState.Square && !pad->OldState.Square)
CVehicleModelInfo::LoadVehicleColours(); CVehicleModelInfo::LoadVehicleColours();
} }
} }
} } else {
else
{
((CPed*)pTarget)->bKindaStayInSamePlace = true; ((CPed*)pTarget)->bKindaStayInSamePlace = true;
// Triangle in mobile // Triangle in mobile
if (pad->NewState.Square && !pad->OldState.Square) { if (pad->NewState.Square && !pad->OldState.Square) {
reloadIFP = 1; reloadIFP = 1;
} else if (pad->NewState.Cross && !pad->OldState.Cross)
{ } else if (pad->NewState.Cross && !pad->OldState.Cross) {
PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId);
}
else if (pad->NewState.Circle && !pad->OldState.Circle) } else if (pad->NewState.Circle && !pad->OldState.Circle) {
{
PlayAnimation(pTarget->GetClump(), animGroup, ANIM_IDLE_STANCE); PlayAnimation(pTarget->GetClump(), animGroup, ANIM_IDLE_STANCE);
}
else if (pad->NewState.DPadUp && pad->OldState.DPadUp == 0) } else if (pad->NewState.DPadUp && pad->OldState.DPadUp == 0) {
{
animId--; animId--;
if (animId < 0) if (animId < 0) {
{
animId = NUM_ANIMS - 1; animId = NUM_ANIMS - 1;
} }
PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId);
}
else if (pad->NewState.DPadDown && !pad->OldState.DPadDown) } else if (pad->NewState.DPadDown && !pad->OldState.DPadDown) {
{
animId = (animId == (NUM_ANIMS - 1) ? 0 : animId + 1); animId = (animId == (NUM_ANIMS - 1) ? 0 : animId + 1);
PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId);
}
else } else {
{ if (pad->NewState.Start && !pad->OldState.Start) {
if (pad->NewState.Start && !pad->OldState.Start)
{
} else { } else {
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) { if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) {
@ -377,19 +342,16 @@ CAnimViewer::Update(void)
} }
} }
if (pad->NewState.DPadLeft && pad->OldState.DPadLeft == 0) if (pad->NewState.DPadLeft && pad->OldState.DPadLeft == 0) {
{
nextModelId = FindMeAModelID(modelId, -1); nextModelId = FindMeAModelID(modelId, -1);
} else if (pad->NewState.DPadRight && pad->OldState.DPadRight == 0) } else if (pad->NewState.DPadRight && pad->OldState.DPadRight == 0) {
{
nextModelId = FindMeAModelID(modelId, 1); nextModelId = FindMeAModelID(modelId, 1);
} }
// There were extra codes here to let us change model id by 50, but xbox CPad struct is different, so I couldn't port.
if (nextModelId != modelId) if (nextModelId != modelId) {
{
modelId = nextModelId; modelId = nextModelId;
if (pTarget) if (pTarget) {
{
CWorld::Remove(pTarget); CWorld::Remove(pTarget);
if (pTarget) if (pTarget)
delete pTarget; delete pTarget;

View file

@ -110,6 +110,9 @@ InitialiseGame(void)
void void
TheModelViewer(void) TheModelViewer(void)
{ {
#ifdef ASPECT_RATIO_SCALE
CDraw::SetAspectRatio(CDraw::FindAspectRatio());
#endif
CAnimViewer::Update(); CAnimViewer::Update();
CTimer::Update(); CTimer::Update();
SetLightsWithTimeOfDayColour(Scene.world); SetLightsWithTimeOfDayColour(Scene.world);