clean up perspective

fix mini
fix frustum matrix in D3D
This commit is contained in:
Chris Danford
2003-09-21 18:07:29 +00:00
parent d2b3919987
commit eebb417840
10 changed files with 72 additions and 79 deletions
+1 -1
View File
@@ -191,7 +191,7 @@ float ArrowGetYPos( PlayerNumber pn, int iCol, float fYOffset, float fYReverseOf
float fMiniPercent = GAMESTATE->m_CurrentPlayerOptions[pn].m_fEffects[PlayerOptions::EFFECT_MINI];
float fZoom = 1 - fMiniPercent*0.5f;
f += SCALE( GAMESTATE->m_CurrentPlayerOptions[pn].GetReversePercentForColumn(iCol), 0.f, 1.f, 0.f, fYReverseOffsetPixels/fZoom );
f += SCALE( GAMESTATE->m_CurrentPlayerOptions[pn].GetReversePercentForColumn(iCol), 0.f, 1.f, -fYReverseOffsetPixels/fZoom/2, fYReverseOffsetPixels/fZoom/2 );
const float* fEffects = GAMESTATE->m_CurrentPlayerOptions[pn].m_fEffects;
+2
View File
@@ -68,6 +68,8 @@ const OptionColumnEntry g_OptionColumnEntries[] =
{"Alternate", 5},
{"Incoming", 6},
{"Space", 6},
{"Hallway", 6},
{"Distant", 6},
{"TimingAssist",-1},
};
+30 -7
View File
@@ -140,8 +140,10 @@ void PlayerMinus::Load( PlayerNumber pn, NoteData* pNoteData, LifeMeter* pLM, Co
if( !BackdropName.empty() )
m_ArrowBackdrop.LoadFromAniDir( THEME->GetPathToB( BackdropName ) );
m_pNoteField->SetY( GRAY_ARROWS_Y_STANDARD );
m_pNoteField->Load( (NoteData*)this, pn, iStartDrawingAtPixels, iStopDrawingAtPixels, GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD );
float fNoteFieldMidde = (GRAY_ARROWS_Y_STANDARD+GRAY_ARROWS_Y_REVERSE)/2;
m_pNoteField->SetY( fNoteFieldMidde );
float fNoteFieldHeight = GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD;
m_pNoteField->Load( (NoteData*)this, pn, iStartDrawingAtPixels, iStopDrawingAtPixels, fNoteFieldHeight );
m_ArrowBackdrop.SetPlayer( pn );
/* Cache note skins that are used as attacks. */
@@ -400,22 +402,43 @@ void PlayerMinus::DrawPrimitives()
float fTilt = GAMESTATE->m_CurrentPlayerOptions[m_PlayerNumber].m_fPerspectiveTilt;
float fSkew = GAMESTATE->m_CurrentPlayerOptions[m_PlayerNumber].m_fSkew;
bool bReverse = GAMESTATE->m_CurrentPlayerOptions[m_PlayerNumber].GetReversePercentForColumn(0)>0.5;
fTilt *= bReverse ? 1.0f : -1.0f;
DISPLAY->CameraPushMatrix();
DISPLAY->PushMatrix();
DISPLAY->LoadMenuPerspective( 45, SCALE(fSkew,0.f,1.f,this->GetX(),CENTER_X), CENTER_Y );
float fCenterY = (GRAY_ARROWS_Y_STANDARD+GRAY_ARROWS_Y_REVERSE)/2;
float fHeight = GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD;
DISPLAY->LoadMenuPerspective( 45, SCALE(fSkew,0.f,1.f,this->GetX(),CENTER_X), fCenterY );
float fOriginalY = m_pNoteField->GetY();
m_pNoteField->SetY( fOriginalY + SCALE(fTilt,-1.f,+1.f,0,bReverse?+30:-40) );
m_pNoteField->SetZ( SCALE(fTilt,-1.f,+1.f,-50,+50) );
m_pNoteField->SetRotationX( SCALE(fTilt,-1.f,+1.f,-30,+30) );
float fTiltDegrees = SCALE(fTilt,-1.f,+1.f,+30,-30) * (bReverse?-1:1);
float fZoom = SCALE( GAMESTATE->m_CurrentPlayerOptions[m_PlayerNumber].m_fEffects[PlayerOptions::EFFECT_MINI], 0.f, 1.f, 1.f, 0.5f );
if( fTilt > 0 )
fZoom *= SCALE( fTilt, 0.f, 1.f, 1.f, 0.9f );
else
fZoom *= SCALE( fTilt, 0.f, -1.f, 1.f, 0.9f );
float fYOffset;
if( fTilt > 0 )
fYOffset = SCALE( fTilt, 0.f, 1.f, 0.f, -45.f ) * (bReverse?-1:1);
else
fYOffset = SCALE( fTilt, 0.f, -1.f, 0.f, -20.f ) * (bReverse?-1:1);
m_pNoteField->SetY( fOriginalY + fYOffset );
m_pNoteField->SetZoom( fZoom );
m_pNoteField->SetRotationX( fTiltDegrees );
m_pNoteField->Draw();
m_pNoteField->SetY( fOriginalY );
DISPLAY->CameraPopMatrix();
DISPLAY->PopMatrix();
if( GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fBlind == 0 )
{
+17 -52
View File
@@ -422,37 +422,6 @@ void RageDisplay::LoadIdentity()
g_WorldStack.LoadIdentity();
}
/*
void RageDisplay::LoadPerspectiveOffCenter(
float fovDegrees,
float fCenterX,
float fCenterY )
{
CLAMP( fovDegrees, 0.1f, 179.9f );
float fovRadians = fovDegrees / 180.f * PI;
float theta = fovRadians/2;
float fDistCameraFromImage = SCREEN_WIDTH/2 / tanf( theta );
// It's the caller's responsibility to push first.
g_ProjectionStack.LoadMatrix(
GetFrustrumMatrix(
(-fCenterX)/fDistCameraFromImage,
(-fCenterX+SCREEN_WIDTH)/fDistCameraFromImage,
(-fCenterY+SCREEN_HEIGHT)/fDistCameraFromImage,
(-fCenterY)/fDistCameraFromImage,
1,
fDistCameraFromImage+1000 ) );
// g_ProjectionStack.TranslateLocal( -fCenterX, -fCenterY, 0 );
g_WorldStack.LoadMatrix(
RageLookAt(
0, 0, fDistCameraFromImage,
0, 0, 0,
0.0f, 1.0f, 0.0f) );
}
*/
void RageDisplay::LoadMenuPerspective( float fovDegrees, float fVanishPointX, float fVanishPointY )
{
/* fovDegrees == 0 looks the same as an ortho projection. However,
@@ -484,7 +453,7 @@ void RageDisplay::LoadMenuPerspective( float fovDegrees, float fVanishPointX, fl
/* It's the caller's responsibility to push first. */
g_ProjectionStack.LoadMatrix(
GetFrustrumMatrix(
GetFrustumMatrix(
(fVanishPointX-SCREEN_WIDTH/2)/fDistCameraFromImage,
(fVanishPointX+SCREEN_WIDTH/2)/fDistCameraFromImage,
(fVanishPointY+SCREEN_HEIGHT/2)/fDistCameraFromImage,
@@ -594,25 +563,6 @@ void RageDisplay::LoadLookAt(float fov, const RageVector3 &Eye, const RageVector
g_ViewStack.LoadMatrix(RageLookAt(Eye.x, Eye.y, Eye.z, At.x, At.y, At.z, Up.x, Up.y, Up.z));
}
RageMatrix RageDisplay::GetFrustrumMatrix(
float left,
float right,
float bottom,
float top,
float znear,
float zfar ) // see glFrustrum docs
{
float A = (right+left) / (right-left);
float B = (top+bottom) / (top-bottom);
float C = -1 * (zfar+znear) / (zfar-znear);
float D = -1 * (2*zfar*znear) / (zfar-znear);
RageMatrix m(
2*znear/(right-left), 0, 0, 0,
0, 2*znear/(top-bottom), 0, 0,
A, B, C, -1,
0, 0, D, 0 );
return m;
}
RageMatrix RageDisplay::GetPerspectiveMatrix(float fovy, float aspect, float zNear, float zFar)
{
@@ -621,7 +571,7 @@ RageMatrix RageDisplay::GetPerspectiveMatrix(float fovy, float aspect, float zNe
float xmin = ymin * aspect;
float xmax = ymax * aspect;
return GetFrustrumMatrix(xmin, xmax, ymin, ymax, zNear, zFar);
return GetFrustumMatrix(xmin, xmax, ymin, ymax, zNear, zFar);
}
SDL_Surface *RageDisplay::CreateSurfaceFromPixfmt( PixelFormat pixfmt,
@@ -654,3 +604,18 @@ PixelFormat RageDisplay::FindPixelFormat(
return NUM_PIX_FORMATS;
}
RageMatrix RageDisplay::GetFrustumMatrix( float l, float r, float b, float t, float zn, float zf )
{
// glFrustrum
float A = (r+l) / (r-l);
float B = (t+b) / (t-b);
float C = -1 * (zf+zn) / (zf-zn);
float D = -1 * (2*zf*zn) / (zf-zn);
RageMatrix m(
2*zn/(r-l), 0, 0, 0,
0, 2*zn/(t-b), 0, 0,
A, B, C, -1,
0, 0, D, 0 );
return m;
}
+1 -7
View File
@@ -243,17 +243,11 @@ public:
PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask );
protected:
RageMatrix GetFrustrumMatrix(
float left,
float right,
float bottom,
float top,
float znear,
float zfar );
RageMatrix GetPerspectiveMatrix(float fovy, float aspect, float zNear, float zFar);
// Different for D3D and OpenGL. Not sure why they're not compatible. -Chris
virtual RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ) = 0;
virtual RageMatrix GetFrustumMatrix( float l, float r, float b, float t, float zn, float zf );
// Called by the RageDisplay derivitives
const RageMatrix* GetProjectionTop();
+1
View File
@@ -1065,3 +1065,4 @@ RageMatrix RageDisplay_D3D::GetOrthoMatrix( float l, float r, float b, float t,
-(r+l)/(r-l), -(t+b)/(t-b), -zn/(zf-zn), 1 );
return m;
}
-1
View File
@@ -78,7 +78,6 @@ protected:
CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut );
void SetViewport(int shift_left, int shift_down);
RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf );
};
#endif
+1
View File
@@ -1227,6 +1227,7 @@ RageMatrix RageDisplay_OGL::GetOrthoMatrix( float l, float r, float b, float t,
return m;
}
/*
* Although we pair texture formats (eg. GL_RGB8) and surface formats
* (pairs of eg. GL_RGB8,GL_UNSIGNED_SHORT_5_5_5_1), it's possible for
+3 -3
View File
@@ -384,14 +384,14 @@ void ScreenPlayerOptions::ExportOptions()
switch(m_iSelectedOption[p][PO_PERSPECTIVE])
{
case 0: po.m_fSkew = 1; po.m_fPerspectiveTilt = -1; break;
case 1: po.m_fSkew = 1; po.m_fPerspectiveTilt = 0; break;
case 2: po.m_fSkew = 0; po.m_fPerspectiveTilt = 1; break;
case 1: po.m_fSkew = 0; po.m_fPerspectiveTilt = 0; break;
case 2: po.m_fSkew = 1; po.m_fPerspectiveTilt = 1; break;
case 3: po.m_fSkew = 0; po.m_fPerspectiveTilt = -1; break;
case 4: po.m_fSkew = 0; po.m_fPerspectiveTilt = 1; break;
default:
ASSERT(0);
}
if(m_iSelectedOption[p][PO_PERSPECTIVE] > 2)
if(m_iSelectedOption[p][PO_PERSPECTIVE] > 4)
{
const int choice = m_iSelectedOption[p][PO_PERSPECTIVE];
GAMESTATE->m_PlayerOptions[p].m_sPositioning = m_OptionRow[PO_PERSPECTIVE].choices[choice];
+16 -8
View File
@@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# Microsoft Developer Studio Generated Build File, Format Version 60000
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
@@ -45,7 +45,7 @@ CFG=StepMania - Win32 Release
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "DEBUG" /Fr /YX"global.h" /FD /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /I "SDL_net-1.2.5\lib\sdl_net.lib" /I "SDL_net-1.2.5\include" /I "vorbis" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "DEBUG" /Fr /YX"global.h" /FD /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /I "SDL_net-1.2.5\lib\sdl_net.lib" /I "SDL_net-1.2.5\include" /I "vorbis" /I "ddk" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "DEBUG" /Fr /YX"global.h" /FD /c
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@@ -62,10 +62,10 @@ LINK32=link.exe
# SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
# Begin Special Build Tool
IntDir=.\../Debug6
TargetDir=\CVS\stepmania\stepmania
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
@@ -98,7 +98,11 @@ XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
# Begin Special Build Tool
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
IntDir=.\Debug
TargetDir=\stepmania\stepmania
TargetName=default
SOURCE="$(InputPath)"
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
@@ -135,10 +139,10 @@ LINK32=link.exe
# SUBTRACT LINK32 /verbose /pdb:none
# Begin Special Build Tool
IntDir=.\../Release6
TargetDir=\CVS\stepmania\stepmania
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
@@ -175,7 +179,11 @@ XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
# Begin Special Build Tool
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
IntDir=.\StepMania___Xbox_Release
TargetDir=\stepmania\stepmania
TargetName=default
SOURCE="$(InputPath)"
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