i fixed the z,y,z problem, but not surprisingly it didnt work?
heres my full code if y0ou want to see:
#include "DarkGDK.h"
#include "SC_Collision.h"
void collision(void);
void DarkGDK ( void )
{
dbSyncOn( );
dbSyncRate( 60 );
dbMaximizeWindow( );
SC_Start( );
dbHideMouse( );
for( int i=10002; i <= 10040; i++ )
{
dbMakeObjectSphere( i, 3 );
dbTextureObject ( i, 5 );
dbSetObjectLight( i, 0 );
dbHideObject( i );
}
dbSetCameraRange( 1.0f, 30000.0f );
dbLoadImage( "texture.jpg", 1 );
dbLoadImage( "detail.jpg", 2 );
dbSetupTerrain( );
dbMakeObjectTerrain( 1 );
dbSetTerrainHeightMap( 1, "map.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 );
dbLoadObject( "skybox2.x", 2 );
dbSetObjectLight( 2, 0 );
dbScaleObject( 2, 30000, 30000, 30000 );
dbSetObjectTexture( 2, 3, 1 );
SC_SetupObject( 2, 1, 2 );
dbLoadObject( "Atomiser.x", 3 );
dbRotateObject( 3, 90, 180 ,175 );
dbPositionObject( 3, 5, -18, 20 );
dbScaleObject( 3, 150, 150, 150 );
dbLoadImage( "crosshair.png", 3 );
dbSprite( 1, 576, 432, 13 );
dbPositionCamera( 10, -15, 40 );
dbLockObjectOn( 3 );
register float fCameraAngleX = 0.0f;
register float fCameraAngleY = 0.0f;
register float fHeight = 0.0f;
while ( LoopGDK ( ) )
{
dbControlCameraUsingArrowKeys(0, 2.0f, 2.0f);
if(dbLeftKey())
dbMoveCameraLeft(0, 3);
if(dbRightKey())
dbMoveCameraRight(0, 3);
fHeight = dbGetTerrainGroundHeight( 1, dbCameraPositionX ( ), dbCameraPositionZ ( ) );
dbPositionCamera( dbCameraPositionX ( ), fHeight + 15.0f, dbCameraPositionZ ( ) );
fCameraAngleX = dbWrapValue( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
fCameraAngleY = dbWrapValue( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );
dbXRotateCamera( fCameraAngleX );
dbYRotateCamera( fCameraAngleY );
collision( );
dbSync( );
}
return;
}
void collision(void)
{
int collision = 0;
int counter = 10002;
if( dbMouseClick( ) == 1 )
{
float oldx = dbCameraPositionX( );
float oldy = dbCameraPositionY( );
float oldz = dbCameraPositionZ( );
dbMoveCamera( 200 );
float x = dbCameraPositionX( );
float y = dbCameraPositionY( );
float z = dbCameraPositionZ( );
dbMoveCamera( -200 );
collision = SC_RayCast( 0, oldx,oldy,oldz, x,y,z, 0 );
}
if( collision > 0 )
{
float newx = SC_GetStaticCollisionX( );
float newy = SC_GetStaticCollisionY( );
float newz = SC_GetStaticCollisionZ( );
float normx = SC_GetCollisionNormalX( );
float normy = SC_GetCollisionNormalY( );
float normz = SC_GetCollisionNormalZ( );
dbPositionObject( counter, newx + normx/10, newy + normy/10, newz + normz/10 );
dbPointObject( counter, newx + normx, newy + normy, newz + normz );
dbShowObject(counter);
counter++;
if( counter > 10040) counter = 10002;
}
}