Use plib for some matrix ops, implement some others without

d3dx.  (Rest coming soon ...)
This commit is contained in:
Glenn Maynard
2002-11-13 03:54:20 +00:00
parent a64cfed1cf
commit ea28757815
3 changed files with 53 additions and 21 deletions
+6 -7
View File
@@ -54,7 +54,6 @@ int g_glVersion;
int RageDisplay::GetFPS() const { return g_iFPS; }
int RageDisplay::GetVPF() const { return g_iVPF; }
int RageDisplay::GetDPF() const { return g_iDPF; }
DEVMODE SMGfx;
static int g_iFramesRenderedSinceLastCheck,
g_iVertsRenderedSinceLastCheck,
@@ -371,7 +370,7 @@ void RageDisplay::Translate( float x, float y, float z )
RageMatrix matTemp;
RageMatrixTranslation( &matTemp, x, y, z );
RageMatrix& matTop = GetTopModelMatrix();
RageMatrixMultiply( &matTop, &matTemp, &matTop );
sgPreMultMat4( matTop.m, matTemp.m );
}
void RageDisplay::TranslateLocal( float x, float y, float z )
@@ -379,7 +378,7 @@ void RageDisplay::TranslateLocal( float x, float y, float z )
RageMatrix matTemp;
RageMatrixTranslation( &matTemp, x, y, z );
RageMatrix& matTop = GetTopModelMatrix();
RageMatrixMultiply( &matTop, &matTop, &matTemp );
sgPostMultMat4( matTop.m, matTemp.m );
}
void RageDisplay::Scale( float x, float y, float z )
@@ -387,7 +386,7 @@ void RageDisplay::Scale( float x, float y, float z )
RageMatrix matTemp;
RageMatrixScaling( &matTemp, x, y, z );
RageMatrix& matTop = GetTopModelMatrix();
RageMatrixMultiply( &matTop, &matTemp, &matTop );
sgPreMultMat4( matTop.m, matTemp.m );
}
void RageDisplay::RotateX( float r )
@@ -395,7 +394,7 @@ void RageDisplay::RotateX( float r )
RageMatrix matTemp;
RageMatrixRotationX( &matTemp, r );
RageMatrix& matTop = GetTopModelMatrix();
RageMatrixMultiply( &matTop, &matTemp, &matTop );
sgPreMultMat4( matTop.m, matTemp.m );
}
void RageDisplay::RotateY( float r )
@@ -403,7 +402,7 @@ void RageDisplay::RotateY( float r )
RageMatrix matTemp;
RageMatrixRotationY( &matTemp, r );
RageMatrix& matTop = GetTopModelMatrix();
RageMatrixMultiply( &matTop, &matTemp, &matTop );
sgPreMultMat4( matTop.m, matTemp.m );
}
void RageDisplay::RotateZ( float r )
@@ -411,7 +410,7 @@ void RageDisplay::RotateZ( float r )
RageMatrix matTemp;
RageMatrixRotationZ( &matTemp, r );
RageMatrix& matTop = GetTopModelMatrix();
RageMatrixMultiply( &matTop, &matTemp, &matTop );
sgPreMultMat4( matTop.m, matTemp.m );
}
void RageDisplay::SetTexture( RageTexture* pTexture )
+46 -14
View File
@@ -15,55 +15,89 @@
#include "RageTypes.h"
#include "D3DX8Math.h"
#ifdef _DEBUG
#pragma comment(lib, "plib-1.6.0/sg_d.lib")
#pragma comment(lib, "plib-1.6.0/ul_d.lib")
#else
#pragma comment(lib, "plib-1.6.0/sg.lib")
#pragma comment(lib, "plib-1.6.0/ul.lib")
#endif
void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV )
{
D3DXVec2Normalize( (D3DXVECTOR2*)pOut, (const D3DXVECTOR2*)pV );
sgNormalizeVec2( (float*)pOut, (const float*)pV );
}
void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM )
{
D3DXVec3TransformCoord( (D3DXVECTOR3*)pOut, (const D3DXVECTOR3*)pV, (const D3DXMATRIX*)pM );
sgFullXformPnt3 ( (float*)pOut, (float*)pV, pM->m );
}
void RageMatrixIdentity( RageMatrix* pOut )
{
D3DXMatrixIdentity( (D3DXMATRIX*)pOut );
sgMakeIdentMat4( pOut->m );
}
void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatrix* pB )
{
D3DXMatrixMultiply( (D3DXMATRIX*)pOut, (const D3DXMATRIX*)pA, (const D3DXMATRIX*)pB );
sgMultMat4( pOut->m, pB->m, pA->m );
}
void RageMatrixTranslation( RageMatrix* pOut, float x, float y, float z )
{
D3DXMatrixTranslation( (D3DXMATRIX*)pOut, x, y, z );
RageMatrixIdentity(pOut);
pOut->m[3][0] = x;
pOut->m[3][1] = y;
pOut->m[3][2] = z;
}
void RageMatrixScaling( RageMatrix* pOut, float x, float y, float z )
{
D3DXMatrixScaling( (D3DXMATRIX*)pOut, x, y, z );
RageMatrixIdentity(pOut);
pOut->m[0][0] = x;
pOut->m[1][1] = y;
pOut->m[2][2] = z;
}
void RageMatrixRotationX( RageMatrix* pOut, float theta )
{
D3DXMatrixRotationX( (D3DXMATRIX*)pOut, theta );
{ /* UNTESTED */
RageMatrixIdentity(pOut);
pOut->m[1][1] = cosf(theta);
pOut->m[2][2] = pOut->m[1][1];
pOut->m[2][1] = sinf(theta);
pOut->m[1][2] = -pOut->m[2][1];
}
void RageMatrixRotationY( RageMatrix* pOut, float theta )
{
D3DXMatrixRotationY( (D3DXMATRIX*)pOut, theta );
{ /* UNTESTED */
RageMatrixIdentity(pOut);
pOut->m[0][0] = cosf(theta);
pOut->m[2][2] = pOut->m[0][0];
pOut->m[0][2] = sinf(theta);
pOut->m[2][0] = -pOut->m[0][2];
}
void RageMatrixRotationZ( RageMatrix* pOut, float theta )
{
D3DXMatrixRotationZ( (D3DXMATRIX*)pOut, theta );
RageMatrixIdentity(pOut);
pOut->m[0][0] = cosf(theta);
pOut->m[1][1] = pOut->m[0][0];
pOut->m[0][1] = sinf(theta);
pOut->m[1][0] = -pOut->m[0][1];
}
void RageMatrixOrthoOffCenterLH( RageMatrix* pOut, float l, float r, float b, float t, float zn, float zf )
{
D3DXMatrixOrthoOffCenterLH( (D3DXMATRIX*)pOut, l, r, b, t, zn, zf );
RageMatrixIdentity(pOut);
pOut->m[0][0] = 2 / (r-l);
pOut->m[1][1] = 2 / (t-b);
pOut->m[2][2] = -2 / (zn-zf);
pOut->m[3][0] = -(r+l)/(r-l);
pOut->m[3][1] = -(t+b)/(t-b);
pOut->m[3][2] = -(zf+zn)/(zn-zf);
}
void RageMatrixLookAtLH( RageMatrix* pOut, const RageVector3* pEye, const RageVector3* pAt, const RageVector3* pUp )
@@ -75,5 +109,3 @@ void RageMatrixPerspectiveFovLH( RageMatrix* pOut, float fovy, float Aspect, flo
{
D3DXMatrixPerspectiveFovLH( (D3DXMATRIX*)pOut, fovy, Aspect, zn, zf );
}
+1
View File
@@ -15,6 +15,7 @@ struct RageVector2;
struct RageVector3;
struct RageMatrix;
#include "plib-1.6.0/sg.h"
void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV );
void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM );