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/>.
|
|
|
|
*/
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_MATERIAL
|
|
|
|
#define INCLUDED_MATERIAL
|
2004-09-23 06:00:56 +02:00
|
|
|
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/CStr.h"
|
2011-03-26 21:17:21 +01:00
|
|
|
#include "ps/Overlay.h"
|
2011-03-18 17:57:54 +01:00
|
|
|
#include "simulation2/helpers/Player.h"
|
|
|
|
|
|
|
|
// FIXME: This material system is almost entirely unused and probably broken
|
2004-09-23 06:00:56 +02:00
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
typedef CColor SMaterialColor;
|
2004-09-23 06:00:56 +02:00
|
|
|
|
|
|
|
class CMaterial
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CMaterial();
|
|
|
|
|
2004-09-24 05:52:03 +02:00
|
|
|
void Bind();
|
2005-04-07 06:29:07 +02:00
|
|
|
void Unbind();
|
2004-09-23 06:00:56 +02:00
|
|
|
|
2006-07-20 16:37:58 +02:00
|
|
|
const CStr& GetTexture() { return m_Texture; }
|
|
|
|
const CStr& GetVertexProgram() { return m_VertexProgram; }
|
|
|
|
const CStr& GetFragmentProgram() { return m_FragmentProgram; }
|
2004-09-23 06:00:56 +02:00
|
|
|
SMaterialColor GetDiffuse();
|
|
|
|
SMaterialColor GetAmbient();
|
|
|
|
SMaterialColor GetSpecular();
|
|
|
|
SMaterialColor GetEmissive();
|
|
|
|
float GetSpecularPower() { return m_SpecularPower; }
|
2005-01-27 03:52:26 +01:00
|
|
|
|
2004-09-23 06:00:56 +02:00
|
|
|
bool UsesAlpha() { return m_Alpha; }
|
|
|
|
|
2005-04-07 06:29:07 +02:00
|
|
|
// Determines whether or not the model goes into the PlayerRenderer
|
2011-03-18 17:57:54 +01:00
|
|
|
bool IsPlayer() { return (m_UseTextureColor || m_UsePlayerColor); }
|
|
|
|
|
|
|
|
// Get the player colour or texture colour to be applied to this object
|
|
|
|
SMaterialColor GetObjectColor();
|
|
|
|
// Get the player colour
|
2005-04-07 06:29:07 +02:00
|
|
|
SMaterialColor GetPlayerColor();
|
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
void SetPlayerID(player_id_t id);
|
|
|
|
void SetTextureColor(const CColor &colour);
|
|
|
|
|
|
|
|
void SetUsePlayerColor(bool use);
|
|
|
|
void SetUseTextureColor(bool use);
|
2005-04-07 06:29:07 +02:00
|
|
|
|
2006-07-20 16:37:58 +02:00
|
|
|
void SetTexture(const CStr& texture);
|
|
|
|
void SetVertexProgram(const CStr& prog);
|
|
|
|
void SetFragmentProgram(const CStr& prog);
|
2008-07-12 12:45:11 +02:00
|
|
|
void SetDiffuse(const SMaterialColor& color);
|
|
|
|
void SetAmbient(const SMaterialColor& color);
|
|
|
|
void SetSpecular(const SMaterialColor& color);
|
|
|
|
void SetEmissive(const SMaterialColor& color);
|
2005-04-07 06:29:07 +02:00
|
|
|
void SetSpecularPower(float power);
|
|
|
|
void SetUsesAlpha(bool flag);
|
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
private:
|
2004-09-23 06:00:56 +02:00
|
|
|
// Various reflective color properties
|
2004-09-24 05:52:03 +02:00
|
|
|
SMaterialColor m_Diffuse;
|
|
|
|
SMaterialColor m_Ambient;
|
|
|
|
SMaterialColor m_Specular;
|
|
|
|
SMaterialColor m_Emissive;
|
2004-09-23 06:00:56 +02:00
|
|
|
float m_SpecularPower;
|
|
|
|
|
|
|
|
// Path to the materials texture
|
|
|
|
CStr m_Texture;
|
|
|
|
|
2005-04-07 06:29:07 +02:00
|
|
|
// Paths to vertex/fragment programs
|
|
|
|
CStr m_VertexProgram;
|
|
|
|
CStr m_FragmentProgram;
|
2004-10-30 23:57:46 +02:00
|
|
|
|
2004-09-23 06:00:56 +02:00
|
|
|
// Alpha required flag
|
|
|
|
bool m_Alpha;
|
2005-01-27 03:52:26 +01:00
|
|
|
|
2011-03-18 17:57:54 +01:00
|
|
|
player_id_t m_PlayerID;
|
2005-04-07 06:29:07 +02:00
|
|
|
SMaterialColor m_TextureColor; // used as an alternative to the per-player colour
|
2011-03-18 17:57:54 +01:00
|
|
|
|
|
|
|
bool m_UsePlayerColor;
|
|
|
|
bool m_UseTextureColor;
|
2004-09-23 06:00:56 +02:00
|
|
|
};
|
|
|
|
|
2004-09-23 07:10:03 +02:00
|
|
|
extern CMaterial NullMaterial;
|
|
|
|
|
2004-09-26 23:21:34 +02:00
|
|
|
#endif
|