Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/GameInterface/ActorViewer.cpp
Show All 30 Lines | |||||
#include "graphics/Patch.h" | #include "graphics/Patch.h" | ||||
#include "graphics/SkeletonAnimManager.h" | #include "graphics/SkeletonAnimManager.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/TerrainTextureEntry.h" | #include "graphics/TerrainTextureEntry.h" | ||||
#include "graphics/TerrainTextureManager.h" | #include "graphics/TerrainTextureManager.h" | ||||
#include "graphics/TerritoryTexture.h" | #include "graphics/TerritoryTexture.h" | ||||
#include "graphics/UnitManager.h" | #include "graphics/UnitManager.h" | ||||
#include "graphics/Overlay.h" | #include "graphics/Overlay.h" | ||||
#include "graphics/WaterManager.h" | |||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/GameSetup/Config.h" | #include "ps/GameSetup/Config.h" | ||||
#include "ps/ProfileViewer.h" | #include "ps/ProfileViewer.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/RenderingOptions.h" | #include "renderer/RenderingOptions.h" | ||||
#include "renderer/Scene.h" | #include "renderer/Scene.h" | ||||
#include "renderer/SkyManager.h" | #include "renderer/SkyManager.h" | ||||
#include "renderer/WaterManager.h" | |||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/components/ICmpAttack.h" | #include "simulation2/components/ICmpAttack.h" | ||||
#include "simulation2/components/ICmpOwnership.h" | #include "simulation2/components/ICmpOwnership.h" | ||||
#include "simulation2/components/ICmpPosition.h" | #include "simulation2/components/ICmpPosition.h" | ||||
#include "simulation2/components/ICmpRangeManager.h" | #include "simulation2/components/ICmpRangeManager.h" | ||||
#include "simulation2/components/ICmpTerrain.h" | #include "simulation2/components/ICmpTerrain.h" | ||||
#include "simulation2/components/ICmpUnitMotion.h" | #include "simulation2/components/ICmpUnitMotion.h" | ||||
Show All 10 Lines | ActorViewerImpl() : | ||||
Terrain(), | Terrain(), | ||||
ColladaManager(g_VFS), | ColladaManager(g_VFS), | ||||
MeshManager(ColladaManager), | MeshManager(ColladaManager), | ||||
SkeletonAnimManager(ColladaManager), | SkeletonAnimManager(ColladaManager), | ||||
UnitManager(), | UnitManager(), | ||||
Simulation2(&UnitManager, g_ScriptContext, &Terrain), | Simulation2(&UnitManager, g_ScriptContext, &Terrain), | ||||
ObjectManager(MeshManager, SkeletonAnimManager, Simulation2), | ObjectManager(MeshManager, SkeletonAnimManager, Simulation2), | ||||
LOSTexture(Simulation2), | LOSTexture(Simulation2), | ||||
TerritoryTexture(Simulation2) | TerritoryTexture(Simulation2), | ||||
WaterManager() | |||||
{ | { | ||||
UnitManager.SetObjectManager(ObjectManager); | UnitManager.SetObjectManager(ObjectManager); | ||||
} | } | ||||
entity_id_t Entity; | entity_id_t Entity; | ||||
CStrW CurrentUnitID; | CStrW CurrentUnitID; | ||||
CStr CurrentUnitAnim; | CStr CurrentUnitAnim; | ||||
float CurrentSpeed; | float CurrentSpeed; | ||||
bool WalkEnabled; | bool WalkEnabled; | ||||
bool GroundEnabled; | bool GroundEnabled; | ||||
bool WaterEnabled; | bool WaterEnabled; | ||||
bool ShadowsEnabled; | bool ShadowsEnabled; | ||||
// Whether shadows, sky and water are enabled outside of the actor viewer. | // Whether shadows, sky are enabled outside of the actor viewer. | ||||
bool OldShadows; | bool OldShadows; | ||||
bool OldSky; | bool OldSky; | ||||
bool OldWater; | |||||
bool SelectionBoxEnabled; | bool SelectionBoxEnabled; | ||||
bool AxesMarkerEnabled; | bool AxesMarkerEnabled; | ||||
int PropPointsMode; // 0 disabled, 1 for point markers, 2 for point markers + axes | int PropPointsMode; // 0 disabled, 1 for point markers, 2 for point markers + axes | ||||
SColor4ub Background; | SColor4ub Background; | ||||
CTerrain Terrain; | CTerrain Terrain; | ||||
CColladaManager ColladaManager; | CColladaManager ColladaManager; | ||||
CMeshManager MeshManager; | CMeshManager MeshManager; | ||||
CSkeletonAnimManager SkeletonAnimManager; | CSkeletonAnimManager SkeletonAnimManager; | ||||
CObjectManager ObjectManager; | CObjectManager ObjectManager; | ||||
CUnitManager UnitManager; | CUnitManager UnitManager; | ||||
CSimulation2 Simulation2; | CSimulation2 Simulation2; | ||||
CLOSTexture LOSTexture; | CLOSTexture LOSTexture; | ||||
CTerritoryTexture TerritoryTexture; | CTerritoryTexture TerritoryTexture; | ||||
WaterManager WaterManager; | |||||
SOverlayLine SelectionBoxOverlay; | SOverlayLine SelectionBoxOverlay; | ||||
SOverlayLine AxesMarkerOverlays[3]; | SOverlayLine AxesMarkerOverlays[3]; | ||||
std::vector<CModel::Prop> Props; | std::vector<CModel::Prop> Props; | ||||
std::vector<SOverlayLine> PropPointOverlays; | std::vector<SOverlayLine> PropPointOverlays; | ||||
// Simplistic implementation of the Scene interface | // Simplistic implementation of the Scene interface | ||||
virtual void EnumerateObjects(const CFrustum& frustum, SceneCollector* c) | virtual void EnumerateObjects(const CFrustum& frustum, SceneCollector* c) | ||||
{ | { | ||||
if (GroundEnabled) | if (GroundEnabled) | ||||
vladislavbelov: Should be `terrain` if it's local. | |||||
{ | { | ||||
for (ssize_t pj = 0; pj < Terrain.GetPatchesPerSide(); ++pj) | for (ssize_t pj = 0; pj < Terrain.GetPatchesPerSide(); ++pj) | ||||
for (ssize_t pi = 0; pi < Terrain.GetPatchesPerSide(); ++pi) | for (ssize_t pi = 0; pi < Terrain.GetPatchesPerSide(); ++pi) | ||||
c->Submit(Terrain.GetPatch(pi, pj)); | c->Submit(Terrain.GetPatch(pi, pj)); | ||||
} | } | ||||
CmpPtr<ICmpVisual> cmpVisual(Simulation2, Entity); | CmpPtr<ICmpVisual> cmpVisual(Simulation2, Entity); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | ActorViewer::ActorViewer() | ||||
m.GroundEnabled = true; | m.GroundEnabled = true; | ||||
m.WaterEnabled = false; | m.WaterEnabled = false; | ||||
m.ShadowsEnabled = g_RenderingOptions.GetShadows(); | m.ShadowsEnabled = g_RenderingOptions.GetShadows(); | ||||
m.SelectionBoxEnabled = false; | m.SelectionBoxEnabled = false; | ||||
m.AxesMarkerEnabled = false; | m.AxesMarkerEnabled = false; | ||||
m.PropPointsMode = 0; | m.PropPointsMode = 0; | ||||
m.Background = SColor4ub(0, 0, 0, 255); | m.Background = SColor4ub(0, 0, 0, 255); | ||||
// Create a tiny empty piece of terrain, just so we can put shadows | // Create a tiny empty piece of terrain, just so we can put shadows | ||||
Done Inline Actionsterrain. vladislavbelov: `terrain`. | |||||
// on it without having to think too hard | // on it without having to think too hard | ||||
m.Terrain.Initialize(2, NULL); | m.Terrain.Initialize(2, NULL); | ||||
CTerrainTextureEntry* tex = g_TexMan.FindTexture("whiteness"); | CTerrainTextureEntry* tex = g_TexMan.FindTexture("whiteness"); | ||||
if (tex) | if (tex) | ||||
{ | { | ||||
for (ssize_t pi = 0; pi < m.Terrain.GetPatchesPerSide(); ++pi) | for (ssize_t pi = 0; pi < m.Terrain.GetPatchesPerSide(); ++pi) | ||||
{ | { | ||||
for (ssize_t pj = 0; pj < m.Terrain.GetPatchesPerSide(); ++pj) | for (ssize_t pj = 0; pj < m.Terrain.GetPatchesPerSide(); ++pj) | ||||
Show All 22 Lines | ActorViewer::ActorViewer() | ||||
// Set player data | // Set player data | ||||
m.Simulation2.SetMapSettings(m.Simulation2.GetPlayerDefaults()); | m.Simulation2.SetMapSettings(m.Simulation2.GetPlayerDefaults()); | ||||
m.Simulation2.LoadPlayerSettings(true); | m.Simulation2.LoadPlayerSettings(true); | ||||
// Tell the simulation we've already loaded the terrain | // Tell the simulation we've already loaded the terrain | ||||
CmpPtr<ICmpTerrain> cmpTerrain(m.Simulation2, SYSTEM_ENTITY); | CmpPtr<ICmpTerrain> cmpTerrain(m.Simulation2, SYSTEM_ENTITY); | ||||
if (cmpTerrain) | if (cmpTerrain) | ||||
cmpTerrain->ReloadTerrain(false); | cmpTerrain->ReloadTerrain(); | ||||
// Remove FOW since we're in Atlas | // Remove FOW since we're in Atlas | ||||
CmpPtr<ICmpRangeManager> cmpRangeManager(m.Simulation2, SYSTEM_ENTITY); | CmpPtr<ICmpRangeManager> cmpRangeManager(m.Simulation2, SYSTEM_ENTITY); | ||||
if (cmpRangeManager) | if (cmpRangeManager) | ||||
cmpRangeManager->SetLosRevealAll(-1, true); | cmpRangeManager->SetLosRevealAll(-1, true); | ||||
m.Simulation2.InitGame(); | m.Simulation2.InitGame(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | void ActorViewer::SetEnabled(bool enabled) | ||||
if (enabled) | if (enabled) | ||||
{ | { | ||||
// Set shadows, sky and water. | // Set shadows, sky and water. | ||||
m.OldShadows = g_RenderingOptions.GetShadows(); | m.OldShadows = g_RenderingOptions.GetShadows(); | ||||
g_RenderingOptions.SetShadows(m.ShadowsEnabled); | g_RenderingOptions.SetShadows(m.ShadowsEnabled); | ||||
m.OldSky = g_Renderer.GetSkyManager()->GetRenderSky(); | m.OldSky = g_Renderer.GetSkyManager()->GetRenderSky(); | ||||
g_Renderer.GetSkyManager()->SetRenderSky(false); | g_Renderer.GetSkyManager()->SetRenderSky(false); | ||||
m.OldWater = g_Renderer.GetWaterManager()->m_RenderWater; | m.WaterManager.SetRenderingEnabled(m.WaterEnabled); | ||||
g_Renderer.GetWaterManager()->m_RenderWater = m.WaterEnabled; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
// Restore the old renderer state | // Restore the old renderer state | ||||
g_RenderingOptions.SetShadows(m.OldShadows); | g_RenderingOptions.SetShadows(m.OldShadows); | ||||
g_Renderer.GetSkyManager()->SetRenderSky(m.OldSky); | g_Renderer.GetSkyManager()->SetRenderSky(m.OldSky); | ||||
g_Renderer.GetWaterManager()->m_RenderWater = m.OldWater; | |||||
} | } | ||||
Done Inline ActionsThe commented code should be removed. vladislavbelov: The commented code should be removed. | |||||
} | } | ||||
void ActorViewer::SetBackgroundColor(const SColor4ub& color) | void ActorViewer::SetBackgroundColor(const SColor4ub& color) | ||||
{ | { | ||||
m.Background = color; | m.Background = color; | ||||
m.Terrain.SetBaseColor(color); | m.Terrain.SetBaseColor(color); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Should be terrain if it's local.