Skip to content

Commit

Permalink
Rework & update
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX committed Sep 5, 2024
1 parent 480363e commit fc57137
Show file tree
Hide file tree
Showing 15 changed files with 647 additions and 95 deletions.
87 changes: 87 additions & 0 deletions Client/game_sa/CEntitySA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ eEntityStatus CEntitySA::GetEntityStatus()

RwFrame* CEntitySA::GetFrameFromId(int id)
{
if (!m_pInterface->m_pRwObject)
return nullptr;

// CClumpModelInfo::GetFrameFromId
return ((RwFrame*(_cdecl*)(RpClump*, int))0x4C53C0)(m_pInterface->m_pRwObject, id);
}
Expand Down Expand Up @@ -673,3 +676,87 @@ bool CEntitySA::GetUnderwater()
{
return m_pInterface->bUnderwater;
}

bool CEntitySA::GetFramePosition(const std::string& frameName, CVector& position)
{
RpClump* clump = GetRpClump();
if (!clump)
return false;

RwFrame* frame = pGame->GetRenderWareSA()->GetFrameFromName(clump, frameName);
if (!frame)
return false;

pGame->GetRenderWareSA()->RwMatrixGetPosition(frame->modelling, position);
return true;
}

bool CEntitySA::GetFrameRotation(const std::string& frameName, CVector& rotation)
{
RpClump* clump = GetRpClump();
if (!clump)
return false;

RwFrame* frame = pGame->GetRenderWareSA()->GetFrameFromName(clump, frameName);
if (!frame)
return false;

pGame->GetRenderWareSA()->RwMatrixGetRotation(frame->modelling, rotation);
return true;
}

bool CEntitySA::GetFrameScale(const std::string& frameName, CVector& scale)
{
RpClump* clump = GetRpClump();
if (!clump)
return false;

RwFrame* frame = pGame->GetRenderWareSA()->GetFrameFromName(clump, frameName);
if (!frame)
return false;

pGame->GetRenderWareSA()->RwMatrixGetScale(frame->modelling, scale);
return true;
}

bool CEntitySA::SetFramePosition(const std::string& frameName, const CVector& position)
{
RpClump* clump = GetRpClump();
if (!clump)
return false;

RwFrame* frame = pGame->GetRenderWareSA()->GetFrameFromName(clump, frameName);
if (!frame)
return false;

pGame->GetRenderWareSA()->RwMatrixSetPosition(frame->modelling, position);
return true;
}

bool CEntitySA::SetFrameRotation(const std::string& frameName, const CVector& rotation)
{
RpClump* clump = GetRpClump();
if (!clump)
return false;

RwFrame* frame = pGame->GetRenderWareSA()->GetFrameFromName(clump, frameName);
if (!frame)
return false;

pGame->GetRenderWareSA()->RwMatrixSetRotation(frame->modelling, rotation);
return true;
}

bool CEntitySA::SetFrameScale(const std::string& frameName, const CVector& scale)
{
RpClump* clump = GetRpClump();
if (!clump)
return false;

RwFrame* frame = pGame->GetRenderWareSA()->GetFrameFromName(clump, frameName);
if (!frame)
return false;

pGame->GetRenderWareSA()->RwMatrixSetScale(frame->modelling, scale);
return true;
}
8 changes: 8 additions & 0 deletions Client/game_sa/CEntitySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ class CEntitySA : public virtual CEntity
bool GetBonePosition(eBone boneId, CVector& position);
bool SetBonePosition(eBone boneId, const CVector& position);

bool GetFramePosition(const std::string& frameName, CVector& position);
bool GetFrameRotation(const std::string& frameName, CVector& rotation);
bool GetFrameScale(const std::string& frameName, CVector& scale);

bool SetFramePosition(const std::string& frameName, const CVector& position);
bool SetFrameRotation(const std::string& frameName, const CVector& rotation);
bool SetFrameScale(const std::string& frameName, const CVector& scale);

// CEntitySA interface
virtual void OnChangingPosition(const CVector& vecNewPosition) {}

Expand Down
34 changes: 0 additions & 34 deletions Client/game_sa/CObjectSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,37 +304,3 @@ void CObjectSA::ResetScale()
{
SetScale(1.0f, 1.0f, 1.0f);
}

bool CObjectSA::SetFramePosition(const std::string& frameName, const CVector& position)
{
RpClump* clump = GetInterface()->m_pRwObject;
if (!clump)
return false;

RwFrame* frame = ((RwFrame*(__cdecl*)(RpClump*, const char*))0x4C5400)(clump, frameName.c_str());
if (!frame)
return false;

pGame->GetRenderWareSA()->RwMatrixSetPosition(frame->modelling, position);
return true;
}

bool CObjectSA::GetObjectParentToRootMatrix(CMatrix& matrixOut)
{
RpClump* clump = GetInterface()->m_pRwObject;
if (!clump)
return false;

CMatrix newMatrix;

RwFrame* parentFrame = static_cast<RwFrame*>(clump->object.parent);
for (; parentFrame && parentFrame != parentFrame->root; parentFrame = static_cast<RwFrame*>(parentFrame->object.parent))
{
CMatrix frameMatrix;
pGame->GetRenderWareSA()->RwMatrixToCMatrix(parentFrame->modelling, frameMatrix);
newMatrix = newMatrix * frameMatrix;
}

matrixOut = newMatrix;
return true;
}
3 changes: 0 additions & 3 deletions Client/game_sa/CObjectSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ class CObjectSA : public virtual CObject, public virtual CPhysicalSA
CVector* GetScale();
void ResetScale();

bool SetFramePosition(const std::string& frameName, const CVector& position);
bool GetObjectParentToRootMatrix(CMatrix& matrixOut);

private:
void CheckForGangTag();
};
Loading

0 comments on commit fc57137

Please sign in to comment.