This is a more flexible version of the original demo. This allows you to change the color of the atmosphere to ANY color you wish. It will also automatically increase/decrease the atmosphere glare and haze thickness.
For some reason dbSetSphereMappingOn() won't allow for gradual transparent fading with the dbSetAlphaMappingOn() function. So I have 10 small images that give the effect of changing the amount of atmosphere glare.
Also you can press 1, 2, 3 to change the planet's texture and cloud types.
//------------------------------------------------------------
//---------------------Planet Camera Test 2-------------------
//------------------------------------------------------------
#include "DarkGDK.h"
#include "dinput.h"
float YAng, XAng, Dist;
float HRed, HGreen, HBlue, HAmount, GlareAmount;
float dist_ratio;
float alm = 15;
int mmx, mmy, mmz, GAM;
int Active_Camera = 1;
void DarkGDK ( void )
{
dbSyncOn ();
dbSyncRate (0);
dbSetWindowPosition(0, 0);
dbSetDisplayModeVSync (1920,1080,32,0);
dbSetWindowOff();
dbSetAmbientLight(2);
dbLoadImage("Clouds.png", 1);
dbLoadImage("LR_Earth.png", 2);
dbLoadImage("Star_tex.jpg", 3);
dbLoadImage("Star_Yellow_BB.png", 4);
dbLoadImage("Moon.png", 5);
dbLoadImage("SkySphere.png", 6);
dbLoadImage("B_Hole.png", 7);
dbLoadImage("GridSphere.png", 8);
dbLoadImage("Mars.png", 9);
dbLoadImage("gg_1.png", 10);
dbLoadImage("MarsClouds.png", 11);
dbLoadImage("PlanetGlare0.png", 20);
dbLoadImage("PlanetGlare10.png", 21);
dbLoadImage("PlanetGlare20.png", 22);
dbLoadImage("PlanetGlare30.png", 23);
dbLoadImage("PlanetGlare40.png", 24);
dbLoadImage("PlanetGlare50.png", 25);
dbLoadImage("PlanetGlare60.png", 26);
dbLoadImage("PlanetGlare70.png", 27);
dbLoadImage("PlanetGlare80.png", 28);
dbLoadImage("PlanetGlare90.png", 29);
dbLoadImage("PlanetGlare100.png", 30);
dbAutoCamOff();
dbMakeCamera(Active_Camera);
dbBackdropOn(Active_Camera);
dbColorBackdrop(Active_Camera, dbRgb(10,10,10));
dbSetCameraRange(Active_Camera, .75, 571000);
dbPositionCamera (Active_Camera, 0, 0, -50);
dbSetCurrentCamera(Active_Camera);
dbHideLight(0);
dbMakeLight(1);
dbMakeLight(2);
dbMakeLight(3);
dbMakeLight(4);
dbPositionLight(1, -12000, 0, 0);
dbSetLightRange(1, 50000);
dbPositionLight(2, -12000, 0, 0);
dbSetLightRange(2, 50000);
dbPositionLight(3, -12000, 0, 0);
dbSetLightRange(3, 50000);
dbPositionLight(4, -12000, 0, 0);
dbSetLightRange(4, 50000);
dbMakeObjectSphere(3, 500, 20, 40); //Sun
dbSetObjectLight(3, 0);
dbPositionObject(3, -12000, 0, 0);
dbTextureObject(3, 3);
dbMakeObjectCube(4, 1000); //Star Glare Cube
dbSetObjectLight(4, 0);
dbPositionObject(4, -12000, 0, 0);
dbTextureObject(4, 4);
dbSetObjectTransparency(4, 2);
dbMakeObjectSphere(2, 4, 20, 40); //Moon
dbPositionObject(2, -150, 0, -150);
dbTextureObject(2, 5);
dbMakeObjectSphere(1, 10, 30, 60); //Planet
dbPositionObject(1, 0, 0, 0);
dbTextureObject(1, 2);
dbMakeObjectSphere(6, 10.02, 30, 60); //Planet Clouds
dbSetObjectTransparency(6, 3);
dbSetAlphaMappingOn(6, 100);
dbPositionObject(6, 0, 0, 0);
dbTextureObject(6, 1);
dbMakeObjectSphere(111, 10.04, 30, 60); //Planet Glare
dbSetSphereMappingOn(111, 25);
dbSetObjectTransparency(111, 3);
dbSetAlphaMappingOn(111, 100);
dbPositionObject(111, 0, 0, 0);
dbPointObject(111, 0, 0, 0);
dbMakeObjectSphere(7, 10.06, 30, 60); //Planet Haze
dbColorObject(7, dbRgb(255,45,45));
dbSetObjectTransparency(7, 5);
dbSetAlphaMappingOn(7, 25);
dbPositionObject(7, 0, 0, 0);
dbMakeObjectSphere(5, -250000, 15, 30); //Stellar Background
dbPositionObject(5, 0, 0, 0);
dbTextureObject(5, 6);
dbSetObjectLight(5, 0);
Dist = -50;
HRed = 10; HGreen = 35; HBlue = 255;
dbMoveObject(666,-12);
while (LoopGDK())
{
mmx = dbMouseMoveX();
mmy = dbMouseMoveY();
mmz = dbMouseMoveZ();
if (dbKeyState(DIK_X)==1) dbShowObject(111);
if (dbKeyState(DIK_Z)==1) dbHideObject(111);
if (dbMouseClick()==4)
{
XAng = XAng + (mmx * .20);
YAng = YAng + (mmy * .20);
}
if (Dist > -5.05) {Dist = -5.05;}
if (Dist >= -5.12 && Dist <= -5.05) Dist = Dist + (mmz*.00015);
if (Dist >= -10 && Dist <= -5.12) Dist = Dist + (mmz*.0005);
if (Dist >= -50 && Dist <= -10) Dist = Dist + (mmz*.005);
if (Dist >= -500 && Dist <= -50) Dist = Dist + (mmz*.025);
if (Dist >= -1000 && Dist <= -500) Dist = Dist + (mmz*.25);
if (Dist >= -10000 && Dist <= -1000) Dist = Dist + (mmz*2.5);
if (Dist <= -10000) Dist = Dist + (mmz*25);
if (dbKeyState(DIK_Q)==1) HRed = HRed +.25; if (HRed>255) HRed = 255;
if (dbKeyState(DIK_A)==1) HRed = HRed -.25; if (HRed<0) HRed = 0;
if (dbKeyState(DIK_W)==1) HGreen = HGreen +.25; if (HGreen>255) HGreen = 255;
if (dbKeyState(DIK_S)==1) HGreen = HGreen -.25; if (HGreen<0) HGreen = 0;
if (dbKeyState(DIK_E)==1) HBlue = HBlue +.25; if (HBlue>255) HBlue = 255;
if (dbKeyState(DIK_D)==1) HBlue = HBlue -.25; if (HBlue<0) HBlue = 0;
if (dbKeyState(DIK_1)==1) {dbTextureObject(1, 2); dbShowObject(6); dbTextureObject(6, 1);}
if (dbKeyState(DIK_2)==1) {dbTextureObject(1, 9); dbShowObject(6); dbTextureObject(6, 11);}
if (dbKeyState(DIK_3)==1) {dbTextureObject(1, 10); dbHideObject(6);}
if (dbKeyState(DIK_4)==1) {dbHideObject(6);}
dbPointObject(4, dbCameraPositionX(Active_Camera), dbCameraPositionY(Active_Camera), dbCameraPositionZ(Active_Camera)); //Point Glare Cube At Camera
dbPointCamera(5, 0, 0, 0);
dbPositionCamera(Active_Camera, 0, 0, 0);
dbRotateCamera(Active_Camera, YAng, XAng, 0.0);
dbMoveCamera(Active_Camera, Dist);
dbText(0, 0, "Press <z> to hide the atmosphere glare effect | Press <x> to show the atmosphere glare effect.");
dbText(0, 15, "Use The mouse-wheel to zoom in and out from the planet.");
dbText(0, 30, "Press the mouse-wheel and move the mouse to pan around the planet.");
dbText(0, 45, "Haze Color R [q+] [a-] (Red Level) : "); dbText(335, 45, dbStr(HRed));
dbText(0, 60, "Haze Color G [w+] [s-] (Green Level) : "); dbText(335, 60, dbStr(HGreen));
dbText(0, 75, "Haze Color B [e+] [d-] (Blue Level) : "); dbText(335, 75, dbStr(HBlue));
dbText(0, 90, "Haze Thickness : "); dbText(135, 90, dbStr(HAmount));
dbText(0, 105, "Glare Amount : "); dbText(135, 105, dbStr(GlareAmount));
dbText(0, 120, "Press <1>, <2>, or <3> to switch to different planet textures....");
HAmount = (HRed + HGreen + HBlue) * .075;
GlareAmount = HAmount*5.5;
dbColorObject(7, dbRgb(HRed, HGreen, HBlue));
dbSetAlphaMappingOn(7, HAmount*2);
GAM = (GlareAmount*.1)+20;
if (GAM>30) GAM=30;
dbSetSphereMappingOn(111, GAM);
dbText(0, 135, dbStr(dbScreenFPS()));
dbText(0, 150, dbStr(YAng));
dbSync ( );
}
return;
}
Home is where my souped-up computer is...
![](/images/smilies/wink.gif)