-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dxDrawModel3D reimplementation (#3266)
- Loading branch information
Showing
23 changed files
with
323 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: game_sa/CRendererSA.cpp | ||
* PURPOSE: Game renderer class | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "StdInc.h" | ||
#include "CRendererSA.h" | ||
#include "CModelInfoSA.h" | ||
#include "CMatrix.h" | ||
#include "gamesa_renderware.h" | ||
|
||
CRendererSA::CRendererSA() | ||
{ | ||
} | ||
|
||
CRendererSA::~CRendererSA() | ||
{ | ||
} | ||
|
||
void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) | ||
{ | ||
CBaseModelInfoSAInterface* pModelInfoSAInterface = pModelInfo->GetInterface(); | ||
if (!pModelInfoSAInterface) | ||
return; | ||
|
||
RwObject* pRwObject = pModelInfoSAInterface->pRwObject; | ||
if (!pRwObject) | ||
return; | ||
|
||
RwFrame* pFrame = RpGetFrame(pRwObject); | ||
|
||
static RwMatrix rwMatrix; | ||
rwMatrix.right = (RwV3d&)matrix.vRight; | ||
rwMatrix.up = (RwV3d&)matrix.vFront; | ||
rwMatrix.at = (RwV3d&)matrix.vUp; | ||
rwMatrix.pos = (RwV3d&)matrix.vPos; | ||
RwFrameTransform(pFrame, &rwMatrix, rwCOMBINEREPLACE); | ||
|
||
if (pRwObject->type == RP_TYPE_ATOMIC) | ||
{ | ||
RpAtomic* pRpAtomic = reinterpret_cast<RpAtomic*>(pRwObject); | ||
pRpAtomic->renderCallback(reinterpret_cast<RpAtomic*>(pRwObject)); | ||
} | ||
else | ||
{ | ||
RpClump* pClump = reinterpret_cast<RpClump*>(pRwObject); | ||
RpClumpRender(pClump); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: game_sa/CRendererSA.h | ||
* PURPOSE: Game renderer class | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <game/CRenderer.h> | ||
|
||
class CRendererSA : public CRenderer | ||
{ | ||
public: | ||
CRendererSA(); | ||
~CRendererSA(); | ||
|
||
void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/deathmatch/logic/CModelRenderer.cpp | ||
* PURPOSE: 3D models renderer | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "StdInc.h" | ||
#include "game\CRenderer.h" | ||
#include "game\CVisibilityPlugins.h" | ||
|
||
bool CModelRenderer::EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix) | ||
{ | ||
if (g_pCore->IsWindowMinimized()) | ||
return false; | ||
|
||
if (pModelInfo && pModelInfo->IsLoaded()) | ||
{ | ||
m_Queue.emplace_back(pModelInfo, matrix); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void CModelRenderer::Update() | ||
{ | ||
CVisibilityPlugins* pVisibilityPlugins = g_pGame->GetVisibilityPlugins(); | ||
assert(pVisibilityPlugins); | ||
|
||
for (auto& modelDesc : m_Queue) | ||
{ | ||
// Insert transparent entities into a sorted list | ||
if (modelDesc.pModelInfo->GetIdeFlag(eModelIdeFlag::DRAW_LAST)) | ||
{ | ||
const CVector& vecCameraPosition = *(CVector*)0xB76870; // CRenderer::ms_vecCameraPosition | ||
const float fDistance = (modelDesc.matrix.GetPosition() - vecCameraPosition).Length(); | ||
|
||
pVisibilityPlugins->InsertEntityIntoEntityList(&modelDesc, fDistance, RenderEntity); | ||
} | ||
} | ||
} | ||
|
||
void CModelRenderer::Render() | ||
{ | ||
CRenderer* pRenderer = g_pGame->GetRenderer(); | ||
assert(pRenderer); | ||
|
||
// Draw opaque entities | ||
for (auto& modelDesc : m_Queue) | ||
{ | ||
if (modelDesc.pModelInfo->IsLoaded() && !modelDesc.pModelInfo->GetIdeFlag(eModelIdeFlag::DRAW_LAST)) | ||
pRenderer->RenderModel(modelDesc.pModelInfo, modelDesc.matrix); | ||
} | ||
|
||
m_Queue.clear(); | ||
} | ||
|
||
void CModelRenderer::RenderEntity(SModelToRender* modelDesc, float distance) | ||
{ | ||
if (!modelDesc->pModelInfo->IsLoaded()) | ||
return; | ||
|
||
CRenderer* pRenderer = g_pGame->GetRenderer(); | ||
assert(pRenderer); | ||
|
||
pRenderer->RenderModel(modelDesc->pModelInfo, modelDesc->matrix); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto v1.0 | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/deathmatch/logic/CModelRenderer.h | ||
* PURPOSE: 3D models renderer | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
class CModelRenderer final | ||
{ | ||
public: | ||
struct SModelToRender final | ||
{ | ||
CModelInfo* pModelInfo; | ||
CMatrix matrix; | ||
|
||
SModelToRender(CModelInfo* pModelInfo, const CMatrix& matrix) : | ||
pModelInfo(pModelInfo), | ||
matrix(matrix) | ||
{ | ||
} | ||
}; | ||
|
||
bool EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix); | ||
|
||
void Update(); | ||
|
||
void Render(); | ||
|
||
static void RenderEntity(SModelToRender* entity, float distance); | ||
|
||
private: | ||
|
||
std::vector<SModelToRender> m_Queue; | ||
}; |
Oops, something went wrong.