Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //spiral body
- void NoteDisplay::DrawHoldBody2( const TapNote& tn, int iCol, int iRow, bool bIsBeingHeld, float fYHead, float fYTail, float fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow,
- float fYStartOffset, float fYEndOffset, bool bIsActive )
- {
- float fBeat = NoteRowToBeat(max(tn.HoldResult.iLastHeldRow, iRow));
- //float fBeat = NoteRowToBeat(iRow);
- float fOrigEndBeat = NoteRowToBeat(iRow+tn.iDuration);
- float fCurBeat = GAMESTATE->m_fSongBeat;
- float fRelativeEndBeat = (fOrigEndBeat-fCurBeat)/(float)NoteRowToBeat(tn.iDuration);
- float fLengthMult = 1.f+(fRelativeEndBeat*m_pPlayerState->m_CurrentPlayerOptions.m_fEffects[PlayerOptions::EFFECT_LONG_HOLDS]);
- float fEndBeat = NoteRowToBeat(iRow+(tn.iDuration*fLengthMult));
- bool spiralUV = ( m_pPlayerState->m_CurrentPlayerOptions.m_fEffects[PlayerOptions::EFFECT_SPIRAL_HOLDS] < 0 );
- //
- // Draw the body (always wavy)
- //
- StripBuffer queue;
- Sprite* pSprBody = GetHoldBodySprite( NoteRowToBeat(iRow), tn.subType == TapNote::hold_head_roll, bIsBeingHeld );
- // draw manually in small segments
- RageTexture* pTexture = pSprBody->GetTexture();
- const RectF *pRect = pSprBody->GetCurrentTextureCoordRect();
- DISPLAY->ClearAllTextures();
- DISPLAY->SetTexture( 0, pTexture );
- DISPLAY->SetBlendMode( BLEND_NORMAL );
- float fhc = m_pPlayerState->m_CurrentPlayerOptions.m_fEffects[PlayerOptions::EFFECT_HOLD_CULL];
- CullMode C = CULL_NONE;
- if( fhc > 1 )
- C = CULL_BACK;
- else if( fhc > 0 )
- C = CULL_FRONT;
- DISPLAY->SetCullMode( C );
- DISPLAY->SetTextureWrapping( true );
- const float fFrameWidth = pSprBody->GetZoomedWidth();
- const float fFrameHeight = pSprBody->GetZoomedHeight();
- //const float fYBodyTop = fYHead + cache->m_iStartDrawingHoldBodyOffsetFromHead;
- //const float fYBodyBottom = fYTail + cache->m_iStopDrawingHoldBodyOffsetFromTail;
- float fYOffsetA = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBeat );
- float fYOffsetB = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fEndBeat );
- const float fYBodyTop = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffsetA, m_fYReverseOffsetPixels ) + cache->m_iStartDrawingHoldBodyOffsetFromHead;
- const float fYBodyBottom = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffsetB, m_fYReverseOffsetPixels ) + cache->m_iStopDrawingHoldBodyOffsetFromTail;
- const bool bReverse = m_pPlayerState->m_CurrentPlayerOptions.GetReversePercentForColumn(iCol) > 0.5f;
- bool bHoldStealth = m_pPlayerState->m_CurrentPlayerOptions.m_fAppearances[PlayerOptions::APPEARANCE_HOLD_STEALTH] > 0;
- bool bAnchorToBottom = bReverse && cache->m_bFlipHeadAndTailWhenReverse;
- if( bGlow )
- fColorScale = 1;
- // 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;
- {
- float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYStartOffset, m_fYReverseOffsetPixels );
- float fYEndPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYEndOffset, m_fYReverseOffsetPixels );
- //float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffsetA, m_fYReverseOffsetPixels );
- //float fYEndPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffsetB, m_fYReverseOffsetPixels );
- fDrawYBodyTop = max( fYBodyTop, bReverse ? fYEndPos : fYStartPos );
- fDrawYBodyBottom = min( fYBodyBottom, bReverse ? fYStartPos : fYEndPos );
- }
- // top to bottom
- bool bAllAreTransparent = true;
- bool bLast = false;
- float fVertTexCoordOffset = 0;
- float fBStep = spiralUV ? (float)fYStep/(ARROW_SIZE*2.0f) : (float)fYStep/(ARROW_SIZE*0.5f);
- float fReverseMult = bReverse ? -1 : 1;
- // FMS_Cat start
- const float EPSILON = fBStep / 8.0; // 8.0 is random
- // FMS_Cat end
- const float fHp = ArrowEffects::HoldPower( m_pPlayerState, iCol );
- for( float fBc = fBeat; !bLast; fBc += fBStep )
- {
- if( fBc >= fEndBeat )
- {
- fBc = fEndBeat;
- bLast = true;
- }
- if( ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBc ) > fYEndOffset )
- {
- bLast = true;
- }
- //const float fYOffset = ArrowEffects::GetYOffsetFromYPos( m_pPlayerState, iCol, fY, m_fYReverseOffsetPixels );
- float fYOffset;
- float fYOffsetHome;
- if( !bIsActive ){
- fYOffset = max(ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBc ), fYStartOffset);
- fYOffsetHome = max(ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBeat ), fYStartOffset);
- }else{
- fYOffset = max(ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBc ), 0);
- fYOffsetHome = 0;
- }
- fYOffset = min( fYOffset, fYEndOffset );
- const float fY = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffset, m_fYReverseOffsetPixels );
- const float fXreal = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
- const float fZreal = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset );
- const float fY2 = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffset+fBStep, m_fYReverseOffsetPixels );
- const float fX2real = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset+fBStep );
- //const float fZ2 = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset+fBStep );
- const float fXhome = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffsetHome );
- const float fX2home = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffsetHome );
- const float fZhome = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffsetHome );
- const float fZoomReal = ArrowEffects::GetZoom( m_pPlayerState, fYOffset, iCol )*ArrowEffects::GetZoomX( m_pPlayerState, fYOffset, iCol )*m_fHoldZoom;
- const float fZoomHome = ArrowEffects::GetZoom( m_pPlayerState, fYOffsetHome, iCol )*ArrowEffects::GetZoomX( m_pPlayerState, fYOffsetHome, iCol )*m_fHoldZoom;
- const float fX = (fHp*fXreal)+((1-fHp)*fXhome);
- const float fX2 = (fHp*fX2real)+((1-fHp)*fX2home);
- const float fZ = (fHp*fZreal)+((1-fHp)*fZhome);
- const float fZoom = (fHp*fZoomReal)+((1-fHp)*fZoomHome);
- const float fAng = atan2f( fY2-fY, fX2-fX );
- const float fAngOffsetX = (fFrameWidth*fZoom)/2 * RageFastSin(fAng);
- const float fAngOffsetY = (fFrameWidth*fZoom)/2 * RageFastCos(fAng);
- const float fXLeft = fX - fAngOffsetX;
- const float fXRight = fX + fAngOffsetX;
- const float fYLeft = fY + fAngOffsetY;
- const float fYRight = fY - fAngOffsetY;
- const float fZLeft = fZ;
- const float fZRight = fZ;
- //const float fDistFromBodyBottom = fYBodyBottom - fY;
- //const float fDistFromBodyTop = fY - fYBodyTop;
- const float fDistFromBodyBottom = spiralUV ? (fEndBeat - fBc)*fFrameHeight*0.25f*max(m_pPlayerState->m_CurrentPlayerOptions.m_fScrollSpeed,1) : fYBodyBottom - fY;
- const float fDistFromBodyTop = spiralUV ? (fBc - fBeat)*fFrameHeight*0.25f*max(m_pPlayerState->m_CurrentPlayerOptions.m_fScrollSpeed,1) : fY - fYBodyTop;
- /*
- const float fTopDistFromTail = (fBc - fEndBeat)*fFrameHeight*2.0f*max(m_pPlayerState->m_CurrentPlayerOptions.m_fScrollSpeed,1);
- const float fTexCoordTop = SCALE( fTopDistFromTail, 0, fFrameHeight, pRect->top, pRect->bottom );
- */
- float fTexCoordTop;
- if(bReverse){
- fTexCoordTop = SCALE( bAnchorToBottom ? fDistFromBodyBottom : fDistFromBodyTop, 0, fFrameHeight, pRect->bottom, pRect->top );
- }else{
- fTexCoordTop = SCALE( bAnchorToBottom ? fDistFromBodyTop : fDistFromBodyBottom, 0, fFrameHeight, pRect->bottom, pRect->top );
- }
- // 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( fBc == fBeat ) // first
- fVertTexCoordOffset = floorf( fTexCoordTop );
- fTexCoordTop -= fVertTexCoordOffset;
- const float fTexCoordLeft = pRect->left;
- const float fTexCoordRight = pRect->right;
- float fAlphaOrGlow = ArrowGetAlphaOrGlow( bGlow, m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- float fHoldAlpha = ArrowEffects::GetHoldAlpha( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- float fHoldGlow = ArrowEffects::GetHoldGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- if( bHoldStealth ){
- if( bGlow )
- fAlphaOrGlow = fHoldGlow;
- else
- fAlphaOrGlow = fHoldAlpha;
- }
- RageColor diffuse;
- RageColor glow;
- float fRd = ArrowEffects::GetRedDiff( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- float fGd = ArrowEffects::GetGreenDiff( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- float fBd = ArrowEffects::GetBlueDiff( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- float fRg = ArrowEffects::GetRedGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- float fGg = ArrowEffects::GetGreenGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- float fBg = ArrowEffects::GetBlueGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels );
- if( !m_pPlayerState->m_CurrentPlayerOptions.arrowGradientColor.empty() && !m_pPlayerState->m_CurrentPlayerOptions.arrowGradientColor[iCol].empty() ){
- const RageColor c = ArrowEffects::GetArrowColor( m_pPlayerState, iCol, fYOffset, m_fYReverseOffsetPixels );
- diffuse = RageColor( c.r, c.g, c.b, c.a*fAlphaOrGlow );
- }else{
- diffuse = RageColor(
- fColorScale*fRd,
- fColorScale*fGd,
- fColorScale*fBd,
- fAlphaOrGlow);
- }
- if( !m_pPlayerState->m_CurrentPlayerOptions.arrowGlowGradientColor.empty() && !m_pPlayerState->m_CurrentPlayerOptions.arrowGlowGradientColor[iCol].empty() ){
- const RageColor c = ArrowEffects::GetArrowGlowColor( m_pPlayerState, iCol, fYOffset, m_fYReverseOffsetPixels );
- glow = RageColor( c.r, c.g, c.b, c.a*fAlphaOrGlow );
- }else{
- if( fRg == 0 && fGg == 0 && fBg == 0 ){
- glow = RageColor( 1,1,1,fAlphaOrGlow );
- }else{
- glow = RageColor(
- fColorScale*fRg,
- fColorScale*fGg,
- fColorScale*fBg,
- fAlphaOrGlow);
- }
- }
- const RageColor color = bGlow ? glow : diffuse ;
- if( fAlphaOrGlow > 0 )
- bAllAreTransparent = false;
- queue.v[0].p = RageVector3(fXLeft, fYLeft, fZLeft); queue.v[0].c = color; queue.v[0].t = RageVector2(fTexCoordLeft, fTexCoordTop);
- queue.v[1].p = RageVector3(fXRight, fYRight, fZRight); queue.v[1].c = color; queue.v[1].t = RageVector2(fTexCoordRight, fTexCoordTop);
- // FMS_Cat Start
- const float fYp = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffset+fBStep, m_fYReverseOffsetPixels );
- const float fXp = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset+fBStep );
- const float fZp = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset+fBStep );
- const RageVector3 na = RageVector3( fXRight - fXLeft, 0.0, fZRight - fZLeft );
- const RageVector3 nb = RageVector3( fXp - fXLeft, fYp - fY, fZp - fZLeft );
- const RageVector3 n = RageVector3(
- na.y * nb.z - na.z * nb.y,
- na.z * nb.x - na.x * nb.z,
- na.x * nb.y - na.y * nb.x
- );
- const float nl = sqrtf( n.x * n.x + n.y * n.y + n.z * n.z );
- queue.v[0].n = n / nl; queue.v[0].n.y = -queue.v[0].n.y;
- queue.v[1].n = n / nl; queue.v[1].n.y = -queue.v[1].n.y;
- // FMS_Cat End
- 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 ){
- if( m_pPlayerState->m_pHoldShader != NULL && m_pPlayerState->m_pHoldShader->IsValid() )
- {
- m_pPlayerState->m_pHoldShader->SetUniform2f( "imageSize", pTexture->GetImageWidth(), pTexture->GetImageHeight() );
- m_pPlayerState->m_pHoldShader->SetUniform2f( "textureSize", pTexture->GetTextureWidth(), pTexture->GetTextureHeight() );
- m_pPlayerState->m_pHoldShader->SetUniform1i( "iCol", iCol ); m_pPlayerState->m_pHoldShader->SetUniform1i( "iPlayfield", m_pPlayerState->m_Playfield );
- m_pPlayerState->m_pHoldShader->SetUniform1i( "isReceptor", 0 ); m_pPlayerState->m_pHoldShader->SetUniform1i( "isHold", 1 );
- m_pPlayerState->m_pHoldShader->SetUniform1f( "fNoteBeat", NoteRowToBeat(iRow) );
- DISPLAY->ApplyShaderProgram( m_pPlayerState->m_pHoldShader );
- }
- queue.Draw();
- DISPLAY->UnapplyShaderProgram();
- }
- queue.Init();
- bAllAreTransparent = true;
- fBc -= fBStep;
- }
- }
- if( !bAllAreTransparent ){
- if( m_pPlayerState->m_pHoldShader != NULL && m_pPlayerState->m_pHoldShader->IsValid() )
- {
- m_pPlayerState->m_pHoldShader->SetUniform2f( "imageSize", pTexture->GetImageWidth(), pTexture->GetImageHeight() );
- m_pPlayerState->m_pHoldShader->SetUniform2f( "textureSize", pTexture->GetTextureWidth(), pTexture->GetTextureHeight() );
- m_pPlayerState->m_pHoldShader->SetUniform1i( "iCol", iCol ); m_pPlayerState->m_pHoldShader->SetUniform1i( "iPlayfield", m_pPlayerState->m_Playfield );
- m_pPlayerState->m_pHoldShader->SetUniform1i( "isReceptor", 0 ); m_pPlayerState->m_pHoldShader->SetUniform1i( "isHold", 1 );
- m_pPlayerState->m_pHoldShader->SetUniform1f( "fNoteBeat", NoteRowToBeat(iRow) );
- DISPLAY->ApplyShaderProgram( m_pPlayerState->m_pHoldShader );
- }
- queue.Draw();
- DISPLAY->UnapplyShaderProgram();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement