Hello guys i need help with, how to setup a 3D camera.
I want to make a camera follow an object and you to move with arrow keys and WASD keys can someone help me?
This is my code so far!
#include "DarkGDK.h"
void Hero();
void Ship();
void UserInput();
void DarkGDK ( void )
{
//Window
dbSyncOn();
dbSyncRate(0);
//Directory
SetCurrentDirectory ( "media" );
//Call Function
Hero();
Ship();
//Mouse
dbHideMouse();
//Camera Range
dbSetCameraRange( 1.0f, 30000.0f );
//Terrain Images
dbLoadImage("map/texture.jpg",1);
dbLoadImage("map/detail.jpg",2);
//Terrain
dbSetupTerrain();
dbMakeObjectTerrain(1);
dbSetTerrainHeightMap(1,"map/map.bmp");
dbSetTerrainScale(1, 20.0f, 4.0f, 20.0f);
dbSetTerrainLight(1, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f);
dbSetTerrainTexture(1, 1, 2);
dbBuildTerrain(1);
//Skybox
dbLoadObject("skybox2.x", 3);
dbSetObjectLight(3,0);
dbScaleObject(3, 30000, 30000, 30000);
//Camera Position
dbPositionCamera(4000,200,3100);
//Camera Variables
float cf,cr;
float ncf=0;
float ncr=0;
float cx,cy;
float ncx=0;
float ncy=0;
char ScreenFPS[32];
//Start loop
while(LoopGDK())
{
dbSetCameraToFollow(dbObjectPositionX(2), dbObjectPositionY(2), dbObjectPositionZ(2), dbObjectAngleY(2), 5, 5, 20, 1);
dbUpdateTerrain();
dbSync();
}
}
void Hero ( void )
{
//Directory
SetCurrentDirectory ( "media" );
//Load Hero
dbLoadObject("colonel/Colonel-X.x", 4);
//Ship Settings
dbPositionObject(4, 4000,0,3300);
dbScaleObject(4, 300, 300, 300);
dbRotateObject(4, 0, 100, 0);
}
void Ship ( void )
{
//Directory
SetCurrentDirectory ( "media" );
//Load Ship
dbLoadObject("Ship/Ship.x", 5);
//Ship Settings
dbPositionObject(5, 3500, 5, 3300);
dbRotateObject(5, 0, 0, 100);
dbScaleObject(5, 200, 200, 200);
}