mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-28 18:51:16 +00:00
Implement/match LegoView/1
This commit is contained in:
parent
e1ff2712ed
commit
c5bf56d476
@ -7,6 +7,7 @@ option(ISLE_USE_SMARTHEAP "Build with SmartHeap" ${MSVC})
|
||||
option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" ON)
|
||||
|
||||
add_library(lego1 SHARED
|
||||
LEGO1/3dmanager/legoview1.cpp
|
||||
LEGO1/3dmanager/tglsurface.cpp
|
||||
LEGO1/act1state.cpp
|
||||
LEGO1/act2brick.cpp
|
||||
|
||||
184
LEGO1/3dmanager/legoview1.cpp
Normal file
184
LEGO1/3dmanager/legoview1.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
// LegoView1.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "legoview1.h"
|
||||
|
||||
#include "../realtime/realtime.h"
|
||||
#include "decomp.h"
|
||||
|
||||
#include <vec.h> // SETMAT4
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoView, 0x78);
|
||||
DECOMP_SIZE_ASSERT(LegoView1, 0x88);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LegoView
|
||||
|
||||
// FUNCTION: LEGO1 0x100ab510
|
||||
LegoView::LegoView()
|
||||
{
|
||||
m_pScene = 0;
|
||||
m_pCamera = 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ab5a0
|
||||
LegoView::~LegoView()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ab600
|
||||
BOOL LegoView::Create(const TglSurface::CreateStruct& rCreateStruct, Tgl::Renderer* pRenderer)
|
||||
{
|
||||
float viewAngle = 45;
|
||||
if (rCreateStruct.m_isWideViewAngle)
|
||||
viewAngle = 90;
|
||||
|
||||
float frontClippingDistance = 0.1;
|
||||
float backClippingDistance = 500;
|
||||
|
||||
assert(!m_pScene);
|
||||
assert(!m_pCamera);
|
||||
assert(pRenderer);
|
||||
|
||||
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()
|
||||
m_pCamera = pRenderer->CreateCamera();
|
||||
assert(m_pCamera);
|
||||
|
||||
if (!TglSurface::Create(rCreateStruct, pRenderer, m_pScene)) {
|
||||
delete m_pScene;
|
||||
m_pScene = 0;
|
||||
|
||||
delete m_pCamera;
|
||||
m_pCamera = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
assert(GetView());
|
||||
GetView()->SetFrustrum(frontClippingDistance, backClippingDistance, viewAngle);
|
||||
GetView()->SetBackgroundColor(.223, .639, .851);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ab6c0
|
||||
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
|
||||
void LegoView::Destroy()
|
||||
{
|
||||
delete m_pScene;
|
||||
m_pScene = 0;
|
||||
|
||||
delete m_pCamera;
|
||||
m_pCamera = 0;
|
||||
|
||||
TglSurface::Destroy();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LegoView1
|
||||
|
||||
// FUNCTION: LEGO1 0x100ab730
|
||||
LegoView1::LegoView1()
|
||||
{
|
||||
m_pSunLight = 0;
|
||||
m_pDirectionalLight = 0;
|
||||
m_pAmbientLight = 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ab7c0
|
||||
LegoView1::~LegoView1()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100ab820
|
||||
BOOL LegoView1::AddLightsToViewport()
|
||||
{
|
||||
GetView()->Add(m_pSunLight);
|
||||
GetView()->Add(m_pDirectionalLight);
|
||||
GetView()->Add(m_pAmbientLight);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100ab860
|
||||
BOOL LegoView1::Create(const TglSurface::CreateStruct& rCreateStruct, Tgl::Renderer* pRenderer)
|
||||
{
|
||||
double position[3] = {0, 0, 0};
|
||||
double direction[3];
|
||||
double up[3] = {0, 1, 0};
|
||||
|
||||
if (!LegoView::Create(rCreateStruct, pRenderer)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// lights
|
||||
m_pSunLight = pRenderer->CreateLight(Tgl::Directional, .9, .9, .9);
|
||||
m_pDirectionalLight = pRenderer->CreateLight(Tgl::Directional, .4, .4, .4);
|
||||
m_pAmbientLight = pRenderer->CreateLight(Tgl::Ambient, .3, .3, .3);
|
||||
|
||||
#if 0
|
||||
direction[0] = 1, direction[1] = -1, direction[2] = 2;
|
||||
m_pSunLight->SetOrientation(direction, up);
|
||||
direction[0] = -1, direction[1] = -2, direction[2] = -1;
|
||||
m_pDirectionalLight->SetOrientation(direction, up);
|
||||
#else
|
||||
{
|
||||
// Change everything to float and proper Matrix types
|
||||
/*
|
||||
Tgl::FloatMatrix4 transformation;
|
||||
Matrix4Data transform;
|
||||
|
||||
direction[0] = 1, direction[1] = -1, direction[2] = 2;
|
||||
CalcLocalTransform(position, direction, up, transform);
|
||||
SETMAT4(transformation, transform);
|
||||
m_pSunLight->SetTransformation(transformation);
|
||||
|
||||
direction[0] = -1, direction[1] = -2, direction[2] = -1;
|
||||
CalcLocalTransform(position, direction, up, transform);
|
||||
SETMAT4(transformation, transform);
|
||||
m_pDirectionalLight->SetTransformation(transformation);
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(GetView());
|
||||
AddLightsToViewport();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100abad0
|
||||
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();
|
||||
}
|
||||
72
LEGO1/3dmanager/legoview1.h
Normal file
72
LEGO1/3dmanager/legoview1.h
Normal file
@ -0,0 +1,72 @@
|
||||
#ifndef _LegoView1_h
|
||||
#define _LegoView1_h
|
||||
|
||||
#include "compat.h"
|
||||
#include "tglsurface.h"
|
||||
|
||||
class Tgl::Camera;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LegoView
|
||||
|
||||
// VTABLE: 0x100dc000
|
||||
// SIZE 0x78
|
||||
class LegoView : public TglSurface {
|
||||
public:
|
||||
LegoView();
|
||||
~LegoView();
|
||||
|
||||
BOOL Create(const CreateStruct&, Tgl::Renderer*);
|
||||
virtual void Destroy() override; // vtable+0x08
|
||||
|
||||
Tgl::Group* GetScene() const;
|
||||
Tgl::Camera* GetCamera() const;
|
||||
|
||||
protected:
|
||||
virtual Tgl::View* CreateView(Tgl::Renderer*, Tgl::Device*); // vtable+0x10
|
||||
|
||||
private:
|
||||
Tgl::Group* m_pScene; // 0x70
|
||||
Tgl::Camera* m_pCamera; // 0x74
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LegoView implementation
|
||||
|
||||
inline Tgl::Group* LegoView::GetScene() const
|
||||
{
|
||||
return m_pScene;
|
||||
}
|
||||
|
||||
inline Tgl::Camera* LegoView::GetCamera() const
|
||||
{
|
||||
return m_pCamera;
|
||||
}
|
||||
|
||||
// SYNTHETIC: LEGO1 0x100ab580
|
||||
// LegoView::`scalar deleting destructor'
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LegoView1
|
||||
|
||||
// VTABLE: LEGO1 0x100dc018
|
||||
// SIZE 0x88
|
||||
class LegoView1 : public LegoView {
|
||||
public:
|
||||
LegoView1();
|
||||
~LegoView1();
|
||||
|
||||
BOOL AddLightsToViewport();
|
||||
BOOL Create(const TglSurface::CreateStruct&, Tgl::Renderer*);
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
Tgl::Light* m_pSunLight; // 0x78
|
||||
Tgl::Light* m_pDirectionalLight; // 0x7c
|
||||
Tgl::Light* m_pAmbientLight; // 0x80
|
||||
};
|
||||
|
||||
// SYNTHETIC: LEGO1 0x100ab7a0
|
||||
// LegoView1::`scalar deleting destructor'
|
||||
|
||||
#endif /* _LegoView1_h */
|
||||
@ -25,7 +25,7 @@ class TglSurface {
|
||||
IDirectDrawSurface* m_pBackBuffer; // 0x10
|
||||
IDirectDrawPalette* m_pPalette; // 0x14
|
||||
BOOL m_isFullScreen; // 0x18
|
||||
unsigned long m_flags; // 0x1c
|
||||
BOOL m_isWideViewAngle; // 0x1c
|
||||
IDirect3D2* m_direct3d; // 0x20
|
||||
IDirect3DDevice2* m_d3dDevice; // 0x24
|
||||
};
|
||||
|
||||
@ -16,7 +16,7 @@ BOOL InitializeCreateStruct(TglSurface::CreateStruct& p_tglSurface, const Lego3D
|
||||
p_tglSurface.m_pBackBuffer = p_createStruct.m_ddSurface2;
|
||||
p_tglSurface.m_pPalette = p_createStruct.m_ddPalette;
|
||||
p_tglSurface.m_isFullScreen = p_createStruct.m_isFullScreen;
|
||||
p_tglSurface.m_flags = p_createStruct.m_flags;
|
||||
p_tglSurface.m_isWideViewAngle = p_createStruct.m_isWideViewAngle;
|
||||
p_tglSurface.m_direct3d = p_createStruct.m_direct3d;
|
||||
p_tglSurface.m_d3dDevice = p_createStruct.m_d3dDevice;
|
||||
return TRUE;
|
||||
|
||||
@ -18,7 +18,7 @@ class Lego3DManager {
|
||||
IDirectDrawSurface* m_ddSurface2; // 0x10
|
||||
IDirectDrawPalette* m_ddPalette; // 0x14
|
||||
BOOL m_isFullScreen; // 0x18
|
||||
MxU32 m_flags; // 0x1c
|
||||
BOOL m_isWideViewAngle; // 0x1c
|
||||
IDirect3D2* m_direct3d; // 0x20
|
||||
IDirect3DDevice2* m_d3dDevice; // 0x24
|
||||
};
|
||||
|
||||
@ -156,7 +156,7 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
|
||||
createStruct.m_ddSurface2 = m_displaySurface->GetDirectDrawSurface2();
|
||||
createStruct.m_ddPalette = m_videoParam.GetPalette()->CreateNativePalette();
|
||||
createStruct.m_isFullScreen = FALSE;
|
||||
createStruct.m_flags = m_videoParam.Flags().GetWideViewAngle();
|
||||
createStruct.m_isWideViewAngle = m_videoParam.Flags().GetWideViewAngle();
|
||||
createStruct.m_direct3d = m_direct3d->GetDirect3D();
|
||||
createStruct.m_d3dDevice = m_direct3d->GetDirect3DDevice();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user