I tried to get shadows but I had success only with static objects:
#define DIRECTINPUT_VERSION 0x0700
#include <DarkGDK.h>
#include <Dinput.h>
// models
int nPlane=1;
int nCaster=2;
int nLightCube=3;
// images
int nFloorImage=1;
int nCrateImage=2;
int nPointLight=0;
void DarkGDK ( void )
{
float camPitch, camYaw, lightPosX=0.0f, lightPosY=10.0f, lightPosZ=0.0f;
dbSetDisplayMode( 800, 600, 32 );
dbSyncOn( );
dbSyncRate( 60 );
dbAutoCamOff();
// scene
dbSetAmbientLight( 10 );
dbSetPointLight( nPointLight, 0, 2, 0 );
dbColorBackdrop( dbRGB(0, 0, 0) );
dbPositionCamera( 0.0f, 4.0f, 8.0f );
dbPointCamera( 0.0f, 0.0f, 0.0f );
// textures
dbLoadImage( "../Media/Floor.tga", nFloorImage );
dbLoadImage( "../Media/Brick.tga", nCrateImage );
// objects
dbLoadObject( "../Media/Walk.x", nCaster );
dbScaleObject( nCaster, 3.0f, 3.0f, 3.0f );
dbPositionObject( nCaster, 0.0f, 0.0f, 0.0f );
dbLoopObject( nCaster );
dbSetObjectSpeed( nCaster, 10 );
//dbLoadObject( "../Media/Cube.x", nCaster );
//dbTextureObject( nCaster, 0, nCrateImage );
//dbPositionObject( nCaster, 0.0f, 2.0f, 0.0f );
dbLoadObject( "../Media/Plane.x", nPlane );
dbTextureObject( nPlane, 0, nFloorImage );
dbMakeObjectCone( nLightCube, 0.3f );
dbPositionObject( nLightCube, lightPosX, lightPosY, lightPosZ );
dbSetNormalizationOn();
dbSetShadowShadingOn( nCaster );
while ( LoopGDK ( ) )
{
// update camera
camYaw = dbCameraAngleY( );
camPitch = dbCameraAngleX( );
if ( dbUpKey() )
dbXRotateCamera( camPitch+1.0f );
if ( dbDownKey() )
dbXRotateCamera( camPitch-1.0f );
if ( dbLeftKey() )
dbYRotateCamera( camYaw-1.0f );
if ( dbRightKey() )
dbYRotateCamera( camYaw+1.0f );
if ( dbKeyState( DIK_A) )
dbMoveCamera( 0.25f );
if ( dbKeyState( DIK_Z) )
dbMoveCamera( -0.25f );
// update light position
if ( dbKeyState( DIK_S ) )
lightPosX = lightPosX + 0.1f;
if ( dbKeyState( DIK_F ) )
lightPosX = lightPosX - 0.1f;
if ( dbKeyState( DIK_E ) )
lightPosZ = lightPosZ - 0.1f;
if ( dbKeyState( DIK_D ) )
lightPosZ = lightPosZ + 0.1f;
dbPositionObject( nLightCube, lightPosX, lightPosY, lightPosZ );
dbPositionLight( nPointLight, lightPosX, lightPosY, lightPosZ );
// update caster
//dbTurnObjectLeft( nCaster, 0.5f );
//dbPitchObjectUp( nCaster, 0.5f );
//dbRollObjectLeft( nCaster, 0.5f );
dbSync ( );
}
}
Do I have to do additional setup?