port from perforce
This commit is contained in:
134
evoke-64k/ev10/camerahelper.h
Normal file
134
evoke-64k/ev10/camerahelper.h
Normal file
@@ -0,0 +1,134 @@
|
||||
#pragma once
|
||||
/*
|
||||
void homeCam()
|
||||
{
|
||||
g_CamPos.x= 0.0f;
|
||||
g_CamPos.y= 60.0f;
|
||||
g_CamPos.z= 75.0f;
|
||||
g_CamRot.x= 3.14f;
|
||||
g_CamRot.y= 0.65f;
|
||||
g_CamRot.z= 0.0f;
|
||||
|
||||
#ifdef MESHTESTER
|
||||
g_CamPos.x= 0.0f;
|
||||
g_CamPos.y= 1.0f;
|
||||
g_CamPos.z= -5.0f;
|
||||
g_CamRot.x= 0.0f;
|
||||
g_CamRot.y= 0.0f;
|
||||
g_CamRot.z= 0.0f;
|
||||
#endif
|
||||
|
||||
#ifdef PUPPETTESTER
|
||||
g_CamPos.x= 0.0f;
|
||||
g_CamPos.y= 1.0f;
|
||||
g_CamPos.z= -5.0f;
|
||||
g_CamRot.x= 0.0f;
|
||||
g_CamRot.y= 0.0f;
|
||||
g_CamRot.z= 0.0f;
|
||||
#endif
|
||||
|
||||
#ifdef CURSOR3D
|
||||
g_CursorPos.x= 0.0f;
|
||||
g_CursorPos.y= 0.0f;
|
||||
g_CursorPos.z= 0.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void EditCam()
|
||||
{
|
||||
static POINT OldCurPos;
|
||||
POINT CurPos;
|
||||
GetCursorPos( &CurPos );
|
||||
|
||||
if( GetAsyncKeyState( VK_HOME ) )
|
||||
{
|
||||
homeCam();
|
||||
}
|
||||
|
||||
if( GetAsyncKeyState( VK_MBUTTON ) || GetAsyncKeyState( VK_RBUTTON ) )
|
||||
{
|
||||
g_CamRot.x+= 0.002f * ( OldCurPos.x - CurPos.x );
|
||||
g_CamRot.y-= 0.002f * ( OldCurPos.y - CurPos.y );
|
||||
g_CamRot.y= max( g_CamRot.y, -1.56f );
|
||||
g_CamRot.y= min( g_CamRot.y, 1.56f );
|
||||
|
||||
|
||||
static float fSpeedA= 0.0f;
|
||||
|
||||
if( GetAsyncKeyState( VK_UP ) )
|
||||
{
|
||||
fSpeedA= max( fSpeedA, 0.0f );
|
||||
fSpeedA+= 0.01f;
|
||||
g_CamPos+= fSpeedA * g_CamFront;
|
||||
}
|
||||
else if( GetAsyncKeyState( VK_DOWN ) )
|
||||
{
|
||||
fSpeedA= min( fSpeedA, 0.0f );
|
||||
fSpeedA-= 0.01f;
|
||||
g_CamPos+= fSpeedA * g_CamFront;
|
||||
}
|
||||
else
|
||||
{
|
||||
fSpeedA= 0.0f;
|
||||
}
|
||||
|
||||
static float fSpeedB= 0.0f;
|
||||
|
||||
if( GetAsyncKeyState( VK_RIGHT ) )
|
||||
{
|
||||
fSpeedB= max( fSpeedB, 0.0f );
|
||||
fSpeedB+= 0.01f;
|
||||
g_CamPos+= fSpeedB * g_CamRight;
|
||||
}
|
||||
else if( GetAsyncKeyState( VK_LEFT ) )
|
||||
{
|
||||
fSpeedB= min( fSpeedB, 0.0f );
|
||||
fSpeedB-= 0.01f;
|
||||
g_CamPos+= fSpeedB * g_CamRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
fSpeedB= 0.0f;
|
||||
}
|
||||
static float fSpeedC= 0.0f;
|
||||
|
||||
if( GetAsyncKeyState( VK_NUMPAD1 ) )
|
||||
{
|
||||
fSpeedC= max( fSpeedC, 0.0f );
|
||||
fSpeedC+= 0.01f;
|
||||
g_CamPos.y+= fSpeedC;
|
||||
}
|
||||
else if( GetAsyncKeyState( VK_NUMPAD0 ) )
|
||||
{
|
||||
fSpeedC= min( fSpeedC, 0.0f );
|
||||
fSpeedC-= 0.01f;
|
||||
g_CamPos.y+= fSpeedC;
|
||||
}
|
||||
else
|
||||
{
|
||||
fSpeedC= 0.0f;
|
||||
}
|
||||
}
|
||||
OldCurPos= CurPos;
|
||||
}*/
|
||||
|
||||
void FillCameraMatrix( D3DXVECTOR3 v3Pos, D3DXVECTOR3 v3Rot, D3DXMATRIX* CamMat )
|
||||
{
|
||||
float fYLeft= cos( v3Rot.y );
|
||||
g_CamFront.x= -sin( v3Rot.x ) * fYLeft ;
|
||||
g_CamFront.y= -sin( v3Rot.y );
|
||||
g_CamFront.z= cos( v3Rot.x ) * fYLeft ;
|
||||
D3DXVec3Normalize(&g_CamFront, &g_CamFront);
|
||||
|
||||
D3DXMatrixRotationYawPitchRoll( CamMat,
|
||||
-v3Rot.x,
|
||||
v3Rot.y,
|
||||
v3Rot.z );
|
||||
|
||||
D3DXMATRIX CamMove;
|
||||
D3DXMatrixTranslation( &CamMove, v3Pos.x, v3Pos.y, v3Pos.z );
|
||||
D3DXMatrixMultiply( CamMat, CamMat, &CamMove );
|
||||
|
||||
|
||||
D3DXMatrixInverse(CamMat, NULL, CamMat );
|
||||
}
|
||||
Reference in New Issue
Block a user