Thank you matty, I will look at that. I also have Dark Physics which is a wrapper for physX, but have not tried that yet either.
I still hope that with a simple tweak, Sparky's can put the object in the correct place, (i.e. not 0,0,0). Perhaps it would help if I shared the fullness of my code. Here it is:
#include "DarkGDK.h"
#include "SC_Collision.h"
void collision()
{
if( SC_ObjectCollision(3, 0) )
{
dbPositionObject( 3, SC_GetCollisionBounceX(),SC_GetCollisionBounceY(),SC_GetCollisionBounceZ() );
}
}
void move(int iObj, float fMove, float fTurn)
{
float fDistance = -10.0, fHeight = 10.0, fSmooth = 1.0;
float fAngle = dbWrapValue( dbObjectAngleY(iObj) );
if( dbUpKey() )
{
//move foreward
dbMoveObject(iObj, -fMove);
}
if( dbDownKey() )
{
//move backward
dbMoveObject(iObj, fMove);
}
if( dbRightKey() )
{
//turn right
dbYRotateObject(iObj, fAngle += fTurn);
}
if( dbLeftKey() )
{
//turn left
dbYRotateObject(iObj, fAngle -= fTurn);
}
dbPositionObject(iObj, dbObjectPositionX(iObj), dbGetTerrainGroundHeight(1, dbObjectPositionX(iObj), dbObjectPositionZ(iObj)) , dbObjectPositionZ(iObj));
SC_UpdateObject(iObj);
//adjust camera
dbSetCameraToFollow(dbObjectPositionX(iObj), dbObjectPositionY(iObj), dbObjectPositionZ(iObj), fAngle, fDistance, fHeight, fSmooth, 0);
dbYRotateCamera( fAngle + 180 );
}
void loadMedia()
{
//Object 3, Mr. bones
dbLoadObject("H-Bones-Move.x", 3);
dbLoopObject(3);
dbSetObjectSpeed(3, 20);
SC_SetupObject(3, 0, 2);
SC_AllowObjectScaling(3);
dbPositionObject(3, 300, 1, 300);
dbScaleObject(3, 500.0, 500.0, 500.0);
dbRotateObject(3, 0, 180, 0);
SC_UpdateObject(3);
//Object 4, hound
dbLoadObject("H-Hound-Move.x", 4);
dbLoopObject(4);
dbSetObjectSpeed(4, 20);
dbScaleObject(4, 501.0, 501.0, 501.0);
//Object 5, bones
dbLoadObject("H-Bones-Attack1.x", 5);
dbLoopObject(5);
dbSetObjectSpeed(5, 20);
dbScaleObject(5, 250.0, 250.0, 250.0);
dbRotateObject(5, 0, 90.0, 0);
//Object 6, bones
dbLoadObject("H-Bones-Attack1.x", 6);
dbLoopObject(6);
dbSetObjectSpeed(6, 20);
dbScaleObject(6, 250.0, 250.0, 250.0);
dbRotateObject(6, 0, -90.0, 0);
//Object 7, Dragon
dbLoadObject("Dragon.x", 7);
dbLoopObject(7, 1, 45);
dbSetObjectSpeed(7, 20);
dbPositionObject(7, 265, 140, 2625);
//object 10, tree
dbLoadObject("lo_jjosh tree1.x", 10);
dbPositionObject(10, 2680, 150, 350);
dbSetObjectTransparency(10, 3);
//object 11, tree2
dbLoadObject("c tree1.dbo", 11);
dbPositionObject(11, 265, 115, 2550);
dbSetObjectTransparency(11, 3);
dbSetObjectCollisionOn(11);
//object12, hut
dbLoadObject("jhut1.x", 12);
SC_SetupObject(12, 0, 0);
SC_AllowObjectScaling(12);
dbScaleObject(12, 10.0f, 10.0f, 10.0f);
dbPositionObject(12, 2200.0f, -3.0f, 2200.0f);
SC_UpdateObject(12);
//object 13, Sarah's Blue Marble
dbMakeObjectSphere(13, 10.0, 20, 20);
dbPositionObject(13, 200, 10, 200);
dbGhostObjectOn(13, 5);
dbColorObject(13, dbRGB(0, 0, 255));
//object 14, Wall2
dbLoadObject("wall2.x", 14);
dbPositionObject(14, 50, 0, 400);
dbScaleObject(14, 95.0f, 100.0f, 100.0f);
dbLoadObject("tower.x", 15);
dbPositionObject(15, 900, 0, 1630);
{//collision setup
SC_SetupObject(14, 0, 2);
SC_SetupObject(15, 0, 0);
}
}
void loadTerrain()
{
dbLoadImage ( "texture7.jpg", 1 );
dbLoadImage ( "detail.jpg", 2 );
dbSetupTerrain ( );
dbMakeObjectTerrain ( 1 );
dbSetTerrainHeightMap ( 1, "map9.bmp" );
dbSetTerrainScale ( 1, 3.0f, 0.6f, 3.0f );
dbSetTerrainLight ( 1, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f );
dbSetTerrainTexture ( 1, 1, 2 );
dbBuildTerrain ( 1 );
dbPositionObject( 1, 0.0f, 0.0f, 0.0f);
}
void loadSkyBox()
{
dbSetCameraRange ( 1.0f, 30000.0f );
dbLoadObject ( "skybox2.x", 2 );
dbSetObjectLight ( 2, 0 );
dbScaleObject ( 2, 30000, 30000, 30000 );
dbSetObjectTexture ( 2, 3, 1 );
}
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbAutoCamOff();
SC_Start();
loadTerrain();
loadSkyBox();
loadMedia();
float oldX, oldY, oldZ;
while ( LoopGDK () )
{
oldX = dbObjectPositionX(3);
oldY = dbObjectPositionY(3);
oldZ = dbObjectPositionZ(3);
move(3, 2.0f, 2.0f);
collision();
dbPositionObject(4, dbCameraPositionX()-5.0, dbCameraPositionY()-10.0, dbCameraPositionZ()+20.0);
dbPositionObject(5, dbCameraPositionX()+0.85, dbCameraPositionY()-5.0, dbCameraPositionZ()-12.0);
dbPositionObject(6, dbCameraPositionX()-0.85, dbCameraPositionY()-5.0, dbCameraPositionZ()-12.0);
char szFPS [ 256 ] = "";
strcpy ( szFPS, "x = ");
strcat( szFPS, dbStr( int( dbCameraPositionX() ) ) );
strcat( szFPS, " z = " );
strcat(szFPS, dbStr( int( dbCameraPositionZ() ) ) );
dbText ( dbScreenWidth ( ) - 20 - dbTextWidth ( szFPS ), dbScreenHeight ( ) - 40, szFPS );
dbUpdateTerrain ( );
SC_UpdateObject(12);
SC_UpdateObject(14);
SC_UpdateObject(15);
dbSync ( );
}
}
I believe that the bug is in the collision() function, possibly with the implimentation of Sparky's.
Please, if anyone could look at this and help me find this bug I would really apprciate it.
ThanX.