map.h
来自「3D游戏开发需要用到BSP树来经行场景渲染的管理。本代码包含完整的BSP及文件生」· C头文件 代码 · 共 97 行
H
97 行
#pragma once
#include "hashtablevec.h"
#include "lexer.h"
#include "string.h"
#include "vector.h"
#include "math.h"
#include "keyvalpair.h"
#include "shader.h"
class CMapBrush;
class CMapEntity {
public:
CVector<CMapBrush>* GetBrushes();
CString* GetValue(CString& key);
void EmitKVPairs(CString *str);
bool Parse();
CDict keyValPairs;
CVector<CMapBrush> brushes;
};
inline CVector<CMapBrush>* CMapEntity::GetBrushes() {
return &brushes;
}
inline CString* CMapEntity::GetValue(CString& key) {
return keyValPairs.Get(key);
}
class CMapLoader {
public:
CMapLoader();
~CMapLoader();
bool LoadMap(CString *filename);
int AddPlane(sPlane& p);
int AddShader(CMapShader& s);
sPlane* GetPlane(int i);
CMapShader* GetShader(int i);
CVector<CMapEntity>* GetEntities();
CLexer* GetLex();
CString* GetFilename();
private:
CVector<CMapEntity> entities;
CVecHash<sPlane> planes;
CVecHash<CMapShader> shaders;
CLexer lex;
CString src;
CString* filename;
};
// While a mediator object might be a more elegant solution
// than a global map pointer, here it seems it will be slower
// and harder to understand.
extern CMapLoader *g_curMap;
inline CMapLoader::CMapLoader():src(true) {
}
inline CMapLoader::~CMapLoader() {
if(g_curMap == this)
g_curMap = 0;
}
inline CString* CMapLoader::GetFilename() {
return filename;
}
inline CVector<CMapEntity>* CMapLoader::GetEntities() {
return &entities;
}
inline int CMapLoader::AddPlane(sPlane& p) {
return planes.AddElem(p);
}
inline sPlane* CMapLoader::GetPlane(int i) {
return planes.GetElem(i);
}
inline int CMapLoader::AddShader(CMapShader& s) {
return shaders.AddElem(s);
}
inline CMapShader* CMapLoader::GetShader(int i) {
return shaders.GetElem(i);
}
inline CLexer* CMapLoader::GetLex() {
return &lex;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?