2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-08-13 23:26:46 +00:00
|
|
|
#include "NoteDisplay.h"
|
|
|
|
|
#include "GameState.h"
|
2003-02-06 07:32:57 +00:00
|
|
|
#include "NoteSkinManager.h"
|
2002-08-13 23:26:46 +00:00
|
|
|
#include "ArrowEffects.h"
|
|
|
|
|
#include "RageLog.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "RageDisplay.h"
|
2003-09-21 20:57:07 +00:00
|
|
|
#include "ActorUtil.h"
|
2006-09-30 00:46:21 +00:00
|
|
|
#include "Style.h"
|
2004-12-20 06:25:59 +00:00
|
|
|
#include "PlayerState.h"
|
2006-08-14 13:15:47 +00:00
|
|
|
#include "Sprite.h"
|
|
|
|
|
#include "NoteTypes.h"
|
2005-07-06 04:20:27 +00:00
|
|
|
#include "LuaBinding.h"
|
2003-02-05 03:53:57 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
const RString& NoteNotePartToString( NotePart i );
|
2006-10-07 08:56:58 +00:00
|
|
|
#define FOREACH_NotePart( i ) FOREACH_ENUM( NotePart, i )
|
2005-04-24 05:44:42 +00:00
|
|
|
|
2006-01-04 22:30:51 +00:00
|
|
|
static const char *NotePartNames[] = {
|
2005-04-24 05:44:42 +00:00
|
|
|
"TapNote",
|
|
|
|
|
"TapMine",
|
2006-08-14 12:16:31 +00:00
|
|
|
"TapLift",
|
2005-04-24 05:44:42 +00:00
|
|
|
"HoldHead",
|
|
|
|
|
"HoldTopCap",
|
|
|
|
|
"HoldBody",
|
|
|
|
|
"HoldBottomCap",
|
|
|
|
|
"HoldTail",
|
|
|
|
|
};
|
2006-10-15 00:09:18 +00:00
|
|
|
XToString( NotePart );
|
2004-04-16 05:21:25 +00:00
|
|
|
|
2006-12-01 13:10:01 +00:00
|
|
|
static bool IsVectorZero( const RageVector2 &v )
|
|
|
|
|
{
|
|
|
|
|
return v.x == 0 && v.y == 0;
|
|
|
|
|
}
|
2004-04-16 05:21:25 +00:00
|
|
|
|
2006-08-08 02:27:59 +00:00
|
|
|
// Don't require that NoteSkins have more than 8 colors. Using 9 colors to display 192nd notes
|
|
|
|
|
// would double the number of texture memory needed for many NoteSkin graphics versus just having
|
|
|
|
|
// 8 colors.
|
|
|
|
|
static const NoteType MAX_DISPLAY_NOTE_TYPE = (NoteType)7;
|
|
|
|
|
|
2003-01-13 08:31:34 +00:00
|
|
|
// cache
|
2004-04-16 04:17:26 +00:00
|
|
|
struct NoteMetricCache_t
|
|
|
|
|
{
|
2003-02-08 23:47:47 +00:00
|
|
|
bool m_bDrawHoldHeadForTapsOnSameRow;
|
2005-10-04 19:45:45 +00:00
|
|
|
float m_fAnimationLengthInBeats[NUM_NotePart];
|
|
|
|
|
bool m_bAnimationIsVivid[NUM_NotePart];
|
2006-12-15 22:27:00 +00:00
|
|
|
RageVector2 m_fAdditionTextureCoordOffset[NUM_NotePart];
|
2005-10-04 19:45:45 +00:00
|
|
|
RageVector2 m_fNoteColorTextureCoordSpacing[NUM_NotePart];
|
2004-04-16 05:21:25 +00:00
|
|
|
|
2003-07-17 07:37:56 +00:00
|
|
|
bool m_bHoldHeadIsAboveWavyParts;
|
|
|
|
|
bool m_bHoldTailIsAboveWavyParts;
|
2003-02-08 23:47:47 +00:00
|
|
|
int m_iStartDrawingHoldBodyOffsetFromHead;
|
|
|
|
|
int m_iStopDrawingHoldBodyOffsetFromTail;
|
2005-10-09 07:01:48 +00:00
|
|
|
float m_fHoldLetGoGrayPercent;
|
2003-12-31 08:15:34 +00:00
|
|
|
bool m_bTapNoteUseLighting;
|
|
|
|
|
bool m_bTapMineUseLighting;
|
2006-08-14 12:16:31 +00:00
|
|
|
bool m_bTapLiftUseLighting;
|
2003-12-31 08:15:34 +00:00
|
|
|
bool m_bHoldHeadUseLighting;
|
|
|
|
|
bool m_bHoldTailUseLighting;
|
2003-10-14 04:41:24 +00:00
|
|
|
bool m_bFlipHeadAndTailWhenReverse;
|
2006-10-30 03:04:41 +00:00
|
|
|
bool m_bHoldActiveIsAddLayer;
|
2003-02-08 23:47:47 +00:00
|
|
|
|
2006-12-15 22:27:00 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void Load( const RString &sButton );
|
2003-02-08 23:47:47 +00:00
|
|
|
} *NoteMetricCache;
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void NoteMetricCache_t::Load( const RString &sButton )
|
2003-02-08 23:47:47 +00:00
|
|
|
{
|
2005-04-24 05:44:42 +00:00
|
|
|
m_bDrawHoldHeadForTapsOnSameRow = NOTESKIN->GetMetricB(sButton,"DrawHoldHeadForTapsOnSameRow");
|
2005-10-04 19:45:45 +00:00
|
|
|
FOREACH_NotePart( p )
|
|
|
|
|
{
|
2006-08-14 12:16:31 +00:00
|
|
|
const RString &s = NotePartToString(p);
|
2005-10-04 19:45:45 +00:00
|
|
|
m_fAnimationLengthInBeats[p] = NOTESKIN->GetMetricF(sButton,s+"AnimationLengthInBeats");
|
|
|
|
|
m_bAnimationIsVivid[p] = NOTESKIN->GetMetricB(sButton,s+"AnimationIsVivid");
|
2006-12-15 22:27:00 +00:00
|
|
|
m_fAdditionTextureCoordOffset[p].x = NOTESKIN->GetMetricF(sButton,s+"AdditionTextureCoordOffsetX");
|
|
|
|
|
m_fAdditionTextureCoordOffset[p].y = NOTESKIN->GetMetricF(sButton,s+"AdditionTextureCoordOffsetY");
|
2005-10-04 19:45:45 +00:00
|
|
|
m_fNoteColorTextureCoordSpacing[p].x = NOTESKIN->GetMetricF(sButton,s+"NoteColorTextureCoordSpacingX");
|
|
|
|
|
m_fNoteColorTextureCoordSpacing[p].y = NOTESKIN->GetMetricF(sButton,s+"NoteColorTextureCoordSpacingY");
|
|
|
|
|
}
|
2006-01-30 23:10:02 +00:00
|
|
|
m_bHoldHeadIsAboveWavyParts = NOTESKIN->GetMetricB(sButton,"HoldHeadIsAboveWavyParts");
|
|
|
|
|
m_bHoldTailIsAboveWavyParts = NOTESKIN->GetMetricB(sButton,"HoldTailIsAboveWavyParts");
|
2005-04-24 05:44:42 +00:00
|
|
|
m_iStartDrawingHoldBodyOffsetFromHead = NOTESKIN->GetMetricI(sButton,"StartDrawingHoldBodyOffsetFromHead");
|
|
|
|
|
m_iStopDrawingHoldBodyOffsetFromTail = NOTESKIN->GetMetricI(sButton,"StopDrawingHoldBodyOffsetFromTail");
|
2006-01-30 23:10:02 +00:00
|
|
|
m_fHoldLetGoGrayPercent = NOTESKIN->GetMetricF(sButton,"HoldLetGoGrayPercent");
|
|
|
|
|
m_bTapNoteUseLighting = NOTESKIN->GetMetricB(sButton,"TapNoteUseLighting");
|
|
|
|
|
m_bTapMineUseLighting = NOTESKIN->GetMetricB(sButton,"TapMineUseLighting");
|
2006-08-14 12:16:31 +00:00
|
|
|
m_bTapLiftUseLighting = NOTESKIN->GetMetricB(sButton,"TapLiftUseLighting");
|
2006-01-30 23:10:02 +00:00
|
|
|
m_bHoldHeadUseLighting = NOTESKIN->GetMetricB(sButton,"HoldHeadUseLighting");
|
|
|
|
|
m_bHoldTailUseLighting = NOTESKIN->GetMetricB(sButton,"HoldTailUseLighting");
|
|
|
|
|
m_bFlipHeadAndTailWhenReverse = NOTESKIN->GetMetricB(sButton,"FlipHeadAndTailWhenReverse");
|
2006-10-30 03:04:41 +00:00
|
|
|
m_bHoldActiveIsAddLayer = NOTESKIN->GetMetricB(sButton,"HoldActiveIsAddLayer");
|
2003-09-12 02:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-21 00:34:24 +00:00
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
struct NoteSkinAndPath
|
|
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
NoteSkinAndPath( const RString sNoteSkin_, const RString sPath_ ) : sNoteSkin(sNoteSkin_), sPath(sPath_) { }
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sNoteSkin;
|
|
|
|
|
RString sPath;
|
2005-04-18 01:19:56 +00:00
|
|
|
bool operator<( const NoteSkinAndPath &other ) const
|
|
|
|
|
{
|
2005-04-23 11:06:28 +00:00
|
|
|
int cmp = strcmp(sNoteSkin, other.sNoteSkin);
|
|
|
|
|
if( cmp < 0 )
|
|
|
|
|
return true;
|
|
|
|
|
else if( cmp == 0 )
|
|
|
|
|
return sPath < other.sPath;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
2005-04-18 01:19:56 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2004-08-21 00:34:24 +00:00
|
|
|
struct NoteResource
|
|
|
|
|
{
|
2005-04-18 01:19:56 +00:00
|
|
|
NoteResource( const NoteSkinAndPath &nsap ): m_nsap(nsap)
|
2004-08-21 00:34:24 +00:00
|
|
|
{
|
|
|
|
|
m_iRefCount = 0;
|
|
|
|
|
m_pActor = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~NoteResource()
|
|
|
|
|
{
|
|
|
|
|
delete m_pActor;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
const NoteSkinAndPath m_nsap; /* should be refcounted along with g_NoteResource[] */
|
2004-08-21 00:34:24 +00:00
|
|
|
int m_iRefCount;
|
|
|
|
|
Actor *m_pActor;
|
|
|
|
|
};
|
|
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
static map<NoteSkinAndPath, NoteResource *> g_NoteResource;
|
2004-08-21 00:34:24 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
static NoteResource *MakeNoteResource( const RString &sButton, const RString &sElement, bool bSpriteOnly )
|
2004-08-21 00:34:24 +00:00
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sElementAndType = sElement;
|
2005-07-05 08:45:51 +00:00
|
|
|
NoteSkinAndPath nsap( NOTESKIN->GetCurrentNoteSkin(), NOTESKIN->GetPath(sButton, sElementAndType) );
|
|
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
map<NoteSkinAndPath, NoteResource *>::iterator it = g_NoteResource.find( nsap );
|
2004-08-21 00:34:24 +00:00
|
|
|
if( it == g_NoteResource.end() )
|
|
|
|
|
{
|
2005-04-18 01:19:56 +00:00
|
|
|
NoteResource *pRes = new NoteResource( nsap );
|
2005-07-06 04:20:27 +00:00
|
|
|
|
|
|
|
|
pRes->m_pActor = ActorUtil::MakeActor( nsap.sPath );
|
|
|
|
|
ASSERT( pRes->m_pActor );
|
|
|
|
|
|
|
|
|
|
/* Make sure pActor is a Sprite (or something derived from Sprite). */
|
2004-08-21 00:34:24 +00:00
|
|
|
if( bSpriteOnly )
|
|
|
|
|
{
|
2006-10-20 09:43:56 +00:00
|
|
|
Sprite *pSprite = dynamic_cast<Sprite *>( pRes->m_pActor );
|
|
|
|
|
if( pSprite == NULL )
|
|
|
|
|
RageException::Throw( "%s: must be a Sprite", nsap.sPath.c_str() );
|
2005-01-17 04:08:08 +00:00
|
|
|
}
|
2004-08-21 00:34:24 +00:00
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
g_NoteResource[nsap] = pRes;
|
|
|
|
|
it = g_NoteResource.find( nsap );
|
2004-08-21 00:34:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NoteResource *pRet = it->second;
|
|
|
|
|
++pRet->m_iRefCount;
|
|
|
|
|
return pRet;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-02 06:47:48 +00:00
|
|
|
static void DeleteNoteResource( NoteResource *pRes )
|
2004-08-21 00:34:24 +00:00
|
|
|
{
|
|
|
|
|
ASSERT( pRes != NULL );
|
|
|
|
|
|
|
|
|
|
ASSERT_M( pRes->m_iRefCount > 0, ssprintf("%i", pRes->m_iRefCount) );
|
|
|
|
|
--pRes->m_iRefCount;
|
|
|
|
|
if( pRes->m_iRefCount )
|
|
|
|
|
return;
|
|
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
g_NoteResource.erase( pRes->m_nsap );
|
2004-08-21 00:34:24 +00:00
|
|
|
delete pRes;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-17 00:39:09 +00:00
|
|
|
NoteColorActor::NoteColorActor()
|
2003-09-12 02:44:14 +00:00
|
|
|
{
|
2005-10-05 05:00:50 +00:00
|
|
|
m_p = NULL;
|
2003-09-12 02:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-17 00:39:09 +00:00
|
|
|
NoteColorActor::~NoteColorActor()
|
2003-09-12 02:44:14 +00:00
|
|
|
{
|
2005-10-05 05:00:50 +00:00
|
|
|
if( m_p )
|
|
|
|
|
DeleteNoteResource( m_p );
|
2005-04-17 00:39:09 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void NoteColorActor::Load( const RString &sButton, const RString &sElement )
|
2005-04-17 00:39:09 +00:00
|
|
|
{
|
2006-11-02 06:47:48 +00:00
|
|
|
m_p = MakeNoteResource( sButton, sElement, false );
|
2005-04-17 00:39:09 +00:00
|
|
|
}
|
2003-09-12 02:44:14 +00:00
|
|
|
|
2003-02-08 23:47:47 +00:00
|
|
|
|
2006-11-02 06:47:48 +00:00
|
|
|
Actor *NoteColorActor::Get()
|
|
|
|
|
{
|
|
|
|
|
return m_p->m_pActor;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-17 00:39:09 +00:00
|
|
|
NoteColorSprite::NoteColorSprite()
|
|
|
|
|
{
|
2005-10-05 05:00:50 +00:00
|
|
|
m_p = NULL;
|
2005-04-17 00:39:09 +00:00
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2005-04-17 00:39:09 +00:00
|
|
|
NoteColorSprite::~NoteColorSprite()
|
|
|
|
|
{
|
2005-10-05 05:00:50 +00:00
|
|
|
if( m_p )
|
|
|
|
|
DeleteNoteResource( m_p );
|
2005-04-17 00:39:09 +00:00
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void NoteColorSprite::Load( const RString &sButton, const RString &sElement )
|
2005-04-17 00:39:09 +00:00
|
|
|
{
|
2006-11-02 06:47:48 +00:00
|
|
|
m_p = MakeNoteResource( sButton, sElement, true );
|
2005-04-17 00:39:09 +00:00
|
|
|
}
|
2003-08-10 10:12:50 +00:00
|
|
|
|
2006-11-02 06:47:48 +00:00
|
|
|
Sprite *NoteColorSprite::Get()
|
|
|
|
|
{
|
|
|
|
|
return dynamic_cast<Sprite *>( m_p->m_pActor );
|
|
|
|
|
}
|
2003-02-06 07:32:57 +00:00
|
|
|
|
2006-01-04 22:30:51 +00:00
|
|
|
static const char *HoldTypeNames[] = {
|
2005-04-18 01:19:56 +00:00
|
|
|
"hold",
|
|
|
|
|
"roll",
|
|
|
|
|
};
|
2006-10-15 00:09:18 +00:00
|
|
|
XToString( HoldType );
|
2005-04-18 01:19:56 +00:00
|
|
|
|
2006-01-04 22:30:51 +00:00
|
|
|
static const char *ActiveTypeNames[] = {
|
2005-04-18 01:19:56 +00:00
|
|
|
"active",
|
|
|
|
|
"inactive",
|
|
|
|
|
};
|
2006-10-15 00:09:18 +00:00
|
|
|
XToString( ActiveType );
|
2005-04-18 01:19:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-17 00:39:09 +00:00
|
|
|
NoteDisplay::NoteDisplay()
|
|
|
|
|
{
|
|
|
|
|
cache = new NoteMetricCache_t;
|
|
|
|
|
}
|
2003-02-08 23:47:47 +00:00
|
|
|
|
2005-04-17 00:39:09 +00:00
|
|
|
NoteDisplay::~NoteDisplay()
|
|
|
|
|
{
|
|
|
|
|
delete cache;
|
|
|
|
|
}
|
2003-02-05 03:53:57 +00:00
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
void NoteDisplay::Load( int iColNum, const PlayerState* pPlayerState, float fYReverseOffsetPixels )
|
2005-04-17 00:39:09 +00:00
|
|
|
{
|
|
|
|
|
m_pPlayerState = pPlayerState;
|
|
|
|
|
m_fYReverseOffsetPixels = fYReverseOffsetPixels;
|
2003-02-08 23:47:47 +00:00
|
|
|
|
2006-09-30 00:46:21 +00:00
|
|
|
const RString &sButton = GAMESTATE->GetCurrentStyle()->ColToButtonName( iColNum );
|
2005-04-18 01:19:56 +00:00
|
|
|
|
|
|
|
|
cache->Load( sButton );
|
|
|
|
|
|
2005-10-04 19:45:45 +00:00
|
|
|
m_TapNote.Load( sButton, "tap note" );
|
|
|
|
|
m_TapMine.Load( sButton, "tap mine" );
|
2006-08-14 12:16:31 +00:00
|
|
|
m_TapLift.Load( sButton, "tap lift" );
|
2005-04-18 01:19:56 +00:00
|
|
|
|
|
|
|
|
FOREACH_HoldType( ht )
|
|
|
|
|
{
|
|
|
|
|
FOREACH_ActiveType( at )
|
|
|
|
|
{
|
2006-01-30 23:10:02 +00:00
|
|
|
m_HoldHead[ht][at].Load( sButton, HoldTypeToString(ht)+" head "+ActiveTypeToString(at) );
|
|
|
|
|
m_HoldTopCap[ht][at].Load( sButton, HoldTypeToString(ht)+" topcap "+ActiveTypeToString(at) );
|
|
|
|
|
m_HoldBody[ht][at].Load( sButton, HoldTypeToString(ht)+" body "+ActiveTypeToString(at) );
|
2005-10-04 19:45:45 +00:00
|
|
|
m_HoldBottomCap[ht][at].Load( sButton, HoldTypeToString(ht)+" bottomcap "+ActiveTypeToString(at) );
|
2006-01-30 23:10:02 +00:00
|
|
|
m_HoldTail[ht][at].Load( sButton, HoldTypeToString(ht)+" tail "+ActiveTypeToString(at) );
|
2005-04-18 01:19:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-02-06 07:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-22 05:00:33 +00:00
|
|
|
bool NoteDisplay::DrawHoldHeadForTapsOnSameRow() const
|
|
|
|
|
{
|
|
|
|
|
return cache->m_bDrawHoldHeadForTapsOnSameRow;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-01 05:58:19 +00:00
|
|
|
void NoteDisplay::Update( float fDeltaTime )
|
|
|
|
|
{
|
2004-08-21 00:34:24 +00:00
|
|
|
/* This function is static: it's called once per game loop, not once per
|
|
|
|
|
* NoteDisplay. Update each cached item exactly once. */
|
2005-04-18 01:19:56 +00:00
|
|
|
map<NoteSkinAndPath, NoteResource *>::iterator it;
|
2004-08-21 00:34:24 +00:00
|
|
|
for( it = g_NoteResource.begin(); it != g_NoteResource.end(); ++it )
|
|
|
|
|
{
|
|
|
|
|
NoteResource *pRes = it->second;
|
|
|
|
|
pRes->m_pActor->Update( fDeltaTime );
|
|
|
|
|
}
|
2004-03-01 05:58:19 +00:00
|
|
|
}
|
2003-02-06 07:32:57 +00:00
|
|
|
|
2005-10-04 19:45:45 +00:00
|
|
|
void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAnimationLengthInBeats, bool bVivid )
|
2003-02-06 07:32:57 +00:00
|
|
|
{
|
2005-03-12 06:09:43 +00:00
|
|
|
/* -inf ... inf */
|
2003-02-06 07:32:57 +00:00
|
|
|
float fSongBeat = GAMESTATE->m_fSongBeat;
|
2005-03-12 06:09:43 +00:00
|
|
|
/* -len ... +len */
|
|
|
|
|
float fPercentIntoAnimation = fmodf( fSongBeat, fAnimationLengthInBeats );
|
|
|
|
|
/* -1 ... 1 */
|
|
|
|
|
fPercentIntoAnimation /= fAnimationLengthInBeats;
|
2003-02-06 07:32:57 +00:00
|
|
|
|
|
|
|
|
if( bVivid )
|
2004-03-01 01:37:22 +00:00
|
|
|
{
|
2006-01-31 03:51:36 +00:00
|
|
|
float fNoteBeatFraction = fmodf( fNoteBeat, 1.0f );
|
|
|
|
|
|
2004-03-01 01:37:22 +00:00
|
|
|
const float fInterval = 1.f / fAnimationLengthInBeats;
|
2006-02-17 05:57:00 +00:00
|
|
|
fPercentIntoAnimation += QuantizeDown( fNoteBeatFraction, fInterval );
|
2003-02-06 07:32:57 +00:00
|
|
|
|
2005-03-12 06:09:43 +00:00
|
|
|
// just in case somehow we're majorly negative with the subtraction
|
|
|
|
|
wrap( fPercentIntoAnimation, 1.f );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* 0 ... 1, wrapped */
|
|
|
|
|
if( fPercentIntoAnimation < 0 )
|
|
|
|
|
fPercentIntoAnimation += 1.0f;
|
|
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2004-08-09 00:46:42 +00:00
|
|
|
float fLengthSeconds = actorToSet.GetAnimationLengthSeconds();
|
|
|
|
|
actorToSet.SetSecondsIntoAnimation( fPercentIntoAnimation*fLengthSeconds );
|
2003-01-13 08:31:34 +00:00
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2006-08-14 13:10:52 +00:00
|
|
|
Actor *NoteDisplay::GetTapActor( NoteColorActor &nca, NotePart part, float fNoteBeat )
|
2003-02-05 03:53:57 +00:00
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
Actor *pActorOut = nca.Get();
|
2006-08-14 12:16:31 +00:00
|
|
|
|
2006-08-14 13:10:52 +00:00
|
|
|
SetActiveFrame( fNoteBeat, *pActorOut, cache->m_fAnimationLengthInBeats[part], cache->m_bAnimationIsVivid[part] );
|
2006-08-14 12:16:31 +00:00
|
|
|
return pActorOut;
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-26 21:05:49 +00:00
|
|
|
Actor *NoteDisplay::GetHoldActor( NoteColorActor nca[NUM_HoldType][NUM_ActiveType], NotePart part, float fNoteBeat, bool bIsRoll, bool bIsBeingHeld )
|
2003-02-05 03:53:57 +00:00
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
return GetTapActor( nca[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive], part, fNoteBeat );
|
2003-02-05 03:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-26 21:05:49 +00:00
|
|
|
Sprite *NoteDisplay::GetHoldSprite( NoteColorSprite ncs[NUM_HoldType][NUM_ActiveType], NotePart part, float fNoteBeat, bool bIsRoll, bool bIsBeingHeld )
|
2003-02-05 03:53:57 +00:00
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
Sprite *pSpriteOut = ncs[bIsRoll ? roll:hold][bIsBeingHeld ? active:inactive].Get();
|
|
|
|
|
|
|
|
|
|
SetActiveFrame( fNoteBeat, *pSpriteOut, cache->m_fAnimationLengthInBeats[part], cache->m_bAnimationIsVivid[part] );
|
2003-02-08 23:47:47 +00:00
|
|
|
return pSpriteOut;
|
2003-02-05 03:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-13 06:12:38 +00:00
|
|
|
static float ArrowGetAlphaOrGlow( bool bGlow, const PlayerState* pPlayerState, int iCol, float fYOffset, float fPercentFadeToFail, float fYReverseOffsetPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
|
2004-04-16 03:05:16 +00:00
|
|
|
{
|
|
|
|
|
if( bGlow )
|
2006-11-13 06:12:38 +00:00
|
|
|
return ArrowEffects::GetGlow( pPlayerState, iCol, fYOffset, fPercentFadeToFail, fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2004-04-16 03:05:16 +00:00
|
|
|
else
|
2006-11-13 06:12:38 +00:00
|
|
|
return ArrowEffects::GetAlpha( pPlayerState, iCol, fYOffset, fPercentFadeToFail, fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2004-04-16 03:05:16 +00:00
|
|
|
}
|
2003-02-05 03:53:57 +00:00
|
|
|
|
2004-10-27 21:58:31 +00:00
|
|
|
struct StripBuffer
|
|
|
|
|
{
|
|
|
|
|
enum { size = 512 };
|
2005-01-10 13:09:19 +00:00
|
|
|
RageSpriteVertex *buf;
|
2004-10-27 21:58:31 +00:00
|
|
|
RageSpriteVertex *v;
|
2005-01-10 13:09:19 +00:00
|
|
|
StripBuffer()
|
|
|
|
|
{
|
|
|
|
|
buf = (RageSpriteVertex *) malloc( size * sizeof(RageSpriteVertex) );
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
~StripBuffer()
|
|
|
|
|
{
|
|
|
|
|
free( buf );
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-27 21:58:31 +00:00
|
|
|
void Init()
|
|
|
|
|
{
|
|
|
|
|
v = buf;
|
|
|
|
|
}
|
|
|
|
|
void Draw()
|
|
|
|
|
{
|
|
|
|
|
DISPLAY->DrawQuadStrip( buf, v-buf );
|
|
|
|
|
}
|
|
|
|
|
int Used() const { return v - buf; }
|
|
|
|
|
int Free() const { return size - Used(); }
|
|
|
|
|
};
|
|
|
|
|
|
2007-01-04 02:14:03 +00:00
|
|
|
void NoteDisplay::DrawHoldTopCap( const TapNote& tn, int iCol, float fBeat, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, bool bIsAddition, float fPercentFadeToFail, float fColorScale,
|
2007-01-04 00:38:19 +00:00
|
|
|
bool bGlow, float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2003-02-05 03:53:57 +00:00
|
|
|
//
|
2003-07-17 06:10:25 +00:00
|
|
|
// Draw the top cap (always wavy)
|
2003-02-05 03:53:57 +00:00
|
|
|
//
|
2004-10-27 21:58:31 +00:00
|
|
|
StripBuffer queue;
|
|
|
|
|
|
2006-10-30 03:04:41 +00:00
|
|
|
vector<Sprite*> vpSpr;
|
2007-01-04 02:14:03 +00:00
|
|
|
Sprite *pSprTopCap = GetHoldSprite( m_HoldTopCap, NotePart_HoldTopCap, fBeat, tn.subType == TapNote::hold_head_roll, bIsBeingHeld && !cache->m_bHoldActiveIsAddLayer );
|
2006-11-03 07:31:19 +00:00
|
|
|
pSprTopCap->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
|
2006-10-30 03:04:41 +00:00
|
|
|
vpSpr.push_back( pSprTopCap );
|
|
|
|
|
if( bIsBeingHeld && cache->m_bHoldActiveIsAddLayer )
|
|
|
|
|
{
|
2007-01-04 02:14:03 +00:00
|
|
|
Sprite *pSpr = GetHoldSprite( m_HoldTopCap, NotePart_HoldTopCap, fBeat, tn.subType == TapNote::hold_head_roll, true );
|
2006-10-30 03:04:41 +00:00
|
|
|
ASSERT( pSpr->GetUnzoomedWidth() == pSprTopCap->GetUnzoomedWidth() );
|
|
|
|
|
ASSERT( pSpr->GetUnzoomedHeight() == pSprTopCap->GetUnzoomedHeight() );
|
2006-11-03 07:31:19 +00:00
|
|
|
pSpr->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
|
2006-10-30 03:04:41 +00:00
|
|
|
vpSpr.push_back( pSpr );
|
|
|
|
|
}
|
2004-06-08 22:27:37 +00:00
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
// draw manually in small segments
|
|
|
|
|
const RectF *pRect = pSprTopCap->GetCurrentTextureCoordRect();
|
2004-02-04 09:55:18 +00:00
|
|
|
DISPLAY->ClearAllTextures();
|
2004-02-04 11:05:33 +00:00
|
|
|
DISPLAY->SetCullMode( CULL_NONE );
|
2003-07-17 06:10:25 +00:00
|
|
|
DISPLAY->SetTextureWrapping(false);
|
|
|
|
|
|
2004-06-08 19:04:26 +00:00
|
|
|
const float fFrameWidth = pSprTopCap->GetZoomedWidth();
|
|
|
|
|
const float fFrameHeight = pSprTopCap->GetZoomedHeight();
|
2003-07-17 06:10:25 +00:00
|
|
|
const float fYCapTop = fYHead+cache->m_iStartDrawingHoldBodyOffsetFromHead-fFrameHeight;
|
|
|
|
|
const float fYCapBottom = fYHead+cache->m_iStartDrawingHoldBodyOffsetFromHead;
|
|
|
|
|
|
2006-08-05 02:38:05 +00:00
|
|
|
bool bReverse = m_pPlayerState->m_PlayerOptions.GetCurrent().GetReversePercentForColumn(iCol) > 0.5f;
|
2005-03-02 10:35:02 +00:00
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
if( bGlow )
|
|
|
|
|
fColorScale = 1;
|
|
|
|
|
|
2005-02-07 21:13:04 +00:00
|
|
|
float fDrawYCapTop;
|
|
|
|
|
float fDrawYCapBottom;
|
|
|
|
|
{
|
2006-11-13 06:12:38 +00:00
|
|
|
float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fDrawDistanceAfterTargetsPixels, m_fYReverseOffsetPixels );
|
|
|
|
|
float fYEndPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fDrawDistanceBeforeTargetsPixels, m_fYReverseOffsetPixels );
|
2005-03-02 10:35:02 +00:00
|
|
|
fDrawYCapTop = max( fYCapTop, bReverse ? fYEndPos : fYStartPos );
|
|
|
|
|
fDrawYCapBottom = min( fYCapBottom, bReverse ? fYStartPos : fYEndPos );
|
2005-02-07 21:13:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// don't draw any part of the head that is after the middle of the tail
|
|
|
|
|
fDrawYCapBottom = min( fYTail, fDrawYCapBottom );
|
|
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
bool bAllAreTransparent = true;
|
2004-04-13 07:47:10 +00:00
|
|
|
bool bLast = false;
|
2005-02-07 21:13:04 +00:00
|
|
|
|
|
|
|
|
float fY = fDrawYCapTop;
|
2004-05-04 05:49:35 +00:00
|
|
|
for( ; !bLast; fY+=fYStep )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2005-02-07 21:13:04 +00:00
|
|
|
if( fY >= fDrawYCapBottom )
|
2004-04-13 07:47:10 +00:00
|
|
|
{
|
2005-02-07 21:13:04 +00:00
|
|
|
fY = fDrawYCapBottom;
|
2004-04-13 07:47:10 +00:00
|
|
|
bLast = true;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-30 23:10:02 +00:00
|
|
|
const float fYOffset = ArrowEffects::GetYOffsetFromYPos( m_pPlayerState, iCol, fY, m_fYReverseOffsetPixels );
|
|
|
|
|
const float fZ = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fXLeft = fX - fFrameWidth/2;
|
|
|
|
|
const float fXRight = fX + fFrameWidth/2;
|
|
|
|
|
const float fTopDistFromHeadTop = fY - fYCapTop;
|
|
|
|
|
const float fTexCoordTop = SCALE( fTopDistFromHeadTop, 0, fFrameHeight, pRect->top, pRect->bottom );
|
|
|
|
|
const float fTexCoordLeft = pRect->left;
|
|
|
|
|
const float fTexCoordRight = pRect->right;
|
2006-11-13 06:12:38 +00:00
|
|
|
const float fAlpha = ArrowGetAlphaOrGlow( bGlow, m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2006-01-30 23:10:02 +00:00
|
|
|
const RageColor color = RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
|
2004-04-16 03:05:16 +00:00
|
|
|
|
|
|
|
|
if( fAlpha > 0 )
|
|
|
|
|
bAllAreTransparent = false;
|
2004-04-13 07:47:10 +00:00
|
|
|
|
2004-10-27 21:58:31 +00:00
|
|
|
queue.v[0].p = RageVector3(fXLeft, fY, fZ); queue.v[0].c = color; queue.v[0].t = RageVector2(fTexCoordLeft, fTexCoordTop);
|
|
|
|
|
queue.v[1].p = RageVector3(fXRight, fY, fZ); queue.v[1].c = color; queue.v[1].t = RageVector2(fTexCoordRight, fTexCoordTop);
|
|
|
|
|
queue.v+=2;
|
|
|
|
|
if( queue.Free() < 2 )
|
|
|
|
|
{
|
|
|
|
|
/* The queue is full. Render it, clear the buffer, and move back a step to
|
|
|
|
|
* start off the quad strip again. */
|
|
|
|
|
if( !bAllAreTransparent )
|
2006-10-30 03:04:41 +00:00
|
|
|
{
|
|
|
|
|
FOREACH( Sprite*, vpSpr, spr )
|
|
|
|
|
{
|
|
|
|
|
RageTexture* pTexture = (*spr)->GetTexture();
|
|
|
|
|
DISPLAY->SetTexture( TextureUnit_1, pTexture->GetTexHandle() );
|
|
|
|
|
DISPLAY->SetBlendMode( spr == vpSpr.begin() ? BLEND_NORMAL : BLEND_ADD );
|
|
|
|
|
queue.Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-10-27 21:58:31 +00:00
|
|
|
queue.Init();
|
|
|
|
|
bAllAreTransparent = true;
|
|
|
|
|
fY -= fYStep;
|
|
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
2006-10-30 03:04:41 +00:00
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
if( !bAllAreTransparent )
|
2006-10-30 03:04:41 +00:00
|
|
|
{
|
|
|
|
|
FOREACH( Sprite*, vpSpr, spr )
|
|
|
|
|
{
|
|
|
|
|
RageTexture* pTexture = (*spr)->GetTexture();
|
|
|
|
|
DISPLAY->SetTexture( TextureUnit_1, pTexture->GetTexHandle() );
|
|
|
|
|
DISPLAY->SetBlendMode( spr == vpSpr.begin() ? BLEND_NORMAL : BLEND_ADD );
|
|
|
|
|
queue.Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-17 06:10:25 +00:00
|
|
|
}
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2004-10-27 21:58:31 +00:00
|
|
|
|
2007-01-04 02:14:03 +00:00
|
|
|
void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, bool bIsAddition, float fPercentFadeToFail, float fColorScale, bool bGlow,
|
2007-01-04 00:38:19 +00:00
|
|
|
float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
|
2003-07-17 06:10:25 +00:00
|
|
|
{
|
2002-08-13 23:26:46 +00:00
|
|
|
//
|
2003-02-05 03:53:57 +00:00
|
|
|
// Draw the body (always wavy)
|
2002-08-13 23:26:46 +00:00
|
|
|
//
|
2004-10-27 21:58:31 +00:00
|
|
|
StripBuffer queue;
|
2003-07-17 06:10:25 +00:00
|
|
|
|
2006-10-30 03:04:41 +00:00
|
|
|
vector<Sprite*> vpSpr;
|
2007-01-04 02:14:03 +00:00
|
|
|
Sprite *pSprBody = GetHoldSprite( m_HoldBody, NotePart_HoldBody, fBeat, tn.subType == TapNote::hold_head_roll, bIsBeingHeld && !cache->m_bHoldActiveIsAddLayer );
|
2006-11-03 07:31:19 +00:00
|
|
|
pSprBody->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
|
2006-10-30 03:04:41 +00:00
|
|
|
vpSpr.push_back( pSprBody );
|
|
|
|
|
if( bIsBeingHeld && cache->m_bHoldActiveIsAddLayer )
|
|
|
|
|
{
|
2007-01-04 02:14:03 +00:00
|
|
|
Sprite *pSpr = GetHoldSprite( m_HoldBody, NotePart_HoldBody, fBeat, tn.subType == TapNote::hold_head_roll, true );
|
2006-10-30 03:04:41 +00:00
|
|
|
ASSERT( pSpr->GetUnzoomedWidth() == pSprBody->GetUnzoomedWidth() );
|
|
|
|
|
ASSERT( pSpr->GetUnzoomedHeight() == pSprBody->GetUnzoomedHeight() );
|
2006-11-03 07:31:19 +00:00
|
|
|
pSpr->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
|
2006-10-30 03:04:41 +00:00
|
|
|
vpSpr.push_back( pSpr );
|
|
|
|
|
}
|
2003-07-17 06:10:25 +00:00
|
|
|
|
2004-06-08 22:27:37 +00:00
|
|
|
|
2006-11-03 03:49:32 +00:00
|
|
|
DISPLAY->ClearAllTextures();
|
|
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
// draw manually in small segments
|
|
|
|
|
const RectF *pRect = pSprBody->GetCurrentTextureCoordRect();
|
2004-06-08 19:04:26 +00:00
|
|
|
const float fFrameWidth = pSprBody->GetZoomedWidth();
|
|
|
|
|
const float fFrameHeight = pSprBody->GetZoomedHeight();
|
2003-07-17 06:10:25 +00:00
|
|
|
const float fYBodyTop = fYHead + cache->m_iStartDrawingHoldBodyOffsetFromHead;
|
|
|
|
|
const float fYBodyBottom = fYTail + cache->m_iStopDrawingHoldBodyOffsetFromTail;
|
2004-06-07 20:54:21 +00:00
|
|
|
|
2006-08-05 02:38:05 +00:00
|
|
|
const bool bReverse = m_pPlayerState->m_PlayerOptions.GetCurrent().GetReversePercentForColumn(iCol) > 0.5f;
|
2003-12-31 23:47:01 +00:00
|
|
|
bool bAnchorToBottom = bReverse && cache->m_bFlipHeadAndTailWhenReverse;
|
|
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
if( bGlow )
|
|
|
|
|
fColorScale = 1;
|
|
|
|
|
|
2005-02-07 21:00:21 +00:00
|
|
|
/* Only draw the section that's within the range specified. If a hold note is
|
|
|
|
|
* very long, don't process or draw the part outside of the range. Don't change
|
|
|
|
|
* fYBodyTop or fYBodyBottom; they need to be left alone to calculate texture
|
|
|
|
|
* coordinates. */
|
|
|
|
|
float fDrawYBodyTop;
|
|
|
|
|
float fDrawYBodyBottom;
|
|
|
|
|
{
|
2006-11-13 06:12:38 +00:00
|
|
|
float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fDrawDistanceAfterTargetsPixels, m_fYReverseOffsetPixels );
|
|
|
|
|
float fYEndPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fDrawDistanceBeforeTargetsPixels, m_fYReverseOffsetPixels );
|
2005-03-02 10:35:02 +00:00
|
|
|
|
|
|
|
|
fDrawYBodyTop = max( fYBodyTop, bReverse ? fYEndPos : fYStartPos );
|
|
|
|
|
fDrawYBodyBottom = min( fYBodyBottom, bReverse ? fYStartPos : fYEndPos );
|
2005-02-07 21:00:21 +00:00
|
|
|
}
|
|
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
// top to bottom
|
2004-04-16 03:05:16 +00:00
|
|
|
bool bAllAreTransparent = true;
|
2004-04-13 07:47:10 +00:00
|
|
|
bool bLast = false;
|
2005-03-30 08:36:55 +00:00
|
|
|
float fVertTexCoordOffset = 0;
|
2005-02-07 21:00:21 +00:00
|
|
|
for( float fY = fDrawYBodyTop; !bLast; fY += fYStep )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2005-02-07 21:00:21 +00:00
|
|
|
if( fY >= fDrawYBodyBottom )
|
2003-12-31 23:47:01 +00:00
|
|
|
{
|
2005-02-07 21:00:21 +00:00
|
|
|
fY = fDrawYBodyBottom;
|
2004-04-13 07:47:10 +00:00
|
|
|
bLast = true;
|
2003-07-17 06:10:25 +00:00
|
|
|
}
|
2004-04-13 07:47:10 +00:00
|
|
|
|
2006-01-30 23:10:02 +00:00
|
|
|
const float fYOffset = ArrowEffects::GetYOffsetFromYPos( m_pPlayerState, iCol, fY, m_fYReverseOffsetPixels );
|
|
|
|
|
const float fZ = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fXLeft = fX - fFrameWidth/2;
|
|
|
|
|
const float fXRight = fX + fFrameWidth/2;
|
2004-04-13 07:47:10 +00:00
|
|
|
const float fDistFromBodyBottom = fYBodyBottom - fY;
|
|
|
|
|
const float fDistFromBodyTop = fY - fYBodyTop;
|
2006-11-02 21:00:20 +00:00
|
|
|
float fTexCoordTop = SCALE( bAnchorToBottom ? fDistFromBodyTop : fDistFromBodyBottom, 0, fFrameHeight, pRect->bottom, pRect->top );
|
2005-03-30 08:36:55 +00:00
|
|
|
/* For very large hold notes, shift the texture coordinates to be near 0, so we
|
|
|
|
|
* don't send very large values to the renderer. */
|
|
|
|
|
if( fY == fDrawYBodyTop ) // first
|
|
|
|
|
fVertTexCoordOffset = floorf( fTexCoordTop );
|
|
|
|
|
fTexCoordTop -= fVertTexCoordOffset;
|
2006-01-30 23:10:02 +00:00
|
|
|
const float fTexCoordLeft = pRect->left;
|
|
|
|
|
const float fTexCoordRight = pRect->right;
|
2006-11-13 06:12:38 +00:00
|
|
|
const float fAlpha = ArrowGetAlphaOrGlow( bGlow, m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2006-01-30 23:10:02 +00:00
|
|
|
const RageColor color = RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
|
2004-04-16 03:05:16 +00:00
|
|
|
|
|
|
|
|
if( fAlpha > 0 )
|
|
|
|
|
bAllAreTransparent = false;
|
2004-04-13 07:47:10 +00:00
|
|
|
|
2006-11-02 21:00:20 +00:00
|
|
|
queue.v[0].p = RageVector3(fXLeft, fY, fZ); queue.v[0].c = color; queue.v[0].t = RageVector2(fTexCoordLeft, fTexCoordTop);
|
|
|
|
|
queue.v[1].p = RageVector3(fXRight, fY, fZ); queue.v[1].c = color; queue.v[1].t = RageVector2(fTexCoordRight, fTexCoordTop);
|
2004-10-27 21:58:31 +00:00
|
|
|
queue.v+=2;
|
|
|
|
|
if( queue.Free() < 2 )
|
|
|
|
|
{
|
|
|
|
|
/* The queue is full. Render it, clear the buffer, and move back a step to
|
|
|
|
|
* start off the quad strip again. */
|
|
|
|
|
if( !bAllAreTransparent )
|
2006-10-30 03:04:41 +00:00
|
|
|
{
|
|
|
|
|
FOREACH( Sprite*, vpSpr, spr )
|
|
|
|
|
{
|
|
|
|
|
RageTexture* pTexture = (*spr)->GetTexture();
|
|
|
|
|
DISPLAY->SetTexture( TextureUnit_1, pTexture->GetTexHandle() );
|
|
|
|
|
DISPLAY->SetBlendMode( spr == vpSpr.begin() ? BLEND_NORMAL : BLEND_ADD );
|
2006-11-02 21:00:20 +00:00
|
|
|
DISPLAY->SetCullMode( CULL_NONE );
|
|
|
|
|
DISPLAY->SetTextureWrapping( true );
|
2006-10-30 03:04:41 +00:00
|
|
|
queue.Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-10-27 21:58:31 +00:00
|
|
|
queue.Init();
|
|
|
|
|
bAllAreTransparent = true;
|
|
|
|
|
fY -= fYStep;
|
|
|
|
|
}
|
2004-04-13 07:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
if( !bAllAreTransparent )
|
2006-10-30 03:04:41 +00:00
|
|
|
{
|
|
|
|
|
FOREACH( Sprite*, vpSpr, spr )
|
|
|
|
|
{
|
|
|
|
|
RageTexture* pTexture = (*spr)->GetTexture();
|
|
|
|
|
DISPLAY->SetTexture( TextureUnit_1, pTexture->GetTexHandle() );
|
|
|
|
|
DISPLAY->SetBlendMode( spr == vpSpr.begin() ? BLEND_NORMAL : BLEND_ADD );
|
2006-11-02 21:00:20 +00:00
|
|
|
DISPLAY->SetCullMode( CULL_NONE );
|
|
|
|
|
DISPLAY->SetTextureWrapping( true );
|
2006-10-30 03:04:41 +00:00
|
|
|
queue.Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-17 06:10:25 +00:00
|
|
|
}
|
2003-02-05 03:53:57 +00:00
|
|
|
|
2007-01-04 02:14:03 +00:00
|
|
|
void NoteDisplay::DrawHoldBottomCap( const TapNote& tn, int iCol, float fBeat, bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, bool bIsAddition, float fPercentFadeToFail, float fColorScale,
|
2007-01-04 00:38:19 +00:00
|
|
|
bool bGlow, float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
|
2003-07-17 06:10:25 +00:00
|
|
|
{
|
2003-02-08 23:47:47 +00:00
|
|
|
//
|
2003-07-17 06:10:25 +00:00
|
|
|
// Draw the bottom cap (always wavy)
|
2003-02-08 23:47:47 +00:00
|
|
|
//
|
2004-10-27 21:58:31 +00:00
|
|
|
StripBuffer queue;
|
2003-07-17 06:10:25 +00:00
|
|
|
|
2006-10-30 03:04:41 +00:00
|
|
|
vector<Sprite*> vpSpr;
|
2007-01-04 02:14:03 +00:00
|
|
|
Sprite* pBottomCap = GetHoldSprite( m_HoldBottomCap, NotePart_HoldBottomCap, fBeat, tn.subType == TapNote::hold_head_roll, bIsBeingHeld && !cache->m_bHoldActiveIsAddLayer );
|
2006-11-03 07:31:19 +00:00
|
|
|
pBottomCap->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
|
2006-10-30 03:04:41 +00:00
|
|
|
vpSpr.push_back( pBottomCap );
|
|
|
|
|
if( bIsBeingHeld && cache->m_bHoldActiveIsAddLayer )
|
|
|
|
|
{
|
2007-01-04 02:14:03 +00:00
|
|
|
Sprite *pSpr = GetHoldSprite( m_HoldBody, NotePart_HoldBody, fBeat, tn.subType == TapNote::hold_head_roll, true );
|
2006-10-30 03:04:41 +00:00
|
|
|
ASSERT( pSpr->GetUnzoomedWidth() == pBottomCap->GetUnzoomedWidth() );
|
|
|
|
|
ASSERT( pSpr->GetUnzoomedHeight() == pBottomCap->GetUnzoomedHeight() );
|
2006-11-03 07:31:19 +00:00
|
|
|
pSpr->SetZoom( ArrowEffects::GetZoom( m_pPlayerState ) );
|
2006-10-30 03:04:41 +00:00
|
|
|
vpSpr.push_back( pSpr );
|
|
|
|
|
}
|
2004-06-08 22:27:37 +00:00
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
// draw manually in small segments
|
|
|
|
|
const RectF *pRect = pBottomCap->GetCurrentTextureCoordRect();
|
2004-02-04 09:55:18 +00:00
|
|
|
DISPLAY->ClearAllTextures();
|
2004-02-04 11:05:33 +00:00
|
|
|
DISPLAY->SetCullMode( CULL_NONE );
|
2003-07-17 06:10:25 +00:00
|
|
|
DISPLAY->SetTextureWrapping(false);
|
|
|
|
|
|
2004-06-08 19:04:26 +00:00
|
|
|
const float fFrameWidth = pBottomCap->GetZoomedWidth();
|
|
|
|
|
const float fFrameHeight = pBottomCap->GetZoomedHeight();
|
2003-07-17 06:10:25 +00:00
|
|
|
const float fYCapTop = fYTail+cache->m_iStopDrawingHoldBodyOffsetFromTail;
|
|
|
|
|
const float fYCapBottom = fYTail+cache->m_iStopDrawingHoldBodyOffsetFromTail+fFrameHeight;
|
|
|
|
|
|
2006-08-05 02:38:05 +00:00
|
|
|
bool bReverse = m_pPlayerState->m_PlayerOptions.GetCurrent().GetReversePercentForColumn(iCol) > 0.5f;
|
2005-03-02 10:35:02 +00:00
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
if( bGlow )
|
|
|
|
|
fColorScale = 1;
|
|
|
|
|
|
2005-02-07 21:13:04 +00:00
|
|
|
float fDrawYCapTop;
|
|
|
|
|
float fDrawYCapBottom;
|
|
|
|
|
{
|
2006-11-13 06:12:38 +00:00
|
|
|
float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fDrawDistanceAfterTargetsPixels, m_fYReverseOffsetPixels );
|
|
|
|
|
float fYEndPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fDrawDistanceBeforeTargetsPixels, m_fYReverseOffsetPixels );
|
2005-03-02 10:35:02 +00:00
|
|
|
fDrawYCapTop = max( fYCapTop, bReverse ? fYEndPos : fYStartPos );
|
|
|
|
|
fDrawYCapBottom = min( fYCapBottom, bReverse ? fYStartPos : fYEndPos );
|
2005-02-07 21:13:04 +00:00
|
|
|
}
|
|
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
bool bAllAreTransparent = true;
|
2004-04-13 07:47:10 +00:00
|
|
|
bool bLast = false;
|
2004-05-04 05:49:35 +00:00
|
|
|
// don't draw any part of the tail that is before the middle of the head
|
2005-02-07 21:13:04 +00:00
|
|
|
float fY=max( fDrawYCapTop, fYHead );
|
2004-04-13 07:47:10 +00:00
|
|
|
for( ; !bLast; fY += fYStep )
|
2003-02-08 23:47:47 +00:00
|
|
|
{
|
2005-02-07 21:13:04 +00:00
|
|
|
if( fY >= fDrawYCapBottom )
|
2004-04-13 07:47:10 +00:00
|
|
|
{
|
2005-02-07 21:13:04 +00:00
|
|
|
fY = fDrawYCapBottom;
|
2004-04-13 07:47:10 +00:00
|
|
|
bLast = true;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-30 23:10:02 +00:00
|
|
|
const float fYOffset = ArrowEffects::GetYOffsetFromYPos( m_pPlayerState, iCol, fY, m_fYReverseOffsetPixels );
|
|
|
|
|
const float fZ = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fXLeft = fX - fFrameWidth/2;
|
|
|
|
|
const float fXRight = fX + fFrameWidth/2;
|
|
|
|
|
const float fTopDistFromTail = fY - fYCapTop;
|
|
|
|
|
const float fTexCoordTop = SCALE( fTopDistFromTail, 0, fFrameHeight, pRect->top, pRect->bottom );
|
|
|
|
|
const float fTexCoordLeft = pRect->left;
|
|
|
|
|
const float fTexCoordRight = pRect->right;
|
2006-11-13 06:12:38 +00:00
|
|
|
const float fAlpha = ArrowGetAlphaOrGlow( bGlow, m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2006-01-30 23:10:02 +00:00
|
|
|
const RageColor color = RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
|
2004-04-16 03:05:16 +00:00
|
|
|
|
|
|
|
|
if( fAlpha > 0 )
|
|
|
|
|
bAllAreTransparent = false;
|
2004-04-13 07:47:10 +00:00
|
|
|
|
2004-10-27 21:58:31 +00:00
|
|
|
queue.v[0].p = RageVector3(fXLeft, fY, fZ); queue.v[0].c = color; queue.v[0].t = RageVector2(fTexCoordLeft, fTexCoordTop);
|
|
|
|
|
queue.v[1].p = RageVector3(fXRight, fY, fZ); queue.v[1].c = color; queue.v[1].t = RageVector2(fTexCoordRight, fTexCoordTop);
|
|
|
|
|
queue.v+=2;
|
|
|
|
|
if( queue.Free() < 2 )
|
|
|
|
|
{
|
|
|
|
|
/* The queue is full. Render it, clear the buffer, and move back a step to
|
|
|
|
|
* start off the quad strip again. */
|
|
|
|
|
if( !bAllAreTransparent )
|
2006-10-30 03:04:41 +00:00
|
|
|
{
|
|
|
|
|
FOREACH( Sprite*, vpSpr, spr )
|
|
|
|
|
{
|
|
|
|
|
RageTexture* pTexture = (*spr)->GetTexture();
|
|
|
|
|
DISPLAY->SetTexture( TextureUnit_1, pTexture->GetTexHandle() );
|
|
|
|
|
DISPLAY->SetBlendMode( spr == vpSpr.begin() ? BLEND_NORMAL : BLEND_ADD );
|
|
|
|
|
queue.Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-10-27 21:58:31 +00:00
|
|
|
queue.Init();
|
|
|
|
|
bAllAreTransparent = true;
|
|
|
|
|
fY -= fYStep;
|
|
|
|
|
}
|
2003-02-08 23:47:47 +00:00
|
|
|
}
|
2006-10-30 03:04:41 +00:00
|
|
|
|
2004-04-16 03:05:16 +00:00
|
|
|
if( !bAllAreTransparent )
|
2006-10-30 03:04:41 +00:00
|
|
|
{
|
|
|
|
|
FOREACH( Sprite*, vpSpr, spr )
|
|
|
|
|
{
|
|
|
|
|
RageTexture* pTexture = (*spr)->GetTexture();
|
|
|
|
|
DISPLAY->SetTexture( TextureUnit_1, pTexture->GetTexHandle() );
|
|
|
|
|
DISPLAY->SetBlendMode( spr == vpSpr.begin() ? BLEND_NORMAL : BLEND_ADD );
|
|
|
|
|
queue.Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-17 06:10:25 +00:00
|
|
|
}
|
2003-02-05 03:53:57 +00:00
|
|
|
|
2007-01-04 02:14:03 +00:00
|
|
|
void NoteDisplay::DrawHoldHeadTail( const TapNote& tn, Actor* pActor, NotePart part, int iCol, float fBeat, float fY, bool bIsAddition, float fPercentFadeToFail, float fColorScale,
|
2007-01-04 01:29:14 +00:00
|
|
|
bool bGlow, bool bUseLighting, float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
|
2003-07-17 06:10:25 +00:00
|
|
|
{
|
2003-02-08 23:47:47 +00:00
|
|
|
//
|
|
|
|
|
// Draw the head
|
|
|
|
|
//
|
2007-01-04 00:16:24 +00:00
|
|
|
const float fYOffset = ArrowEffects::GetYOffsetFromYPos( m_pPlayerState, iCol, fY, m_fYReverseOffsetPixels );
|
2006-11-13 06:12:38 +00:00
|
|
|
if( fYOffset < fDrawDistanceAfterTargetsPixels || fYOffset > fDrawDistanceBeforeTargetsPixels )
|
2006-11-13 02:27:23 +00:00
|
|
|
return;
|
2007-01-04 00:16:24 +00:00
|
|
|
const float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fZ = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fAlpha = ArrowEffects::GetAlpha( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
|
|
|
|
const float fGlow = ArrowEffects::GetGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
|
|
|
|
const RageColor colorDiffuse = RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
|
2003-07-17 06:10:25 +00:00
|
|
|
const RageColor colorGlow = RageColor(1,1,1,fGlow);
|
2003-02-08 23:47:47 +00:00
|
|
|
|
2004-03-20 19:15:15 +00:00
|
|
|
pActor->SetRotationZ( 0 );
|
2003-07-17 06:10:25 +00:00
|
|
|
pActor->SetXY( fX, fY );
|
|
|
|
|
pActor->SetZ( fZ );
|
2007-01-04 02:21:58 +00:00
|
|
|
pActor->SetZoom( ArrowEffects::GetZoom(m_pPlayerState) );
|
2003-07-09 00:49:05 +00:00
|
|
|
|
2006-12-15 22:27:00 +00:00
|
|
|
bool bNeedsTranslate = (bIsAddition && !IsVectorZero(cache->m_fAdditionTextureCoordOffset[part])) || !IsVectorZero(cache->m_fNoteColorTextureCoordSpacing[part]);
|
|
|
|
|
if( bNeedsTranslate )
|
2005-10-04 19:45:45 +00:00
|
|
|
{
|
|
|
|
|
DISPLAY->TexturePushMatrix();
|
2007-01-04 02:23:44 +00:00
|
|
|
NoteType nt = BeatToNoteType( fBeat );
|
2006-08-08 02:27:59 +00:00
|
|
|
ENUM_CLAMP( nt, (NoteType)0, MAX_DISPLAY_NOTE_TYPE );
|
2006-12-15 22:27:00 +00:00
|
|
|
DISPLAY->TextureTranslate( (bIsAddition ? cache->m_fAdditionTextureCoordOffset[part] : RageVector2(0,0)) + cache->m_fNoteColorTextureCoordSpacing[part]*(float)nt );
|
2005-10-04 19:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
if( bGlow )
|
|
|
|
|
{
|
|
|
|
|
pActor->SetDiffuse( RageColor(1,1,1,0) );
|
|
|
|
|
pActor->SetGlow( colorGlow );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pActor->SetDiffuse( colorDiffuse );
|
|
|
|
|
pActor->SetGlow( RageColor(0,0,0,0) );
|
|
|
|
|
}
|
2003-07-10 03:38:45 +00:00
|
|
|
|
2007-01-04 01:29:14 +00:00
|
|
|
if( bUseLighting )
|
2003-07-17 06:10:25 +00:00
|
|
|
{
|
|
|
|
|
DISPLAY->SetLighting( true );
|
|
|
|
|
DISPLAY->SetLightDirectional(
|
|
|
|
|
0,
|
2003-12-31 03:42:59 +00:00
|
|
|
RageColor(1,1,1,1),
|
2003-07-17 06:10:25 +00:00
|
|
|
RageColor(1,1,1,1),
|
|
|
|
|
RageColor(1,1,1,1),
|
|
|
|
|
RageVector3(1, 0, +1) );
|
|
|
|
|
}
|
2003-07-10 03:38:45 +00:00
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
pActor->Draw();
|
2003-07-10 03:38:45 +00:00
|
|
|
|
2007-01-04 01:29:14 +00:00
|
|
|
if( bUseLighting )
|
2003-07-17 06:10:25 +00:00
|
|
|
{
|
|
|
|
|
DISPLAY->SetLightOff( 0 );
|
|
|
|
|
DISPLAY->SetLighting( false );
|
2003-02-08 23:47:47 +00:00
|
|
|
}
|
2005-10-04 19:45:45 +00:00
|
|
|
|
2006-12-15 22:27:00 +00:00
|
|
|
if( bNeedsTranslate )
|
2005-10-04 19:45:45 +00:00
|
|
|
{
|
|
|
|
|
DISPLAY->TexturePopMatrix();
|
|
|
|
|
}
|
2003-07-17 06:10:25 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-15 22:27:00 +00:00
|
|
|
void NoteDisplay::DrawHold( const TapNote &tn, int iCol, int iRow, bool bIsBeingHeld, bool bIsActive, const HoldNoteResult &Result, bool bIsAddition, float fPercentFadeToFail,
|
2006-11-13 06:12:38 +00:00
|
|
|
bool bDrawGlowOnly, float fReverseOffsetPixels, float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fDrawDistanceBeforeTargetsPixels2, float fFadeInPercentOfDrawFar )
|
2003-07-17 06:10:25 +00:00
|
|
|
{
|
2005-04-07 06:41:02 +00:00
|
|
|
int iEndRow = iRow + tn.iDuration;
|
2005-01-25 05:45:51 +00:00
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
// bDrawGlowOnly is a little hacky. We need to draw the diffuse part and the glow part one pass at a time to minimize state changes
|
|
|
|
|
|
2006-08-05 02:38:05 +00:00
|
|
|
bool bReverse = m_pPlayerState->m_PlayerOptions.GetCurrent().GetReversePercentForColumn(iCol) > 0.5f;
|
2005-04-07 01:41:16 +00:00
|
|
|
float fStartBeat = NoteRowToBeat( max(tn.HoldResult.iLastHeldRow, iRow) );
|
2005-04-07 06:41:02 +00:00
|
|
|
float fThrowAway = 0;
|
2004-01-01 02:14:01 +00:00
|
|
|
|
2005-04-07 06:41:02 +00:00
|
|
|
// HACK: If active, don't set YOffset to 0 so that it doesn't jiggle around the receptor.
|
|
|
|
|
bool bStartIsPastPeak = true;
|
|
|
|
|
float fStartYOffset = 0;
|
|
|
|
|
if( bIsActive )
|
|
|
|
|
; // use the default values filled in above
|
|
|
|
|
else
|
|
|
|
|
fStartYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fStartBeat, fThrowAway, bStartIsPastPeak );
|
|
|
|
|
|
2004-12-20 06:25:59 +00:00
|
|
|
float fStartYPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fStartYOffset, fReverseOffsetPixels );
|
2005-04-07 06:41:02 +00:00
|
|
|
float fEndPeakYOffset = 0;
|
|
|
|
|
bool bEndIsPastPeak = false;
|
|
|
|
|
float fEndYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, NoteRowToBeat(iEndRow), fEndPeakYOffset, bEndIsPastPeak );
|
|
|
|
|
|
|
|
|
|
// In boomerang, the arrows reverse direction at Y offset value fPeakAtYOffset.
|
|
|
|
|
// If fPeakAtYOffset lies inside of the hold we're drawing, then the we
|
|
|
|
|
// want to draw the tail at that max Y offset, or else the hold will appear
|
|
|
|
|
// to magically grow as the tail approaches the max Y offset.
|
|
|
|
|
if( bStartIsPastPeak && !bEndIsPastPeak )
|
|
|
|
|
fEndYOffset = fEndPeakYOffset; // use the calculated PeakYOffset so that long holds don't appear to grow
|
|
|
|
|
|
2004-12-20 06:25:59 +00:00
|
|
|
float fEndYPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fEndYOffset, fReverseOffsetPixels );
|
2003-07-17 06:10:25 +00:00
|
|
|
|
|
|
|
|
const float fYHead = bReverse ? fEndYPos : fStartYPos; // the center of the head
|
|
|
|
|
const float fYTail = bReverse ? fStartYPos : fEndYPos; // the center the tail
|
|
|
|
|
|
2004-12-20 06:25:59 +00:00
|
|
|
const bool WavyPartsNeedZBuffer = ArrowEffects::NeedZBuffer( m_pPlayerState );
|
2003-07-17 06:10:25 +00:00
|
|
|
/* Hack: Z effects need a finer grain step. */
|
2007-01-04 03:18:37 +00:00
|
|
|
const int fYStep = WavyPartsNeedZBuffer? 4: 16; // use small steps only if wavy
|
2003-07-17 06:10:25 +00:00
|
|
|
|
2005-10-09 07:01:48 +00:00
|
|
|
const float fColorScale = tn.HoldResult.fLife + (1-tn.HoldResult.fLife)*cache->m_fHoldLetGoGrayPercent;
|
2003-07-17 06:10:25 +00:00
|
|
|
|
2003-10-19 07:47:16 +00:00
|
|
|
bool bFlipHeadAndTail = bReverse && cache->m_bFlipHeadAndTailWhenReverse;
|
|
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
/* The body and caps should have no overlap, so their order doesn't matter.
|
|
|
|
|
* Draw the head last, so it appears on top. */
|
2007-01-04 02:14:03 +00:00
|
|
|
float fBeat = NoteRowToBeat(iRow);
|
2003-07-17 07:37:56 +00:00
|
|
|
if( !cache->m_bHoldHeadIsAboveWavyParts )
|
2007-01-04 01:29:14 +00:00
|
|
|
{
|
|
|
|
|
Actor *pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
|
2007-01-04 02:14:03 +00:00
|
|
|
DrawHoldHeadTail( tn, pActor, NotePart_HoldHead, iCol, fBeat, bFlipHeadAndTail ? fYTail : fYHead, bIsAddition, fPercentFadeToFail, fColorScale, bDrawGlowOnly, cache->m_bHoldHeadUseLighting, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2007-01-04 01:29:14 +00:00
|
|
|
}
|
2003-07-17 07:37:56 +00:00
|
|
|
if( !cache->m_bHoldTailIsAboveWavyParts )
|
2007-01-04 01:29:14 +00:00
|
|
|
{
|
|
|
|
|
Actor *pActor = GetHoldActor( m_HoldTail, NotePart_HoldTail, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
|
2007-01-04 02:14:03 +00:00
|
|
|
DrawHoldHeadTail( tn, pActor, NotePart_HoldTail, iCol, fBeat, bFlipHeadAndTail ? fYHead : fYTail, bIsAddition, fPercentFadeToFail, fColorScale, bDrawGlowOnly, cache->m_bHoldTailUseLighting, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2007-01-04 01:29:14 +00:00
|
|
|
}
|
2003-07-17 07:37:56 +00:00
|
|
|
|
2003-07-17 06:10:25 +00:00
|
|
|
if( bDrawGlowOnly )
|
|
|
|
|
DISPLAY->SetTextureModeGlow();
|
|
|
|
|
else
|
|
|
|
|
DISPLAY->SetTextureModeModulate();
|
2004-05-15 18:35:03 +00:00
|
|
|
DISPLAY->SetZTestMode( WavyPartsNeedZBuffer?ZTEST_WRITE_ON_PASS:ZTEST_OFF );
|
|
|
|
|
DISPLAY->SetZWrite( WavyPartsNeedZBuffer );
|
2004-01-01 00:03:14 +00:00
|
|
|
|
|
|
|
|
if( !bFlipHeadAndTail )
|
2007-01-04 02:14:03 +00:00
|
|
|
DrawHoldBottomCap( tn, iCol, fBeat, bIsBeingHeld, fYHead, fYTail, fYStep, bIsAddition, fPercentFadeToFail, fColorScale, bDrawGlowOnly, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
|
|
|
|
DrawHoldBody( tn, iCol, fBeat, bIsBeingHeld, fYHead, fYTail, fYStep, bIsAddition, fPercentFadeToFail, fColorScale, bDrawGlowOnly, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2004-01-01 00:03:14 +00:00
|
|
|
if( bFlipHeadAndTail )
|
2007-01-04 02:14:03 +00:00
|
|
|
DrawHoldTopCap( tn, iCol, fBeat, bIsBeingHeld, fYHead, fYTail, fYStep, bIsAddition, fPercentFadeToFail, fColorScale, bDrawGlowOnly, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2003-07-17 06:10:25 +00:00
|
|
|
|
|
|
|
|
/* These set the texture mode themselves. */
|
2003-07-17 07:37:56 +00:00
|
|
|
if( cache->m_bHoldTailIsAboveWavyParts )
|
2007-01-04 01:29:14 +00:00
|
|
|
{
|
|
|
|
|
Actor *pActor = GetHoldActor( m_HoldTail, NotePart_HoldTail, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
|
2007-01-04 02:14:03 +00:00
|
|
|
DrawHoldHeadTail( tn, pActor, NotePart_HoldTail, iCol, fBeat, bFlipHeadAndTail ? fYHead : fYTail, bIsAddition, fPercentFadeToFail, fColorScale, bDrawGlowOnly, cache->m_bHoldTailUseLighting, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2007-01-04 01:29:14 +00:00
|
|
|
}
|
2003-07-17 07:37:56 +00:00
|
|
|
if( cache->m_bHoldHeadIsAboveWavyParts )
|
2007-01-04 01:29:14 +00:00
|
|
|
{
|
|
|
|
|
Actor *pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
|
2007-01-04 02:14:03 +00:00
|
|
|
DrawHoldHeadTail( tn, pActor, NotePart_HoldHead, iCol, fBeat, bFlipHeadAndTail ? fYTail : fYHead, bIsAddition, fPercentFadeToFail, fColorScale, bDrawGlowOnly, cache->m_bHoldHeadUseLighting, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2007-01-04 01:29:14 +00:00
|
|
|
}
|
2002-09-17 23:02:37 +00:00
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
// now, draw the glow pass
|
2002-08-29 01:38:21 +00:00
|
|
|
if( !bDrawGlowOnly )
|
2006-12-15 22:27:00 +00:00
|
|
|
DrawHold( tn, iCol, iRow, bIsBeingHeld, bIsActive, Result, bIsAddition, fPercentFadeToFail, true, fReverseOffsetPixels, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
2007-01-04 01:33:36 +00:00
|
|
|
void NoteDisplay::DrawActor( const TapNote& tn, Actor* pActor, NotePart part, int iCol, float fBeat, bool bIsAddition, float fPercentFadeToFail, float fReverseOffsetPixels, bool bUseLighting, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2006-01-30 23:10:02 +00:00
|
|
|
const float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBeat );
|
2004-12-20 06:25:59 +00:00
|
|
|
const float fYPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffset, fReverseOffsetPixels );
|
2006-01-30 23:10:02 +00:00
|
|
|
const float fRotation = ArrowEffects::GetRotation( m_pPlayerState, fBeat );
|
2006-03-06 00:16:08 +00:00
|
|
|
const float fXPos = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
|
|
|
|
|
const float fZPos = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset );
|
2006-11-13 06:12:38 +00:00
|
|
|
const float fAlpha = ArrowEffects::GetAlpha( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
|
|
|
|
const float fGlow = ArrowEffects::GetGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2007-01-04 01:33:36 +00:00
|
|
|
const float fColorScale = ArrowEffects::GetBrightness( m_pPlayerState, fBeat );
|
2003-01-14 05:35:12 +00:00
|
|
|
RageColor diffuse = RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
|
|
|
|
|
RageColor glow = RageColor(1,1,1,fGlow);
|
|
|
|
|
|
2003-08-10 06:00:30 +00:00
|
|
|
pActor->SetRotationZ( fRotation );
|
2003-05-09 04:42:04 +00:00
|
|
|
pActor->SetXY( fXPos, fYPos );
|
2003-07-09 00:49:05 +00:00
|
|
|
pActor->SetZ( fZPos );
|
2003-05-09 04:42:04 +00:00
|
|
|
pActor->SetDiffuse( diffuse );
|
|
|
|
|
pActor->SetGlow( glow );
|
2007-01-04 02:21:58 +00:00
|
|
|
pActor->SetZoom( ArrowEffects::GetZoom(m_pPlayerState) );
|
2003-05-11 07:23:47 +00:00
|
|
|
|
2006-12-15 22:27:00 +00:00
|
|
|
bool bNeedsTranslate = (bIsAddition && !IsVectorZero(cache->m_fAdditionTextureCoordOffset[part])) || !IsVectorZero(cache->m_fNoteColorTextureCoordSpacing[part]);
|
|
|
|
|
if( bNeedsTranslate )
|
2005-10-04 19:45:45 +00:00
|
|
|
{
|
|
|
|
|
DISPLAY->TexturePushMatrix();
|
|
|
|
|
NoteType nt = BeatToNoteType( fBeat );
|
2006-08-08 02:27:59 +00:00
|
|
|
ENUM_CLAMP( nt, (NoteType)0, MAX_DISPLAY_NOTE_TYPE );
|
2006-12-15 22:27:00 +00:00
|
|
|
DISPLAY->TextureTranslate( (bIsAddition ? cache->m_fAdditionTextureCoordOffset[part] : RageVector2(0,0)) + cache->m_fNoteColorTextureCoordSpacing[part]*(float)nt );
|
2005-10-04 19:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
2003-12-31 08:15:34 +00:00
|
|
|
if( bUseLighting )
|
2003-05-13 13:35:32 +00:00
|
|
|
{
|
2003-05-15 06:09:19 +00:00
|
|
|
DISPLAY->SetLighting( true );
|
2003-05-13 13:35:32 +00:00
|
|
|
DISPLAY->SetLightDirectional(
|
|
|
|
|
0,
|
2003-12-31 03:42:59 +00:00
|
|
|
RageColor(1,1,1,1),
|
2003-05-13 13:35:32 +00:00
|
|
|
RageColor(1,1,1,1),
|
|
|
|
|
RageColor(1,1,1,1),
|
|
|
|
|
RageVector3(1, 0, +1) );
|
|
|
|
|
}
|
2003-05-11 07:23:47 +00:00
|
|
|
|
2003-05-09 04:42:04 +00:00
|
|
|
pActor->Draw();
|
2003-05-11 07:23:47 +00:00
|
|
|
|
2003-12-31 08:15:34 +00:00
|
|
|
if( bUseLighting )
|
2003-05-13 13:35:32 +00:00
|
|
|
{
|
|
|
|
|
DISPLAY->SetLightOff( 0 );
|
2003-05-15 06:09:19 +00:00
|
|
|
DISPLAY->SetLighting( false );
|
2003-05-13 13:35:32 +00:00
|
|
|
}
|
2005-10-04 19:45:45 +00:00
|
|
|
|
2006-12-15 22:27:00 +00:00
|
|
|
if( bNeedsTranslate )
|
2005-10-04 19:45:45 +00:00
|
|
|
{
|
|
|
|
|
DISPLAY->TexturePopMatrix();
|
|
|
|
|
}
|
2003-01-14 05:35:12 +00:00
|
|
|
}
|
|
|
|
|
|
2007-01-04 01:33:36 +00:00
|
|
|
void NoteDisplay::DrawTap( const TapNote& tn, int iCol, float fBeat, bool bOnSameRowAsHoldStart, bool bIsAddition, float fPercentFadeToFail, float fReverseOffsetPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
|
2003-11-15 08:51:47 +00:00
|
|
|
{
|
|
|
|
|
Actor* pActor = NULL;
|
2003-12-31 08:15:34 +00:00
|
|
|
bool bUseLighting = false;
|
2006-08-14 12:16:31 +00:00
|
|
|
NotePart part = NotePart_Tap;
|
|
|
|
|
|
2007-01-04 00:45:47 +00:00
|
|
|
if( tn.type == TapNote::lift )
|
2006-08-14 12:16:31 +00:00
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
pActor = GetTapActor( m_TapLift, NotePart_Lift, fBeat );
|
2006-08-14 12:16:31 +00:00
|
|
|
bUseLighting = cache->m_bTapLiftUseLighting;
|
|
|
|
|
part = NotePart_Lift;
|
|
|
|
|
}
|
2007-01-04 00:45:47 +00:00
|
|
|
else if( tn.type == TapNote::mine )
|
2003-12-31 08:15:34 +00:00
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
pActor = GetTapActor( m_TapMine, NotePart_Mine, fBeat );
|
2003-12-31 08:15:34 +00:00
|
|
|
bUseLighting = cache->m_bTapMineUseLighting;
|
2006-08-14 12:16:31 +00:00
|
|
|
part = NotePart_Mine;
|
2003-12-31 08:15:34 +00:00
|
|
|
}
|
2003-11-15 08:51:47 +00:00
|
|
|
else if( bOnSameRowAsHoldStart && cache->m_bDrawHoldHeadForTapsOnSameRow )
|
2003-12-31 08:15:34 +00:00
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, fBeat, false, false );
|
2003-12-31 08:15:34 +00:00
|
|
|
bUseLighting = cache->m_bHoldHeadUseLighting;
|
|
|
|
|
}
|
2003-11-15 08:51:47 +00:00
|
|
|
else
|
2003-12-31 08:15:34 +00:00
|
|
|
{
|
2006-08-14 13:10:52 +00:00
|
|
|
pActor = GetTapActor( m_TapNote, NotePart_Tap, fBeat );
|
2003-12-31 08:15:34 +00:00
|
|
|
bUseLighting = cache->m_bTapNoteUseLighting;
|
|
|
|
|
}
|
2003-11-15 08:51:47 +00:00
|
|
|
|
2007-01-04 01:03:36 +00:00
|
|
|
if( tn.type == TapNote::attack )
|
|
|
|
|
{
|
|
|
|
|
Lua *L = LUA->Get();
|
|
|
|
|
LuaTable tab;
|
|
|
|
|
LuaHelpers::Push( L, tn.sAttackModifiers );
|
|
|
|
|
tab.Set( L, "Modifiers" );
|
|
|
|
|
pActor->PlayCommand( "SetAttack", &tab );
|
|
|
|
|
LUA->Release( L );
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-04 01:33:36 +00:00
|
|
|
DrawActor( tn, pActor, part, iCol, fBeat, bIsAddition, fPercentFadeToFail, fReverseOffsetPixels, bUseLighting, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
|
2007-01-04 01:03:36 +00:00
|
|
|
|
|
|
|
|
if( tn.type == TapNote::attack )
|
|
|
|
|
pActor->PlayCommand( "UnsetAttack" );
|
2003-11-15 08:51:47 +00:00
|
|
|
}
|
2004-06-08 00:08:04 +00:00
|
|
|
|
|
|
|
|
/*
|
2006-08-14 13:10:52 +00:00
|
|
|
* (c) 2001-2006 Brian Bugh, Ben Nordstrom, Chris Danford, Steve Checkoway
|
2004-06-08 00:08:04 +00:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|