Hey everyone, I have a program where i have an animated 3d character, and the camera moves behind him as he walks.
The problem I'm having is when I have the character turn left or right, the screen flickers momentarilly, almost as if its a frame from another view.
If I keep the camera static, it doesnt do this.
Any help, thanks.
#include "DarkGDK.h"
#include "input.cpp"
#include "EZrotate.h"
#include "walking.h"
void DarkGDK ( void )
{
dbSetWindowOff();
dbSyncOn ( );
dbSyncRate ( 72 );
dbSetDisplayMode( 1280, 1024, 32 );
dbLoadObject("WALKN.x", 1);
dbLoadObject("level.x",2);
dbSetObjectSpeed(1, 3200);
dbSetObjectSmoothing ( 1, 100 );
bool IsMoving;
dbMakeCamera ( 1 );
dbSetCameraRange ( 1, 1.0f, 20000.0f );
D3DXVECTOR3 Cam1Off;
D3DXVECTOR3 Cam2Off;
D3DXVECTOR3 Cam3Off;
Cam1Off.x = 0.0; Cam1Off.y = 10.0; Cam1Off.z = -20.0;
Cam2Off.x = 0.0; Cam2Off.y = 1.5; Cam2Off.z = -3.0;
Cam3Off.x = 0.0; Cam3Off.y = 1.5; Cam3Off.z = -3.0;
D3DXVECTOR3 CameraEuler;
D3DXMATRIX CameraMatrix;
D3DXVECTOR3 CameraPos;
int objanglex = dbObjectAngleX( 1 );
D3DXVECTOR3 Roid_Euler;
D3DXMATRIX Char_Matrix;
D3DXVECTOR3 CharAxisP1;
D3DXVECTOR3 CharAxisP2;
char * c= new char [50];
while ( LoopGDK ( ) )
{
//this is the part where i start to have trouble
//if i take this out the screen doesnt flicker, but maybe from the rotation this causes
//the screen flickers momentarilly, almost as if it's looking from another angle
CameraEuler.x = dbObjectAngleX( 1 );
CameraEuler.y = dbObjectAngleY( 1 );
CameraEuler.z = dbObjectAngleZ( 1 );
CameraMatrix = EZro_Euler2Matrix( CameraEuler );
CameraMatrix._41 = dbObjectPositionX( 1 );
CameraMatrix._42 = dbObjectPositionY( 1 );
CameraMatrix._43 = dbObjectPositionZ( 1 );
CameraPos = EZro_FindPointFromOffset( CameraMatrix, Cam1Off );
dbPositionCamera( 1, CameraPos.x, CameraPos.y, CameraPos.z);
dbRotateCamera ( 1, dbObjectAngleX( 1 ), dbObjectAngleY( 1 ), dbObjectAngleZ( 1 ) );
if ((dbKeyState(17)== 1 && dbKeyState(31) == 0) ||
(dbKeyState(17)== 0 && dbKeyState(31) == 1) ||(dbKeyState ( 30 )==1 && dbKeyState ( 32 )==0)||
(dbKeyState ( 30 )==0 && dbKeyState ( 32 )==1))
{
if (! IsMoving)
{
dbLoopObject (1);
IsMoving = true;
}
} else {
if (IsMoving)
{
IsMoving = false;
dbStopObject(1);
}
}
if(checkLeft())
{
dbTurnObjectLeft(1, 1);
}
dbSync ( );
}
return;
}