Hi all, I'm having some trouble with collision when I import an fpsc map, so I'm wondering if its my code that's the problem or the universe.dbo file.
Here's the code:
// camera variables
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
void mousecontrol()
{
// create a rotation axis based on mouse movement, mouse control
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );
// rotate camera
dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );
}
void controls()
{
//the keys go top left to bottom right, starting with `~, thrn 1, 2, etc
//moving forward
if (dbKeyState(17) == 1)
{
dbMoveCamera(5);
}
//moving backwards
if (dbKeyState(31) == 1)
{
dbMoveCamera(-4.5);
}
//moving left
if (dbKeyState(30) == 1)
{
dbMoveCameraLeft(0,3);
}
//right
if (dbKeyState(32) == 1)
{
dbMoveCameraRight(0,3);
}
}
void gravity()
{
//this function controls the gravity duh
//declares the camera y position value(for gravity)
float camerayposition = dbCameraPositionY (0) ;
//gravity makes objects fall at 9.8 meters per second
camerayposition -= 9.8;
//lower the camera(create gravity)
dbPositionCamera ( 0, dbCameraPositionX(), camerayposition, dbCameraPositionZ() ) ;
}
void DarkGDK ( void )
{
//hide the mouse
dbHideMouse();
//turn on sync and set the fps to 60
dbSyncOn ( );
dbSyncRate ( 60 );
//sets collision stuff (RTFC)
dbAutomaticCameraCollision(0,2,1);
//////////////////////////MEDIA LOADING STUFF///////////////////////////////////////
// switch to the media directory, load our world
// and turn lighting ON
//and set the collision to polys
SetCurrentDirectory ( "media" );
dbLoadObject ( "universe.dbo", 1 );
dbPositionObject (1, 0, 0, 0);
dbSetObjectLight ( 1, 2);
dbSetObjectCollisionToPolygons (1);
// load a model for our sky
dbLoadObject ( "Pln.x", 2 );
dbScaleObject (2, 100000, 100000, 100000);
/////////////////////////////////////////////////////////////////////////////////////////////////
//CAMERA STUFF
//former position 2480, 530, -1550
// position the camera
dbPositionCamera ( 1200, 7000, -1000 );
//let the camera see x units away
dbSetCameraRange (1, 15000);
// main loop
while ( LoopGDK ( ) )
{
gravity();
controls();
mousecontrol();
// update the screen
dbSync ( );
}
// return back to windows
return;
}
The code is full of stupid comments so just pretend they're not there please.
Any help would be appreciated, thanks in advance.