2019-05-15 14:52:37 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2019-06-17 08:30:02 +00:00
|
|
|
#include "main.h"
|
2020-04-23 20:25:18 +00:00
|
|
|
#include "RwHelper.h"
|
2019-06-30 10:53:39 +00:00
|
|
|
#include "Lights.h"
|
2019-06-12 19:17:02 +00:00
|
|
|
#include "PointLights.h"
|
|
|
|
#include "RpAnimBlend.h"
|
|
|
|
#include "AnimBlendClumpData.h"
|
2020-04-23 20:25:18 +00:00
|
|
|
#include "Bones.h"
|
2019-06-12 19:17:02 +00:00
|
|
|
#include "Renderer.h"
|
|
|
|
#include "ModelIndices.h"
|
|
|
|
#include "Shadows.h"
|
2019-06-30 10:53:39 +00:00
|
|
|
#include "Timecycle.h"
|
2020-07-29 09:17:53 +00:00
|
|
|
#include "CutsceneShadow.h"
|
2019-05-15 14:52:37 +00:00
|
|
|
#include "CutsceneObject.h"
|
2020-07-29 09:17:53 +00:00
|
|
|
#include "ModelIndices.h"
|
|
|
|
#include "RpAnimBlend.h"
|
|
|
|
|
2019-06-12 18:07:37 +00:00
|
|
|
|
|
|
|
CCutsceneObject::CCutsceneObject(void)
|
|
|
|
{
|
2020-04-30 13:45:45 +00:00
|
|
|
SetStatus(STATUS_SIMPLE);
|
2019-06-12 18:07:37 +00:00
|
|
|
bUsesCollision = false;
|
2019-06-27 12:17:42 +00:00
|
|
|
bStreamingDontDelete = true;
|
2019-06-12 18:07:37 +00:00
|
|
|
ObjectCreatedBy = CUTSCENE_OBJECT;
|
|
|
|
m_fMass = 1.0f;
|
|
|
|
m_fTurnMass = 1.0f;
|
2020-07-29 09:17:53 +00:00
|
|
|
|
2020-07-31 18:21:58 +00:00
|
|
|
m_pAttachTo = nil;
|
|
|
|
m_pAttachmentObject = nil;
|
|
|
|
m_pShadow = nil;
|
2020-07-29 09:17:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CCutsceneObject::~CCutsceneObject(void)
|
|
|
|
{
|
|
|
|
if ( m_pShadow )
|
|
|
|
{
|
|
|
|
delete m_pShadow;
|
2020-07-31 18:21:58 +00:00
|
|
|
m_pShadow = nil;
|
2020-07-29 09:17:53 +00:00
|
|
|
}
|
2019-06-12 18:07:37 +00:00
|
|
|
}
|
2019-06-12 19:17:02 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
CCutsceneObject::SetModelIndex(uint32 id)
|
|
|
|
{
|
|
|
|
CEntity::SetModelIndex(id);
|
|
|
|
assert(RwObjectGetType(m_rwObject) == rpCLUMP);
|
|
|
|
RpAnimBlendClumpInit((RpClump*)m_rwObject);
|
2021-01-13 12:06:38 +00:00
|
|
|
(*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity3d = &m_vecMoveSpeed;
|
2019-06-12 19:17:02 +00:00
|
|
|
(*RPANIMBLENDCLUMPDATA(m_rwObject))->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION_3D;
|
|
|
|
}
|
|
|
|
|
2020-07-29 09:17:53 +00:00
|
|
|
void
|
|
|
|
CCutsceneObject::CreateShadow(void)
|
|
|
|
{
|
2021-01-11 17:53:15 +00:00
|
|
|
// empty in LCS
|
|
|
|
/*
|
2020-07-29 09:17:53 +00:00
|
|
|
if ( IsPedModel(GetModelIndex()) )
|
|
|
|
{
|
|
|
|
m_pShadow = new CCutsceneShadow();
|
|
|
|
if (!m_pShadow->IsInitialized())
|
|
|
|
m_pShadow->Create(m_rwObject, 6, true, 4, true);
|
|
|
|
}
|
2021-01-11 17:53:15 +00:00
|
|
|
*/
|
2020-07-29 09:17:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-12 19:17:02 +00:00
|
|
|
void
|
|
|
|
CCutsceneObject::ProcessControl(void)
|
|
|
|
{
|
|
|
|
CPhysical::ProcessControl();
|
|
|
|
|
2020-07-29 09:17:53 +00:00
|
|
|
if ( m_pAttachTo )
|
|
|
|
{
|
|
|
|
if ( m_pAttachmentObject )
|
|
|
|
GetMatrix() = CMatrix((RwMatrix*)m_pAttachTo);
|
|
|
|
else
|
|
|
|
GetMatrix() = CMatrix(RwFrameGetLTM((RwFrame*)m_pAttachTo));
|
|
|
|
}
|
2019-06-12 19:17:02 +00:00
|
|
|
else
|
2020-07-29 09:17:53 +00:00
|
|
|
{
|
|
|
|
if(CTimer::GetTimeStep() < 1/100.0f)
|
|
|
|
m_vecMoveSpeed *= 100.0f;
|
|
|
|
else
|
|
|
|
m_vecMoveSpeed *= 1.0f/CTimer::GetTimeStep();
|
|
|
|
|
|
|
|
ApplyMoveSpeed();
|
|
|
|
}
|
2020-04-23 20:25:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static RpMaterial*
|
|
|
|
MaterialSetAlpha(RpMaterial *material, void *data)
|
|
|
|
{
|
|
|
|
((RwRGBA*)RpMaterialGetColor(material))->alpha = (uint8)(uintptr)data;
|
|
|
|
return material;
|
2019-06-12 19:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CCutsceneObject::PreRender(void)
|
|
|
|
{
|
2020-07-29 09:17:53 +00:00
|
|
|
if ( m_pAttachTo )
|
|
|
|
{
|
|
|
|
if ( m_pAttachmentObject )
|
|
|
|
{
|
|
|
|
m_pAttachmentObject->UpdateRpHAnim();
|
|
|
|
GetMatrix() = CMatrix((RwMatrix*)m_pAttachTo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GetMatrix() = CMatrix(RwFrameGetLTM((RwFrame*)m_pAttachTo));
|
|
|
|
|
|
|
|
if ( RwObjectGetType(m_rwObject) == rpCLUMP && IsClumpSkinned(GetClump()) )
|
|
|
|
{
|
|
|
|
RpAtomic *atomic = GetFirstAtomic(GetClump());
|
|
|
|
atomic->boundingSphere.center = (*RPANIMBLENDCLUMPDATA(GetClump()))->frames[0].hanimFrame->t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( RwObjectGetType(m_rwObject) == rpCLUMP )
|
|
|
|
UpdateRpHAnim();
|
|
|
|
|
|
|
|
if(IsPedModel(GetModelIndex()))
|
|
|
|
{
|
2020-07-31 18:21:58 +00:00
|
|
|
if ( m_pShadow == nil )
|
2020-07-29 09:17:53 +00:00
|
|
|
{
|
|
|
|
CShadows::StoreShadowForPedObject(this,
|
|
|
|
CTimeCycle::m_fShadowDisplacementX[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowDisplacementY[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowFrontX[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowFrontY[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowSideX[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowSideY[CTimeCycle::m_CurrentStoredValue]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_pShadow->IsInitialized() )
|
|
|
|
m_pShadow->UpdateForCutscene();
|
|
|
|
|
|
|
|
CShadows::StoreShadowForCutscenePedObject(this,
|
|
|
|
CTimeCycle::m_fShadowDisplacementX[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowDisplacementY[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowFrontX[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowFrontY[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowSideX[CTimeCycle::m_CurrentStoredValue],
|
|
|
|
CTimeCycle::m_fShadowSideY[CTimeCycle::m_CurrentStoredValue]);
|
|
|
|
}
|
|
|
|
|
2020-04-23 20:25:18 +00:00
|
|
|
// For some reason xbox/android limbs are transparent here...
|
|
|
|
RpGeometry *geometry = RpAtomicGetGeometry(GetFirstAtomic(GetClump()));
|
|
|
|
RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR);
|
|
|
|
RpGeometryForAllMaterials(geometry, MaterialSetAlpha, (void*)255);
|
|
|
|
}
|
2019-06-12 19:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CCutsceneObject::Render(void)
|
|
|
|
{
|
2021-01-11 17:53:15 +00:00
|
|
|
SetCullMode(rwCULLMODECULLNONE);
|
2019-06-12 19:17:02 +00:00
|
|
|
CObject::Render();
|
2021-01-11 17:53:15 +00:00
|
|
|
SetCullMode(rwCULLMODECULLBACK);
|
2019-06-12 19:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CCutsceneObject::SetupLighting(void)
|
|
|
|
{
|
|
|
|
ActivateDirectional();
|
|
|
|
SetAmbientColoursForPedsCarsAndObjects();
|
|
|
|
|
|
|
|
if(bRenderScorched){
|
|
|
|
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
|
|
|
|
}else{
|
|
|
|
CVector coors = GetPosition();
|
|
|
|
float lighting = CPointLights::GenerateLightsAffectingObject(&coors);
|
2020-07-29 09:17:53 +00:00
|
|
|
if(lighting != 1.0f){
|
2019-06-12 19:17:02 +00:00
|
|
|
SetAmbientAndDirectionalColours(lighting);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CCutsceneObject::RemoveLighting(bool reset)
|
|
|
|
{
|
|
|
|
CRenderer::RemoveVehiclePedLights(this, reset);
|
|
|
|
}
|