forked from 0ad/0ad
# Aura and territory rendering
-Auras now take additional parameters from XML, containing a tag for r, g, b, and a. No line thickness parameter yet. -For territories, added function to frustum for determining if line segment passes through the frustum. This was SVN commit r4242.
This commit is contained in:
parent
6732af1ba9
commit
50e5e9acd9
Binary file not shown.
After Width: | Height: | Size: 822 B |
Binary file not shown.
After Width: | Height: | Size: 822 B |
Binary file not shown.
After Width: | Height: | Size: 822 B |
Binary file not shown.
After Width: | Height: | Size: 822 B |
Binary file not shown.
After Width: | Height: | Size: 822 B |
@ -19,6 +19,10 @@
|
||||
<Courage>
|
||||
<Radius>20</Radius>
|
||||
<Bonus>10</Bonus>
|
||||
<r>0.1</r>
|
||||
<g>0.9</g>
|
||||
<b>0.1</b>
|
||||
<a>0.5</a>
|
||||
</Courage>
|
||||
</Auras>
|
||||
|
||||
|
@ -53,6 +53,10 @@
|
||||
<Stone/>
|
||||
<Ore/>
|
||||
</Types>
|
||||
<r>0.1</r>
|
||||
<g>0.2</g>
|
||||
<b>.9</b>
|
||||
<a>0.4</a>
|
||||
</Dropsite>
|
||||
</Auras>
|
||||
|
||||
|
@ -34,6 +34,10 @@
|
||||
<Radius>30</Radius>
|
||||
<Rate>5</Rate>
|
||||
<Speed>2000</Speed>
|
||||
<r>1.0</r>
|
||||
<g>1.0</g>
|
||||
<b>0.0</b>
|
||||
<a>0.6</a>
|
||||
</Heal>
|
||||
</Auras>
|
||||
|
||||
|
@ -41,6 +41,10 @@
|
||||
<Types>
|
||||
<Food/>
|
||||
</Types>
|
||||
<r>0.1</r>
|
||||
<g>0.2</g>
|
||||
<b>1.0</b>
|
||||
<a>0.4</a>
|
||||
</Dropsite>
|
||||
</Auras>
|
||||
|
||||
|
@ -42,6 +42,10 @@
|
||||
<Stone/>
|
||||
<Ore/>
|
||||
</Types>
|
||||
<r>0.1</r>
|
||||
<g>0.2</g>
|
||||
<b>1.0</b>
|
||||
<a>0.4</a>
|
||||
</Dropsite>
|
||||
</Auras>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
</Id>
|
||||
|
||||
<Auras>
|
||||
<Auras>s
|
||||
<Trample>
|
||||
<Radius>10</Radius>
|
||||
<Speed>1000</Speed>
|
||||
@ -21,6 +21,10 @@
|
||||
<Crush>0.0</Crush>
|
||||
<Hack>0.5</Hack>
|
||||
<Pierce>0.5</Pierce>
|
||||
<r>1.0</r>
|
||||
<g>0.1</g>
|
||||
<b>0.2</b>
|
||||
<a>0.5</a>
|
||||
</Trample>
|
||||
</Auras>
|
||||
|
||||
|
@ -16,6 +16,10 @@
|
||||
<Infidelity>
|
||||
<Radius>20</Radius>
|
||||
<Time>0</Time>
|
||||
<r>.8</r>
|
||||
<g>.8</g>
|
||||
<b>1.0</b>
|
||||
<a>0.5</a>
|
||||
</Infidelity>
|
||||
</Auras>
|
||||
|
||||
|
@ -16,6 +16,10 @@
|
||||
<Infidelity>
|
||||
<Radius>20</Radius>
|
||||
<Time>0</Time>
|
||||
<r>0.8</r>
|
||||
<g>0.8</g>
|
||||
<b>1.0</b>
|
||||
<a>0.5</a>
|
||||
</Infidelity>
|
||||
</Auras>
|
||||
|
||||
|
@ -24,6 +24,10 @@
|
||||
<Crush>0</Crush>
|
||||
<Hack>0.9</Hack>
|
||||
<Pierce>0.1</Pierce>
|
||||
<r>1.0</r>
|
||||
<g>0.1</g>
|
||||
<b>0.2</b>
|
||||
<a>0.5</a>
|
||||
</Trample>
|
||||
</Auras>
|
||||
|
||||
|
@ -20,6 +20,10 @@
|
||||
<Infidelity>
|
||||
<Radius>30</Radius>
|
||||
<Time>10</Time>
|
||||
<r>0.8</r>
|
||||
<g>0.8</g>
|
||||
<b>1.0</b>
|
||||
<a>0.5</a>
|
||||
</Infidelity>
|
||||
</Auras>
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
<Courage>
|
||||
<Radius>20</Radius>
|
||||
<Bonus>5</Bonus>
|
||||
<r>0.1</r>
|
||||
<g>0.9</g>
|
||||
<b>0.1</b>
|
||||
<a>0.5</a>
|
||||
</Courage>
|
||||
</Auras>
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
<Fear>
|
||||
<Radius>20</Radius>
|
||||
<Bonus>5</Bonus>
|
||||
<r>0.0</r>
|
||||
<g>0.0</g>
|
||||
<b>0.0</b>
|
||||
<a>0.5</a>
|
||||
</Fear>
|
||||
</Auras>
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
<Courage>
|
||||
<Radius>20</Radius>
|
||||
<Bonus>10</Bonus>
|
||||
<r>0.1</r>
|
||||
<g>0.9</g>
|
||||
<b>0.1</b>
|
||||
<a>0.5</a>
|
||||
</Courage>
|
||||
</Auras>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
// To add a new generic order, do the following all within template_entity_script.js:
|
||||
|
||||
// * Pick a number to be its ID (add this to the "const"s directly below).
|
||||
// * Pick a number to be its ID (add this to the "const"s directly below). f
|
||||
|
||||
// * Add code in the entityInit() function below that will call setActionParams to set the action's range, speed and animation if the entity supports this action. For example this.setActionParams( ACTION_GATHER, 0.0, a.range, a.speed, "gather" ) tells the entity that the action with ID of ACTION_GATHER has min range 0, max range a.range, speed a.speed, and should play the animation called "gather" while active.
|
||||
|
||||
@ -471,38 +471,38 @@ function attachAuras()
|
||||
if( this.traits.auras.courage )
|
||||
{
|
||||
a = this.traits.auras.courage;
|
||||
this.addAura ( "courage", a.radius, 0, new DamageModifyAura( this, true, a.bonus ) );
|
||||
this.addAura ( "courage", a.radius, 0, a.r, a.g, a.b, a.a, new DamageModifyAura( this, true, a.bonus ) );
|
||||
}
|
||||
if( this.traits.auras.fear )
|
||||
{
|
||||
a = this.traits.auras.fear;
|
||||
this.addAura ( "fear", a.radius, 0, new DamageModifyAura( this, false, -a.bonus ) );
|
||||
this.addAura ( "fear", a.radius, 0, a.r, a.g, a.b, a.a, new DamageModifyAura( this, false, -a.bonus ) );
|
||||
}
|
||||
if( this.traits.auras.infidelity )
|
||||
{
|
||||
a = this.traits.auras.infidelity;
|
||||
this.addAura ( "infidelity", a.radius, 0, new InfidelityAura( this, a.time ) );
|
||||
this.addAura ( "infidelity", a.radius, 0, a.r, a.g, a.b, a.a, new InfidelityAura( this, a.time ) );
|
||||
}
|
||||
if( this.traits.auras.dropsite )
|
||||
{
|
||||
a = this.traits.auras.dropsite;
|
||||
this.addAura ( "dropsite", a.radius, 0, new DropsiteAura( this, a.types ) );
|
||||
this.addAura ( "dropsite", a.radius, 0, a.r, a.g, a.b, a.a, new DropsiteAura( this, a.types ) );
|
||||
}
|
||||
if( this.traits.auras.heal )
|
||||
{
|
||||
a = this.traits.auras.heal;
|
||||
this.addAura ( "heal", a.radius, a.speed, new HealAura( this ) );
|
||||
this.addAura ( "heal", a.radius, a.speed, a.r, a.g, a.b, a.a, new HealAura( this ) );
|
||||
}
|
||||
if( this.traits.auras.trample )
|
||||
{
|
||||
a = this.traits.auras.trample;
|
||||
this.addAura ( "trample", a.radius, a.speed, new TrampleAura( this ) );
|
||||
this.addAura ( "trample", a.radius, a.speed, a.r, a.g, a.b, a.a, new TrampleAura( this ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( this.hasClass("Settlement") )
|
||||
{
|
||||
this.addAura ( "settlement", 1.0, 0, new SettlementAura( this ) );
|
||||
this.addAura ( "settlement", 1.0, 0, 0.0, 0.0, 0.0, 0.0, new SettlementAura( this ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,16 @@ bool CFrustum::IsPointVisible (const CVector3D &point) const
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFrustum::DoesSegmentIntersect(const CVector3D& start, const CVector3D &end)
|
||||
{
|
||||
CVector3D intersect;
|
||||
for ( int i = 0; i<m_NumPlanes; ++i )
|
||||
{
|
||||
if ( m_aPlanes[i].FindLineSegIntersection(start, end, &intersect) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool CFrustum::IsSphereVisible (const CVector3D ¢er, float radius) const
|
||||
{
|
||||
for (int i=0; i<m_NumPlanes; i++)
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
//The following methods return true if the shape is
|
||||
//partially or completely in front of the frustum planes
|
||||
bool IsPointVisible (const CVector3D &point) const;
|
||||
bool DoesSegmentIntersect(const CVector3D& start, const CVector3D &end);
|
||||
bool IsSphereVisible (const CVector3D ¢er, float radius) const;
|
||||
bool IsBoxVisible (const CVector3D &position,const CBound &bounds) const;
|
||||
|
||||
|
@ -97,7 +97,7 @@ float CPlane::DistanceToPlane (const CVector3D &point) const
|
||||
|
||||
//calculates the intersection point of a line with this
|
||||
//plane. Returns false if there is no intersection
|
||||
bool CPlane::FindLineSegIntersection (CVector3D &start, CVector3D &end, CVector3D *intsect)
|
||||
bool CPlane::FindLineSegIntersection (const CVector3D &start, const CVector3D &end, CVector3D *intsect)
|
||||
{
|
||||
PLANESIDE StartS, EndS;
|
||||
CVector3D Dir;
|
||||
|
@ -47,7 +47,7 @@ class CPlane
|
||||
|
||||
//calculates the intersection point of a line with this
|
||||
//plane. Returns false if there is no intersection
|
||||
bool FindLineSegIntersection (CVector3D &start, CVector3D &end, CVector3D *intsect);
|
||||
bool FindLineSegIntersection (const CVector3D &start, const CVector3D &end, CVector3D *intsect);
|
||||
bool FindRayIntersection (CVector3D &start, CVector3D &direction, CVector3D *intsect);
|
||||
|
||||
public:
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "simulation/EntityHandles.h"
|
||||
#include "simulation/EntityManager.h"
|
||||
#include "simulation/FormationManager.h"
|
||||
#include "simulation/TerritoryManager.h"
|
||||
#include "simulation/PathfindEngine.h"
|
||||
#include "simulation/Scheduler.h"
|
||||
#include "simulation/Projectile.h"
|
||||
@ -323,12 +324,22 @@ void Render()
|
||||
g_EntityManager.renderAll(); // <-- collision outlines, pathing routes
|
||||
}
|
||||
|
||||
PROFILE_START( "render entity outlines" );
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
PROFILE_START( "render entity outlines" );
|
||||
g_Mouseover.renderSelectionOutlines();
|
||||
g_Selection.renderSelectionOutlines();
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
PROFILE_END( "render entity outlines" );
|
||||
|
||||
PROFILE_START( "render entity auras" );
|
||||
g_Mouseover.renderAuras();
|
||||
g_Selection.renderAuras();
|
||||
PROFILE_END( "render entity auras" );
|
||||
|
||||
PROFILE_START( "render territories" );
|
||||
g_Game->GetWorld()->GetTerritoryManager()->renderTerritories();
|
||||
PROFILE_END( "render territories" );
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
|
||||
|
||||
PROFILE_START( "render entity bars" );
|
||||
pglActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
|
@ -111,7 +111,15 @@ void CSelectedEntities::renderBars()
|
||||
glDisable( GL_BLEND );
|
||||
}*/
|
||||
}
|
||||
void CSelectedEntities::renderAuras()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
for ( it = m_selected.begin(); it != m_selected.end(); ++it )
|
||||
(*it)->renderAuras();
|
||||
}
|
||||
void CSelectedEntities::renderHealthBars()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
@ -859,7 +867,15 @@ void CMouseoverEntities::renderSelectionOutlines()
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
void CMouseoverEntities::renderAuras()
|
||||
{
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
for ( it = m_mouseover.begin(); it != m_mouseover.end(); ++it )
|
||||
it->entity->renderAuras();
|
||||
}
|
||||
void CMouseoverEntities::renderBars()
|
||||
{
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
|
@ -77,6 +77,7 @@ struct CSelectedEntities : public Singleton<CSelectedEntities>
|
||||
|
||||
void renderSelectionOutlines();
|
||||
void renderOverlays();
|
||||
void renderAuras();
|
||||
void renderRallyPoints();
|
||||
void renderBars();
|
||||
void renderHealthBars();
|
||||
@ -136,6 +137,7 @@ struct CMouseoverEntities : public Singleton<CMouseoverEntities>
|
||||
void renderSelectionOutlines();
|
||||
void renderOverlays();
|
||||
void renderRallyPoints();
|
||||
void renderAuras();
|
||||
void renderBars();
|
||||
void renderHealthBars();
|
||||
void renderStaminaBars();
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
CAura::CAura( JSContext* cx, CEntity* source, CStrW& name, float radius, size_t tickRate, JSObject* handler )
|
||||
CAura::CAura( JSContext* cx, CEntity* source, CStrW& name, float radius, size_t tickRate, const CVector4D& color, JSObject* handler )
|
||||
: m_cx(cx), m_source(source), m_name(name), m_radius(radius), m_handler(handler),
|
||||
m_tickRate(tickRate), m_tickCyclePos(0)
|
||||
m_tickRate(tickRate), m_tickCyclePos(0), m_color(color)
|
||||
{
|
||||
JS_AddRoot( m_cx, &m_handler ); // don't GC it so we can call it later
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define __AURA_H__
|
||||
|
||||
#include "EntityHandles.h"
|
||||
#include "maths/Vector4D.h"
|
||||
|
||||
class CEntity;
|
||||
|
||||
@ -11,13 +12,14 @@ public:
|
||||
JSContext* m_cx;
|
||||
CEntity* m_source;
|
||||
CStrW m_name;
|
||||
CVector4D m_color;
|
||||
float m_radius; // In graphics units
|
||||
size_t m_tickRate; // In milliseconds
|
||||
JSObject* m_handler;
|
||||
std::vector<HEntity> m_influenced;
|
||||
size_t m_tickCyclePos; // Add time to this until it's time to tick again
|
||||
|
||||
CAura( JSContext* cx, CEntity* source, CStrW& name, float radius, size_t tickRate, JSObject* handler );
|
||||
CAura( JSContext* cx, CEntity* source, CStrW& name, float radius, size_t tickRate, const CVector4D& color, JSObject* handler );
|
||||
~CAura();
|
||||
|
||||
// Remove all entities from under our influence; this isn't done in the destructor since
|
||||
|
@ -195,7 +195,25 @@ void CEntity::loadBase()
|
||||
for ( int i=0; i<m_base->m_sectorDivs; ++i )
|
||||
m_sectorValues[i] = false;
|
||||
}
|
||||
void CEntity::initAuraData()
|
||||
{
|
||||
if ( m_auras.empty() )
|
||||
return;
|
||||
m_unsnappedPoints.resize(m_auras.size());
|
||||
size_t i=0;
|
||||
for ( AuraTable::iterator it=m_auras.begin(); it!=m_auras.end(); ++it, ++i )
|
||||
{
|
||||
m_unsnappedPoints[i].resize(SELECTION_CIRCLE_POINTS);
|
||||
float radius = it->second->m_radius;
|
||||
|
||||
for ( int j=0; j<SELECTION_CIRCLE_POINTS; ++j )
|
||||
{
|
||||
float val = j * 2*PI / (float)SELECTION_CIRCLE_POINTS;
|
||||
m_unsnappedPoints[i][j] = CVector2D( cosf(val)*radius,
|
||||
sinf(val)*radius );
|
||||
}
|
||||
}
|
||||
}
|
||||
void CEntity::kill()
|
||||
{
|
||||
g_Selection.removeAll( me );
|
||||
@ -639,6 +657,7 @@ bool CEntity::Initialize()
|
||||
kill();
|
||||
return false;
|
||||
}
|
||||
initAuraData();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1075,6 +1094,76 @@ void CEntity::renderSelectionOutline( float alpha )
|
||||
|
||||
glEnd();
|
||||
}
|
||||
void CEntity::renderAuras()
|
||||
{
|
||||
if( !(m_bounds && m_visible && !m_auras.empty()) )
|
||||
return;
|
||||
|
||||
const SPlayerColour& col = m_player->GetColour();
|
||||
glPushMatrix();
|
||||
glTranslatef(m_graphics_position.X, m_graphics_position.Y,
|
||||
m_graphics_position.Z);
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex3f(0.0f, getAnchorLevel(m_graphics_position.X,
|
||||
m_graphics_position.Z)-m_graphics_position.Y+.5f, 0.0f);
|
||||
size_t i=0;
|
||||
|
||||
for ( AuraTable::iterator it=m_auras.begin(); it!=m_auras.end(); ++it, ++i )
|
||||
{
|
||||
CVector4D color = it->second->m_color;
|
||||
glColor4f(color.m_X, color.m_Y, color.m_Z, color.m_W);
|
||||
|
||||
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
||||
//This starts to break when the radius is bigger
|
||||
if ( it->second->m_radius < 15.0f )
|
||||
{
|
||||
for ( int j=0; j<SELECTION_CIRCLE_POINTS; ++j )
|
||||
{
|
||||
CVector2D ypos( m_unsnappedPoints[i][j].x+m_graphics_position.X,
|
||||
m_unsnappedPoints[i][j].y+m_graphics_position.Z );
|
||||
CVector3D pos( m_unsnappedPoints[i][j].x, getAnchorLevel(ypos.x, ypos.y)-
|
||||
m_graphics_position.Y+.5f, m_unsnappedPoints[i][j].y );
|
||||
glVertex3f(pos.X, pos.Y, pos.Z);
|
||||
}
|
||||
//Loop around
|
||||
CVector3D pos( m_unsnappedPoints[i][0].x,
|
||||
getAnchorLevel(m_unsnappedPoints[i][0].x+m_graphics_position.X,
|
||||
m_unsnappedPoints[i][0].y+m_graphics_position.Z)-
|
||||
m_graphics_position.Y+.5f, m_unsnappedPoints[i][0].y );
|
||||
glVertex3f(pos.X, pos.Y, pos.Z);
|
||||
}
|
||||
glEnd();
|
||||
//Draw edges
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glColor3f( col.r, col.g, col.b );
|
||||
for ( int j=0; j<SELECTION_CIRCLE_POINTS; ++j )
|
||||
{
|
||||
CVector2D ypos( m_unsnappedPoints[i][j].x+m_graphics_position.X,
|
||||
m_unsnappedPoints[i][j].y+m_graphics_position.Z );
|
||||
CVector3D pos( m_unsnappedPoints[i][j].x, getAnchorLevel(ypos.x, ypos.y)-
|
||||
m_graphics_position.Y+.5f, m_unsnappedPoints[i][j].y );
|
||||
glVertex3f(pos.X, pos.Y, pos.Z);
|
||||
}
|
||||
glEnd();
|
||||
#else
|
||||
if ( it->second->m_radius < 15.0f )
|
||||
{
|
||||
for ( int j=0; j<SELECTION_CIRLCE_POINTS; ++j )
|
||||
glVertex3f(m_unsnappedPoints[i][j].x, .25f, m_unsnappedPoints[i][j].y);
|
||||
glVertex3f(m_unsnappedPoints[i][0].x, .25f, m_unsnappedPoints[i][0].y);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
//Draw edges
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glColor3f( col.r, col.g, col.b );
|
||||
for ( int j=0; j<SELECTION_CIRLCE_POINTS; ++j )
|
||||
glVertex3f(unsnappedPoints[i][j].x, .25f, m_unsnappedPoints[i][j].y);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
CVector2D CEntity::getScreenCoords( float height )
|
||||
{
|
||||
@ -1915,19 +2004,24 @@ jsval CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv )
|
||||
|
||||
jsval CEntity::AddAura( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
debug_assert( argc >= 4 );
|
||||
debug_assert( JSVAL_IS_OBJECT(argv[3]) );
|
||||
debug_assert( argc >= 8 );
|
||||
debug_assert( JSVAL_IS_OBJECT(argv[7]) );
|
||||
|
||||
CStrW name = ToPrimitive<CStrW>( argv[0] );
|
||||
float radius = ToPrimitive<float>( argv[1] );
|
||||
size_t tickRate = max( 0, ToPrimitive<int>( argv[2] ) ); // since it's a size_t we don't want it to be negative
|
||||
JSObject* handler = JSVAL_TO_OBJECT( argv[3] );
|
||||
float r = ToPrimitive<float>( argv[3] );
|
||||
float g = ToPrimitive<float>( argv[4] );
|
||||
float b = ToPrimitive<float>( argv[5] );
|
||||
float a = ToPrimitive<float>( argv[6] );
|
||||
CVector4D color(r, g, b, a);
|
||||
JSObject* handler = JSVAL_TO_OBJECT( argv[7] );
|
||||
|
||||
if( m_auras[name] )
|
||||
{
|
||||
delete m_auras[name];
|
||||
}
|
||||
m_auras[name] = new CAura( cx, this, name, radius, tickRate, handler );
|
||||
m_auras[name] = new CAura( cx, this, name, radius, tickRate, color, handler );
|
||||
|
||||
return JSVAL_VOID;
|
||||
}
|
||||
|
@ -225,6 +225,8 @@ public:
|
||||
int m_currentRequest; //Notification we our notifiers are sending
|
||||
|
||||
std::vector<bool> m_sectorValues;
|
||||
//Slight optimization for aura rendering
|
||||
std::vector< std::vector<CVector2D> > m_unsnappedPoints;
|
||||
|
||||
private:
|
||||
CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set<CStr8>& actorSelections, const CStrW* building = 0 );
|
||||
@ -272,6 +274,7 @@ public:
|
||||
|
||||
// Process initialization
|
||||
bool Initialize();
|
||||
void initAuraData();
|
||||
|
||||
// Process tick.
|
||||
void Tick();
|
||||
@ -298,6 +301,7 @@ public:
|
||||
// Things like selection circles and debug info - possibly move to gui if/when it becomes responsible for (and capable of) it.
|
||||
void render();
|
||||
void renderSelectionOutline( float alpha = 1.0f );
|
||||
void renderAuras();
|
||||
void renderBars();
|
||||
void renderBarBorders();
|
||||
void renderHealthBar();
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ps/Game.h"
|
||||
#include "ps/Player.h"
|
||||
#include "graphics/Terrain.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "Entity.h"
|
||||
#include "EntityManager.h"
|
||||
#include "graphics/Unit.h"
|
||||
@ -12,11 +13,11 @@
|
||||
#include "graphics/Model.h"
|
||||
#include "lib/allocators.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/ogl.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
CTerritoryManager::CTerritoryManager()
|
||||
{
|
||||
m_TerritoryMatrix = 0;
|
||||
@ -206,3 +207,56 @@ void CTerritoryManager::CalculateBoundary( std::vector<CEntity*>& centres, size_
|
||||
}
|
||||
}
|
||||
}
|
||||
void CTerritoryManager::renderTerritories()
|
||||
{
|
||||
const CTerrain* pTerrain = g_Game->GetWorld()->GetTerrain();
|
||||
CFrustum frustum = g_Game->GetView()->GetCamera()->GetFrustum();
|
||||
std::vector<CTerritory*>::iterator terr=m_Territories.begin();
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glLineWidth(1.4f);
|
||||
|
||||
for ( ; terr != m_Territories.end(); ++terr )
|
||||
{
|
||||
std::vector<CVector2D>::iterator it=(*terr)->boundary.begin()+1;
|
||||
const SPlayerColour& col = (*terr)->owner->GetColour();
|
||||
glColor3f(col.r, col.g, col.b);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
for ( ; it != (*terr)->boundary.end(); ++it )
|
||||
{
|
||||
CVector3D front(it->x, pTerrain->getExactGroundLevel(it->x, it->y), it->y);
|
||||
CVector3D prev((it-1)->x, pTerrain->getExactGroundLevel((it-1)->x, (it-1)->y), (it-1)->y);
|
||||
if ( !frustum.DoesSegmentIntersect(prev, front) )
|
||||
continue;
|
||||
|
||||
float iterf = (front - prev).GetLength() / TERRITORY_PRECISION_STEP;
|
||||
for ( float i=0; i<iterf; i+= TERRITORY_PRECISION_STEP )
|
||||
{
|
||||
CVector2D pos( Interpolate(prev, front, i/iterf) );
|
||||
glVertex3f(pos.x, pTerrain->getExactGroundLevel(pos)+.25f, pos.y);
|
||||
}
|
||||
glVertex3f(front.X, pTerrain->getExactGroundLevel(front.X, front.Z)+.25f, front.Z);
|
||||
}
|
||||
//Loop around
|
||||
CVector2D first2D((*terr)->boundary.front()), back2D((*terr)->boundary.back());
|
||||
CVector3D first(first2D.x, pTerrain->getExactGroundLevel(first2D), first2D.y);
|
||||
CVector3D back(back2D.x, pTerrain->getExactGroundLevel(back2D), back2D.y);
|
||||
|
||||
if ( !frustum.DoesSegmentIntersect(back, first) )
|
||||
{
|
||||
glEnd();
|
||||
continue;
|
||||
}
|
||||
float iterf = (first - back).GetLength() / TERRITORY_PRECISION_STEP;
|
||||
for ( float i=0; i<iterf; i+= TERRITORY_PRECISION_STEP )
|
||||
{
|
||||
CVector2D pos( Interpolate(back, first, i/iterf) );
|
||||
glVertex3f(pos.x, pTerrain->getExactGroundLevel(pos)+.25f, pos.y);
|
||||
}
|
||||
glVertex3f(first.X, pTerrain->getExactGroundLevel(first2D)+.25f, first.Z);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glLineWidth(1.0f);
|
||||
}
|
@ -20,6 +20,8 @@
|
||||
class CUnit;
|
||||
class CPlayer;
|
||||
|
||||
const float TERRITORY_PRECISION_STEP = 1.0f / 6;
|
||||
|
||||
class CTerritory
|
||||
{
|
||||
public:
|
||||
@ -44,11 +46,12 @@ public:
|
||||
|
||||
void Initialize(); // initialize, called after the game is fully loaded
|
||||
void Recalculate(); // recalculate the territory boundaries
|
||||
|
||||
void renderTerritories();
|
||||
CTerritory* GetTerritory(int x, int z); // get the territory to which the given tile belongs
|
||||
CTerritory* GetTerritory(float x, float z); // get the territory to which the given world-space point belongs
|
||||
|
||||
std::vector<CTerritory*>& GetTerritories() { return m_Territories; }
|
||||
|
||||
private:
|
||||
void CalculateBoundary( std::vector<CEntity*>& centres, size_t index, std::vector<CVector2D>& boundary );
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user