Ok, next question: Can someone tell me how the texture combiner for the team colors work? I know it's the MeshCallbackTeamColor class in renderer.cpp, but I can't figure out how it works. Google isn't telling me either
What I am trying to do is render something additional for each unit (a billboard flying over their head actually), but the team color texture keeps interfering with my color & alpha.
I basically added this to the inner loop in Renderer:renderUnits(), just before glPopMatrix():
// if unit is not a building, render billboard
if(!unit->getType()->isOfClass(ucBuilding)) {
renderUnitBillboard(unit);
}
The renderUnitBillboard is a private function and looks like this:
void Renderer::renderUnitBillboard(Unit* unit) {
Vec3f v1(-0.5f,-0.5f, 0.1f);
Vec3f v2( 0.5f,-0.5f, 0.1f);
Vec3f v3( 0.5f, 0.5f, 0.1f);
Vec3f v4(-0.5f, 0.5f, 0.1f);
glPushAttrib(GL_ALL_ATTRIB_BITS);
glTranslatef(0.0f, 5.0f, 0.0f);
glDisable(GL_DEPTH);
glDisable(GL_CULL_FACE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glBindTexture(GL_TEXTURE_2D, static_cast<Texture2DGl*>(coreDate.getSomeTexture())->getHandle());
// render the billboard
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3fv(v1.ptr());
glTexCoord2f(1.0f, 0.0f);
glVertex3fv(v2.ptr());
glTexCoord2f(1.0f, 1.0f);
glVertex3fv(v3.ptr());
glTexCoord2f(0.0f, 1.0f);
glVertex3fv(v4.ptr());
glEnd();
glPopAttrib();
}
Like I said, the team color keeps getting put in place of the transparency I'm actually looking for. What's really strange is that sometimes it works, like when I send Workers to mine or harvest. I tried turning off the team colors altogether, commenting out the line
meshCallbackTeamColor.setTeamTexture(world->getFaction(i)->getTexture());
in the unit render loop. It works that way, but I want to keep the team colors, just not in my billboards.
Can someone help me out? Thanks!