This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9889 for ps


Ignore:
Timestamp:
07/20/11 21:48:06 (13 years ago)
Author:
philip
Message:

# Initial support for territories

Location:
ps/trunk
Files:
12 added
1 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/shaders/terrain_base.xml

    r9814 r9889  
    66        <uniform name="losTransform" loc="1" type="vec2"/>
    77        <uniform name="shadowTransform" loc="2" type="mat4"/>
     8        <uniform name="territoryTransform" loc="6" type="vec2"/>
    89    </vertex>
    910
     
    1213        <uniform name="shadowTex" loc="2" type="sampler2DShadow"/>
    1314        <uniform name="losTex" loc="3" type="sampler2D"/>
     15        <uniform name="territoryTex" loc="4" type="sampler2D"/>
    1416
    1517        <uniform name="ambient" loc="0" type="vec3"/>
  • ps/trunk/binaries/data/mods/public/shaders/terrain_blend.xml

    r9814 r9889  
    88        <uniform name="losTransform" loc="1" type="vec2"/>
    99        <uniform name="shadowTransform" loc="2" type="mat4"/>
     10        <uniform name="territoryTransform" loc="6" type="vec2"/>
    1011    </vertex>
    1112
     
    1516        <uniform name="shadowTex" loc="2" type="sampler2DShadow"/>
    1617        <uniform name="losTex" loc="3" type="sampler2D"/>
     18        <uniform name="territoryTex" loc="4" type="sampler2D"/>
    1719
    1820        <uniform name="ambient" loc="0" type="vec3"/>
  • ps/trunk/binaries/data/mods/public/shaders/terrain_common.fp

    r9814 r9889  
    8282#endif
    8383
     84// Blend with the territory boundary texture
     85TEX tex, fragment.texcoord[4], texture[4], 2D;
     86LRP color.rgb, tex.a, tex, color;
     87
    8488// Multiply everything by the LOS texture
    8589TEX tex.a, fragment.texcoord[3], texture[3], 2D;
  • ps/trunk/binaries/data/mods/public/shaders/terrain_common.vp

    r9123 r9889  
    33PARAM losTransform = program.local[1];
    44PARAM shadowTransform[4] = { program.local[2..5] };
     5PARAM territoryTransform = program.local[6];
    56
    67TEMP lighting;
     
    3940
    4041MAD result.texcoord[3], position.xzzz, losTransform.x, losTransform.y;
     42MAD result.texcoord[4], position.xzzz, territoryTransform.x, territoryTransform.y;
    4143
    4244END
  • ps/trunk/binaries/data/mods/public/shaders/terrain_decal.xml

    r9814 r9889  
    88        <uniform name="losTransform" loc="1" type="vec2"/>
    99        <uniform name="shadowTransform" loc="2" type="mat4"/>
     10        <uniform name="territoryTransform" loc="6" type="vec2"/>
    1011    </vertex>
    1112
     
    1415        <uniform name="shadowTex" loc="2" type="sampler2DShadow"/>
    1516        <uniform name="losTex" loc="3" type="sampler2D"/>
     17        <uniform name="territoryTex" loc="4" type="sampler2D"/>
    1618
    1719        <uniform name="ambient" loc="0" type="vec3"/>
  • ps/trunk/source/graphics/GameView.cpp

    r9764 r9889  
    3232#include "graphics/Terrain.h"
    3333#include "graphics/TerrainTextureManager.h"
     34#include "graphics/TerritoryTexture.h"
    3435#include "graphics/Unit.h"
    3536#include "graphics/UnitManager.h"
     
    160161        ObjectManager(MeshManager, SkeletonAnimManager, *game->GetSimulation2()),
    161162        LOSTexture(*game->GetSimulation2()),
     163        TerritoryTexture(*game->GetSimulation2()),
    162164        ViewCamera(),
    163165        CullCamera(),
     
    205207    CObjectManager ObjectManager;
    206208    CLOSTexture LOSTexture;
     209    CTerritoryTexture TerritoryTexture;
    207210
    208211    /**
     
    382385}
    383386
     387CTerritoryTexture& CGameView::GetTerritoryTexture()
     388{
     389    return m->TerritoryTexture;
     390}
     391
    384392
    385393void CGameViewImpl::ScriptingInit()
  • ps/trunk/source/graphics/GameView.h

    r9764 r9889  
    2828class CCamera;
    2929class CCinemaManager;
    30 class CLOSTexture;
    3130class CVector3D;
    3231struct SViewPort;
     
    5251    virtual void EnumerateObjects(const CFrustum& frustum, SceneCollector* c);
    5352    virtual CLOSTexture& GetLOSTexture();
     53    virtual CTerritoryTexture& GetTerritoryTexture();
    5454    //END: Implementation of Scene
    5555
  • ps/trunk/source/graphics/LOSTexture.cpp

    r9673 r9889  
    2424#include "ps/Game.h"
    2525#include "ps/Profile.h"
    26 #include "ps/World.h"
    2726#include "renderer/Renderer.h"
    2827#include "simulation2/Simulation2.h"
  • ps/trunk/source/gui/MiniMap.cpp

    r9673 r9889  
    2828#include "graphics/TerrainTextureEntry.h"
    2929#include "graphics/TerrainTextureManager.h"
     30#include "graphics/TerritoryTexture.h"
    3031#include "lib/ogl.h"
    3132#include "lib/external_libraries/sdl.h"
     
    4041#include "simulation2/Simulation2.h"
    4142#include "simulation2/components/ICmpMinimap.h"
     43#include "simulation2/components/ICmpTerritoryManager.h"
    4244
    4345bool g_GameRestarted = false;
     
    311313    DrawTexture(texCoordMax, angle, x, y, x2, y2, z);
    312314
    313     /* // TODO: reimplement with new sim system
    314     // Shade territories by player
    315     CTerritoryManager* territoryMgr = g_Game->GetWorld()->GetTerritoryManager();
    316     std::vector<CTerritory*>& territories = territoryMgr->GetTerritories();
    317 
    318     PROFILE_START("minimap territory shade");
    319    
    320     glDisable(GL_TEXTURE_2D);
     315
     316    // Draw territory boundaries
     317    CTerritoryTexture& territoryTexture = g_Game->GetView()->GetTerritoryTexture();
     318    territoryTexture.BindTexture(0);
    321319    glEnable(GL_BLEND);
    322     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    323     for( size_t i=0; i<territories.size(); i++ )
    324     {
    325         if( territories[i]->owner->GetPlayerID() == 0 )
    326             continue;
    327         std::vector<CVector2D>& boundary = territories[i]->boundary;
    328         SPlayerColour col = territories[i]->owner->GetColour();
    329         glColor4f(col.r, col.g, col.b, 0.25f);
    330         glBegin(GL_POLYGON);
    331         for( size_t j=0; j<boundary.size(); j++ )
    332         {
    333             float fx = boundary[j].x / (m_Terrain->GetTilesPerSide() * CELL_SIZE);
    334             float fy = boundary[j].y / (m_Terrain->GetTilesPerSide() * CELL_SIZE);
    335             glVertex3f( x*(1-fx) + x2*fx, y*(1-fy) + y2*fy, z );
    336         }
    337         glEnd();
    338     }
     320    glMatrixMode(GL_TEXTURE);
     321    glLoadMatrixf(territoryTexture.GetMinimapTextureMatrix());
     322    glMatrixMode(GL_MODELVIEW);
     323
     324    DrawTexture(1.0f, angle, x, y, x2, y2, z);
     325
     326    glMatrixMode(GL_TEXTURE);
     327    glLoadIdentity();
     328    glMatrixMode(GL_MODELVIEW);
    339329    glDisable(GL_BLEND);
    340330
    341     PROFILE_END("minimap territory shade");
    342 
    343     // Draw territory boundaries
    344     glEnable(GL_LINE_SMOOTH);
    345     glLineWidth(1.0f);
    346     glEnable(GL_BLEND);
    347     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    348     glColor4f(0.8f, 0.8f, 0.8f, 0.8f);
    349     for( size_t i=0; i<territories.size(); i++ )
    350     {
    351         std::vector<CVector2D>& boundary = territories[i]->boundary;
    352         glBegin(GL_LINE_LOOP);
    353         for( size_t j=0; j<boundary.size(); j++ )
    354         {
    355             float fx = boundary[j].x / (m_Terrain->GetTilesPerSide() * CELL_SIZE);
    356             float fy = boundary[j].y / (m_Terrain->GetTilesPerSide() * CELL_SIZE);
    357             glVertex3f( x*(1-fx) + x2*fx, y*(1-fy) + y2*fy, z );
    358         }
    359         glEnd();
    360     }
    361     glLineWidth(1.0f);
    362     glDisable(GL_LINE_SMOOTH);
    363     glDisable(GL_BLEND);
    364     */
    365331
    366332    // Draw the LOS quad in black, using alpha values from the LOS texture
  • ps/trunk/source/renderer/Scene.h

    r9172 r9889  
    3636class CPatch;
    3737class CLOSTexture;
     38class CTerritoryTexture;
    3839struct SOverlayLine;
    3940struct SOverlaySprite;
     
    6465     */
    6566    virtual CLOSTexture& GetLOSTexture() = 0;
     67
     68    /**
     69     * Return the territory texture to be used for rendering this scene.
     70     */
     71    virtual CTerritoryTexture& GetTerritoryTexture() = 0;
    6672};
    6773
  • ps/trunk/source/renderer/TerrainRenderer.cpp

    r9814 r9889  
    3232#include "graphics/Model.h"
    3333#include "graphics/ShaderManager.h"
     34#include "graphics/TerritoryTexture.h"
    3435
    3536#include "maths/MathUtil.h"
     
    401402    shader->BindTexture("losTex", los.GetTexture());
    402403    shader->Uniform("losTransform", los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
     404
     405    CTerritoryTexture& territory = g_Renderer.GetScene().GetTerritoryTexture();
     406    shader->BindTexture("territoryTex", territory.GetTexture());
     407    shader->Uniform("territoryTransform", territory.GetTextureMatrix()[0], territory.GetTextureMatrix()[12], 0.f, 0.f);
    403408
    404409    shader->Uniform("ambient", lightEnv.m_TerrainAmbientColor);
  • ps/trunk/source/simulation2/Simulation2.cpp

    r9665 r9889  
    8585        m_ComponentManager.AddComponent(SYSTEM_ENTITY, CID_SoundManager, noParam);
    8686        m_ComponentManager.AddComponent(SYSTEM_ENTITY, CID_Terrain, noParam);
     87        m_ComponentManager.AddComponent(SYSTEM_ENTITY, CID_TerritoryManager, noParam);
    8788        m_ComponentManager.AddComponent(SYSTEM_ENTITY, CID_WaterManager, noParam);
    8889
  • ps/trunk/source/simulation2/TypeList.h

    r9605 r9889  
    1 /* Copyright (C) 2010 Wildfire Games.
     1/* Copyright (C) 2011 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
     
    120120COMPONENT(Selectable)
    121121
     122INTERFACE(Settlement)
     123COMPONENT(SettlementScripted)
     124
    122125INTERFACE(SoundManager)
    123126COMPONENT(SoundManager)
     
    125128INTERFACE(Terrain)
    126129COMPONENT(Terrain)
     130
     131INTERFACE(TerritoryInfluence)
     132COMPONENT(TerritoryInfluence)
     133
     134INTERFACE(TerritoryManager)
     135COMPONENT(TerritoryManager)
    127136
    128137INTERFACE(UnitMotion)
  • ps/trunk/source/simulation2/components/ICmpObstruction.h

    r9510 r9889  
    3333    virtual ICmpObstructionManager::tag_t GetObstruction() = 0;
    3434
     35    /**
     36     * Gets the square corresponding to this obstruction shape.
     37     * @return true and updates @p out on success;
     38     *         false on failure (e.g. object not in the world).
     39     */
    3540    virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) = 0;
    3641
  • ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp

    r9720 r9889  
    3232#include "graphics/TerrainTextureEntry.h"
    3333#include "graphics/TerrainTextureManager.h"
     34#include "graphics/TerritoryTexture.h"
    3435#include "graphics/UnitManager.h"
    3536#include "maths/MathUtil.h"
     
    6162        Simulation2(&UnitManager, &Terrain),
    6263        ObjectManager(MeshManager, SkeletonAnimManager, Simulation2),
    63         LOSTexture(Simulation2)
     64        LOSTexture(Simulation2),
     65        TerritoryTexture(Simulation2)
    6466    {
    6567        UnitManager.SetObjectManager(ObjectManager);
     
    8587    CSimulation2 Simulation2;
    8688    CLOSTexture LOSTexture;
     89    CTerritoryTexture TerritoryTexture;
    8790
    8891    // Simplistic implementation of the Scene interface
     
    104107    }
    105108
     109    virtual CTerritoryTexture& GetTerritoryTexture()
     110    {
     111        return TerritoryTexture;
     112    }
    106113};
    107114
Note: See TracChangeset for help on using the changeset viewer.