1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-01 02:25:55 +00:00
re3/src/objects/CutsceneObject.cpp

154 lines
3.6 KiB
C++
Raw Normal View History

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"
#include "RwHelper.h"
2019-06-30 10:53:39 +00:00
#include "Lights.h"
#include "PointLights.h"
#include "RpAnimBlend.h"
#include "AnimBlendClumpData.h"
#include "Bones.h"
#include "Renderer.h"
#include "ModelIndices.h"
#include "Shadows.h"
2019-06-30 10:53:39 +00:00
#include "Timecycle.h"
2019-05-15 14:52:37 +00:00
#include "CutsceneObject.h"
CCutsceneObject::CCutsceneObject(void)
{
SetStatus(STATUS_SIMPLE);
bUsesCollision = false;
2019-06-27 12:17:42 +00:00
bStreamingDontDelete = true;
ObjectCreatedBy = CUTSCENE_OBJECT;
m_fMass = 1.0f;
m_fTurnMass = 1.0f;
#ifdef PED_SKIN
bRenderHead = true;
bRenderRightHand = true;
bRenderLeftHand = true;
#endif
}
void
CCutsceneObject::SetModelIndex(uint32 id)
{
CEntity::SetModelIndex(id);
assert(RwObjectGetType(m_rwObject) == rpCLUMP);
RpAnimBlendClumpInit((RpClump*)m_rwObject);
2021-01-13 12:06:31 +00:00
(*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity3d = &m_vecMoveSpeed;
(*RPANIMBLENDCLUMPDATA(m_rwObject))->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION_3D;
}
void
CCutsceneObject::ProcessControl(void)
{
CPhysical::ProcessControl();
if(CTimer::GetTimeStep() < 1/100.0f)
m_vecMoveSpeed *= 100.0f;
else
m_vecMoveSpeed *= 1.0f/CTimer::GetTimeStep();
ApplyMoveSpeed();
#ifdef PED_SKIN
if(IsClumpSkinned(GetClump()))
UpdateRpHAnim();
#endif
}
static RpMaterial*
MaterialSetAlpha(RpMaterial *material, void *data)
{
((RwRGBA*)RpMaterialGetColor(material))->alpha = (uint8)(uintptr)data;
return material;
}
void
CCutsceneObject::PreRender(void)
{
if(IsPedModel(GetModelIndex())){
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]);
// For some reason xbox/android limbs are transparent here...
RpGeometry *geometry = RpAtomicGetGeometry(GetFirstAtomic(GetClump()));
RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR);
RpGeometryForAllMaterials(geometry, MaterialSetAlpha, (void*)255);
}
}
void
CCutsceneObject::Render(void)
{
#ifdef PED_SKIN
if(IsClumpSkinned(GetClump())){
if(bRenderLeftHand) RenderLimb(BONE_Lhand);
if(bRenderRightHand) RenderLimb(BONE_Rhand);
if(bRenderHead) RenderLimb(BONE_head);
}
#endif
CObject::Render();
}
#ifdef PED_SKIN
void
CCutsceneObject::RenderLimb(int32 bone)
{
RpAtomic *atomic;
2020-05-05 11:48:35 +00:00
CPedModelInfo *mi = (CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex());
switch(bone){
case BONE_head:
atomic = mi->getHead();
break;
case BONE_Lhand:
atomic = mi->getLeftHand();
break;
case BONE_Rhand:
atomic = mi->getRightHand();
break;
default:
return;
}
if(atomic){
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
int idx = RpHAnimIDGetIndex(hier, bone);
RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
RwFrame *frame = RpAtomicGetFrame(atomic);
*RwFrameGetMatrix(frame) = *mat;
RwFrameUpdateObjects(frame);
RpAtomicRender(atomic);
}
}
#endif
bool
CCutsceneObject::SetupLighting(void)
{
ActivateDirectional();
SetAmbientColoursForPedsCarsAndObjects();
if(bRenderScorched){
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
}else{
CVector coors = GetPosition();
float lighting = CPointLights::GenerateLightsAffectingObject(&coors);
2019-06-22 09:42:21 +00:00
if(!bHasBlip && lighting != 1.0f){
SetAmbientAndDirectionalColours(lighting);
return true;
}
}
return false;
}
void
CCutsceneObject::RemoveLighting(bool reset)
{
CRenderer::RemoveVehiclePedLights(this, reset);
}