I'm trying to go off the example for just moving around in a "box" area. I am tyring to make it so that when you click down you can move the camera and otherwise you just can move the mouse freely when not clicked.
Turning around the Y Axis is fine, but not for the X Axis, it seems to reset the Camera Angle for the X Axis to zero when I unclick and go back to the changed Angle when I click back down.
Is there something wrong with the dbXRotateCamera() or is my code. Everything looks the same as far as Y (which works) compared to X.
Any help would be great.
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// switch to the media directory, load our world
// and turn lighting off
SetCurrentDirectory ( "media" );
dbLoadObject ( "Test_Box.x", 1 );
dbSetObjectLight ( 1, 1 );
dbScaleObject ( 1, 1000, 1000, 1000);
// load a model for our sky
dbLoadObject ( "skybox2.x", 2 );
dbSetObjectLight ( 2, 0 );
dbSetObjectTexture ( 2, 3, 2 );
dbScaleObject ( 2, 5000, 5000, 5000 );
dbMakeCamera(1);
dbPositionCamera(1,434,42,-517);
// position the camera
dbPositionMouse ( dbScreenWidth()/2, dbScreenHeight()/2);
// camera variables
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
int Justclikt = 0;
float MouseMovedX = 0.0f;
float MouseMovedY = 0.0f;
float aMouseMovedX = 0.0f;
float aMouseMovedY = 0.0f;
// our main loop
while ( LoopGDK ( ) )
{
// move the camera using the arrow keys
dbControlCameraUsingArrowKeys ( 1, 5.0f, 0.3f );
fCameraAngleY = dbCameraAngleY(1);
if (dbMouseClick() == 4){
if (Justclikt == 0)
{
Justclikt=1;
MouseMovedX = dbMouseX(); //Gets position of Cursor
MouseMovedY = dbMouseY();
}
else
{
// create a rotation axis based on mouse movement
fCameraAngleX = dbWrapValue ( fCameraAngleX + (dbMouseMoveY())*0.4f);
fCameraAngleY = dbWrapValue ( fCameraAngleY + (dbMouseMoveX())*0.4f);
// rotate camera
dbXRotateCamera (1, fCameraAngleX );
dbYRotateCamera (1, fCameraAngleY );
}
dbHideMouse();
}
else
{
if (Justclikt == 1)
{
Justclikt =0;
dbPositionMouse((MouseMovedX), (MouseMovedY)); //replaces cursor back before clicking
}
else
{
dbShowMouse();
}
}
// update the screen
dbSync ( );
}
// return back to windows
return;