Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dxDrawModel3D lighting #3904

Merged
merged 43 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
34f939d
Add SetPaused to timer class
jvstns Aug 27, 2024
66440b7
Add pause variables to class
jvstns Aug 27, 2024
799913c
Add new functions "pauseTimer" and "isTimerPaused"
jvstns Aug 27, 2024
005ffe7
Add new timer function defs
jvstns Aug 27, 2024
5115648
Add "PauseTimer" to CLuaTimerManager
jvstns Aug 27, 2024
69e2aee
Def "PauseTimer" in CLuaTimerManager
jvstns Aug 27, 2024
746ad73
Adds pauseTimer() and isTimerPaused()
jvstns Aug 27, 2024
7400bb9
Add new timer function defs
jvstns Aug 27, 2024
ec73d91
Add "PauseTimer" to CLuaTimerManager
jvstns Aug 27, 2024
5372afa
Def "PauseTimer" in CLuaTimerManager
jvstns Aug 27, 2024
a38431f
Merge branch 'multitheftauto:master' into Implement/NewTimerFuncs
jvstns Aug 27, 2024
968bd03
fix typo
jvstns Aug 27, 2024
07da2bc
fix typo
jvstns Aug 27, 2024
d314dab
A few minor adjustments
jvstns Aug 27, 2024
22a4177
Minor adjustments #2
jvstns Aug 27, 2024
ca63aa4
Update to ArgumentParser
jvstns Aug 27, 2024
36c6a9c
Update to ArgumentParser
jvstns Aug 27, 2024
a468297
minor adjustment
jvstns Aug 27, 2024
850ae8e
Minor adjustment to function name
jvstns Aug 27, 2024
769ae40
Updated to ArgumentParser and changed function name
jvstns Aug 27, 2024
4ba657a
Update to ArgumentParser
jvstns Aug 27, 2024
aa3aaa9
Minor adjustment to function name
jvstns Aug 27, 2024
4b70ef2
Minor adjustment to function name
jvstns Aug 27, 2024
984132e
Removed hungarian notation
jvstns Aug 28, 2024
c937f0e
Removed hungarian notation
jvstns Aug 28, 2024
910b54f
Removed hungarian notation & useless luaState
jvstns Aug 28, 2024
ead0c52
Removed hungarian notation & useless luaState
jvstns Aug 28, 2024
aa1fdba
Removed hungarian notations
jvstns Aug 28, 2024
99da369
Removed hungarian notation
jvstns Aug 28, 2024
9e8bc21
Removed hungarian notation & useless luaState
jvstns Aug 28, 2024
44a72f2
Removed hungarian notation & useless luaState
jvstns Aug 28, 2024
76225a7
Removed hungarian notations
jvstns Aug 28, 2024
116085e
Removed hungarian notations
jvstns Aug 28, 2024
8940cd9
Merge branch 'master' into Implement/NewTimerFuncs
tederis Aug 28, 2024
a43fbcd
Merge branch 'master' of https://github.com/tederis/mtasa-blue
tederis Sep 4, 2024
772ec20
Merge branch 'master' of https://github.com/tederis/mtasa-blue
tederis Sep 4, 2024
53954bf
Merge branch 'multitheftauto:master' into master
tederis Sep 5, 2024
ce31e1b
Merge branch 'multitheftauto:master' into master
tederis Sep 6, 2024
5ff7bd1
Merge branch 'multitheftauto:master' into master
tederis Sep 11, 2024
e7eeb22
Merge branch 'multitheftauto:master' into master
tederis Dec 24, 2024
c12f678
dxDrawModel3D lighting argument
tederis Dec 24, 2024
da5d705
Cleanup
tederis Dec 24, 2024
876ce72
Merge branch 'master' into 3dmodel_lighting
tederis Dec 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Client/game_sa/CRendererSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "CMatrix.h"
#include "gamesa_renderware.h"

#define SetLightColoursForPedsCarsAndObjects(fMult) ((RpLight*(__cdecl*)(float))0x735D90)(fMult)
#define SetAmbientColours() ((RpLight*(__cdecl*)())0x735D30)()

TheNormalnij marked this conversation as resolved.
Show resolved Hide resolved
CRendererSA::CRendererSA()
{
}
Expand All @@ -23,7 +26,7 @@ CRendererSA::~CRendererSA()
{
}

void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix)
void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix, float lighting)
{
CBaseModelInfoSAInterface* pModelInfoSAInterface = pModelInfo->GetInterface();
if (!pModelInfoSAInterface)
Expand All @@ -40,7 +43,10 @@ void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix)
rwMatrix.up = (RwV3d&)matrix.vFront;
rwMatrix.at = (RwV3d&)matrix.vUp;
rwMatrix.pos = (RwV3d&)matrix.vPos;
RwFrameTransform(pFrame, &rwMatrix, rwCOMBINEREPLACE);
RwFrameTransform(pFrame, &rwMatrix, rwCOMBINEREPLACE);

