I'm not sure what the culling on a terrian is but here is my code.
// Dark GDK - The Game Creators - www.thegamecreators.com
// include the Dark GDK header
#include "DarkGDK.h"
#include "dinput.h"
#include "Start Up.h"
#include "controls.h"
void DarkGDK ( void )
{
Start();
// 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 );
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 );
// 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 );
// we dont need it to respond to light so switch light off
dbSetObjectLight ( 2, 0 );
// make the skybox much larger
dbScaleObject ( 2, 3000, 3000, 3000 );
dbLoadObject ( "H-AK47-Static.x", 10 );
dbScaleObject(10,100000,100000,100000);
// position the camera
dbPositionCamera ( 385, 23, 100 );
dbSetCameraRange (.001f,5000);
// adjust texture properties of sky box
dbSetObjectTexture ( 2, 3, 1 );
dbPositionObject(10,dbCameraPositionX()-30,dbCameraPositionY()-200,dbCameraPositionZ()+20);
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
// now onto our main loop
while ( LoopGDK ( ) )
{
// let the user move the camera around with the arrow keys
dbControlCameraUsingArrowKeys ( 0, 2.0f, 2.0f );
// 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 ( ) );
// update the terrain
dbUpdateTerrain ( );
// create a rotation axis based on mouse movement
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.04f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.04f );
// rotate camera
dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );
if(dbReturnKey())
{
dbMakeObjectSphere(20,10,180,180);
dbPositionObject(20,dbCameraPositionX()-30,dbCameraPositionY()-200,dbCameraPositionZ()+20);
}
//dbPositionObject(10,dbCameraPositionX()+1,dbCameraPositionY(),dbCameraPositionZ());
dbLockObjectOn ( 10 ); //controls();
// update the screen
dbSync ( );
}
}