Added Use3D metric to MusicWheel
Added GrooveGraph class
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
#include "global.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: GrooveGraph
|
||||
|
||||
Desc: See header.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "GrooveGraph.h"
|
||||
#include "RageUtil.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageBitmapTexture.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "Notes.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "Song.h"
|
||||
#include "GameState.h"
|
||||
#include "StyleDef.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
const float GRAPH_EDGE_WIDTH = 2;
|
||||
|
||||
GrooveGraph::GrooveGraph()
|
||||
{
|
||||
for( int c=0; c<NUM_RADAR_CATEGORIES; c++ )
|
||||
{
|
||||
float fTotalWidth = 60 * NUM_RADAR_CATEGORIES;
|
||||
float fX = SCALE(c,0,NUM_RADAR_CATEGORIES-1, -fTotalWidth, +fTotalWidth );
|
||||
|
||||
m_Mountains[c].SetXY( fX, -20 );
|
||||
this->AddChild( &m_Mountains[c] );
|
||||
|
||||
m_sprLabels[c].Load( THEME->GetPathTo("Graphics","GrooveGraph labels 1x5") );
|
||||
m_sprLabels[c].StopAnimating();
|
||||
m_sprLabels[c].SetState( c );
|
||||
m_sprLabels[c].SetXY( fX, +10 );
|
||||
this->AddChild( &m_sprLabels[c] );
|
||||
}
|
||||
}
|
||||
|
||||
void GrooveGraph::SetFromSong( Song* pSong )
|
||||
{
|
||||
float fValues[NUM_RADAR_CATEGORIES][NUM_DIFFICULTIES];
|
||||
for( int i=0; i<NUM_DIFFICULTIES; i++ )
|
||||
{
|
||||
Notes* pNotes = pSong->GetNotes( GAMESTATE->GetCurrentStyleDef()->m_NotesType, (Difficulty)i );
|
||||
const float* fRadarValues = pNotes ? pNotes->GetRadarValues() : NULL;
|
||||
for( int j=0; j<NUM_RADAR_CATEGORIES; j++ )
|
||||
fValues[j][i] = fRadarValues ? fRadarValues[j] : 0;
|
||||
}
|
||||
|
||||
for( int j=0; j<NUM_RADAR_CATEGORIES; j++ )
|
||||
{
|
||||
m_Mountains[j].SetValues( fValues[j] );
|
||||
}
|
||||
}
|
||||
|
||||
void GrooveGraph::TweenOnScreen()
|
||||
{
|
||||
}
|
||||
|
||||
void GrooveGraph::TweenOffScreen()
|
||||
{
|
||||
}
|
||||
|
||||
GrooveGraph::Mountain::Mountain()
|
||||
{
|
||||
m_PercentTowardNew = 0;
|
||||
|
||||
for( int i=0; i<NUM_DIFFICULTIES; i++ )
|
||||
{
|
||||
m_fValuesNew[i] = 0;
|
||||
m_fValuesOld[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void GrooveGraph::Mountain::SetValues( float fNewValues[NUM_DIFFICULTIES] )
|
||||
{
|
||||
m_PercentTowardNew = 0;
|
||||
|
||||
memcpy( m_fValuesOld, m_fValuesNew, sizeof(m_fValuesNew) );
|
||||
memcpy( m_fValuesNew, fNewValues, sizeof(fNewValues) );
|
||||
}
|
||||
|
||||
void GrooveGraph::Mountain::Update( float fDeltaTime )
|
||||
{
|
||||
ActorFrame::Update( fDeltaTime );
|
||||
|
||||
m_PercentTowardNew = min( m_PercentTowardNew+4.0f*fDeltaTime, 1 );
|
||||
}
|
||||
|
||||
const RageColor g_DifficultyColors[NUM_DIFFICULTIES] =
|
||||
{
|
||||
RageColor(0.5f,0.5f,1,1), // light blue
|
||||
RageColor(1,1,0,1), // yellow
|
||||
RageColor(1,0,0,1), // red
|
||||
RageColor(0,1,0,1), // green
|
||||
RageColor(0,0,1,1), // blue
|
||||
};
|
||||
|
||||
void GrooveGraph::Mountain::DrawPrimitives()
|
||||
{
|
||||
ActorFrame::DrawPrimitives();
|
||||
|
||||
DISPLAY->SetTexture( NULL );
|
||||
DISPLAY->SetTextureModeModulate();
|
||||
RageVertex v[3];
|
||||
|
||||
for( int i=NUM_DIFFICULTIES-1; i>=0; i-- )
|
||||
{
|
||||
float fValue = m_fValuesOld[i] + (m_fValuesNew[i]-m_fValuesOld[i]) * m_PercentTowardNew;
|
||||
v[0].p = RageVector3( -30, -30, 0 );
|
||||
v[1].p = RageVector3( 30, -30, 0 );
|
||||
v[2].p = RageVector3( 0, -30+60*fValue, 0 );
|
||||
v[0].c = v[1].c = v[2].c = g_DifficultyColors[i];
|
||||
}
|
||||
|
||||
DISPLAY->DrawFan( v, 3 );
|
||||
|
||||
switch( PREFSMAN->m_iPolygonRadar )
|
||||
{
|
||||
case 0: DISPLAY->DrawLoop_LinesAndPoints( v, 3, 2 ); break;
|
||||
case 1: DISPLAY->DrawLoop_Polys( v, 3, 2 ); break;
|
||||
default:
|
||||
case -1: DISPLAY->DrawLoop( v, 3, 2 ); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef GrooveGraph_H
|
||||
#define GrooveGraph_H
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: GrooveGraph
|
||||
|
||||
Desc: The song's GrooveGraph displayed in SelectSong.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "Sprite.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
class Song;
|
||||
|
||||
|
||||
class GrooveGraph : public ActorFrame
|
||||
{
|
||||
public:
|
||||
GrooveGraph();
|
||||
|
||||
void SetFromSong( Song* pSong ); // NULL means no Song
|
||||
|
||||
void TweenOnScreen();
|
||||
void TweenOffScreen();
|
||||
|
||||
protected:
|
||||
|
||||
class Mountain : public ActorFrame
|
||||
{
|
||||
public:
|
||||
Mountain();
|
||||
|
||||
virtual void Update( float fDeltaTime );
|
||||
virtual void DrawPrimitives();
|
||||
|
||||
void SetValues( float fNewValues[] );
|
||||
|
||||
float m_PercentTowardNew;
|
||||
float m_fValuesNew[NUM_DIFFICULTIES];
|
||||
float m_fValuesOld[NUM_DIFFICULTIES];
|
||||
};
|
||||
|
||||
Mountain m_Mountains[NUM_RADAR_CATEGORIES];
|
||||
Sprite m_sprLabels[NUM_RADAR_CATEGORIES];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -13,7 +13,9 @@
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "Sprite.h"
|
||||
#include "song.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
class Notes;
|
||||
|
||||
|
||||
class GrooveRadar : public ActorFrame
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "Song.h"
|
||||
#include "Course.h"
|
||||
#include "RageDisplay.h"
|
||||
|
||||
|
||||
#define NUM_WHEEL_ITEMS min( MAX_WHEEL_ITEMS, THEME->GetMetricI("MusicWheel","NumWheelItems") )
|
||||
@@ -44,7 +45,7 @@ CachedThemeMetricF ITEM_SPACING_Y ("MusicWheel","ItemSpacingY");
|
||||
#define SONG_REAL_EXTRA_COLOR THEME->GetMetricC("MusicWheel","SongRealExtraColor")
|
||||
#define SHOW_ROULETTE THEME->GetMetricB("MusicWheel","ShowRoulette")
|
||||
#define SHOW_RANDOM THEME->GetMetricB("MusicWheel","ShowRandom")
|
||||
|
||||
CachedThemeMetricB USE_3D ("MusicWheel","Use3D");
|
||||
|
||||
const int MAX_WHEEL_SOUND_SPEED = 15;
|
||||
|
||||
@@ -74,6 +75,7 @@ MusicWheel::MusicWheel()
|
||||
// update theme metric cache
|
||||
ITEM_CURVE_X.Refresh();
|
||||
ITEM_SPACING_Y.Refresh();
|
||||
USE_3D.Refresh();
|
||||
|
||||
// for debugging
|
||||
if( GAMESTATE->m_CurStyle == STYLE_INVALID )
|
||||
@@ -508,16 +510,31 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
||||
}
|
||||
}
|
||||
|
||||
float MusicWheel::GetBannerY( float fPosOffsetsFromMiddle )
|
||||
void MusicWheel::GetItemPosition( float fPosOffsetsFromMiddle, float& fX_out, float& fY_out, float& fZ_out, float& fRotationX_out )
|
||||
{
|
||||
return roundf( fPosOffsetsFromMiddle*ITEM_SPACING_Y );
|
||||
}
|
||||
if( USE_3D )
|
||||
{
|
||||
fRotationX_out = SCALE(fPosOffsetsFromMiddle,-7,+7,-PI/2.f,+PI/2.f);
|
||||
|
||||
float MusicWheel::GetBannerX( float fPosOffsetsFromMiddle )
|
||||
{
|
||||
float fX = (1-cosf(fPosOffsetsFromMiddle/PI))*ITEM_CURVE_X;
|
||||
|
||||
return roundf( fX );
|
||||
printf( "fRotationX_out = %f\n", fRotationX_out );
|
||||
|
||||
float radius = 200;
|
||||
|
||||
fX_out = 0;
|
||||
fY_out = -radius*sinf(fRotationX_out);
|
||||
fZ_out = -100+radius*cosf(fRotationX_out); // getting werid results with acosf()
|
||||
}
|
||||
else
|
||||
{
|
||||
fX_out = (1-cosf(fPosOffsetsFromMiddle/PI))*ITEM_CURVE_X;
|
||||
fY_out = fPosOffsetsFromMiddle*ITEM_SPACING_Y;
|
||||
fZ_out = 0;
|
||||
fRotationX_out = 0;
|
||||
|
||||
fX_out = roundf( fX_out );
|
||||
fY_out = roundf( fY_out );
|
||||
fZ_out = roundf( fZ_out );
|
||||
}
|
||||
}
|
||||
|
||||
void MusicWheel::RebuildMusicWheelItems()
|
||||
@@ -562,29 +579,45 @@ void MusicWheel::NotesChanged( PlayerNumber pn ) // update grade graphics and to
|
||||
|
||||
void MusicWheel::DrawPrimitives()
|
||||
{
|
||||
if( USE_3D )
|
||||
{
|
||||
DISPLAY->PushMatrix();
|
||||
DISPLAY->EnterPerspective(45, false);
|
||||
|
||||
// construct view and project matrix
|
||||
RageVector3 Up( 0.0f, 1.0f, 0.0f );
|
||||
RageVector3 Eye( CENTER_X, CENTER_Y, 550 );
|
||||
RageVector3 At( CENTER_X, CENTER_Y, 0 );
|
||||
|
||||
DISPLAY->LookAt(Eye, At, Up);
|
||||
}
|
||||
|
||||
for( int i=0; i<NUM_WHEEL_ITEMS; i++ )
|
||||
{
|
||||
MusicWheelItem& display = m_MusicWheelItems[i];
|
||||
|
||||
switch( m_WheelState )
|
||||
{
|
||||
case STATE_SELECTING_MUSIC:
|
||||
case STATE_ROULETTE_SPINNING:
|
||||
case STATE_ROULETTE_SLOWING_DOWN:
|
||||
case STATE_RANDOM_SPINNING:
|
||||
case STATE_LOCKED:
|
||||
{
|
||||
// switch( m_WheelState )
|
||||
// {
|
||||
// case STATE_SELECTING_MUSIC:
|
||||
// case STATE_ROULETTE_SPINNING:
|
||||
// case STATE_ROULETTE_SLOWING_DOWN:
|
||||
// case STATE_RANDOM_SPINNING:
|
||||
// case STATE_LOCKED:
|
||||
// {
|
||||
float fThisBannerPositionOffsetFromSelection = i - NUM_WHEEL_ITEMS/2 + m_fPositionOffsetFromSelection;
|
||||
|
||||
float fY = GetBannerY( fThisBannerPositionOffsetFromSelection );
|
||||
float fX, fY, fZ, fRotationX;
|
||||
GetItemPosition( fThisBannerPositionOffsetFromSelection, fX, fY, fZ, fRotationX );
|
||||
|
||||
if( fY < -SCREEN_HEIGHT/2 || fY > SCREEN_HEIGHT/2 )
|
||||
continue; // skip
|
||||
|
||||
float fX = GetBannerX( fThisBannerPositionOffsetFromSelection );
|
||||
display.SetXY( fX, fY );
|
||||
}
|
||||
break;
|
||||
}
|
||||
display.SetZ( fZ );
|
||||
display.SetRotationX( fRotationX );
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
|
||||
if( m_WheelState == STATE_LOCKED && i != NUM_WHEEL_ITEMS/2 )
|
||||
display.m_fPercentGray = 0.5f;
|
||||
@@ -595,6 +628,12 @@ void MusicWheel::DrawPrimitives()
|
||||
}
|
||||
|
||||
ActorFrame::DrawPrimitives();
|
||||
|
||||
if( USE_3D )
|
||||
{
|
||||
DISPLAY->ExitPerspective();
|
||||
DISPLAY->PopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicWheel::UpdateScrollbar()
|
||||
@@ -1041,9 +1080,12 @@ void MusicWheel::TweenOnScreen(bool changing_sort)
|
||||
|
||||
m_WheelState = STATE_TWEENING_ON_SCREEN;
|
||||
|
||||
float fX = GetBannerX(0), fY = GetBannerY(0);
|
||||
float fX, fY, fZ, fRotationX;
|
||||
GetItemPosition( 0, fX, fY, fZ, fRotationX );
|
||||
|
||||
m_sprSelectionOverlay.SetXY( fX+320, fY );
|
||||
m_sprSelectionOverlay.SetZ( fZ );
|
||||
m_sprSelectionOverlay.SetRotationX( fRotationX );
|
||||
|
||||
if(changing_sort) {
|
||||
m_sprSelectionOverlay.BeginTweening( 0.04f * NUM_WHEEL_ITEMS/2 * factor ); // sleep
|
||||
@@ -1067,9 +1109,11 @@ void MusicWheel::TweenOnScreen(bool changing_sort)
|
||||
MusicWheelItem& display = m_MusicWheelItems[i];
|
||||
float fThisBannerPositionOffsetFromSelection = i - NUM_WHEEL_ITEMS/2 + m_fPositionOffsetFromSelection;
|
||||
|
||||
float fX = GetBannerX(fThisBannerPositionOffsetFromSelection);
|
||||
float fY = GetBannerY(fThisBannerPositionOffsetFromSelection);
|
||||
float fX, fY, fZ, fRotationX;
|
||||
GetItemPosition( fThisBannerPositionOffsetFromSelection, fX, fY, fZ, fRotationX );
|
||||
display.SetXY( fX+320, fY );
|
||||
display.SetZ( fZ );
|
||||
display.SetRotationX( fRotationX );
|
||||
display.BeginTweening( 0.04f*i * factor ); // sleep
|
||||
display.BeginTweening( 0.2f * factor, Actor::TWEEN_ACCELERATE );
|
||||
display.SetTweenX( fX );
|
||||
@@ -1085,10 +1129,11 @@ void MusicWheel::TweenOffScreen(bool changing_sort)
|
||||
|
||||
m_WheelState = STATE_TWEENING_OFF_SCREEN;
|
||||
|
||||
float fX, fY;
|
||||
fX = GetBannerX(0);
|
||||
fY = GetBannerY(0);
|
||||
float fX, fY, fZ, fRotationX;
|
||||
GetItemPosition( 0, fX, fY, fZ, fRotationX );
|
||||
m_sprSelectionOverlay.SetXY( fX, fY );
|
||||
m_sprSelectionOverlay.SetZ( fZ );
|
||||
m_sprSelectionOverlay.SetRotationX( fRotationX );
|
||||
|
||||
if(changing_sort) {
|
||||
/* When changing sort, tween the overlay with the item in the center;
|
||||
@@ -1110,9 +1155,11 @@ void MusicWheel::TweenOffScreen(bool changing_sort)
|
||||
MusicWheelItem& display = m_MusicWheelItems[i];
|
||||
float fThisBannerPositionOffsetFromSelection = i - NUM_WHEEL_ITEMS/2 + m_fPositionOffsetFromSelection;
|
||||
|
||||
float fX = GetBannerX(fThisBannerPositionOffsetFromSelection);
|
||||
float fY = GetBannerY(fThisBannerPositionOffsetFromSelection);
|
||||
float fX, fY, fZ, fRotationX;
|
||||
GetItemPosition( fThisBannerPositionOffsetFromSelection, fX, fY, fZ, fRotationX );
|
||||
display.SetXY( fX, fY );
|
||||
display.SetZ( fZ );
|
||||
display.SetRotationX( fRotationX );
|
||||
display.BeginTweening( 0.04f*i * factor ); // sleep
|
||||
display.BeginTweening( 0.2f * factor, Actor::TWEEN_DECELERATE );
|
||||
display.SetTweenX( fX+320 );
|
||||
|
||||
@@ -63,8 +63,7 @@ public:
|
||||
|
||||
void NotesChanged( PlayerNumber pn ); // update grade graphics and top score
|
||||
|
||||
float GetBannerX( float fPosOffsetsFromMiddle );
|
||||
float GetBannerY( float fPosOffsetsFromMiddle );
|
||||
void GetItemPosition( float fPosOffsetsFromMiddle, float& fX_out, float& fY_out, float& fZ_out, float& fRotationX_out );
|
||||
|
||||
bool Select(); // return true if the selected item is a music, otherwise false
|
||||
WheelItemType GetSelectedType() { return m_CurWheelItemData[m_iSelection]->m_Type; };
|
||||
|
||||
@@ -267,11 +267,11 @@ void Player::DrawPrimitives()
|
||||
DISPLAY->EnterPerspective(45, false);
|
||||
|
||||
// construct view and project matrix
|
||||
RageVector3 Eye, At, Up( 0.0f, 1.0f, 0.0f );
|
||||
Eye = RageVector3( CENTER_X, CENTER_Y+SCALE(fTilt*fReverseScale,-1,1,-350,350), 500 );
|
||||
RageVector3 Up( 0.0f, 1.0f, 0.0f );
|
||||
RageVector3 Eye( CENTER_X, CENTER_Y+SCALE(fTilt*fReverseScale,-1,1,-350,350), 500 );
|
||||
// give a push the receptors toward the edge of the screen so they aren't so far in the middle
|
||||
float fYOffset = SCALE(fTilt,-1,+1,10*fReverseScale,60*fReverseScale);
|
||||
At = RageVector3( CENTER_X, CENTER_Y+fYOffset, 0 );
|
||||
RageVector3 At( CENTER_X, CENTER_Y+fYOffset, 0 );
|
||||
|
||||
DISPLAY->LookAt(Eye, At, Up);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ IntDir=.\../Release6
|
||||
TargetDir=\stepmania\stepmania
|
||||
TargetName=StepMania
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -95,7 +95,7 @@ IntDir=.\../Debug6
|
||||
TargetDir=\stepmania\stepmania
|
||||
TargetName=StepMania-debug
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -1052,6 +1052,14 @@ SOURCE=.\GradeDisplay.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GrooveGraph.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GrooveGraph.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GrooveRadar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
Reference in New Issue
Block a user