This commit is contained in:
Jack Andersen 2016-08-02 12:14:41 -10:00
commit 135aac5fef
5 changed files with 193 additions and 29 deletions

View File

@ -1,4 +1,5 @@
set(AUTOMAPPER_SOURCES set(AUTOMAPPER_SOURCES
CMapUniverse.hpp CMapUniverse.cpp
CMapWorldInfo.hpp CMapWorldInfo.cpp CMapWorldInfo.hpp CMapWorldInfo.cpp
CMapWorld.hpp CMapWorld.cpp CMapWorld.hpp CMapWorld.cpp
CMapArea.hpp CMapArea.cpp CMapArea.hpp CMapArea.cpp

View File

@ -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<count ; ++i)
x10_worldDatas.emplace_back(in, version);
}
CMapUniverse::CMapWorldData::CMapWorldData(CInputStream& in, u32 version)
: x0_label(in.readString()),
x10_worldAssetId(in.readUint32Big())
{
x14_transform.read34RowMajor(in);
u32 worldCount = in.readUint32Big();
x44_areaData.reserve(worldCount);
for (u32 i = 0 ; i<worldCount ; ++i)
{
x44_areaData.emplace_back();
x44_areaData.back().read34RowMajor(in);
}
if (version != 0)
x54_.readRGBABig(in);
else
x54_.fromRGBA32(255 | (x10_worldAssetId & 0xFFFFFF00));
x58_ = zeus::CColor::lerp(zeus::CColor::skWhite, x54_, 0.5f);
x5c_ = zeus::CColor::lerp(zeus::CColor::skBlack, x54_, 0.5f);
x60_ = zeus::CColor::lerp(zeus::CColor::skWhite, x5c_, 0.5f);
for (const zeus::CTransform& xf : x44_areaData)
{
zeus::CMatrix4f mat = xf.toMatrix4f().transposed();
x64_.x += mat.vec[1].x;
x64_.y += mat.vec[2].y;
x64_.z += mat.vec[3].z;
}
x64_ *= 1.0f / float(x44_areaData.size());
}
CFactoryFnReturn FMapUniverseFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&)
{
in.readUint32Big();
u32 version = in.readUint32Big();
return TToken<CMapUniverse>::GetIObjObjectFor(std::unique_ptr<CMapUniverse>(new CMapUniverse(in, version)));
}
}

View File

@ -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<zeus::CTransform> 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<CMapArea> x4_hexagonToken;
std::vector<CMapWorldData> 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

View File

@ -8,42 +8,58 @@ const zeus::CVector3f CMappableObject::skDoorVerts[8] = {};
zeus::CTransform CMappableObject::AdjustTransformForType() zeus::CTransform CMappableObject::AdjustTransformForType()
{ {
/* TODO - Phil: Finish this */ const float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x;
float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x; const float doorCenterZ = g_tweakAutoMapper->GetDoorCenter().z;
float doorCenterY = g_tweakAutoMapper->GetDoorCenter().y; if (x0_type == EMappableObjectType::BigDoor1)
if (x0_ == EMappableObjectType::BigDoor1)
{ {
zeus::CTransform scale;
scale.scaleBy(1.5);
zeus::CTransform orientation; zeus::CTransform orientation;
orientation.origin = {-1.4f*doorCenterX, 0.0f, 0.0f}; orientation.origin = {-1.4f*doorCenterX, 0.0f, 0.0f};
zeus::CTransform tmp3 = x10_ * orientation;
orientation.rotateLocalZ(zeus::degToRad(90.0f)); 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 else if (x0_type == EMappableObjectType::IceDoorCeiling || x0_type == EMappableObjectType::WaveDoorCeiling
|| x0_ == EMappableObjectType::Eleven) || 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 else if (x0_type == EMappableObjectType::IceDoorFloor || x0_type == EMappableObjectType::WaveDoorFloor
|| x0_ == EMappableObjectType::Twelve) || 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 else if ((u32(x0_type) - u32(EMappableObjectType::IceDoorFloor2)) <= u32(EMappableObjectType::ShieldDoor)
|| x0_ == EMappableObjectType::Fifteen) || 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 *) void CMappableObject::PostConstruct(const void *)
{ {
#if __BYTE_ORDER__!= __ORDER_BIG_ENDIAN__ #if __BYTE_ORDER__!= __ORDER_BIG_ENDIAN__
x0_ = EMappableObjectType(SBIG(u32(x0_))); x0_type = EMappableObjectType(SBIG(u32(x0_type)));
x4_ = SBIG(x4_); x4_ = SBIG(x4_);
x8_ = SBIG(x8_); x8_ = SBIG(x8_);
xc_ = SBIG(xc_); xc_ = SBIG(xc_);
@ -51,17 +67,22 @@ void CMappableObject::PostConstruct(const void *)
{ {
for (u32 j = 0 ; j<4 ; j++) for (u32 j = 0 ; j<4 ; j++)
{ {
u32* tmp = reinterpret_cast<u32*>(&x10_.basis.m[i][j]); u32* tmp = reinterpret_cast<u32*>(&x10_transform.basis.m[i][j]);
*tmp = SBIG(*tmp); *tmp = SBIG(*tmp);
} }
} }
#endif #endif
x10_.origin.x = x10_.basis.m[0][3]; x10_transform.origin.x = x10_transform.basis.m[0][3];
x10_.origin.y = x10_.basis.m[1][3]; x10_transform.origin.y = x10_transform.basis.m[1][3];
x10_.origin.z = x10_.basis.m[2][3]; x10_transform.origin.z = x10_transform.basis.m[2][3];
x10_.basis.transpose(); x10_transform.basis.transpose();
x10_ = AdjustTransformForType(); x10_transform = AdjustTransformForType();
}
zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(s32) const
{
return {};
} }
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)

View File

@ -26,8 +26,8 @@ public:
IceDoorFloor = 8, IceDoorFloor = 8,
WaveDoorCeiling = 9, WaveDoorCeiling = 9,
WaveDoorFloor = 10, WaveDoorFloor = 10,
Eleven = 11, PlasmaDoorCeiling= 11,
Twelve = 12, PlasmaDoorFloor = 12,
IceDoorFloor2 = 13, IceDoorFloor2 = 13,
WaveDoorFloor2 = 14, WaveDoorFloor2 = 14,
Fifteen = 15, Fifteen = 15,
@ -45,11 +45,11 @@ public:
private: private:
static const zeus::CVector3f skDoorVerts[8]; static const zeus::CVector3f skDoorVerts[8];
EMappableObjectType x0_; EMappableObjectType x0_type;
u32 x4_; u32 x4_;
TEditorId x8_; TEditorId x8_;
u32 xc_; u32 xc_;
zeus::CTransform x10_; zeus::CTransform x10_transform;
zeus::CTransform AdjustTransformForType(); zeus::CTransform AdjustTransformForType();
public: public:
void PostConstruct(const void*); void PostConstruct(const void*);
@ -57,7 +57,7 @@ public:
EMappableObjectType GetType() const; EMappableObjectType GetType() const;
void Draw(int, const CStateManager&, float, bool) const; void Draw(int, const CStateManager&, float, bool) const;
void DrawDoorSurface(int, const CStateManager&, float, int, 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 IsDoorConnectedToArea(s32, const CStateManager&) const;
bool IsDoorConnectedToVisitedArea(const CStateManager&) const; bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
bool GetIsVisibleToAutoMapper(bool) const; bool GetIsVisibleToAutoMapper(bool) const;