// Setup ambient light multiplier
SetLightColoursForPedsCarsAndObjects(lighting);

if (pRwObject->type == RP_TYPE_ATOMIC)
{
Expand All @@ -52,4 +58,7 @@ void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix)
RpClump* pClump = reinterpret_cast<RpClump*>(pRwObject);
RpClumpRender(pClump);
}

// Restore ambient light
SetAmbientColours();
}
2 changes: 1 addition & 1 deletion Client/game_sa/CRendererSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ class CRendererSA : public CRenderer
CRendererSA();
~CRendererSA();

void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) override;
void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix, float lighting) override;
};
8 changes: 4 additions & 4 deletions Client/mods/deathmatch/logic/CModelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include "game\CRenderer.h"
#include "game\CVisibilityPlugins.h"

bool CModelRenderer::EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix)
bool CModelRenderer::EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix, float lighting)
{
if (g_pCore->IsWindowMinimized())
return false;

if (pModelInfo && pModelInfo->IsLoaded())
{
m_Queue.emplace_back(pModelInfo, matrix);
m_Queue.emplace_back(pModelInfo, matrix, lighting);
return true;
}

Expand Down Expand Up @@ -54,7 +54,7 @@ void CModelRenderer::Render()
for (auto& modelDesc : m_Queue)
{
if (modelDesc.pModelInfo->IsLoaded() && !modelDesc.pModelInfo->GetIdeFlag(eModelIdeFlag::DRAW_LAST))
pRenderer->RenderModel(modelDesc.pModelInfo, modelDesc.matrix);
pRenderer->RenderModel(modelDesc.pModelInfo, modelDesc.matrix, modelDesc.lighting);
}

m_Queue.clear();
Expand All @@ -68,5 +68,5 @@ void CModelRenderer::RenderEntity(SModelToRender* modelDesc, float distance)
CRenderer* pRenderer = g_pGame->GetRenderer();
assert(pRenderer);

pRenderer->RenderModel(modelDesc->pModelInfo, modelDesc->matrix);
pRenderer->RenderModel(modelDesc->pModelInfo, modelDesc->matrix, modelDesc->lighting);
}
8 changes: 5 additions & 3 deletions Client/mods/deathmatch/logic/CModelRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ class CModelRenderer final
{
CModelInfo* pModelInfo;
CMatrix matrix;
float lighting;

SModelToRender(CModelInfo* pModelInfo, const CMatrix& matrix) :
SModelToRender(CModelInfo* pModelInfo, const CMatrix& matrix, float lighting = 0.0f) :
pModelInfo(pModelInfo),
matrix(matrix)
matrix(matrix),
lighting(lighting)
{
}
};

bool EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix);
bool EnqueueModel(CModelInfo* pModelInfo, const CMatrix& matrix, float lighting);

void Update();

Expand Down
4 changes: 2 additions & 2 deletions Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ bool CLuaDrawingDefs::DxDrawWiredSphere(lua_State* const luaVM, const CVector po
return true;
}

bool CLuaDrawingDefs::DxDrawModel3D(std::uint32_t modelID, CVector position, CVector rotation, const std::optional<CVector> scale)
bool CLuaDrawingDefs::DxDrawModel3D(std::uint32_t modelID, CVector position, CVector rotation, const std::optional<CVector> scale, const std::optional<float> lighting)
{
CModelInfo* pModelInfo = g_pGame->GetModelInfo(modelID);
if (!pModelInfo)
Expand All @@ -2138,5 +2138,5 @@ bool CLuaDrawingDefs::DxDrawModel3D(std::uint32_t modelID, CVector position, CVe
ConvertDegreesToRadians(rotation);

return g_pClientGame->GetModelRenderer()->EnqueueModel(pModelInfo,
CMatrix{position, rotation, scale.value_or(CVector{1.0f, 1.0f, 1.0f})});
CMatrix{position, rotation, scale.value_or(CVector{1.0f, 1.0f, 1.0f})}, lighting.value_or(0.0f));
}
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CLuaDrawingDefs : public CLuaDefs
static bool DxDrawWiredSphere(lua_State* const luaVM, const CVector position, const float radius, const std::optional<SColor> color,
const std::optional<float> lineWidth, const std::optional<unsigned int> iterations);

static bool DxDrawModel3D(std::uint32_t modelID, CVector position, CVector rotation, const std::optional<CVector> scale);
static bool DxDrawModel3D(std::uint32_t modelID, CVector position, CVector rotation, const std::optional<CVector> scale, const std::optional<float> lighting);

private:
static void AddDxMaterialClass(lua_State* luaVM);
Expand Down
2 changes: 1 addition & 1 deletion Client/sdk/game/CRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ class CRenderer
public:
virtual ~CRenderer() {}

virtual void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) = 0;
virtual void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix, float lighting) = 0;
};
Loading