mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-22 15:48:09 -05:00
Implement SetLightPosition and related (#757)
* Implement SetLightPosition and related * Update p name * style
This commit is contained in:
parent
f447397eef
commit
369f3fba22
4 changed files with 68 additions and 12 deletions
|
@ -25,8 +25,8 @@ void FUN_1003ef00(MxBool);
|
||||||
void SetAppCursor(WPARAM p_wparam);
|
void SetAppCursor(WPARAM p_wparam);
|
||||||
MxBool FUN_1003ef60();
|
MxBool FUN_1003ef60();
|
||||||
MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId);
|
MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId);
|
||||||
MxS32 UpdateLightPosition(MxS32 p_value);
|
MxS32 UpdateLightPosition(MxS32 p_increase);
|
||||||
void SetLightPosition(MxU32);
|
void SetLightPosition(MxS32 p_index);
|
||||||
LegoNamedTexture* ReadNamedTexture(LegoFile* p_file);
|
LegoNamedTexture* ReadNamedTexture(LegoFile* p_file);
|
||||||
void FUN_1003f540(LegoFile* p_file, const char* p_filename);
|
void FUN_1003f540(LegoFile* p_file, const char* p_filename);
|
||||||
void WriteNamedTexture(LegoFile* p_file, LegoNamedTexture* p_texture);
|
void WriteNamedTexture(LegoFile* p_file, LegoNamedTexture* p_texture);
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
#include "mxnotificationmanager.h"
|
#include "mxnotificationmanager.h"
|
||||||
#include "mxstreamer.h"
|
#include "mxstreamer.h"
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
#include "realtime/realtime.h"
|
||||||
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <vec.h>
|
||||||
|
|
||||||
// STUB: LEGO1 0x1003e050
|
// STUB: LEGO1 0x1003e050
|
||||||
void FUN_1003e050(LegoAnimPresenter* p_presenter)
|
void FUN_1003e050(LegoAnimPresenter* p_presenter)
|
||||||
|
@ -340,16 +342,12 @@ MxBool FUN_1003ef60()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1003f050
|
// FUNCTION: LEGO1 0x1003f050
|
||||||
MxS32 UpdateLightPosition(MxS32 p_value)
|
MxS32 UpdateLightPosition(MxS32 p_increase)
|
||||||
{
|
{
|
||||||
// This function updates the light position
|
|
||||||
// relatively by the amount passed in p_value.
|
|
||||||
// Because it operates relatively, it does not set
|
|
||||||
// the light position to an arbitrary value.
|
|
||||||
|
|
||||||
MxS32 lightPosition = atoi(VariableTable()->GetVariable("lightposition"));
|
MxS32 lightPosition = atoi(VariableTable()->GetVariable("lightposition"));
|
||||||
|
|
||||||
if (p_value > 0) {
|
// Only ever increases by 1 irrespective of p_increase
|
||||||
|
if (p_increase > 0) {
|
||||||
lightPosition += 1;
|
lightPosition += 1;
|
||||||
if (lightPosition > 5) {
|
if (lightPosition > 5) {
|
||||||
lightPosition = 5;
|
lightPosition = 5;
|
||||||
|
@ -372,9 +370,41 @@ MxS32 UpdateLightPosition(MxS32 p_value)
|
||||||
return lightPosition;
|
return lightPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x1003f0d0
|
// FUNCTION: LEGO1 0x1003f0d0
|
||||||
void SetLightPosition(MxU32)
|
void SetLightPosition(MxS32 p_index)
|
||||||
{
|
{
|
||||||
|
float lights[6][6] = {
|
||||||
|
{1.0, 0.0, 0.0, -150.0, 50.0, -50.0},
|
||||||
|
{0.809, -0.588, 0.0, -75.0, 50.0, -50.0},
|
||||||
|
{0.0, -1.0, 0.0, 0.0, 150.0, -150.0},
|
||||||
|
{-0.309, -0.951, 0.0, 25.0, 50.0, -50.0},
|
||||||
|
{-0.809, -0.588, 0.0, 75.0, 50.0, -50.0},
|
||||||
|
{-1.0, 0.0, 0.0, 150.0, 50.0, -50.0}
|
||||||
|
};
|
||||||
|
|
||||||
|
Mx3DPointFloat up(1.0, 0.0, 0.0);
|
||||||
|
Mx3DPointFloat direction;
|
||||||
|
Mx3DPointFloat position;
|
||||||
|
|
||||||
|
Tgl::FloatMatrix4 matrix;
|
||||||
|
Matrix4 in(matrix);
|
||||||
|
MxMatrix transform;
|
||||||
|
|
||||||
|
if (p_index < 0) {
|
||||||
|
p_index = 0;
|
||||||
|
}
|
||||||
|
else if (p_index > 5) {
|
||||||
|
p_index = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
direction = lights[p_index];
|
||||||
|
position = &lights[p_index][3];
|
||||||
|
|
||||||
|
CalcLocalTransform(position, direction, up, transform);
|
||||||
|
SETMAT4(in, transform);
|
||||||
|
|
||||||
|
VideoManager()->Get3DManager()->GetLego3DView()->SetLight(FALSE, matrix);
|
||||||
|
VideoManager()->Get3DManager()->GetLego3DView()->SetLight(TRUE, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1003f3b0
|
// FUNCTION: LEGO1 0x1003f3b0
|
||||||
|
|
|
@ -182,3 +182,24 @@ void LegoView1::Destroy()
|
||||||
|
|
||||||
LegoView::Destroy();
|
LegoView::Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100abb60
|
||||||
|
void LegoView1::SetLight(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix)
|
||||||
|
{
|
||||||
|
Tgl::Light* pLight;
|
||||||
|
|
||||||
|
if (bDirectionalLight == FALSE) {
|
||||||
|
pLight = m_pSunLight;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pLight = m_pDirectionalLight;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLight(pLight, rMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100abb80
|
||||||
|
void LegoView1::SetLight(Tgl::Light* pLight, Tgl::FloatMatrix4& rMatrix)
|
||||||
|
{
|
||||||
|
pLight->SetTransformation(rMatrix);
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
namespace Tgl
|
namespace Tgl
|
||||||
{
|
{
|
||||||
class Camera;
|
class Camera;
|
||||||
}
|
class Light;
|
||||||
|
} // namespace Tgl
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// LegoView
|
// LegoView
|
||||||
|
@ -64,7 +65,11 @@ class LegoView1 : public LegoView {
|
||||||
BOOL Create(const TglSurface::CreateStruct&, Tgl::Renderer*);
|
BOOL Create(const TglSurface::CreateStruct&, Tgl::Renderer*);
|
||||||
void Destroy() override; // vtable+0x08
|
void Destroy() override; // vtable+0x08
|
||||||
|
|
||||||
|
void SetLight(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void SetLight(Tgl::Light* pLight, Tgl::FloatMatrix4& rMatrix);
|
||||||
|
|
||||||
Tgl::Light* m_pSunLight; // 0x78
|
Tgl::Light* m_pSunLight; // 0x78
|
||||||
Tgl::Light* m_pDirectionalLight; // 0x7c
|
Tgl::Light* m_pDirectionalLight; // 0x7c
|
||||||
Tgl::Light* m_pAmbientLight; // 0x80
|
Tgl::Light* m_pAmbientLight; // 0x80
|
||||||
|
|
Loading…
Reference in a new issue