ok after many hours perseverance i figured out i was using the wrong command! 'DOH!!
At any rate i have now been to set it up so that my object changes colour when it dtects a collision and change direction. (based on a tutorial i found on the forum.) however the ball still does not seem to bounce correctly...
again any help would be apriciated .
Main.cpp
// The Sanitarium Project - Movian - Richard Burgess - 08/03/2008
#include "DarkGDK.h"
#include "MovCon.h"
#include "Environment.h"
#include "Ball.h"
#include "SC_Collision.h"
#include "globstruct.h"
//Inlcuded as a fix - *Fix still dosn't show window
void dbExitPrompt(const char* Msg, const char* Title)
{
dbHideWindow();
MessageBox( g_pGlob->hWnd, Msg, Title, MB_OK );
PostQuitMessage( 0 );
ExitProcess( 0 );
}
void DarkGDK ( void )
{
SC_Start( );
//set Window Options
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetWindowTitle ("The Sanitarium Project");
CreateEnvironment ();
CreateBall ();
//Configure Camera To be Within Terrain
dbSetCameraRange ( 1.0f, 30000.0f );
dbPositionCamera (dbObjectPositionX (3), dbObjectPositionY (3), dbObjectPositionZ(3));
dbMoveCamera (-50);
while ( LoopGDK ( ) )
{
//Display FPS and Ball Collision INformation
char str [ 128 ];
sprintf_s( str, 128, "FPS: %d", dbScreenFPS( ) ); dbText( 0,80,str );
sprintf_s( str, 128, "Ball Collision: %d", SC_ObjectCollision (3,0)); dbText( 0,90,str);
//When COllision Detected Change Ball COlour and change Ball Direction
if (SC_ObjectCollision (3,0) > 0)
{
dbColorObject (3,dbRGB(0,255,0));
dbPointObject (3, SC_GetStaticCollisionX () + SC_GetCollisionBounceX (), SC_GetStaticCollisionX () + SC_GetCollisionBounceY (), SC_GetStaticCollisionZ () + SC_GetCollisionBounceZ ());
}
else
{
dbColorObject (3,dbRGB(255,0,0));
}
//When left Click fire ball from camera position *still not quite working*
if (dbMouseClick () == 1 )
{
dbPositionObject (3,dbCameraPositionX (), dbCameraPositionY (), dbCameraPositionZ ());
dbPointObject (3, dbCameraAngleX (), dbCameraPositionY (), dbCameraPositionZ ());
dbMoveObject (3, 10);
}
//call moves ball with speed int
MoveBall (0.5);
MovCon ();
if (dbEscapeKey() == 1)
{
dbExitPrompt ("Leaving The Sanitarium Project","Quit");
}
dbUpdateTerrain ();
dbSync ();
}
return;
}
Environment.cpp
#include "DarkGDK.h"
#include "Environment.h"
#include "SC_Collision.h"
void CreateEnvironment (void)
{
//Loading Resources
dbLoadImage ("Resources/texture.jpg",1);
dbLoadImage ("Resources/detail.jpg",2);
//Initiating Terrain For BG Scenery
dbSetupTerrain ();
dbMakeObjectTerrain(1);
dbSetTerrainHeightMap (1,"Resources/Map.bmp");
dbSetTerrainScale (1,3.0f,0.6f,3.0f);
dbSetTerrainLight (1,1.0f,-2.25f,0.0f,1.0f,1.0f,0.78f,0.5f);
dbSetTerrainTexture (1,1,2);
dbBuildTerrain (1);
SC_SetupTerrainObject (1,0,9);
SC_SetObjectCollisionOn (1);
dbLoadObject ( "Resources/skybox2.x", 2 );
dbSetObjectLight ( 2, 0 );
dbScaleObject ( 2, 30000, 30000, 30000 );
}
Ball.cpp
#include "DarkGDK.h"
#include "Ball.h"
#include "SC_Collision.h"
void CreateBall (void)
{
//Sets up all Ball Object Properties Including Collision
dbMakeObjectSphere (3,10);
dbColorObject (3,dbRGB(255,0,0));
dbPositionObject (3,380,90,90);
dbSetObjectSmoothing (3,100);
SC_SetupObject (3, 0, 1);
SC_SetObjectCollisionOn (3);
}
float newx,newy,newz;
void MoveBall (float speed)
{
//Moves and updates Ball object
dbMoveObject (3,speed);
SC_UpdateObject(3);
SC_UpdateObject(1);
}