2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-07-29 17:00:23 +00:00
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
2016-07-31 01:43:34 +00:00
|
|
|
#include "CResFactory.hpp"
|
2016-07-29 17:00:23 +00:00
|
|
|
#include "zeus/CAABox.hpp"
|
|
|
|
#include "zeus/CVector3f.hpp"
|
2017-04-22 06:42:32 +00:00
|
|
|
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
|
|
|
#include "Graphics/CLineRenderer.hpp"
|
|
|
|
#include "Graphics/Shaders/CMapSurfaceShader.hpp"
|
|
|
|
#include "CMappableObject.hpp"
|
2016-07-29 17:00:23 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2017-04-16 05:52:43 +00:00
|
|
|
class IWorld;
|
2016-07-29 17:00:23 +00:00
|
|
|
class CMapArea
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class CMapAreaSurface
|
|
|
|
{
|
2017-04-22 06:42:32 +00:00
|
|
|
friend class CMapArea;
|
|
|
|
zeus::CVector3f x0_normal;
|
|
|
|
zeus::CVector3f xc_centroid;
|
|
|
|
const u8* x18_surfOffset;
|
|
|
|
const u8* x1c_outlineOffset;
|
|
|
|
u32 m_primStart;
|
|
|
|
u32 m_primCount;
|
2017-04-25 01:11:31 +00:00
|
|
|
struct Instance
|
|
|
|
{
|
|
|
|
CMapSurfaceShader m_surfacePrims;
|
|
|
|
std::vector<CLineRenderer> m_linePrims;
|
2017-11-05 06:17:12 +00:00
|
|
|
Instance(boo::IGraphicsDataFactory::Context& ctx,
|
|
|
|
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
|
|
|
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
2017-04-25 01:11:31 +00:00
|
|
|
: m_surfacePrims(ctx, vbo, ibo) {}
|
2017-11-05 06:17:12 +00:00
|
|
|
Instance(Instance&&) = default;
|
|
|
|
Instance& operator=(Instance&&) = default;
|
2017-04-25 01:11:31 +00:00
|
|
|
};
|
|
|
|
std::vector<Instance> m_instances;
|
2016-07-29 17:00:23 +00:00
|
|
|
public:
|
2017-04-22 06:42:32 +00:00
|
|
|
CMapAreaSurface(const void* surfBuf);
|
|
|
|
CMapAreaSurface(CMapAreaSurface&&) = default;
|
|
|
|
void PostConstruct(const u8* buf, std::vector<u32>& index);
|
|
|
|
void Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor,
|
2017-04-25 01:11:31 +00:00
|
|
|
const zeus::CColor& lineColor, float lineWidth, int instIdx=0) const;
|
2017-04-22 06:42:32 +00:00
|
|
|
const zeus::CVector3f& GetNormal() const { return x0_normal; }
|
|
|
|
const zeus::CVector3f& GetCenterPosition() const { return xc_centroid; }
|
2016-07-29 17:00:23 +00:00
|
|
|
};
|
2017-04-18 23:41:01 +00:00
|
|
|
enum class EVisMode
|
|
|
|
{
|
|
|
|
Always,
|
|
|
|
MapStationOrVisit,
|
|
|
|
Visit,
|
|
|
|
Never
|
|
|
|
};
|
2016-07-29 17:00:23 +00:00
|
|
|
|
|
|
|
private:
|
2016-07-31 01:43:34 +00:00
|
|
|
u32 x0_magic;
|
|
|
|
u32 x4_version;
|
|
|
|
u32 x8_;
|
2017-04-18 23:41:01 +00:00
|
|
|
EVisMode xc_visibilityMode;
|
2016-07-31 01:43:34 +00:00
|
|
|
zeus::CAABox x10_box;
|
|
|
|
u32 x28_mappableObjCount;
|
|
|
|
u32 x2c_vertexCount;
|
|
|
|
u32 x30_surfaceCount;
|
|
|
|
u32 x34_size;
|
|
|
|
u8* x38_moStart;
|
2017-04-22 06:42:32 +00:00
|
|
|
std::vector<CMappableObject> m_mappableObjects;
|
2016-07-31 01:43:34 +00:00
|
|
|
u8* x3c_vertexStart;
|
2017-04-25 01:11:31 +00:00
|
|
|
std::vector<zeus::CVector3f> m_verts;
|
2016-12-11 01:54:08 +00:00
|
|
|
u8* x40_surfaceStart;
|
2017-04-22 06:42:32 +00:00
|
|
|
std::vector<CMapAreaSurface> m_surfaces;
|
2016-07-31 01:43:34 +00:00
|
|
|
std::unique_ptr<u8[]> x44_buf;
|
2017-11-05 06:17:12 +00:00
|
|
|
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
|
|
|
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
2017-04-22 06:42:32 +00:00
|
|
|
|
2016-07-29 17:00:23 +00:00
|
|
|
public:
|
2017-04-22 06:42:32 +00:00
|
|
|
CMapArea(CInputStream& in, u32 size);
|
2016-07-29 17:00:23 +00:00
|
|
|
void PostConstruct();
|
2017-04-22 06:42:32 +00:00
|
|
|
bool GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const;
|
2017-03-20 05:09:53 +00:00
|
|
|
zeus::CVector3f GetAreaCenterPoint() const { return x10_box.center(); }
|
2017-04-16 05:52:43 +00:00
|
|
|
const zeus::CAABox& GetBoundingBox() const { return x10_box; }
|
2017-04-22 06:42:32 +00:00
|
|
|
const CMappableObject& GetMappableObject(int idx) const { return m_mappableObjects[idx]; }
|
|
|
|
const CMapAreaSurface& GetSurface(int idx) const { return m_surfaces[idx]; }
|
|
|
|
u32 GetNumMappableObjects() const { return m_mappableObjects.size(); }
|
|
|
|
u32 GetNumSurfaces() const { return m_surfaces.size(); }
|
2017-04-16 05:52:43 +00:00
|
|
|
zeus::CTransform GetAreaPostTransform(const IWorld& world, TAreaId aid) const;
|
2017-04-18 23:41:01 +00:00
|
|
|
static const zeus::CVector3f& GetAreaPostTranslate(const IWorld& world, TAreaId aid);
|
2017-04-25 01:11:31 +00:00
|
|
|
const zeus::CVector3f* GetVertices() const { return m_verts.data(); }
|
2016-07-29 17:00:23 +00:00
|
|
|
};
|
2016-07-31 01:43:34 +00:00
|
|
|
|
2017-03-24 05:30:16 +00:00
|
|
|
CFactoryFnReturn FMapAreaFactory(const SObjectTag& objTag, CInputStream& in, const CVParamTransfer&,
|
|
|
|
CObjectReference*);
|
2016-07-29 17:00:23 +00:00
|
|
|
}
|