2023-06-30 14:34:39 -04:00
|
|
|
#include "viewmanager.h"
|
|
|
|
|
2024-03-02 09:43:19 -05:00
|
|
|
#include "tgl/d3drm/impl.h"
|
2024-03-04 16:57:35 -05:00
|
|
|
#include "viewlod.h"
|
2024-02-02 12:18:46 -05:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(ViewManager, 0x1bc)
|
|
|
|
|
2024-03-04 16:57:35 -05:00
|
|
|
inline undefined4 GetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer);
|
|
|
|
inline undefined4 GetFrame(IDirect3DRMFrame2*& frame, Tgl::Group* scene);
|
2024-03-02 09:43:19 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100a5eb0
|
2024-01-13 14:58:10 -05:00
|
|
|
ViewManager::ViewManager(Tgl::Renderer* pRenderer, Tgl::Group* scene, const OrientableROI* point_of_view)
|
2024-03-02 09:43:19 -05:00
|
|
|
: scene(scene), flags(c_bit1 | c_bit2 | c_bit3 | c_bit4)
|
2024-01-10 17:40:24 -05:00
|
|
|
{
|
2024-03-02 09:43:19 -05:00
|
|
|
SetPOVSource(point_of_view);
|
|
|
|
unk0x28 = 0.09;
|
2024-03-04 16:57:35 -05:00
|
|
|
GetD3DRM(d3drm, pRenderer);
|
|
|
|
GetFrame(frame, scene);
|
2024-03-02 13:40:42 -05:00
|
|
|
width = 0.0;
|
|
|
|
height = 0.0;
|
|
|
|
view_angle = 0.0;
|
|
|
|
pov.SetIdentity();
|
|
|
|
front = 0.0;
|
|
|
|
back = 0.0;
|
2024-03-02 09:43:19 -05:00
|
|
|
|
|
|
|
memset(unk0xf0, 0, sizeof(unk0xf0));
|
|
|
|
seconds_allowed = 1.0;
|
2024-01-10 17:40:24 -05:00
|
|
|
}
|
|
|
|
|
2024-03-02 09:43:19 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a60c0
|
2024-01-10 17:40:24 -05:00
|
|
|
ViewManager::~ViewManager()
|
|
|
|
{
|
2024-03-02 09:43:19 -05:00
|
|
|
SetPOVSource(NULL);
|
2024-01-10 17:40:24 -05:00
|
|
|
}
|
|
|
|
|
2024-03-04 16:06:40 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a6410
|
2024-03-04 12:54:25 -05:00
|
|
|
void ViewManager::Remove(ViewROI* p_roi)
|
|
|
|
{
|
2024-03-04 16:06:40 -05:00
|
|
|
for (CompoundObject::iterator it = rois.begin(); it != rois.end(); it++) {
|
|
|
|
if (*it == p_roi) {
|
|
|
|
rois.erase(it);
|
|
|
|
|
|
|
|
if (p_roi->GetUnknown0xe0() >= 0) {
|
|
|
|
FUN_100a66a0(p_roi);
|
|
|
|
}
|
|
|
|
|
|
|
|
const CompoundObject* comp = p_roi->GetComp();
|
|
|
|
|
|
|
|
if (comp != NULL) {
|
|
|
|
for (CompoundObject::const_iterator it = comp->begin(); !(it == comp->end()); it++) {
|
|
|
|
if (((ViewROI*) *it)->GetUnknown0xe0() >= 0) {
|
|
|
|
FUN_100a66a0((ViewROI*) *it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2024-03-04 12:54:25 -05:00
|
|
|
}
|
|
|
|
|
2024-03-02 14:26:19 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a64d0
|
|
|
|
void ViewManager::RemoveAll(ViewROI* p_roi)
|
|
|
|
{
|
|
|
|
if (p_roi == NULL) {
|
2024-03-04 16:06:40 -05:00
|
|
|
for (CompoundObject::iterator it = rois.begin(); it != rois.end(); it++) {
|
|
|
|
RemoveAll((ViewROI*) *it);
|
2024-03-02 14:26:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
rois.erase(rois.begin(), rois.end());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (p_roi->GetUnknown0xe0() >= 0) {
|
|
|
|
FUN_100a66a0(p_roi);
|
|
|
|
}
|
|
|
|
|
|
|
|
p_roi->SetUnknown0xe0(-1);
|
|
|
|
const CompoundObject* comp = p_roi->GetComp();
|
|
|
|
|
|
|
|
if (comp != NULL) {
|
|
|
|
for (CompoundObject::const_iterator it = comp->begin(); !(it == comp->end()); it++) {
|
2024-03-04 16:06:40 -05:00
|
|
|
if ((ViewROI*) *it != NULL) {
|
|
|
|
RemoveAll((ViewROI*) *it);
|
2024-03-02 14:26:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-04 16:57:35 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a66a0
|
2024-03-02 14:26:19 -05:00
|
|
|
void ViewManager::FUN_100a66a0(ViewROI* p_roi)
|
2023-06-30 14:34:39 -04:00
|
|
|
{
|
2024-03-04 16:57:35 -05:00
|
|
|
const ViewLOD* lod = (const ViewLOD*) p_roi->GetLOD(p_roi->GetUnknown0xe0());
|
|
|
|
|
|
|
|
if (lod != NULL) {
|
|
|
|
const Tgl::Mesh* meshGroup = NULL;
|
|
|
|
Tgl::Group* roiGeometry = p_roi->GetGeometry();
|
|
|
|
|
|
|
|
meshGroup = (const Tgl::Mesh*) lod->GetGeometry();
|
|
|
|
|
|
|
|
if (meshGroup != NULL) {
|
|
|
|
roiGeometry->Remove(meshGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
scene->Remove(roiGeometry);
|
|
|
|
}
|
|
|
|
|
|
|
|
p_roi->SetUnknown0xe0(-1);
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|
2024-01-10 17:40:24 -05:00
|
|
|
|
2024-01-20 15:43:53 -05:00
|
|
|
// STUB: LEGO1 0x100a6930
|
|
|
|
void ViewManager::Update(float p_previousRenderTime, float p_und2)
|
|
|
|
{
|
2024-03-02 09:43:19 -05:00
|
|
|
// TODO
|
2024-01-20 15:43:53 -05:00
|
|
|
}
|
|
|
|
|
2024-03-02 13:40:42 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a6d50
|
2024-01-13 14:58:10 -05:00
|
|
|
void ViewManager::SetResolution(int width, int height)
|
|
|
|
{
|
2024-03-02 13:40:42 -05:00
|
|
|
flags |= c_bit3;
|
|
|
|
this->width = width;
|
|
|
|
this->height = height;
|
2024-01-13 14:58:10 -05:00
|
|
|
}
|
|
|
|
|
2024-03-02 13:40:42 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a6d70
|
2024-01-13 14:58:10 -05:00
|
|
|
void ViewManager::SetFrustrum(float fov, float front, float back)
|
|
|
|
{
|
2024-03-02 13:40:42 -05:00
|
|
|
this->front = front;
|
|
|
|
this->back = back;
|
|
|
|
flags |= c_bit3;
|
|
|
|
view_angle = fov * 0.017453292519944444;
|
2024-01-13 14:58:10 -05:00
|
|
|
}
|
|
|
|
|
2024-03-02 13:40:42 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a6da0
|
2024-01-10 17:40:24 -05:00
|
|
|
void ViewManager::SetPOVSource(const OrientableROI* point_of_view)
|
|
|
|
{
|
2024-03-02 13:40:42 -05:00
|
|
|
if (point_of_view != NULL) {
|
|
|
|
pov = point_of_view->GetLocal2World();
|
|
|
|
flags |= c_bit2;
|
|
|
|
}
|
2024-03-02 09:43:19 -05:00
|
|
|
}
|
|
|
|
|
2024-03-04 12:54:25 -05:00
|
|
|
// STUB: LEGO1 0x100a6e00
|
|
|
|
ViewROI* ViewManager::Pick(Tgl::View* p_view, unsigned long x, unsigned long y)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-03-04 16:57:35 -05:00
|
|
|
inline undefined4 GetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer)
|
2024-03-02 09:43:19 -05:00
|
|
|
{
|
|
|
|
d3drm = ((TglImpl::RendererImpl*) pRenderer)->ImplementationData();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-03-04 16:57:35 -05:00
|
|
|
inline undefined4 GetFrame(IDirect3DRMFrame2*& frame, Tgl::Group* scene)
|
2024-03-02 09:43:19 -05:00
|
|
|
{
|
|
|
|
frame = ((TglImpl::GroupImpl*) scene)->ImplementationData();
|
|
|
|
return 0;
|
2024-01-10 17:40:24 -05:00
|
|
|
}
|