More AutoMapper imps (CMapArea and CMappableObject)

This commit is contained in:
Phillip Stephens 2016-07-30 18:43:34 -07:00
parent df4ce27240
commit 4541234706
8 changed files with 158 additions and 13 deletions

View File

@ -1266,18 +1266,28 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
targetMSet.head.addMaterialEndOff(endOff);
}
for (const hecl::ProjectPath& path : texPaths)
texPaths.reserve(mset.size()*4);
for (const Mesh::Material& mat : mset)
{
const hecl::SystemString& relPath = path.getRelativePath();
/* TODO: incorporate hecl hashes */
size_t search = relPath.find(_S("TXTR_"));
if (search != hecl::SystemString::npos)
targetMSet.head.addTexture(relPath.c_str() + search + 5);
else
LogDNACommon.report(logvisor::Fatal, "unable to get hash from path");
for (const hecl::ProjectPath& path : mat.texs)
{
bool found = false;
for (const hecl::ProjectPath& ePath : texPaths)
{
if (path == ePath)
{
found = true;
break;
}
}
if (!found)
texPaths.push_back(path);
}
}
for (const hecl::ProjectPath& path : texPaths)
targetMSet.head.addTexture(path);
size_t secSz = targetMSet.binarySize(0);
size_t secSz32 = ROUND_UP_32(secSz);
head.secSizes.push_back(secSz32);

View File

@ -1 +1,54 @@
#include "CMapArea.hpp"
#include "GameGlobalObjects.hpp"
#include "CMappableObject.hpp"
#include "CToken.hpp"
namespace urde
{
CMapArea::CMapArea(CInputStream& in, u32 size)
: x0_magic(in.readUint32()),
x4_version(in.readUint32Big()),
x8_(in.readUint32Big()),
xc_(in.readUint32Big()),
x10_box(zeus::CAABox::ReadBoundingBoxBig(in)),
x28_mappableObjCount(in.readUint32Big()),
x2c_vertexCount(in.readUint32Big()),
x30_surfaceCount(in.readUint32Big()),
x34_size(size - 52)
{
x44_buf.reset(new u8[x34_size]);
in.readUBytesToBuf(x44_buf.get(), x34_size);
PostConstruct();
}
void CMapArea::PostConstruct()
{
x38_moStart = x44_buf.get();
x3c_vertexStart = x38_moStart + (x28_mappableObjCount * 0x50);
x40_surfaceStart = x40_surfaceStart + (x2c_vertexCount * 12);
for (u32 i = 0, j=0 ; i<x28_mappableObjCount ; ++i, j += 0x50)
(reinterpret_cast<CMappableObject*>(x38_moStart + j))->PostConstruct(x44_buf.get());
#if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__
u8* tmp = x3c_vertexStart;
for (u32 i = 0 ; i<(x2c_vertexCount*3) ; ++i)
{
u32* fl = reinterpret_cast<u32*>(x3c_vertexStart + i);
*fl = SBIG(*fl);
tmp += 4;
}
#endif
for (u32 i = 0, j = 0 ; i<x30_surfaceCount ; ++i, j += 32)
(reinterpret_cast<CMapAreaSurface*>(x40_surfaceStart + j))->PostConstruct(x44_buf.get());
}
CFactoryFnReturn FMapAreaFactory(const SObjectTag& objTag, CInputStream& in, const CVParamTransfer&)
{
u32 size = g_ResFactory->ResourceSize(objTag);
return TToken<CMapArea>::GetIObjObjectFor(std::unique_ptr<CMapArea>
(new CMapArea(in, size)));
}
}

View File

@ -2,6 +2,7 @@
#define __URDE_CMAPAREA_HPP__
#include "RetroTypes.hpp"
#include "CResFactory.hpp"
#include "zeus/CAABox.hpp"
#include "zeus/CVector3f.hpp"
@ -20,8 +21,21 @@ public:
};
private:
u32 x0_magic;
u32 x4_version;
u32 x8_;
u32 xc_;
zeus::CAABox x10_box;
u32 x28_mappableObjCount;
u32 x2c_vertexCount;
u32 x30_surfaceCount;
u32 x34_size;
u8* x38_moStart;
u8* x3c_vertexStart;
u32 x40_surfaceStart;
std::unique_ptr<u8[]> x44_buf;
public:
CMapArea(CInputStream&, uint);
CMapArea(CInputStream&, u32);
void PostConstruct();
bool GetIsVisibleToAutoMapper(bool, bool) const;
zeus::CVector3f GetAreaCenterPoint() const;
@ -33,5 +47,7 @@ public:
u32 GetNumSurfaces() const;
};
CFactoryFnReturn FMapAreaFactory(const SObjectTag& objTag, CInputStream& in, const CVParamTransfer&);
}
#endif // __URDE_CMAPAREA_HPP__

