1
0
forked from 0ad/0ad

Added a new material, "player_trans.xml" which will give a model player color. So now if you want a player to be colored, just add this material!

This was SVN commit r1830.
This commit is contained in:
NoMonkey 2005-01-27 02:52:26 +00:00
parent 969ed22f97
commit d7b3d6b0c7
14 changed files with 100 additions and 29 deletions

View File

@ -7,6 +7,7 @@
<Name>Celtic Basic Swordsman Infantry</Name>
<ModelName>art/meshes/skeletal/m_pants_b.pmd</ModelName>
<TextureName>art/textures/skins/skeletal/celt_isw_b.dds</TextureName>
<Material>art/materials/player_trans.xml</Material>
<Properties
autoflatten="0"
castshadows="1"

View File

@ -7,6 +7,7 @@
<Name>Propped Dude</Name>
<ModelName>art/meshes/skeletal/m_dress_a.pmd</ModelName>
<TextureName>art/textures/skins/skeletal/plac_rome_e.dds</TextureName>
<Material>art/materials/player_trans.xml</Material>
<Properties
autoflatten="0"
castshadows="1"

View File

@ -0,0 +1,5 @@
<Material>
<Alpha
usage="playercolor"
/>
</Material>

View File

@ -194,7 +194,7 @@
</object>
<object type="input" name="pregame_sp_mapname" sprite="only_black" absolute="false" size="130 90 290 110" textcolor="255 255 255">
ph.pmp
nm_playercolors.pmp
</object>
<object type="button" name="pregame_sp_start_bt" sprite="message_box_button_normal" sprite_over="message_box_button_over" text_align="center" text_valign="center" absolute="false" size="50%-100 100%-50 50%-10 100%-20">

Binary file not shown.

Binary file not shown.

View File

@ -301,5 +301,4 @@ void CMapReader::ReadXML(const char* filename)
debug_warn("Invalid XML data - DTD shouldn't allow this");
}
}
}

View File

@ -32,7 +32,8 @@ CMaterial::CMaterial()
m_Specular(IdentitySpecular),
m_Emissive(IdentityEmissive),
m_SpecularPower(0.0f),
m_Alpha(false)
m_Alpha(false),
m_bPlayer(false)
{
ComputeHash();
}
@ -55,6 +56,7 @@ void CMaterial::operator =(const CMaterial &material)
m_SpecularPower = material.m_SpecularPower;
m_Alpha = material.m_Alpha;
m_bPlayer = material.m_bPlayer;
ComputeHash();
}
@ -67,7 +69,8 @@ bool CMaterial::operator ==(const CMaterial &material)
m_Specular == material.m_Specular &&
m_Emissive == material.m_Emissive &&
m_SpecularPower == material.m_SpecularPower &&
m_Alpha == material.m_Alpha
m_Alpha == material.m_Alpha &&
m_bPlayer == material.m_bPlayer
);
}
@ -160,6 +163,12 @@ void CMaterial::SetUsesAlpha(bool flag)
ComputeHash();
}
void CMaterial::SetIsPlayer(bool flag)
{
m_bPlayer = flag;
ComputeHash();
}
void CMaterial::ComputeHash()
{
m_Hash =

View File

@ -61,7 +61,10 @@ public:
SMaterialColor GetSpecular();
SMaterialColor GetEmissive();
float GetSpecularPower() { return m_SpecularPower; }
bool UsesAlpha() { return m_Alpha; }
// Determines whether or not the model goes into the PlayerRenderer
bool IsPlayer() { return m_bPlayer; } // John M. Mena
void SetTexture(const CStr &texture);
void SetVertexProgram(const CStr &prog);
@ -72,6 +75,9 @@ public:
void SetEmissive(const SMaterialColor &color);
void SetSpecularPower(float power);
void SetUsesAlpha(bool flag);
// Sets the player flag which is used to
// place the model in the player renderer
void SetIsPlayer(bool flag);
void operator =(const CMaterial &material);
bool operator ==(const CMaterial &material);
@ -96,6 +102,9 @@ protected:
// Alpha required flag
bool m_Alpha;
// Player required flag for PlayerRenderer : John M. Mena
bool m_bPlayer;
};
extern CMaterial NullMaterial;

View File

@ -252,7 +252,12 @@ CMaterial &CMaterialManager::LoadMaterial(const char *file)
else if(token == el_alpha)
{
temp = (CStr)attrs.getNamedItem(at_usage);
material->SetUsesAlpha(ParseUsage(temp));
// Determine whether the alpha is used for basic transparency or player color
if (temp == CStr("playercolor"))
material->SetIsPlayer(true);
else
material->SetUsesAlpha(ParseUsage(temp));
}
}

View File

@ -21,7 +21,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Constructor
CModel::CModel()
: m_Flags(0), m_PlayerID(-1), m_Anim(0), m_AnimTime(0),
: m_Flags(0), m_PlayerID(3), m_Anim(0), m_AnimTime(0),
m_BoneMatrices(0), m_InvBoneMatrices(0), m_BoneMatricesValid(false)
{
}

View File

