Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
PortalSystem.h
Go to the documentation of this file.
1#ifndef PORTAL_SYSTEM_H_INCLUDED
2#define PORTAL_SYSTEM_H_INCLUDED
3
4#include <vector>
5
6#include <Ult/ModelData.h>
7#include <Ult/TokenStream.h>
11
12class Sector;
13
14struct stModel{};
16
18{
19 float x,y,z;
20 float tu,tv;
21};
22
32
33class Portal
34{
35public:
37 mConnectedArea = -1;
38 mSize = 0;
39 }
41
42 void operator=(const Portal& p) {
43 mConnectedArea = p.GetConnectedArea();
44 mCenter = p.GetCenter();
45 mSize = p.GetSize();
46 mName = p.GetName();
47 }
48
49 void SetConnectedArea(int area) { mConnectedArea = area; }
50 int GetConnectedArea() const { return mConnectedArea; }
51
52 void SetCenter(const Ult::Vector3D& pos) { mCenter = pos; }
53 Ult::Vector3D GetCenter() const { return mCenter; }
54
55 void SetSize(const float size) { mSize = size; }
56 float GetSize() const { return mSize; }
57
58 void SetName(const std::string& name) { mName = name; }
59 std::string GetName() const { return mName; }
60
61private:
62 int mConnectedArea;
63 Ult::Vector3D mCenter;
64 float mSize;
65 std::string mName;
66};
67
68class Sector
69{
70public:
71 Sector() {}
73
74 bool LoadSectorFromFile(const char* modelFile);
75
76 std::string GetDecalFile() const { return mMesh.mDecalFile; }
77 void SetDecal(const Ult::Texture& decal) {
78 mMesh.mDecal.Initialize(decal.GetIndex());
79 }
80
81 void SetMesh(const SectorMesh& mesh) { mMesh = mesh; }
82 SectorMesh* GetMesh() { return &mMesh; }
83
84 void SetPortal(const Portal& p) { mPortals.push_back(p); }
85 std::vector<Portal>* GetPortals() { return &mPortals; }
86
87 Ult::BoundingBox GetBoundingBox() const { return mAabb; }
88
89private:
90 SectorMesh mMesh;
91 std::vector<Portal> mPortals;
92 Ult::BoundingBox mAabb;
93};
94
95#endif // PORTAL_SYSTEM_H_INCLUDED
96
Ult::Handle< stModel > ULT_MODEL
Definition PortalSystem.h:15
Definition PortalSystem.h:34
~Portal()
Definition PortalSystem.h:40
void SetName(const std::string &name)
Definition PortalSystem.h:58
float GetSize() const
Definition PortalSystem.h:56
void SetSize(const float size)
Definition PortalSystem.h:55
int GetConnectedArea() const
Definition PortalSystem.h:50
std::string GetName() const
Definition PortalSystem.h:59
void SetCenter(const Ult::Vector3D &pos)
Definition PortalSystem.h:52
void operator=(const Portal &p)
Definition PortalSystem.h:42
Ult::Vector3D GetCenter() const
Definition PortalSystem.h:53
void SetConnectedArea(int area)
Definition PortalSystem.h:49
Portal()
Definition PortalSystem.h:36
Definition PortalSystem.h:69
bool LoadSectorFromFile(const char *modelFile)
Definition PortalSystem.cpp:6
void SetDecal(const Ult::Texture &decal)
Definition PortalSystem.h:77
void SetPortal(const Portal &p)
Definition PortalSystem.h:84
std::string GetDecalFile() const
Definition PortalSystem.h:76
std::vector< Portal > * GetPortals()
Definition PortalSystem.h:85
~Sector()
Definition PortalSystem.h:72
SectorMesh * GetMesh()
Definition PortalSystem.h:82
void SetMesh(const SectorMesh &mesh)
Definition PortalSystem.h:81
Sector()
Definition PortalSystem.h:71
Ult::BoundingBox GetBoundingBox() const
Definition PortalSystem.h:87
Definition PortalSystem.h:24
Ult::ModelData mGeometry
Definition PortalSystem.h:28
std::string mDecalFile
Definition PortalSystem.h:30
Ult::Texture mDecal
Definition PortalSystem.h:29
SectorMesh()
Definition PortalSystem.h:26
Definition BoundingBox.h:18
Definition Handle.h:13
int GetIndex() const
Definition Handle.h:36
Definition ModelData.h:26
Definition Vector3D.h:12
Handle< stTexture > Texture
Definition Texture.h:10
Definition PortalSystem.h:14
Definition PortalSystem.h:18
float x
Definition PortalSystem.h:19
float z
Definition PortalSystem.h:19
float tv
Definition PortalSystem.h:20
float tu
Definition PortalSystem.h:20
float y
Definition PortalSystem.h:19