View File

@ -90,7 +90,7 @@ public:
u32 GetNumAreas() const;
void GetLoadedMapArea(s32) const;
void GetMapArea(s32) const;
void IsMapAreaInBFSInfoVector(const CMapWorld::CMapAreaData*, const std::vector<CMapAreaBFSInfo>&) const;
void IsMapAreaInBFSInfoVector(const CMapAreaData*, const std::vector<CMapAreaBFSInfo>&) const;
void SetWhichMapAreasLoaded(const IWorld&, int start, int count);
bool IsMapAreasStreaming() const;
void MoveMapAreaToList(CMapAreaData*, EMapAreaList);

View File

@ -1,15 +1,67 @@
#include "CMappableObject.hpp"
#include "GameGlobalObjects.hpp"
#include "ITweakAutoMapper.hpp"
namespace urde
{
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)
{
}
else if (x0_ == EMappableObjectType::BigDoor2)
{
}
else if (x0_ == EMappableObjectType::IceDoorCeiling || x0_ == EMappableObjectType::WaveDoorCeiling
|| x0_ == EMappableObjectType::Eleven)
{
}
else if (x0_ == EMappableObjectType::IceDoorCeiling || x0_ == EMappableObjectType::WaveDoorFloor
|| x0_ == EMappableObjectType::Twelve)
{
}
else if (EMappableObjectType(u32(x0_) - u32(EMappableObjectType::IceDoorFloor2)) <= EMappableObjectType::ShieldDoor
|| x0_ == EMappableObjectType::Fifteen)
{
}
return x10_;
}
void CMappableObject::PostConstruct(const void *)
{
#if __BYTE_ORDER__!= __ORDER_BIG_ENDIAN__
x0_ = EMappableObjectType(SBIG(u32(x0_)));
x4_ = SBIG(x4_);
x8_ = SBIG(x8_);
xc_ = SBIG(xc_);
for (u32 i = 0 ; i<3 ; i++)
{
for (u32 j = 0 ; j<4 ; j++)
{
u32* tmp = reinterpret_cast<u32*>(&x10_.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();
}
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)
{
const zeus::CVector3f& center = tweaks.GetDoorCenter();
/* Ugly hack, but necessary */
zeus::CVector3f* doorVerts = (zeus::CVector3f*)CMappableObject::skDoorVerts;
zeus::CVector3f* doorVerts = const_cast<zeus::CVector3f*>(&CMappableObject::skDoorVerts[0]);
/* Wrap door verts around -Z to build surface */
doorVerts[0].assign( -center.z, -center.y, 0.f);
doorVerts[1].assign( -center.z, -center.y, 2.f * center.x);

View File

@ -9,6 +9,7 @@ namespace urde
{
class CStateManager;
class ITweakAutoMapper;
class CMappableObject
{
public:
@ -25,8 +26,11 @@ public:
IceDoorFloor = 8,
WaveDoorCeiling = 9,
WaveDoorFloor = 10,
Eleven = 11,
Twelve = 12,
IceDoorFloor2 = 13,
WaveDoorFloor2 = 14,
Fifteen = 15,
DownArrowYellow = 27, /* Maintenance Tunnel */
UpArrowYellow = 28, /* Phazon Processing Center */
DownArrowGreen = 29, /* Elevator A */
@ -41,6 +45,12 @@ public:
private:
static const zeus::CVector3f skDoorVerts[8];
EMappableObjectType x0_;
u32 x4_;
TEditorId x8_;
u32 xc_;
zeus::CTransform x10_;
zeus::CTransform AdjustTransformForType();
public:
void PostConstruct(const void*);
const zeus::CTransform& GetTransform() const;

View File

@ -3,6 +3,7 @@
#include "../DataSpec/DNACommon/Tweaks/ITweakGame.hpp"
#include "../DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp"
#include "../DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp"
#include "AutoMapper/ITweakAutoMapper.hpp"
namespace urde
{
@ -19,6 +20,7 @@ extern class CBooRenderer* g_Renderer;
extern DataSpec::ITweakGame* g_tweakGame;
extern DataSpec::ITweakPlayer* g_tweakPlayer;
extern DataSpec::ITweakPlayerControl* g_tweakPlayerControl;
extern ITweakAutoMapper* g_tweakAutoMapper;
}

View File

@ -9,10 +9,12 @@ CPVSBounds::CPVSBounds(CInputStream& in)
u32 CPVSBounds::GetBoundsFileSize()
{
return 0;
}
bool CPVSBounds::PointInBounds(const zeus::CVector3f&) const
{
return false;
}
}