summaryrefslogtreecommitdiffstats
path: root/src/objects/CutsceneHead.cpp
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-07-07 13:09:11 +0200
committeraap <aap@papnet.eu>2019-07-07 13:09:11 +0200
commit53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb (patch)
treefc65a6c40fa719f9d43be9e0e15be79c490135e0 /src/objects/CutsceneHead.cpp
parentfinished CPhysical (diff)
downloadre3-53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb.tar
re3-53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb.tar.gz
re3-53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb.tar.bz2
re3-53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb.tar.lz
re3-53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb.tar.xz
re3-53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb.tar.zst
re3-53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb.zip
Diffstat (limited to 'src/objects/CutsceneHead.cpp')
-rw-r--r--src/objects/CutsceneHead.cpp118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/objects/CutsceneHead.cpp b/src/objects/CutsceneHead.cpp
new file mode 100644
index 00000000..a9c47777
--- /dev/null
+++ b/src/objects/CutsceneHead.cpp
@@ -0,0 +1,118 @@
+#include "common.h"
+#include <rpskin.h>
+#include "patcher.h"
+#include "main.h"
+#include "RwHelper.h"
+#include "RpAnimBlend.h"
+#include "AnimBlendClumpData.h"
+#include "Directory.h"
+#include "CutsceneMgr.h"
+#include "Streaming.h"
+#include "CutsceneHead.h"
+
+
+CCutsceneHead::CCutsceneHead(CObject *obj)
+{
+ RpAtomic *atm;
+
+ assert(RwObjectGetType(obj->m_rwObject) == rpCLUMP);
+ m_pHeadNode = RpAnimBlendClumpFindFrame((RpClump*)obj->m_rwObject, "Shead")->frame;
+ atm = (RpAtomic*)GetFirstObject(m_pHeadNode);
+ if(atm){
+ assert(RwObjectGetType(atm) == rpATOMIC);
+ RpAtomicSetFlags(atm, RpAtomicGetFlags(atm) & ~rpATOMICRENDER);
+ }
+}
+
+void
+CCutsceneHead::CreateRwObject(void)
+{
+ RpAtomic *atm;
+
+ CEntity::CreateRwObject();
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ RpSkinAtomicSetHAnimHierarchy(atm, RpHAnimFrameGetHierarchy(GetFirstChild(RpClumpGetFrame((RpClump*)m_rwObject))));
+}
+
+void
+CCutsceneHead::DeleteRwObject(void)
+{
+ CEntity::DeleteRwObject();
+}
+
+void
+CCutsceneHead::ProcessControl(void)
+{
+ RpAtomic *atm;
+ RpHAnimHierarchy *hier;
+
+ CPhysical::ProcessControl();
+
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
+ UpdateRwFrame();
+
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ hier = RpSkinAtomicGetHAnimHierarchy(atm);
+ RpHAnimHierarchyAddAnimTime(hier, CTimer::GetTimeStepNonClipped()/50.0f);
+}
+
+void
+CCutsceneHead::Render(void)
+{
+ RpAtomic *atm;
+
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
+ UpdateRwFrame();
+
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ RpHAnimHierarchyUpdateMatrices(RpSkinAtomicGetHAnimHierarchy(atm));
+
+ CObject::Render();
+}
+
+void
+CCutsceneHead::PlayAnimation(const char *animName)
+{
+ RpAtomic *atm;
+ RpHAnimHierarchy *hier;
+ RpHAnimAnimation *anim;
+ uint32 offset, size;
+ RwStream *stream;
+
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ hier = RpSkinAtomicGetHAnimHierarchy(atm);
+
+ sprintf(gString, "%s.anm", animName);
+
+ if(CCutsceneMgr::ms_pCutsceneDir->FindItem(gString, offset, size)){
+ stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "ANIM\\CUTS.IMG");
+ assert(stream);
+
+ CStreaming::MakeSpaceFor(size*2048);
+ CStreaming::ImGonnaUseStreamingMemory();
+
+ RwStreamSkip(stream, offset*2048);
+ if(RwStreamFindChunk(stream, rwID_HANIMANIMATION, nil, nil)){
+ anim = RpHAnimAnimationStreamRead(stream);
+ RpHAnimHierarchySetCurrentAnim(hier, anim);
+ }
+
+ CStreaming::IHaveUsedStreamingMemory();
+
+ RwStreamClose(stream, nil);
+ }
+}
+
+STARTPATCHES
+ InjectHook(0x4BA650, &CCutsceneHead::CreateRwObject_, PATCH_JUMP);
+ InjectHook(0x4BA690, &CCutsceneHead::DeleteRwObject_, PATCH_JUMP);
+ InjectHook(0x4BA760, &CCutsceneHead::ProcessControl_, PATCH_JUMP);
+ InjectHook(0x4BA800, &CCutsceneHead::Render_, PATCH_JUMP);
+ InjectHook(0x4BA6A0, &CCutsceneHead::PlayAnimation, PATCH_JUMP);
+ENDPATCHES