cleaned up and fixed animviewer

This commit is contained in:
aap 2020-06-08 13:01:07 +02:00
parent be9954ecc6
commit 94e5b24fc8
3 changed files with 76 additions and 92 deletions

View File

@ -47,6 +47,12 @@ 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) {
#ifdef FIX_BUGS
#ifdef PED_SKIN
if(pTarget->IsPed())
((CPed*)pTarget)->UpdateRpHAnim();
#endif
#endif
pTarget->Render(); pTarget->Render();
CRenderer::RenderOneNonRoad(pTarget); CRenderer::RenderOneNonRoad(pTarget);
} }
@ -67,11 +73,7 @@ CAnimViewer::Initialise(void) {
CReferences::Init(); CReferences::Init();
TheCamera.Init(); TheCamera.Init();
TheCamera.SetRwCamera(Scene.camera); TheCamera.SetRwCamera(Scene.camera);
TheCamera.Cams[TheCamera.ActiveCam].Distance = 5.0f;
// I didn't get which camera og code selects.
for (int i = 0; i < 3; i++) {
TheCamera.Cams[i].Distance = 5.0f;
}
gbModelViewer = true; gbModelViewer = true;
CHud::m_Wants_To_Draw_Hud = false; CHud::m_Wants_To_Draw_Hud = false;
@ -146,30 +148,33 @@ int
LastPedModelId(int modelId) LastPedModelId(int modelId)
{ {
CBaseModelInfo *model; CBaseModelInfo *model;
for (int i = modelId; i >= 0; i--) { for(;;){
model = CModelInfo::GetModelInfo(i); assert(modelId < MODELINFOSIZE);
if (model->GetModelType() == MITYPE_PED) model = CModelInfo::GetModelInfo(modelId);
return i; if (model && model->GetModelType() == MITYPE_PED)
break;
modelId--;
} }
return modelId; return modelId;
} }
int int
LastVehicleModelId(int modelId) FirstCarModelId(int modelId)
{ {
CBaseModelInfo *model; CBaseModelInfo *model;
for (int i = modelId; i >= 0; i--) { for(;;){
model = CModelInfo::GetModelInfo(i); assert(modelId < MODELINFOSIZE);
if (model->GetModelType() == MITYPE_VEHICLE) model = CModelInfo::GetModelInfo(modelId);
return i; if (model && model->GetModelType() == MITYPE_VEHICLE)
break;
modelId++;
} }
return modelId; return modelId;
} }
// It's me that named this.
int int
FindMeAModelID(int modelId, int wantedChange) NextModelId(int modelId, int wantedChange)
{ {
// Max. 2 trials wasn't here, it's me that added it. // Max. 2 trials wasn't here, it's me that added it.
@ -220,7 +225,6 @@ CAnimViewer::Update(void)
AssocGroupId animGroup = ASSOCGRP_STD; AssocGroupId animGroup = ASSOCGRP_STD;
int nextModelId = modelId; int nextModelId = modelId;
CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId); CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId);
CEntity *newEntity = nil;
if (modelInfo->GetModelType() == MITYPE_PED) { if (modelInfo->GetModelType() == MITYPE_PED) {
int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup; int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup;
@ -261,40 +265,30 @@ CAnimViewer::Update(void)
if (modelInfo->GetModelType() == MITYPE_VEHICLE) { if (modelInfo->GetModelType() == 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 pTarget = new CAutomobile(modelId, RANDOM_VEHICLE);
/* if (veh->m_vehicleType == VEHICLE_TYPE_BOAT) } else if (veh->m_vehicleType == VEHICLE_TYPE_BOAT) {
{ pTarget = new CBoat(modelId, RANDOM_VEHICLE);
v33 = (CBoat*)CVehicle::operator new((CVehicle*)0x488, v6); } else {
CBoat::CBoat(v33, modelId, 1u); pTarget = new CObject(modelId, true);
newEntity = (int)v33;
pTarget = (int)v33;
}
else
{
*/ newEntity = pTarget = new CObject(modelId, true);
if (!modelInfo->GetColModel()) { if (!modelInfo->GetColModel()) {
modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1); modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1);
} }
// }
} else {
newEntity = pTarget = new CAutomobile(modelId, RANDOM_VEHICLE);
newEntity->SetStatus(STATUS_ABANDONED);
} }
newEntity->bIsStuck = true; pTarget->SetStatus(STATUS_ABANDONED);
} else if (modelInfo->GetModelType() == MITYPE_PED) { } else if (modelInfo->GetModelType() == MITYPE_PED) {
pTarget = newEntity = new CPed(PEDTYPE_CIVMALE); pTarget = new CPed(PEDTYPE_CIVMALE);
newEntity->SetModelIndex(modelId); pTarget->SetModelIndex(modelId);
} else { } else {
newEntity = pTarget = new CObject(modelId, true); pTarget = new CObject(modelId, true);
if (!modelInfo->GetColModel()) if (!modelInfo->GetColModel())
{ {
modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1); modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1);
} }
newEntity->bIsStuck = true; pTarget->SetStatus(STATUS_ABANDONED);
} }
newEntity->SetPosition(0.0f, 0.0f, 0.0f); pTarget->SetPosition(0.0f, 0.0f, 0.0f);
CWorld::Add(newEntity); CWorld::Add(pTarget);
TheCamera.TakeControl(pTarget, CCam::MODE_MODELVIEW, JUMP_CUT, CAMCONTROL_SCRIPT); TheCamera.TakeControl(pTarget, CCam::MODE_MODELVIEW, JUMP_CUT, CAMCONTROL_SCRIPT);
} }
if (pTarget->IsVehicle() || pTarget->IsPed() || pTarget->IsObject()) { if (pTarget->IsVehicle() || pTarget->IsPed() || pTarget->IsObject()) {
@ -302,43 +296,26 @@ CAnimViewer::Update(void)
} }
pTarget->GetMatrix().GetPosition().z = 0.0f; pTarget->GetMatrix().GetPosition().z = 0.0f;
if (modelInfo->GetModelType() != MITYPE_PED) { if (modelInfo->GetModelType() == MITYPE_PED) {
if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) {
nextModelId = LastPedModelId(modelId);
AsciiToUnicode("Switched to peds", gUString);
CMessages::AddMessage(gUString, 1000, 0);
} else {
// Start in mobile
if (pad->NewState.Square && !pad->OldState.Square) {
CVehicleModelInfo::LoadVehicleColours();
AsciiToUnicode("Carcols.dat reloaded", gUString);
CMessages::AddMessage(gUString, 1000, 0);
}
}
}
} else {
((CPed*)pTarget)->bKindaStayInSamePlace = true; ((CPed*)pTarget)->bKindaStayInSamePlace = true;
// Triangle in mobile // Triangle in mobile
if (pad->NewState.Square && !pad->OldState.Square) { if (pad->GetSquareJustDown()) {
reloadIFP = 1; reloadIFP = 1;
AsciiToUnicode("IFP reloaded", gUString); AsciiToUnicode("IFP reloaded", gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);
} else if (pad->NewState.Cross && !pad->OldState.Cross) { } else if (pad->GetCrossJustDown()) {
PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId);
AsciiToUnicode("Animation restarted", gUString); AsciiToUnicode("Animation restarted", gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);
} else if (pad->NewState.Circle && !pad->OldState.Circle) { } else if (pad->GetCircleJustDown()) {
PlayAnimation(pTarget->GetClump(), animGroup, ANIM_IDLE_STANCE); PlayAnimation(pTarget->GetClump(), animGroup, ANIM_IDLE_STANCE);
AsciiToUnicode("Idle animation playing", gUString); AsciiToUnicode("Idle animation playing", gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);
} else if (pad->NewState.DPadUp && pad->OldState.DPadUp == 0) { } else if (pad->GetDPadUpJustDown()) {
animId--; animId--;
if (animId < 0) { if (animId < 0) {
animId = NUM_ANIMS - 1; animId = NUM_ANIMS - 1;
@ -349,7 +326,7 @@ CAnimViewer::Update(void)
AsciiToUnicode(gString, gUString); AsciiToUnicode(gString, gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);
} else if (pad->NewState.DPadDown && !pad->OldState.DPadDown) { } else if (pad->GetDPadDownJustDown()) {
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);
@ -357,17 +334,14 @@ CAnimViewer::Update(void)
AsciiToUnicode(gString, gUString); AsciiToUnicode(gString, gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);
} else { } else if (pad->GetStartJustDown()) {
if (pad->NewState.Start && !pad->OldState.Start) {
} else { } else if (pad->GetLeftShoulder1JustDown()) {
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) { nextModelId = FirstCarModelId(modelId);
nextModelId = LastVehicleModelId(modelId);
AsciiToUnicode("Switched to vehicles", gUString); AsciiToUnicode("Switched to vehicles", gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);
} else {
// Originally it was GetPad(1)->LeftShoulder2 // Originally it was GetPad(1)->LeftShoulder2
if (pad->NewState.Triangle) { } else if (pad->NewState.Triangle) {
#ifdef PED_SKIN #ifdef PED_SKIN
if(IsClumpSkinned(pTarget->GetClump())) if(IsClumpSkinned(pTarget->GetClump()))
((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->AnimatePedColModelSkinned(pTarget->GetClump()); ((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->AnimatePedColModelSkinned(pTarget->GetClump());
@ -378,21 +352,30 @@ CAnimViewer::Update(void)
AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString); AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString);
CMessages::AddMessage(gUString, 100, 0); CMessages::AddMessage(gUString, 100, 0);
} }
} } else if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
}
if (pad->GetLeftShoulder1JustDown()) {
nextModelId = LastPedModelId(modelId);
AsciiToUnicode("Switched to peds", gUString);
CMessages::AddMessage(gUString, 1000, 0);
// Start in mobile
} else if (pad->GetSquareJustDown()) {
CVehicleModelInfo::LoadVehicleColours();
AsciiToUnicode("Carcols.dat reloaded", gUString);
CMessages::AddMessage(gUString, 1000, 0);
} }
} }
} }
if (pad->NewState.DPadLeft && pad->OldState.DPadLeft == 0) { if (pad->GetDPadLeftJustDown()) {
nextModelId = FindMeAModelID(modelId, -1); nextModelId = NextModelId(modelId, -1);
sprintf(gString, "Current model ID: %d", nextModelId); sprintf(gString, "Current model ID: %d", nextModelId);
AsciiToUnicode(gString, gUString); AsciiToUnicode(gString, gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);
} else if (pad->NewState.DPadRight && pad->OldState.DPadRight == 0) { } else if (pad->GetDPadRightJustDown()) {
nextModelId = FindMeAModelID(modelId, 1); nextModelId = NextModelId(modelId, 1);
sprintf(gString, "Current model ID: %d", nextModelId); sprintf(gString, "Current model ID: %d", nextModelId);
AsciiToUnicode(gString, gUString); AsciiToUnicode(gString, gUString);

View File

@ -1046,8 +1046,8 @@ void CPad::UpdatePads(void)
GetPad(0)->UpdateMouse(); GetPad(0)->UpdateMouse();
#ifdef XINPUT #ifdef XINPUT
GetPad(0)->AffectFromXinput(0); GetPad(0)->AffectFromXinput(m_bMapPadOneToPadTwo ? 1 : 0);
GetPad(1)->AffectFromXinput(1); GetPad(1)->AffectFromXinput(m_bMapPadOneToPadTwo ? 0 : 1);
#else #else
CapturePad(0); CapturePad(0);
#endif #endif

View File

@ -463,6 +463,7 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil); DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil);
DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil); DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil);
DebugMenuAddVarBool8("Debug", "pad 1 -> pad 2", &CPad::m_bMapPadOneToPadTwo, nil);
DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil); DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil);
#ifdef MENU_MAP #ifdef MENU_MAP
DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint);