extra team color markers ( by default use * to toggle/switch on )

This commit is contained in:
Titus Tscharntke 2011-07-06 22:02:38 +00:00
parent eb67fb8121
commit 9ef8c82441
7 changed files with 116 additions and 5 deletions

View File

@ -14,6 +14,7 @@ ChangeFontColor=C
GameSpeedIncrease='+' GameSpeedIncrease='+'
GameSpeedDecrease='-' GameSpeedDecrease='-'
ExitKey=escape ExitKey=escape
ExtraTeamColorMarker='*'
GroupUnitsKey1='0' GroupUnitsKey1='0'
GroupUnitsKey2='1' GroupUnitsKey2='1'
GroupUnitsKey3='2' GroupUnitsKey3='2'

View File

@ -66,6 +66,7 @@ Game::Game(Program *program, const GameSettings *gameSettings):
lastRenderLog2d = 0; lastRenderLog2d = 0;
totalRenderFps = 0; totalRenderFps = 0;
lastMaxUnitCalcTime = 0; lastMaxUnitCalcTime = 0;
renderExtraTeamColor = 0;
mouseMoved= false; mouseMoved= false;
quitTriggeredIndicator = false; quitTriggeredIndicator = false;
@ -1598,6 +1599,10 @@ void Game::keyDown(SDL_KeyboardEvent key) {
//printf("Toggle pause paused = %d\n",paused); //printf("Toggle pause paused = %d\n",paused);
setPaused(!paused); setPaused(!paused);
} }
else if(isKeyPressed(configKeys.getSDLKey("ExtraTeamColorMarker"),key, false) == true) {
//printf("Toggle ExtraTeamColorMarker\n");
toggleTeamColorMarker();
}
//switch display color //switch display color
//else if(key == configKeys.getCharKey("ChangeFontColor")) { //else if(key == configKeys.getCharKey("ChangeFontColor")) {
else if(isKeyPressed(configKeys.getSDLKey("ChangeFontColor"),key, false) == true) { else if(isKeyPressed(configKeys.getSDLKey("ChangeFontColor"),key, false) == true) {
@ -1895,11 +1900,23 @@ void Game::render3d(){
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderSelectionEffects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderSelectionEffects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start(); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
// renderTeamColorCircle
if((renderExtraTeamColor&renderTeamColorCircleBit)>0){
renderer.renderTeamColorCircle();
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
}
//units //units
renderer.renderUnits(avgRenderFps); renderer.renderUnits(avgRenderFps);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderUnits]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderUnits]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start(); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
// renderTeamColorPlane
if((renderExtraTeamColor&renderTeamColorPlaneBit)>0){
renderer.renderTeamColorPlane();
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
}
//objects //objects
renderer.renderObjects(avgRenderFps); renderer.renderObjects(avgRenderFps);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
@ -2475,5 +2492,9 @@ Vec2i Game::getPerformanceTimerResults() {
void Game::consoleAddLine(string line) { void Game::consoleAddLine(string line) {
console.addLine(line); console.addLine(line);
} }
void Game::toggleTeamColorMarker() {
renderExtraTeamColor++;
renderExtraTeamColor=renderExtraTeamColor%4;
}
}}//end namespace }}//end namespace

View File

@ -114,6 +114,10 @@ private:
int updateFpsAvgTest; int updateFpsAvgTest;
int renderFpsAvgTest; int renderFpsAvgTest;
int renderExtraTeamColor;
static const int renderTeamColorCircleBit=1;
static const int renderTeamColorPlaneBit=2;
bool photoModeEnabled; bool photoModeEnabled;
bool visibleHUD; bool visibleHUD;
bool withRainEffect; bool withRainEffect;
@ -146,6 +150,8 @@ public:
bool getPaused() const { return paused;} bool getPaused() const { return paused;}
void setPaused(bool value); void setPaused(bool value);
const int getTotalRenderFps() const {return totalRenderFps;} const int getTotalRenderFps() const {return totalRenderFps;}
void toggleTeamColorMarker();
//init //init
virtual void load(LoadGameItem loadTypes); virtual void load(LoadGameItem loadTypes);
virtual void load(); virtual void load();

View File

@ -64,6 +64,11 @@ void CoreData::load() {
fireTexture->getPixmap()->init(1); fireTexture->getPixmap()->init(1);
fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga"); fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga");
teamColorTexture= renderer.newTexture2D(rsGlobal);
teamColorTexture->setFormat(Texture::fAlpha);
teamColorTexture->getPixmap()->init(1);
teamColorTexture->getPixmap()->load(dir+"/misc_textures/team_color_texture.tga");
snowTexture= renderer.newTexture2D(rsGlobal); snowTexture= renderer.newTexture2D(rsGlobal);
snowTexture->setMipmap(false); snowTexture->setMipmap(false);
snowTexture->setFormat(Texture::fAlpha); snowTexture->setFormat(Texture::fAlpha);

View File

@ -50,6 +50,7 @@ private:
std::vector<Texture2D *> logoTextureList; std::vector<Texture2D *> logoTextureList;
Texture2D *backgroundTexture; Texture2D *backgroundTexture;
Texture2D *fireTexture; Texture2D *fireTexture;
Texture2D *teamColorTexture;
Texture2D *snowTexture; Texture2D *snowTexture;
Texture2D *waterSplashTexture; Texture2D *waterSplashTexture;
Texture2D *customTexture; Texture2D *customTexture;
@ -83,6 +84,7 @@ public:
Texture2D *getBackgroundTexture() const {return backgroundTexture;} Texture2D *getBackgroundTexture() const {return backgroundTexture;}
Texture2D *getFireTexture() const {return fireTexture;} Texture2D *getFireTexture() const {return fireTexture;}
Texture2D *getTeamColorTexture() const {return teamColorTexture;}
Texture2D *getSnowTexture() const {return snowTexture;} Texture2D *getSnowTexture() const {return snowTexture;}
Texture2D *getLogoTexture() const {return logoTexture;} Texture2D *getLogoTexture() const {return logoTexture;}
Texture2D *getWaterSplashTexture() const {return waterSplashTexture;} Texture2D *getWaterSplashTexture() const {return waterSplashTexture;}

View File

@ -2946,6 +2946,54 @@ void Renderer::renderWater() {
assertGl(); assertGl();
} }
void Renderer::renderTeamColorCircle(){
VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.size() > 0) {
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDepthFunc(GL_ALWAYS);
glDisable(GL_STENCIL_TEST);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glLineWidth(2.f);
for(int visibleUnitIndex = 0;
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
Vec3f currVec= unit->getCurrVectorFlat();
Vec3f color=unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0);
glColor4f(color.x, color.y, color.z, 0.7f);
renderSelectionCircle(currVec, unit->getType()->getSize(), 0.8f, 0.05f);
}
glPopAttrib();
}
}
void Renderer::renderTeamColorPlane(){
VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.size() > 0){
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_COLOR_MATERIAL);
const Texture2D *texture=CoreData::getInstance().getTeamColorTexture();
for(int visibleUnitIndex = 0;
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex){
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
Vec3f currVec= unit->getCurrVectorFlat();
renderTeamColorEffect(currVec,visibleUnitIndex,unit->getType()->getSize(),
unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0),texture);
}
glDisable(GL_COLOR_MATERIAL);
glPopAttrib();
}
}
void Renderer::renderUnits(const int renderFps) { void Renderer::renderUnits(const int renderFps) {
Unit *unit=NULL; Unit *unit=NULL;
const World *world= game->getWorld(); const World *world= game->getWorld();
@ -3055,8 +3103,34 @@ void Renderer::renderUnits(const int renderFps) {
glAlphaFunc(GL_GREATER, 0.0f); glAlphaFunc(GL_GREATER, 0.0f);
//assert //assert
assertGl(); assertGl();
} }
void Renderer::renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture) {
GLUquadricObj *disc;
float halfSize=size;
halfSize=halfSize;
float heigthoffset=0.5+heigth%25*0.004;
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, static_cast<const Texture2DGl*>(texture)->getHandle());
glColor4f(color.x, color.y, color.z, 1.0f);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2i(0, 1);
glVertex3f(v.x-halfSize,v.y+heigthoffset,v.z+halfSize);
glTexCoord2i(0, 0);
glVertex3f(v.x-halfSize,v.y+heigthoffset, v.z-halfSize);
glTexCoord2i(1, 1);
glVertex3f(v.x+halfSize,v.y+heigthoffset, v.z+halfSize);
glTexCoord2i(1, 0);
glVertex3f(v.x+halfSize,v.y+heigthoffset, v.z-halfSize);
glEnd();
glPopMatrix();
}
void Renderer::renderSelectionEffects() { void Renderer::renderSelectionEffects() {
const World *world= game->getWorld(); const World *world= game->getWorld();
@ -3336,10 +3410,9 @@ void Renderer::renderWaterEffects(){
} }
void Renderer::renderHud(){ void Renderer::renderHud(){
const Metrics &metrics= Metrics::getInstance();
const World *world= game->getWorld();
Texture2D *hudTexture=game->getGui()->getHudTexture(); Texture2D *hudTexture=game->getGui()->getHudTexture();
if(hudTexture!=NULL){ if(hudTexture!=NULL){
const Metrics &metrics= Metrics::getInstance();
renderTextureQuad(0, 0, metrics.getVirtualW(), metrics.getVirtualH(),hudTexture,1.0f); renderTextureQuad(0, 0, metrics.getVirtualW(), metrics.getVirtualH(),hudTexture,1.0f);
} }
} }
@ -5056,7 +5129,7 @@ void Renderer::enableProjectiveTexturing() {
// ==================== private aux drawing ==================== // ==================== private aux drawing ====================
void Renderer::renderSelectionCircle(Vec3f v, int size, float radius) { void Renderer::renderSelectionCircle(Vec3f v, int size, float radius, float thickness) {
GLUquadricObj *disc; GLUquadricObj *disc;
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
@ -5066,7 +5139,7 @@ void Renderer::renderSelectionCircle(Vec3f v, int size, float radius) {
glRotatef(90.f, 1.f, 0.f, 0.f); glRotatef(90.f, 1.f, 0.f, 0.f);
disc= gluNewQuadric(); disc= gluNewQuadric();
gluQuadricDrawStyle(disc, GLU_FILL); gluQuadricDrawStyle(disc, GLU_FILL);
gluCylinder(disc, radius*(size-0.2f), radius*size, 0.2f, 30, 1); gluCylinder(disc, radius*(size-thickness), radius*size, thickness, 30, 1);
gluDeleteQuadric(disc); gluDeleteQuadric(disc);
glPopMatrix(); glPopMatrix();

View File

@ -424,6 +424,8 @@ public:
void loadConfig(); void loadConfig();
void saveScreen(const string &path); void saveScreen(const string &path);
Quad2i getVisibleQuad() const {return visibleQuad;} Quad2i getVisibleQuad() const {return visibleQuad;}
void renderTeamColorPlane();
void renderTeamColorCircle();
//static //static
static Shadows strToShadows(const string &s); static Shadows strToShadows(const string &s);
@ -495,7 +497,8 @@ private:
void enableProjectiveTexturing(); void enableProjectiveTexturing();
//private aux drawing //private aux drawing
void renderSelectionCircle(Vec3f v, int size, float radius); void renderSelectionCircle(Vec3f v, int size, float radius, float thickness=0.2f);
void renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture);
void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width); void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width);
void renderTile(const Vec2i &pos); void renderTile(const Vec2i &pos);
void renderQuad(int x, int y, int w, int h, const Texture2D *texture); void renderQuad(int x, int y, int w, int h, const Texture2D *texture);