mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Some checks are pending
CI / clang-format (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain /usr/local/vitasdk/share/vita.toolchain.cmake, false, false, Ninja, Vita, ubuntu-latest, true, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0, false, false, Visual Studio 17 2022, true, Xbox One, windows-latest, amd64, false, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake, false, devkitpro/devkitarm:latest, false, Ninja, true, Nintendo 3DS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake, false, devkitpro/devkita64:latest, false, Ninja, Nintendo Switch, true, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, emcmake, false, false, true, Ninja, Emscripten, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, false, Ninja, true, MSVC (arm64), windows-latest, amd64_arm64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, true, Ninja, true, MSVC (x86), windows-latest, amd64_x86, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, false, Ninja, true, MSVC (x64), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, true, false, Ninja, true, MSVC (x64 Debug), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, -DCMAKE_SYSTEM_NAME=iOS, false, false, Xcode, true, iOS, macos-15, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, Ninja, true, mingw-w64-i686, mingw32, msys2 mingw32, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, false, Ninja, Android, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, true, false, Ninja, macOS, macos-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, false, Ninja, true, mingw-w64-x86_64, mingw64, msys2 mingw64, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux (Debug), ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux, ubuntu-latest, true) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (aarch64, ubuntu-22.04-arm) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (x86_64, ubuntu-latest) (push) Waiting to run
CI / C++ (push) Waiting to run
CI / Release (push) Blocked by required conditions
Docker / Publish web port (push) Waiting to run
245 lines
5.3 KiB
C++
245 lines
5.3 KiB
C++
// LegoView1.cpp : implementation file
|
|
//
|
|
|
|
#include "legoview1.h"
|
|
|
|
#include "decomp.h"
|
|
#include "mxgeometry/mxgeometry3d.h"
|
|
#include "mxgeometry/mxmatrix.h"
|
|
#include "realtime/realtime.h"
|
|
|
|
#include <vec.h>
|
|
|
|
DECOMP_SIZE_ASSERT(LegoView, 0x78);
|
|
DECOMP_SIZE_ASSERT(LegoView1, 0x88);
|
|
|
|
// GLOBAL: LEGO1 0x101013e4
|
|
float g_sunLightRGB = 1.0;
|
|
|
|
// GLOBAL: LEGO1 0x101013e8
|
|
float g_directionalLightRGB = 1.0;
|
|
|
|
// GLOBAL: LEGO1 0x101013ec
|
|
float g_ambientLightRGB = 0.3;
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// LegoView
|
|
|
|
// FUNCTION: LEGO1 0x100ab510
|
|
// FUNCTION: BETA10 0x1017bb90
|
|
LegoView::LegoView()
|
|
{
|
|
m_pScene = 0;
|
|
m_pCamera = 0;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100ab5a0
|
|
// FUNCTION: BETA10 0x1017bc19
|
|
LegoView::~LegoView()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100ab600
|
|
// FUNCTION: BETA10 0x1017bc89
|
|
BOOL LegoView::Create(const TglSurface::CreateStruct& rCreateStruct, Tgl::Renderer* pRenderer)
|
|
{
|
|
float viewAngle = 45;
|
|
|
|
float frontClippingDistance = 0.1;
|
|
float backClippingDistance = 500;
|
|
|
|
assert(!m_pScene);
|
|
assert(!m_pCamera);
|
|
assert(pRenderer);
|
|
|
|
if (rCreateStruct.m_isWideViewAngle) {
|
|
viewAngle = 90;
|
|
}
|
|
|
|
assert(!m_pScene);
|
|
m_pScene = pRenderer->CreateGroup();
|
|
assert(m_pScene);
|
|
// TglSurface::Create() calls CreateView(), and we need the camera in
|
|
// CreateView(), so create camera before calling TglSurface::Create()
|
|
assert(!m_pCamera);
|
|
m_pCamera = pRenderer->CreateCamera();
|
|
assert(m_pCamera);
|
|
|
|
if (!TglSurface::Create(rCreateStruct, pRenderer, m_pScene)) {
|
|
delete m_pScene;
|
|
m_pScene = NULL;
|
|
|
|
delete m_pCamera;
|
|
m_pCamera = NULL;
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
assert(GetView());
|
|
GetView()->SetFrustrum(frontClippingDistance, backClippingDistance, viewAngle);
|
|
GetView()->SetBackgroundColor(.223, .639, .851);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100ab6c0
|
|
// FUNCTION: BETA10 0x1017befd
|
|
Tgl::View* LegoView::CreateView(Tgl::Renderer* pRenderer, Tgl::Device* pDevice)
|
|
{
|
|
assert(pRenderer);
|
|
assert(pDevice);
|
|
|
|
return pRenderer->CreateView(pDevice, m_pCamera, 0, 0, GetWidth(), GetHeight());
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100ab6f0
|
|
// FUNCTION: BETA10 0x1017bf96
|
|
void LegoView::Destroy()
|
|
{
|
|
delete m_pScene;
|
|
m_pScene = NULL;
|
|
|
|
delete m_pCamera;
|
|
m_pCamera = NULL;
|
|
|
|
TglSurface::Destroy();
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// LegoView1
|
|
|
|
// FUNCTION: LEGO1 0x100ab730
|
|
// FUNCTION: BETA10 0x1017c028
|
|
LegoView1::LegoView1()
|
|
{
|
|
m_pSunLight = 0;
|
|
m_pDirectionalLight = 0;
|
|
m_pAmbientLight = 0;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100ab7c0
|
|
// FUNCTION: BETA10 0x1017c0be
|
|
LegoView1::~LegoView1()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100ab820
|
|
// FUNCTION: BETA10 0x1017c12e
|
|
BOOL LegoView1::AddLightsToViewport()
|
|
{
|
|
assert(GetView());
|
|
GetView()->Add(m_pSunLight);
|
|
GetView()->Add(m_pDirectionalLight);
|
|
GetView()->Add(m_pAmbientLight);
|
|
return TRUE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100ab860
|
|
// FUNCTION: BETA10 0x1017c1ea
|
|
BOOL LegoView1::Create(const TglSurface::CreateStruct& rCreateStruct, Tgl::Renderer* pRenderer)
|
|
{
|
|
if (!LegoView::Create(rCreateStruct, pRenderer)) {
|
|
return FALSE;
|
|
}
|
|
|
|
// lights
|
|
m_pSunLight = pRenderer->CreateLight(Tgl::Point, g_sunLightRGB, g_sunLightRGB, g_sunLightRGB);
|
|
m_pDirectionalLight =
|
|
pRenderer->CreateLight(Tgl::Directional, g_directionalLightRGB, g_directionalLightRGB, g_directionalLightRGB);
|
|
m_pAmbientLight = pRenderer->CreateLight(Tgl::Ambient, g_ambientLightRGB, g_ambientLightRGB, g_ambientLightRGB);
|
|
|
|
Mx3DPointFloat position(0.0, 0.0, 0.0);
|
|
Mx3DPointFloat direction(0.0, -1.0, 0.0);
|
|
Mx3DPointFloat up(1.0, 0.0, 0.0);
|
|
|
|
Tgl::FloatMatrix4 matrix;
|
|
Matrix4 in(matrix);
|
|
MxMatrix transform;
|
|
|
|
CalcLocalTransform(position, direction, up, transform);
|
|
SETMAT4(in, transform);
|
|
m_pDirectionalLight->SetTransformation(matrix);
|
|
|
|
position[0] = 0, position[1] = 150, position[2] = -150;
|
|
CalcLocalTransform(position, direction, up, transform);
|
|
SETMAT4(in, transform);
|
|
m_pSunLight->SetTransformation(matrix);
|
|
|
|
// assert(GetView());
|
|
|
|
return AddLightsToViewport();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100abad0
|
|
// FUNCTION: BETA10 0x1017c912
|
|
void LegoView1::Destroy()
|
|
{
|
|
if (m_pSunLight) {
|
|
GetView()->Remove(m_pSunLight);
|
|
delete m_pSunLight;
|
|
m_pSunLight = 0;
|
|
}
|
|
|
|
if (m_pDirectionalLight) {
|
|
GetView()->Remove(m_pDirectionalLight);
|
|
delete m_pDirectionalLight;
|
|
m_pDirectionalLight = 0;
|
|
}
|
|
|
|
if (m_pAmbientLight) {
|
|
GetView()->Remove(m_pAmbientLight);
|
|
delete m_pAmbientLight;
|
|
m_pAmbientLight = 0;
|
|
}
|
|
|
|
LegoView::Destroy();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100abb60
|
|
// FUNCTION: BETA10 0x1017ca80
|
|
void LegoView1::SetLightTransform(BOOL bDirectionalLight, Tgl::FloatMatrix4& rMatrix)
|
|
{
|
|
Tgl::Light* pLight;
|
|
|
|
if (bDirectionalLight == FALSE) {
|
|
pLight = m_pSunLight;
|
|
}
|
|
else {
|
|
pLight = m_pDirectionalLight;
|
|
}
|
|
|
|
SetLightTransform(pLight, rMatrix);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100abb80
|
|
// FUNCTION: BETA10 0x1017cacf
|
|
void LegoView1::SetLightTransform(Tgl::Light* pLight, Tgl::FloatMatrix4& rMatrix)
|
|
{
|
|
pLight->SetTransformation(rMatrix);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100abba0
|
|
// FUNCTION: BETA10 0x1017caf6
|
|
void LegoView1::SetLightColor(BOOL bDirectionalLight, float red, float green, float blue)
|
|
{
|
|
Tgl::Light* pLight;
|
|
|
|
if (bDirectionalLight == FALSE) {
|
|
pLight = m_pSunLight;
|
|
}
|
|
else {
|
|
pLight = m_pDirectionalLight;
|
|
}
|
|
|
|
SetLightColor(pLight, red, green, blue);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100abbd0
|
|
// FUNCTION: BETA10 0x1017cb4d
|
|
void LegoView1::SetLightColor(Tgl::Light* pLight, float red, float green, float blue)
|
|
{
|
|
pLight->SetColor(red, green, blue);
|
|
}
|