hi, again, i have a little problem with collisions i just have 2 models, 1 i can control with the arrow keys the other 1 is just static, so i can check for collision, the code is as follows
// Dark GDK - The Game Creators - www.thegamecreators.com
// include the Dark GDK header
#include "DarkGDK.h"
void DarkGDK ( void )
{
// entry point for the application
// switch on sync rate and set to a maximum of 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// we are going to use a skybox in this demo and it will
// be scaled up to quite a large size, this will initially
// result in it being outside of the cameras default range
// therefore it will not be drawn, to adjust this we simply
// increase the cameras range
dbSetCameraRange ( 1.0f, 30000.0f );
// two textures are going to be used for the terrain, the first
// will be the diffuse part and the second will be used to
// create extra detail on the terrain
dbLoadImage ( "texture.jpg", 1 );
dbLoadImage ( "detail.jpg", 2 );
// the first step in creating a terrain is to call the
// function dbSetupTerrain, this will perform some internal
// work that allows us to get started
dbSetupTerrain ( );
// now we can get started on making the terrain object
dbMakeObjectTerrain ( 1 );
// here we pass in a heightmap that will be used to create the terrain
dbSetTerrainHeightMap ( 1, "map.bmp" );
// now we set the scale, this will have the effect of making
// the terrain large on the X and Z axis but quite small on the Y
dbSetTerrainScale ( 1, 3.0f, 0.3f, 3.0f );
// adjust the lighting for the terrain, this function takes the ID
// number, then a direction for the light, then 3 colours for the light
// and finally the scale, by using this function we can adjust the
// overall colour of the terrain
dbSetTerrainLight ( 1, 1.0f, -0.25f, 0.3f, 1.0f, 1.0f, 0.78f, 0.5f );
// in this call we're telling the terrain that its diffuse texture
// will come from image 1 and its detail texture will come from
// image 2
dbSetTerrainTexture ( 1, 1, 2 );
// once we have set all properties of the terrain we can build it,
// at this point it gets created and added into your world
dbBuildTerrain ( 1 );
// with the terrain in place we can now load a skybox
dbLoadObject ( "skybox2.x", 2 );
dbLoadObject ("bigtree1.x",3);
dbLoadObject ("tiny.x",4);
dbLoadObject ("tiny.x",5);
// we dont need it to respond to light so switch light off
dbSetObjectLight ( 2, 0 );
dbSetObjectLight (3,0);
dbSetObjectLight (4,0);
dbSetObjectLight (5,0);
// make the skybox much larger
dbScaleObject ( 2, 2000, 2000, 2000 );
dbPositionObject (3, 0, 50, 0);
dbScaleObject (4,5,5,5);
dbScaleObject (5,5,5,5);
dbRotateObject (4, 0,180,0);
dbPlayObject(4);
dbSetObjectSpeed (4,5500);
dbLoopObject (4);
dbPositionObject(4,40,40,40);
dbPositionObject (5,60,60,60);
dbSetObjectRadius (4,3);
dbSetObjectRadius (5,3);
dbSetObjectCollisionOn (4);
dbSetObjectCollisionOn (5);
if (dbObjectCollision(4,5)==1){
dbScaleObject(5,100,100,100);
}
// position the camera
dbPositionCamera ( 40,30,30 );
// adjust texture properties of sky box
dbSetObjectTexture ( 2, 3, 1 );
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
// now onto our main loop
while ( LoopGDK ( ) )
{
if (dbUpKey()==1){
dbMoveObject (4,-.4);
}
if (dbRightKey()==1){
dbTurnObjectRight ( 4,1 );
}
if (dbLeftKey()==1){
dbTurnObjectLeft(4,1);
}
if (dbDownKey()==1){
dbMoveObject (4,.4);
}
float fH = dbGetTerrainGroundHeight ( 1, dbObjectPositionX (4), dbObjectPositionZ (4 ) );
dbPositionObject ( 4, dbObjectPositionX (4), fH + 13.0f, dbObjectPositionZ (4 ) );
float fH1 = dbGetTerrainGroundHeight ( 1, dbObjectPositionX (5), dbObjectPositionZ (5 ) );
dbPositionObject ( 5, dbObjectPositionX (5), fH + 13.0f, dbObjectPositionZ (5 ) );
dbHideMouse();
// let the user move the camera around with the arrow keys
dbControlCameraUsingArrowKeys ( 0, .4f, .4f );
// find the ground height of the terrain
float fHeight = dbGetTerrainGroundHeight ( 1, dbCameraPositionX ( ), dbCameraPositionZ ( ) );
// reposition the camera so it is directly above the ground
dbPositionCamera ( dbCameraPositionX ( ), fHeight + 20.0f, dbCameraPositionZ ( ) );
// create a rotation axis based on mouse movement
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );
// rotate camera
dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );
// update the terrain
dbUpdateTerrain ( );
// update the screen
dbSync ( );
}
}
its a little messy
but this is just a test...
please could someone tell me where my mistake is
? thanks