I'm just starting with DarkGDK and currently all I want to do is load a object, move the camera and have the camera point to it. I saw the dbPointCamera function in the help file. I use it and the code compiles it however I allways have to adjust the view with the mouse, it feels like the point camera function is not working as intended or I have no clue how to use it (however it appears fairly strait forward).
Here is my code. Most of it is from the Game Level tutorial because it already had the camera movement code done for me. It loads a 1x1x1 cube I made in 3DS Max and exported to .X format. Then it sets the object to 1,1,1 and camera to 10,10,10.
// Dark GDK - The Game Creators - www.thegamecreators.com
// whenever using Dark GDK you must ensure you include the header file
#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 ( "1x1.x", 1 );
dbSetObjectLight (1,1);
dbPositionObject(1,1.0f,1.0f,1.0f);
// position the camera
dbPositionCamera ( 5, 5, 5 );
dbPointCamera(0,dbObjectPositionX(1),dbObjectPositionY(1),dbObjectPositionZ(1));
// camera variables
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
// our main loop
while ( LoopGDK ( ) )
{
// move the camera using the arrow keys
dbControlCameraUsingArrowKeys ( 0, 1.0f, 1.0f );
// create a rotation axis based on mouse movement
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.3f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.3f );
// rotate camera
dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );
// update the screen
dbSync ( );
}
// return back to windows
return;
}
Thanks for any help. It's likely a simple fix but I'v just banged my head agenst the wall for the past 2hrs trying to get this to work.