@ -2,12 +2,21 @@
#include "gui/MiniMap.h"
#include "ps/Game.h"
#include "CConsole.h"
#include "ogl.h"
#include "renderer/Renderer.h"
#include "graphics/TextureEntry.h"
#include "graphics/TextureManager.h"
#include "graphics/Unit.h"
#include "graphics/Camera.h"
#include "Bound.h"
#include "Model.h"
extern CConsole* g_Console;
extern int g_mouse_x, g_mouse_y;
static unsigned int ScaleColor(unsigned int color,float x)
{
@ -81,7 +90,7 @@ void CMiniMap::Draw()
glDisable(GL_DEPTH_TEST);
glEnable(GL_POINT_SMOOTH);
glDisable(GL_TEXTURE_2D);
glPointSize(2.5f);
glPointSize(3.0f);
// REMOVED: glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_POINTS);
for(; iter != units.end(); iter++)
@ -101,8 +110,34 @@ void CMiniMap::Draw()
glVertex3f(x + pos.y, y + pos.x, GetBufferedZ());
}
}
glEnd();
// render view rect : John M. Mena
CCamera &g_Camera=*g_Game->GetView()->GetCamera();
CVector3D pos3D = g_Camera.GetWorldCoordinates();
pos = GetMapSpaceCoords(pos3D);
// Restrict the drawing to the map
glScissor((int)m_CachedActualSize.left, 0, (int)m_CachedActualSize.right, (int)m_CachedActualSize.GetHeight());
glEnable(GL_SCISSOR_TEST);
glLineWidth(2);
glColor3f(1.0f,0.3f,0.3f);
// Draw the viewing rectangle
glBegin(GL_LINE_LOOP);
glVertex2f(x + pos.y - 10, y + pos.x - 10);
glVertex2f(x + pos.y + 10, y + pos.x - 10);
glVertex2f(x + pos.y + 10, y + pos.x + 10);
glVertex2f(x + pos.y - 10, y + pos.x + 10);
glEnd();
glDisable(GL_SCISSOR_TEST);
glPointSize(1.0f);
glLineWidth(1.0f);
glEnable(GL_TEXTURE_2D);
glDisable(GL_POINT_SMOOTH);
glEnable(GL_DEPTH_TEST);

View File

@ -87,33 +87,36 @@ CGameAttributes::CGameAttributes():
AddProperty(L"players", (GetFn)&CGameAttributes::JSGetPlayers);
m_Players.resize(8);
for (int i=0;i<8;i++)
m_Players.resize(9);
for (int i=0;i<9;i++)
m_Players[i]=new CPlayer(i);
m_Players[0]->SetName(L"Gaia");
m_Players[0]->SetColour(SPlayerColour(1.0f, 0.0f, 0.0f));
m_Players[0]->SetColour(SPlayerColour(1.0f, 1.0f, 1.0f));
m_Players[1]->SetName(L"Acumen");
m_Players[1]->SetColour(SPlayerColour(0.0f, 1.0f, 0.0f));
m_Players[1]->SetName(L"Sally Jessie Rapheal");
m_Players[1]->SetColour(SPlayerColour(1.0f, 0.0f, 0.0f));
m_Players[2]->SetName(L"Boco the Insignificant");
m_Players[2]->SetColour(SPlayerColour(0.0f, 0.0f, 1.0f));
m_Players[2]->SetName(L"Acumen");
m_Players[2]->SetColour(SPlayerColour(0.0f, 1.0f, 0.0f));
m_Players[3]->SetName(L"NoMonkey the Magnificent");
m_Players[3]->SetColour(SPlayerColour(1.0f, 1.0f, 0.0f));
m_Players[3]->SetName(L"Boco the Insignificant");
m_Players[3]->SetColour(SPlayerColour(0.0f, 0.0f, 1.0f));
m_Players[4]->SetName(L"Wijit");
m_Players[4]->SetColour(SPlayerColour(1.0f, 0.0f, 1.0f));
m_Players[4]->SetName(L"NoMonkey the Magnificent");
m_Players[4]->SetColour(SPlayerColour(1.0f, 1.0f, 0.0f));
m_Players[5]->SetName(L"Ykkrosh");
m_Players[5]->SetColour(SPlayerColour(0.0f, 1.0f, 1.0f));
m_Players[5]->SetName(L"Wijit");
m_Players[5]->SetColour(SPlayerColour(1.0f, 0.0f, 1.0f));
m_Players[6]->SetName(L"Code Monkey");
m_Players[6]->SetColour(SPlayerColour(1.0f, 0.5f, 1.0f));
m_Players[6]->SetName(L"Ykkrosh");
m_Players[6]->SetColour(SPlayerColour(0.0f, 1.0f, 1.0f));
m_Players[7]->SetName(L"Ykkrosh");
m_Players[7]->SetColour(SPlayerColour(1.0f, 0.8f, 0.5f));
m_Players[7]->SetName(L"Code Monkey");
m_Players[7]->SetColour(SPlayerColour(1.0f, 0.5f, 1.0f));
m_Players[8]->SetName(L"Ykkrosh");
m_Players[8]->SetColour(SPlayerColour(1.0f, 0.8f, 0.5f));
}
CGameAttributes::~CGameAttributes()

View File

@ -50,10 +50,14 @@ void CModelRData::Build()
/*if (g_Renderer.IsTextureTransparent(m_Model->GetTexture())) {
m_Flags|=MODELRDATA_FLAG_TRANSPARENT;
}*/
if(m_Model->GetPlayerID() + 1) // Add one because the default value is -1
if(m_Model->GetMaterial().IsPlayer())
{
m_Flags |= MODELRDATA_FLAG_PLAYERCOLOR;
}
else if(m_Model->GetMaterial().UsesAlpha())
{
m_Flags |= MODELRDATA_FLAG_TRANSPARENT;
}
}
void CModelRData::BuildIndices()