It appears that clipping is broken - that is to say, when a spaceship is behind the earth and should not be visible it's getting drawn anyway! Is there a trick to enabling the Z-buffer or something similar to prevent this?
Also my spaceship acceleration vector is broken - the spaceship accelerates in the wrong directions when up is pressed.
Lastly, I have a light inside the sun, which lights the earth and moon and spaceships nicely. Unfortunately, it doesn't light up the sun itself, since it's inside the sun! What would a good solution for lighting up the sun itself be? Something spectacular or dramatic would be nice, but I'd settle for just having it "lit"...something simple would be good too. I'll post all the code so you can read what I've got and help me. Hopefully this code will be useful to others too?
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 3D project that uses Dark GDK
// it can be used as a starting point in making your own 3D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 0 );
dbRandomize ( dbTimer ( ) );
dbSetDisplayMode(800,600,16);
dbSetWindowOff();
dbHideMouse();
dbColorBackdrop(dbRGB(0,0,0));
dbText(0,0,"Loading Models...");
dbSync();
dbLoadObject("earth.3ds", 1);
dbPositionObject ( 1, 0,0,0);
dbScaleObject(1,100,100,100);
dbText(0,0,"Earth Loaded");
dbSync();
dbLoadObject("sun.3ds",2);
dbScaleObject(2,1850,1850, 1850);
dbPositionObject(2,1275,0,0);
dbText(0,0,"Sun Loaded");
dbSync();
dbLoadObject("moon.3ds",3);
dbPositionObject(3, 6, 6, 6);
dbScaleObject(3,33,33,33);
dbText(0,0,"Moon Loaded");
dbSync();
dbLoadObject("redship.3ds",4);
dbPositionObject(4,1.5,0,0);
dbScaleObject(4, 5.3,5.3,5.3);
dbText(0,0,"SpaceShip Loaded");
dbSync();
for(int i=0;i<50;i++)
{
dbLoadObject("redship.3ds", 100 + i);
dbPositionObject(100+i, dbRnd(20) / 10.0, dbRnd(20) / 10.0, dbRnd(20)/10.0);
dbScaleObject(100+i, dbRnd(20)/20.0,dbRnd(20)/20.0,dbRnd(20)/20.0);
dbSync();
}
dbMakeLight(1);
dbPositionLight(1, 1275,0,0);
dbSetLightRange(1,9999999999999);
dbHideLight(0);
dbMakeLight(2);
dbPositionLight(2,240,0,0);
dbSetLightRange(2,9999999);
dbSetCameraRange(0,99999999999999);
dbRotateCamera(0,0,1);
double x, y, z, xvel, yvel, zvel;
x = 0; y = 0; z = -1.5;
xvel = yvel = zvel = 0;
double acceleration = .00001;
while ( LoopGDK ( ) )
{
dbSync ( );
dbPositionCamera ( x, y, z );
dbTurnCameraRight(dbMouseMoveX());
dbPitchCameraDown(dbMouseMoveY());
if(dbUpKey())
{
xvel += acceleration * dbCameraAngleX() /360.0;
yvel += acceleration * dbCameraAngleY() /360.0;
zvel += acceleration * dbCameraAngleZ() /360.0;
}
x+=xvel;y+=yvel;z-=zvel;
}
dbDeleteObject(1);
dbDeleteObject(2);
dbDeleteObject(3);
// and now everything is ready to return back to Windows
return;
}