270 lines
8.3 KiB
C++
270 lines
8.3 KiB
C++
#pragma once
|
|
|
|
#include "eter_render/RenderCommands3D.h"
|
|
#include "eter_render/TerrainHeightmap.h"
|
|
#include "eter_render/MapObjectManager.h"
|
|
#include "eter_render/WaterManager.h"
|
|
#include "eter_render/EnvironmentData.h"
|
|
#include "eter_render/SkyBox.h"
|
|
#include "eter_render/SpeedTreeForest.h"
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace ava2 {
|
|
|
|
struct OutdoorMapInfo {
|
|
std::string name;
|
|
uint32_t baseX = 0;
|
|
uint32_t baseY = 0;
|
|
int16_t terrainCountX = 0;
|
|
int16_t terrainCountY = 0;
|
|
};
|
|
|
|
class CPythonBackground {
|
|
public:
|
|
enum {
|
|
SHADOW_NONE = 0,
|
|
SHADOW_GROUND = 1,
|
|
SHADOW_GROUND_AND_SOLO = 2,
|
|
SHADOW_ALL = 3,
|
|
SHADOW_ALL_HIGH = 4,
|
|
SHADOW_ALL_MAX = 5,
|
|
};
|
|
|
|
enum {
|
|
DISTANCE0 = 0,
|
|
DISTANCE1 = 1,
|
|
DISTANCE2 = 2,
|
|
DISTANCE3 = 3,
|
|
DISTANCE4 = 4,
|
|
NUM_DISTANCE_SET = 5,
|
|
};
|
|
|
|
enum {
|
|
PART_TERRAIN = 0,
|
|
PART_OBJECT = 1,
|
|
PART_CLOUD = 2,
|
|
PART_WATER = 3,
|
|
PART_TREE = 4,
|
|
PART_SKY = 5,
|
|
PART_SHOP = 6,
|
|
PART_NUM = 7,
|
|
};
|
|
|
|
enum {
|
|
DAY_MODE_LIGHT = 0,
|
|
DAY_MODE_DARK = 1,
|
|
};
|
|
|
|
enum ETerrainRenderSort {
|
|
DISTANCE_SORT = 0,
|
|
TEXTURE_SORT = 1,
|
|
};
|
|
|
|
enum {
|
|
SKY_RENDER_MODE_DEFAULT = 0,
|
|
SKY_RENDER_MODE_DIFFUSE = 1,
|
|
SKY_RENDER_MODE_TEXTURE = 2,
|
|
SKY_RENDER_MODE_MODULATE = 3,
|
|
SKY_RENDER_MODE_MODULATE2X = 4,
|
|
SKY_RENDER_MODE_MODULATE4X = 5,
|
|
};
|
|
|
|
struct SViewDistanceSet {
|
|
float m_fFogStart = 12800.0f;
|
|
float m_fFogEnd = 17920.0f;
|
|
float m_fFarClip = 25600.0f;
|
|
float m_v3SkyBoxScale[3] = {15360.0f, 15360.0f, 15360.0f};
|
|
};
|
|
|
|
struct TMapInfo {
|
|
std::string m_strName;
|
|
uint32_t m_dwBaseX = 0;
|
|
uint32_t m_dwBaseY = 0;
|
|
uint32_t m_dwSizeX = 0;
|
|
uint32_t m_dwSizeY = 0;
|
|
uint32_t m_dwEndX = 0;
|
|
uint32_t m_dwEndY = 0;
|
|
};
|
|
|
|
static CPythonBackground& Instance();
|
|
|
|
CPythonBackground();
|
|
~CPythonBackground();
|
|
|
|
void Initialize();
|
|
void Destroy();
|
|
void Create();
|
|
|
|
bool IsMapReady() const;
|
|
|
|
bool LoadMap(const std::string& mapName, float x = 0.0f, float y = 0.0f, float z = 0.0f);
|
|
bool Warp(uint32_t x, uint32_t y);
|
|
|
|
const std::string& GetCurrentMapName() const { return m_strMapName; }
|
|
const std::string& GetWarpMapName() const { return m_strWarpMapName; }
|
|
|
|
void GlobalPositionToLocalPosition(long& rGlobalX, long& rGlobalY);
|
|
void LocalPositionToGlobalPosition(long& rLocalX, long& rLocalY);
|
|
TMapInfo* GlobalPositionToMapInfo(uint32_t dwGlobalX, uint32_t dwGlobalY);
|
|
|
|
float GetHeight(float fx, float fy);
|
|
bool IsAttrOn(float fx, float fy, uint8_t attr);
|
|
|
|
bool GetPickingPoint(float* pIntersectPt);
|
|
void SetPickingPoint(float x, float y, float z);
|
|
|
|
void SelectViewDistanceNum(int eNum);
|
|
void SetViewDistanceSet(int eNum, float fFarClip);
|
|
float GetFarClip();
|
|
void GetDistanceSetInfo(int* peNum, float* pfStart, float* pfEnd, float* pfFarClip);
|
|
|
|
bool SetVisiblePart(int ePart, bool isVisible);
|
|
bool IsVisiblePart(int ePart) const;
|
|
|
|
bool SetShadowLevel(int eLevel);
|
|
int GetShadowLevel() const { return m_eShadowLevel; }
|
|
uint32_t GetRenderShadowTime() const { return m_dwRenderShadowTime; }
|
|
|
|
bool SetSplatLimit(int iSplatNum);
|
|
int GetSplatLimit() const { return m_iSplatLimit; }
|
|
std::string GetRenderedSplatNumStr(int* pPatch, int* pSplat, float* pRatio);
|
|
void GetRenderedGraphicThingInstanceNum(uint32_t* pCount, uint32_t* pCRC);
|
|
|
|
uint32_t GetShadowMapColor(float fx, float fy);
|
|
|
|
void ReserveSoftwareTilingEnable(bool enable) { m_bSoftwareTilingEnable = enable; }
|
|
bool IsSoftwareTilingEnable() const { return m_bSoftwareTilingEnable; }
|
|
|
|
void EnableSnowEnvironment(bool enable = true);
|
|
void DisableSnowEnvironment();
|
|
bool IsSnowEnvironment() const { return m_bSnowEnable; }
|
|
|
|
void SetTransparentTree(bool enable) { m_bTransparentTree = enable; }
|
|
bool IsTransparentTree() const { return m_bTransparentTree; }
|
|
|
|
void SetXMaxTree(int iGrade) { m_iXMasTreeGrade = iGrade; }
|
|
int GetXMaxTree() const { return m_iXMasTreeGrade; }
|
|
|
|
void RegisterDungeonMapName(const char* szName);
|
|
|
|
void VisibleGuildArea() { m_bVisibleGuildArea = true; }
|
|
void DisableGuildArea() { m_bVisibleGuildArea = false; }
|
|
void RegisterGuildArea(int isx, int isy, int iex, int iey);
|
|
void ClearGuildArea();
|
|
|
|
bool RegisterEnvironmentData(int iIndex, const char* pszEnvironmentFileName);
|
|
bool SetEnvironmentData(int iIndex);
|
|
const EnvironmentData* GetCurrentEnvironmentData() const { return m_pCurrentEnvironment; }
|
|
|
|
void BeginEnvironment();
|
|
void EndEnvironment();
|
|
|
|
void SetCharacterDirLight();
|
|
void SetBackgroundDirLight();
|
|
|
|
void SetTerrainRenderSort(int eSort) { m_eTerrainRenderSort = eSort; }
|
|
void SetBGLoading(bool bgLoading) { m_bBGLoading = bgLoading; }
|
|
|
|
void CreatePrivateShopPos(int vid);
|
|
void DeletePrivateShopPos();
|
|
|
|
void CreateTargetEffect(uint32_t dwID, uint32_t dwChrVID);
|
|
void CreateTargetEffect(uint32_t dwID, long lx, long ly);
|
|
void DeleteTargetEffect(uint32_t dwID);
|
|
|
|
void CreateTargetEffectShop(uint32_t dwID, uint32_t dwChrVID);
|
|
void CreateTargetEffectShop(uint32_t dwID, long lx, long ly);
|
|
|
|
void CreateSpecialEffect(uint32_t dwID, float fx, float fy, float fz, const char* szFileName);
|
|
void DeleteSpecialEffect(uint32_t dwID);
|
|
|
|
void Update(float fCameraX, float fCameraY, float fCameraZ);
|
|
|
|
void Render();
|
|
void RenderSky();
|
|
void RenderCloud();
|
|
void RenderWater();
|
|
void RenderEffect();
|
|
void RenderCollision();
|
|
void RenderPCBlocker();
|
|
void RenderBeforeLensFlare();
|
|
void RenderAfterLensFlare();
|
|
void RenderCharacterShadowToTexture();
|
|
void RenderSnow();
|
|
|
|
TerrainHeightmap* GetTerrain() { return m_terrain.get(); }
|
|
MapObjectManager* GetMapObjects() { return m_mapObjects.get(); }
|
|
WaterManager* GetWater() { return m_water.get(); }
|
|
SkyBox* GetSkyBox() { return m_skybox.get(); }
|
|
SpeedTreeForest* GetForest() { return m_forest.get(); }
|
|
const OutdoorMapInfo* GetOutdoorMap() const { return m_strMapName.empty() ? nullptr : &m_outdoorMap; }
|
|
|
|
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, const float* camPos, std::vector<Render3DDraw>& outDraws);
|
|
|
|
private:
|
|
void LoadAtlas();
|
|
|
|
std::string m_strMapName;
|
|
std::string m_strWarpMapName;
|
|
uint32_t m_dwBaseX = 0;
|
|
uint32_t m_dwBaseY = 0;
|
|
|
|
int m_eViewDistanceNum = 0;
|
|
SViewDistanceSet m_ViewDistanceSet[NUM_DISTANCE_SET];
|
|
|
|
bool m_bVisiblePart[PART_NUM] = {true, true, true, true, true, true, true};
|
|
int m_eShadowLevel = SHADOW_NONE;
|
|
uint32_t m_dwRenderShadowTime = 0;
|
|
int m_iSplatLimit = 0;
|
|
|
|
bool m_bSoftwareTilingEnable = false;
|
|
bool m_bSnowEnable = false;
|
|
bool m_bTransparentTree = false;
|
|
int m_iXMasTreeGrade = 0;
|
|
bool m_bVisibleGuildArea = false;
|
|
int m_eTerrainRenderSort = DISTANCE_SORT;
|
|
bool m_bBGLoading = false;
|
|
|
|
float m_v3PickingPoint[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
std::set<std::string> m_kSet_strDungeonMapName;
|
|
|
|
std::vector<TMapInfo> m_kVct_kMapInfo;
|
|
std::string m_atlasLocale;
|
|
|
|
std::map<int, EnvironmentData> m_mapEnvironmentData;
|
|
const EnvironmentData* m_pCurrentEnvironment = nullptr;
|
|
EnvironmentData m_defaultEnvironment;
|
|
|
|
std::unique_ptr<TerrainHeightmap> m_terrain;
|
|
std::unique_ptr<MapObjectManager> m_mapObjects;
|
|
std::unique_ptr<WaterManager> m_water;
|
|
std::unique_ptr<SkyBox> m_skybox;
|
|
std::unique_ptr<SpeedTreeForest> m_forest;
|
|
|
|
OutdoorMapInfo m_outdoorMap;
|
|
|
|
std::map<uint32_t, uint32_t> m_targetEffects;
|
|
std::map<uint32_t, uint32_t> m_targetEffectsShop;
|
|
std::map<uint32_t, std::pair<float, float>> m_targetPositions;
|
|
uint32_t m_privateShopPosVID = 0;
|
|
};
|
|
|
|
void initBackground();
|
|
|
|
TerrainHeightmap* GetActiveBackgroundTerrain();
|
|
void SetActiveBackgroundTerrain(std::unique_ptr<TerrainHeightmap> terrain);
|
|
bool LoadBackgroundMap(const std::string& mapName, float x = 0.0f, float y = 0.0f, float z = 0.0f);
|
|
bool WarpBackgroundMap(uint32_t x, uint32_t y);
|
|
void GlobalToLocalPosition(int32_t& x, int32_t& y);
|
|
void LocalToGlobalPosition(int32_t& x, int32_t& y);
|
|
const OutdoorMapInfo* GetOutdoorMap();
|
|
|
|
} // namespace ava2
|