2010-06-03 03:29:43 +02:00
|
|
|
/* Copyright (C) 2010 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2004-12-01 07:52:39 +01:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
2004-09-23 06:00:56 +02:00
|
|
|
#include "Material.h"
|
2010-06-30 23:41:04 +02:00
|
|
|
|
|
|
|
#include "lib/ogl.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/Game.h"
|
|
|
|
#include "ps/Overlay.h" // for CColor
|
2004-09-23 06:00:56 +02:00
|
|
|
|
2004-09-23 07:10:03 +02:00
|
|
|
CMaterial NullMaterial;
|
|
|
|
|
2006-11-07 03:48:27 +01:00
|
|
|
static SMaterialColor BrokenColor(0.3f, 0.3f, 0.3f, 1.0f);
|
2005-04-07 06:29:07 +02:00
|
|
|
|
2012-02-13 15:02:14 +01:00
|
|
|
CMaterial::CMaterial() :
|
2005-01-27 03:52:26 +01:00
|
|
|
m_Alpha(false),
|
2011-03-18 17:57:54 +01:00
|
|
|
m_PlayerID(INVALID_PLAYER),
|
|
|
|
m_TextureColor(BrokenColor),
|
|
|
|
m_UsePlayerColor(false),
|
|
|
|
m_UseTextureColor(false)
|
2004-09-23 06:00:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
SMaterialColor CMaterial::GetObjectColor()
|
|
|
|
{
|
|
|
|
if (m_UseTextureColor)
|
|
|
|
return m_TextureColor;
|
|
|
|
|
|
|
|
return GetPlayerColor();
|
|
|
|
}
|
|
|
|
|
2005-04-07 06:29:07 +02:00
|
|
|
SMaterialColor CMaterial::GetPlayerColor()
|
|
|
|
{
|
2011-03-18 17:57:54 +01:00
|
|
|
if (m_PlayerID == -1)
|
|
|
|
return BrokenColor;
|
2005-04-07 06:29:07 +02:00
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
CColor c(g_Game->GetPlayerColour(m_PlayerID));
|
|
|
|
return SMaterialColor(c.r, c.g, c.b, c.a);
|
|
|
|
}
|
2005-04-07 06:29:07 +02:00
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
void CMaterial::SetPlayerID(player_id_t id)
|
|
|
|
{
|
|
|
|
m_PlayerID = id;
|
|
|
|
}
|
2005-04-07 06:29:07 +02:00
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
void CMaterial::SetUsePlayerColor(bool use)
|
|
|
|
{
|
|
|
|
m_UsePlayerColor = use;
|
2005-04-07 06:29:07 +02:00
|
|
|
}
|
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
void CMaterial::SetUseTextureColor(bool use)
|
2005-04-07 06:29:07 +02:00
|
|
|
{
|
2011-03-18 17:57:54 +01:00
|
|
|
m_UseTextureColor = use;
|
2005-04-07 06:29:07 +02:00
|
|
|
}
|
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
void CMaterial::SetTextureColor(const CColor& colour)
|
2005-04-07 06:29:07 +02:00
|
|
|
{
|
|
|
|
m_TextureColor = SMaterialColor(colour.r, colour.g, colour.b, colour.a);
|
|
|
|
}
|
|
|
|
|
2008-07-12 12:45:11 +02:00
|
|
|
void CMaterial::SetTexture(const CStr& texture)
|
2004-09-24 05:52:03 +02:00
|
|
|
{
|
|
|
|
m_Texture = texture;
|
|
|
|
}
|
2004-09-23 06:00:56 +02:00
|
|
|
|
2004-09-24 05:52:03 +02:00
|
|
|
void CMaterial::SetUsesAlpha(bool flag)
|
|
|
|
{
|
|
|
|
m_Alpha = flag;
|
|
|
|
}
|