Added GL cel shading option for models

This commit is contained in:
Kevin Slaughter
2004-06-18 11:02:40 +00:00
parent 2102a978b6
commit b3f1d8f874
6 changed files with 78 additions and 71 deletions
+26 -25
View File
@@ -8,6 +8,8 @@
#include "song.h"
#include "Character.h"
#include "StageStats.h"
#include "PrefsManager.h"
#include "SDL_opengl.h"
#define DC_X( choice ) THEME->GetMetricF("DancingCharacters",ssprintf("2DCharacterXP%d",choice+1))
#define DC_Y( choice ) THEME->GetMetricF("DancingCharacters",ssprintf("2DCharacterYP%d",choice+1))
@@ -127,10 +129,12 @@ DancingCharacters::DancingCharacters()
if( pChar->GetModelPath().empty() )
continue;
if( GAMESTATE->GetNumPlayersEnabled()==2 )
if( GAMESTATE->GetNumPlayersEnabled()==2 ) {
m_Character[p].SetX( MODEL_X_TWO_PLAYERS[p] );
else
}
else {
m_Character[p].SetX( MODEL_X_ONE_PLAYER );
}
switch( GAMESTATE->m_PlayMode )
{
@@ -168,7 +172,6 @@ void DancingCharacters::LoadNextSong()
m_Character[p].PlayAnimation( "rest" );
}
int Neg1OrPos1() { return rand()%2 ? -1 : +1; }
void DancingCharacters::Update( float fDelta )
@@ -176,8 +179,8 @@ void DancingCharacters::Update( float fDelta )
if( GAMESTATE->m_bFreeze )
{
// spin the camera Matrix style
m_CameraPanYStart += fDelta*40;
m_CameraPanYEnd += fDelta*40;
//m_CameraPanYStart += fDelta*40;
//m_CameraPanYEnd += fDelta*40;
}
else
{
@@ -192,8 +195,9 @@ void DancingCharacters::Update( float fDelta )
FOREACH_PlayerNumber( p )
{
if( GAMESTATE->IsPlayerEnabled(p) )
if( GAMESTATE->IsPlayerEnabled(p) ) {
m_Character[p].Update( fDelta*fUpdateScale );
}
}
}
@@ -328,25 +332,22 @@ void DancingCharacters::DrawPrimitives()
FOREACH_EnabledPlayer( p )
{
bool bFailed = g_CurStageStats.bFailed[p];
bool bDanger = m_bDrawDangerLight;
DISPLAY->SetLighting( true );
RageColor ambient = bFailed ? RageColor(0.2f,0.1f,0.1f,1) : (bDanger ? RageColor(0.4f,0.1f,0.1f,1) : RageColor(0.4f,0.4f,0.4f,1));
RageColor diffuse = bFailed ? RageColor(0.4f,0.1f,0.1f,1) : (bDanger ? RageColor(0.8f,0.1f,0.1f,1) : RageColor(0.8f,0.8f,0.8f,1));
RageColor specular = RageColor(0.8f,0.8f,0.8f,1);
DISPLAY->SetLightDirectional(
0,
ambient,
diffuse,
specular,
RageVector3(+1, 0, +1) );
m_Character[p].Draw();
DISPLAY->SetLightOff( 0 );
DISPLAY->SetLighting( false );
if(!PREFSMAN->m_bCelShadeModels) {
bool bFailed = g_CurStageStats.bFailed[p];
bool bDanger = m_bDrawDangerLight;
DISPLAY->SetLighting( true );
RageColor ambient = bFailed ? RageColor(0.2f,0.1f,0.1f,1) : (bDanger ? RageColor(0.4f,0.1f,0.1f,1) : RageColor(0.4f,0.4f,0.4f,1));
RageColor diffuse = bFailed ? RageColor(0.4f,0.1f,0.1f,1) : (bDanger ? RageColor(0.8f,0.1f,0.1f,1) : RageColor(0.8f,0.8f,0.8f,1));
RageColor specular = RageColor(0.8f,0.8f,0.8f,1);
DISPLAY->SetLightDirectional(
0,
ambient,
diffuse,
specular,
RageVector3(+1, 0, +1) );
m_Character[p].Draw();
}
else {m_Character[p].DrawCelShaded();}
}
+30 -29
View File
@@ -11,6 +11,7 @@
#include "ActorUtil.h"
#include <cerrno>
#include "ModelManager.h"
#include "SDL_opengl.h"
const float FRAMES_PER_SECOND = 30;
const CString DEFAULT_ANIMATION_NAME = "default";
@@ -421,6 +422,18 @@ bool Model::EarlyAbortDraw()
return m_pGeometry == NULL || m_pGeometry->m_Meshes.empty();
}
void Model::DrawCelShaded()
{
this->SetGlow(RageColor(0,0,0,1));
glPolygonMode (GL_BACK, GL_LINE);
glLineWidth(4.0f);
this->Draw();
DISPLAY->ClearZBuffer();
this->SetGlow(RageColor(1,1,1,0));
glPolygonMode(GL_BACK, GL_FILL);
this->Draw();
}
void Model::DrawPrimitives()
{
/* Don't if we're fully transparent */
@@ -431,7 +444,6 @@ void Model::DrawPrimitives()
DISPLAY->Scale( 1, -1, 1 ); // flip Y so positive is up
//////////////////////
// render the diffuse pass
//////////////////////
@@ -444,11 +456,20 @@ void Model::DrawPrimitives()
msMesh *pMesh = &m_pGeometry->m_Meshes[i];
const RageCompiledGeometry* TempGeometry = m_pTempGeometry ? m_pTempGeometry : m_pGeometry->m_pGeometry;
// apply mesh-specific bone (if any)
if( pMesh->nBoneIndex != -1 )
{
DISPLAY->PushMatrix();
RageMatrix &mat = m_vpBones[pMesh->nBoneIndex].mFinal;
DISPLAY->PreMultMatrix( mat );
}
if( pMesh->nMaterialIndex != -1 ) // has a material
{
// apply material
msMaterial& mat = m_Materials[ pMesh->nMaterialIndex ];
RageColor Emissive = mat.Emissive;
RageColor Ambient = mat.Ambient;
RageColor Diffuse = mat.Diffuse;
@@ -457,18 +478,11 @@ void Model::DrawPrimitives()
Ambient *= m_pTempState->diffuse[0];
Diffuse *= m_pTempState->diffuse[0];
DISPLAY->SetMaterial(
Emissive,
Ambient,
Diffuse,
mat.Specular,
mat.fShininess );
DISPLAY->SetMaterial( Emissive, Ambient, Diffuse, mat.Specular, mat.fShininess );
// render the first pass with texture 1
DISPLAY->SetTexture( 0, mat.diffuse.ani.GetCurrentTexture() );
DISPLAY->SetSphereEnironmentMapping( mat.diffuse.bSphereMapped );
// UGLY: This overrides the Actor's BlendMode
// DISPLAY->SetBlendMode( mat.diffuse.blendMode );
// render the second pass with texture 2
if( mat.alpha.ani.GetCurrentTexture() )
@@ -487,25 +501,12 @@ void Model::DrawPrimitives()
static const RageColor diffuse( 0.7f,0.7f,0.7f,1 );
static const RageColor specular( 0.2f,0.2f,0.2f,1 );
static const float shininess = 1;
DISPLAY->SetMaterial(
emissive,
ambient,
diffuse,
specular,
shininess );
DISPLAY->SetMaterial( emissive, ambient, diffuse, specular, shininess );
DISPLAY->ClearAllTextures();
DISPLAY->SetSphereEnironmentMapping( false );
}
// apply mesh-specific bone (if any)
if( pMesh->nBoneIndex != -1 )
{
DISPLAY->PushMatrix();
RageMatrix &mat = m_vpBones[pMesh->nBoneIndex].mFinal;
DISPLAY->PreMultMatrix( mat );
}
// Draw it
DISPLAY->DrawCompiledGeometry( TempGeometry, i, m_pGeometry->m_Meshes );
DISPLAY->SetSphereEnironmentMapping( false );
@@ -530,9 +531,9 @@ void Model::DrawPrimitives()
// apply material
RageColor emissive = m_pTempState->glow;
RageColor ambient = RageColor(0,0,0,0);
RageColor diffuse = RageColor(0,0,0,0);
RageColor specular = RageColor(0,0,0,0);
RageColor ambient = RageColor(0,0,0,1);
RageColor diffuse = RageColor(0,0,0,1);
RageColor specular = RageColor(0,0,0,1);
float shininess = 1;
DISPLAY->SetMaterial(
+1
View File
@@ -35,6 +35,7 @@ public:
virtual void DrawPrimitives();
void AdvanceFrame (float dt);
void DrawCelShaded();
virtual void SetState( int iNewState );
float GetCurFrame();
+3 -3
View File
@@ -41,7 +41,7 @@ void PrefsManager::Init()
m_iMaxTextureResolution = 2048;
m_iRefreshRate = REFRESH_DEFAULT;
m_bOnlyDedicatedMenuButtons = false;
m_bCelShadeDancers = false; // Work-In-Progress.. disable by default.
m_bCelShadeModels = false; // Work-In-Progress.. disable by default.
#ifdef DEBUG
m_bShowStats = true;
#else
@@ -332,7 +332,7 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
ini.GetValue( "Options", "ScreenWidth", m_fScreenWidth );
ini.GetValue( "Options", "ScreenHeight", m_fScreenHeight );
#endif
ini.GetValue( "Options", "CelShadeDancers", m_bCelShadeDancers );
ini.GetValue( "Options", "CelShadeModels", m_bCelShadeModels );
ini.GetValue( "Options", "DisplayWidth", m_iDisplayWidth );
ini.GetValue( "Options", "DisplayHeight", m_iDisplayHeight );
ini.GetValue( "Options", "DisplayColorDepth", m_iDisplayColorDepth );
@@ -564,7 +564,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
IniFile ini;
ini.SetValue( "Options", "Windowed", m_bWindowed );
ini.SetValue( "Options", "CelShadeDancers", m_bCelShadeDancers );
ini.SetValue( "Options", "CelShadeModels", m_bCelShadeModels );
ini.SetValue( "Options", "DisplayWidth", m_iDisplayWidth );
ini.SetValue( "Options", "DisplayHeight", m_iDisplayHeight );
ini.SetValue( "Options", "DisplayColorDepth", m_iDisplayColorDepth );
+1 -1
View File
@@ -199,7 +199,7 @@ public:
bool m_bHideDefaultNoteSkin;
int m_iMaxHighScoresPerListForMachine;
int m_iMaxHighScoresPerListForPlayer;
bool m_bCelShadeDancers;
bool m_bCelShadeModels;
// Number of seconds it takes for a button on the controller to release
// after pressed.
+17 -13
View File
@@ -304,19 +304,23 @@ void ScreenHowToPlay::DrawPrimitives()
if( m_pmDancePad || m_pmCharacter )
{
DISPLAY->SetLighting( true );
DISPLAY->SetLightDirectional(
0,
RageColor(0.5,0.5,0.5,1),
RageColor(1,1,1,1),
RageColor(0,0,0,1),
RageVector3(0, 0, 1) );
if( m_pmCharacter )
m_pmCharacter->Draw();
if( m_pmDancePad )
m_pmDancePad->Draw();
if(!PREFSMAN->m_bCelShadeModels) {
DISPLAY->SetLighting( true );
DISPLAY->SetLightDirectional(
0,
RageColor(0.5,0.5,0.5,1),
RageColor(1,1,1,1),
RageColor(0,0,0,1),
RageVector3(0, 0, 1) );
if( m_pmCharacter ) {m_pmCharacter->Draw();}
if( m_pmDancePad ) {m_pmDancePad->Draw();}
}
else {
if( m_pmDancePad ) {m_pmDancePad->DrawCelShaded();}
if( m_pmCharacter ) {m_pmCharacter->DrawCelShaded();}
}
DISPLAY->SetLightOff( 0 );
DISPLAY->SetLighting( false );