diff --git a/Runtime/AutoMapper/CMakeLists.txt b/Runtime/AutoMapper/CMakeLists.txt index 7272715b4..13f6e9153 100644 --- a/Runtime/AutoMapper/CMakeLists.txt +++ b/Runtime/AutoMapper/CMakeLists.txt @@ -1,4 +1,5 @@ set(AUTOMAPPER_SOURCES + CMapUniverse.hpp CMapUniverse.cpp CMapWorldInfo.hpp CMapWorldInfo.cpp CMapWorld.hpp CMapWorld.cpp CMapArea.hpp CMapArea.cpp diff --git a/Runtime/AutoMapper/CMapUniverse.cpp b/Runtime/AutoMapper/CMapUniverse.cpp new file mode 100644 index 000000000..1ab35d753 --- /dev/null +++ b/Runtime/AutoMapper/CMapUniverse.cpp @@ -0,0 +1,59 @@ +#include "CMapUniverse.hpp" +#include "GameGlobalObjects.hpp" +#include "CSimplePool.hpp" + +namespace urde +{ + +CMapUniverse::CMapUniverse(CInputStream& in, u32 version) + : x0_hexagonId(in.readUint32Big()) +{ + x4_hexagonToken = g_SimplePool->GetObj({'MAPA', x0_hexagonId}); + u32 count = in.readUint32Big(); + x10_worldDatas.reserve(count); + for (u32 i = 0 ; i::GetIObjObjectFor(std::unique_ptr(new CMapUniverse(in, version))); +} + +} diff --git a/Runtime/AutoMapper/CMapUniverse.hpp b/Runtime/AutoMapper/CMapUniverse.hpp new file mode 100644 index 000000000..be7b09227 --- /dev/null +++ b/Runtime/AutoMapper/CMapUniverse.hpp @@ -0,0 +1,83 @@ +#ifndef __URDE_CMAPUNIVERSE_HPP__ +#define __URDE_CMAPUNIVERSE_HPP__ + +#include "RetroTypes.hpp" +#include "zeus/CVector3f.hpp" +#include "zeus/CColor.hpp" +#include "zeus/CTransform.hpp" +#include "IFactory.hpp" +#include "CToken.hpp" + +namespace urde +{ +class CStateManager; +class CMapArea; +class CMapUniverse +{ +public: + class CMapUniverseDrawParms + { + public: + CMapUniverseDrawParms(float, int, const CStateManager&, + const zeus::CTransform&, const zeus::CTransform&); + s32 GetFocusWorldIndex() const; + zeus::CTransform GetCameraTransform() const; + zeus::CTransform GetPaneProjectionTransform() const; + float GetAlpha() const; + }; + + class CMapObjectSortInfo + { + public: + CMapObjectSortInfo(float, int, int, int, const zeus::CColor&, const zeus::CColor&); + zeus::CColor GetOutlineColor() const; + zeus::CColor GetSurfaceColor() const; + s32 GetObjectIndex() const; + s32 GetAreaIndex() const; + s32 GetWorldIndex() const; + float GetZDistance() const; + }; + + class CMapWorldData + { + std::string x0_label; + ResId x10_worldAssetId; + zeus::CTransform x14_transform; + std::vector x44_areaData; + zeus::CColor x54_; + zeus::CColor x58_ = zeus::CColor(1.0f, 0.0f, 1.0f); + zeus::CColor x5c_ = zeus::CColor(1.0f, 0.0f, 1.0f); + zeus::CColor x60_ = zeus::CColor(1.0f, 0.0f, 1.0f); + zeus::CVector3f x64_ = zeus::CVector3f::skZero; + public: + CMapWorldData(CInputStream& in, u32 version); + ResId GetWorldAssetId() const; + zeus::CVector3f GetWorldCenterPoint() const; + std::string GetWorldLabel() const; + zeus::CTransform GetWorldTransform() const; + void GetMapAreaData(s32) const; + zeus::CColor GetOutlineColorUnselected() const; + zeus::CColor GetOutlineColorSelected() const; + zeus::CColor GetSurfaceColorUnselected() const; + zeus::CColor GetSurfaceColorSelected() const; + u32 GetNumMapAreaDatas() const; + }; + +private: + ResId x0_hexagonId; + TLockedToken x4_hexagonToken; + std::vector x10_worldDatas; + zeus::CVector3f x20_ = zeus::CVector3f::skZero; +public: + CMapUniverse(CInputStream&, u32); + void GetMapWorldData(s32) const; + u32 GetNumMapWorldDatas() const; + float GetMapUniverseRadius() const; + zeus::CVector3f GetMapUniverseCenterPoint() const; + void Draw(const CMapUniverseDrawParms&, const zeus::CVector3f&, float, float) const; +}; + +CFactoryFnReturn FMapUniverseFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms); + +} +#endif diff --git a/Runtime/AutoMapper/CMappableObject.cpp b/Runtime/AutoMapper/CMappableObject.cpp index ab4ad79de..93c98f105 100644 --- a/Runtime/AutoMapper/CMappableObject.cpp +++ b/Runtime/AutoMapper/CMappableObject.cpp @@ -8,42 +8,58 @@ const zeus::CVector3f CMappableObject::skDoorVerts[8] = {}; zeus::CTransform CMappableObject::AdjustTransformForType() { - /* TODO - Phil: Finish this */ - float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x; - float doorCenterY = g_tweakAutoMapper->GetDoorCenter().y; - if (x0_ == EMappableObjectType::BigDoor1) + const float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x; + const float doorCenterZ = g_tweakAutoMapper->GetDoorCenter().z; + if (x0_type == EMappableObjectType::BigDoor1) { - zeus::CTransform scale; - scale.scaleBy(1.5); zeus::CTransform orientation; orientation.origin = {-1.4f*doorCenterX, 0.0f, 0.0f}; - zeus::CTransform tmp3 = x10_ * orientation; orientation.rotateLocalZ(zeus::degToRad(90.0f)); - return tmp3 * scale; + return (x10_transform * orientation) * zeus::CTransform::Scale(zeus::CVector3f{1.5f}); } - else if (x0_ == EMappableObjectType::BigDoor2) + else if (x0_type == EMappableObjectType::BigDoor2) { - + zeus::CTransform orientation; + orientation.origin = {0.f, -2.0f * doorCenterZ, -1.4f * doorCenterX}; + orientation.rotateLocalZ(zeus::degToRad(-90.f)); + return (x10_transform * orientation) * zeus::CTransform::Scale(zeus::CVector3f{1.5f}); } - else if (x0_ == EMappableObjectType::IceDoorCeiling || x0_ == EMappableObjectType::WaveDoorCeiling - || x0_ == EMappableObjectType::Eleven) + else if (x0_type == EMappableObjectType::IceDoorCeiling || x0_type == EMappableObjectType::WaveDoorCeiling + || x0_type == EMappableObjectType::PlasmaDoorCeiling) { + zeus::CTransform orientation; + orientation.origin = {-1.65 * doorCenterX, 0.f, -1.5 * doorCenterZ}; + orientation.rotateLocalY(zeus::degToRad(90.f)); + return x10_transform * orientation; } - else if (x0_ == EMappableObjectType::IceDoorCeiling || x0_ == EMappableObjectType::WaveDoorFloor - || x0_ == EMappableObjectType::Twelve) + else if (x0_type == EMappableObjectType::IceDoorFloor || x0_type == EMappableObjectType::WaveDoorFloor + || x0_type == EMappableObjectType::PlasmaDoorFloor) { + zeus::CTransform orientation; + orientation.origin = {-1.65 * doorCenterX, 0.f, -1.0 * doorCenterZ}; + orientation.rotateLocalY(zeus::degToRad(90.f)); + return x10_transform * orientation; } - else if (EMappableObjectType(u32(x0_) - u32(EMappableObjectType::IceDoorFloor2)) <= EMappableObjectType::ShieldDoor - || x0_ == EMappableObjectType::Fifteen) + else if ((u32(x0_type) - u32(EMappableObjectType::IceDoorFloor2)) <= u32(EMappableObjectType::ShieldDoor) + || x0_type == EMappableObjectType::Fifteen) { + zeus::CTransform orientation; + orientation.origin = {-0.49 * doorCenterX, 0.f, -1.0 * doorCenterZ}; + orientation.rotateLocalY(zeus::degToRad(90.f)); + return x10_transform * orientation; } - return x10_; + else if (x0_type >= EMappableObjectType::BlueDoor || x0_type <= EMappableObjectType::Fifteen) + { + zeus::CMatrix4f tmp = x10_transform.toMatrix4f().transposed(); + return zeus::CTransform::Translate(tmp.m[1][0], tmp.m[2][1], tmp[3][2]); + } + return x10_transform; } void CMappableObject::PostConstruct(const void *) { #if __BYTE_ORDER__!= __ORDER_BIG_ENDIAN__ - x0_ = EMappableObjectType(SBIG(u32(x0_))); + x0_type = EMappableObjectType(SBIG(u32(x0_type))); x4_ = SBIG(x4_); x8_ = SBIG(x8_); xc_ = SBIG(xc_); @@ -51,17 +67,22 @@ void CMappableObject::PostConstruct(const void *) { for (u32 j = 0 ; j<4 ; j++) { - u32* tmp = reinterpret_cast(&x10_.basis.m[i][j]); + u32* tmp = reinterpret_cast(&x10_transform.basis.m[i][j]); *tmp = SBIG(*tmp); } } #endif - x10_.origin.x = x10_.basis.m[0][3]; - x10_.origin.y = x10_.basis.m[1][3]; - x10_.origin.z = x10_.basis.m[2][3]; - x10_.basis.transpose(); - x10_ = AdjustTransformForType(); + x10_transform.origin.x = x10_transform.basis.m[0][3]; + x10_transform.origin.y = x10_transform.basis.m[1][3]; + x10_transform.origin.z = x10_transform.basis.m[2][3]; + x10_transform.basis.transpose(); + x10_transform = AdjustTransformForType(); +} + +zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(s32) const +{ + return {}; } void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) diff --git a/Runtime/AutoMapper/CMappableObject.hpp b/Runtime/AutoMapper/CMappableObject.hpp index ba72a6c99..1c24690dc 100644 --- a/Runtime/AutoMapper/CMappableObject.hpp +++ b/Runtime/AutoMapper/CMappableObject.hpp @@ -26,8 +26,8 @@ public: IceDoorFloor = 8, WaveDoorCeiling = 9, WaveDoorFloor = 10, - Eleven = 11, - Twelve = 12, + PlasmaDoorCeiling= 11, + PlasmaDoorFloor = 12, IceDoorFloor2 = 13, WaveDoorFloor2 = 14, Fifteen = 15, @@ -45,11 +45,11 @@ public: private: static const zeus::CVector3f skDoorVerts[8]; - EMappableObjectType x0_; + EMappableObjectType x0_type; u32 x4_; TEditorId x8_; u32 xc_; - zeus::CTransform x10_; + zeus::CTransform x10_transform; zeus::CTransform AdjustTransformForType(); public: void PostConstruct(const void*); @@ -57,7 +57,7 @@ public: EMappableObjectType GetType() const; void Draw(int, const CStateManager&, float, bool) const; void DrawDoorSurface(int, const CStateManager&, float, int, bool) const; - void BuildSurfaceCenterPoint(s32) const; + zeus::CVector3f BuildSurfaceCenterPoint(s32) const; bool IsDoorConnectedToArea(s32, const CStateManager&) const; bool IsDoorConnectedToVisitedArea(const CStateManager&) const; bool GetIsVisibleToAutoMapper(bool) const;