#include <acknex.h>
#ifndef sky_wdl
#define sky_wdl
// ---------------------------------------------------------------------
// STARTHEADER
//
// ver: 5.0
// engineReq: 6.4
// date: 061011
//
// title: Day/Night Animated Sky (00)
// class: ENVIR
// type: USER
// image: sky00.pcx
// help: Create 3 sky spheres (with animation) and 2 scene maps.
//
//
// prefix: sky00_
// idcode: 01A
//
// ENDHEADER
// ---------------------------------------------------------------------
// block: Template Includes
// nothing...
// ---------------------------------------------------------------------
// section: Sky Sphere 0 (night sky)
ENTITY* sky00_00_sky =
{
flags2 = SKY|DOME|VISIBLE;
// entry: Sky image
// id: 1
type = "sky_stars.pcx";
// entry: Speed X
// id: 2
// help: Animation speed in x
speed_u = 1.5;
// entry: Speed Y
// id: 3
// help: animation speed in y
speed_v = 0.0;
// entry: Scale X
// id: 4
// help: Scale in X dimention
scale_x = 0.125;
// entry: Scale Y
// id: 5
// help: Scale in y dimention
scale_y = 0.125;
// entry: Layer
// id: 6
layer = 1;
}
// section: Sky Sphere 1 (day sky)
ENTITY* sky00_01_sky =
{
flags2 = SKY|DOME|VISIBLE;//???|TRANSPARENT;
// entry: Sky image
// id: 7
type = "sky_blue.pcx";
// entry: Speed X
// id: 8
// help: Animation speed in x
speed_u = 1.5;
// entry: Speed Y
// id: 9
// help: Animation speed in y
speed_v = 0.5;
// entry: Scale X
// id: 10
// help: Scale in X dimention
scale_x = 1.0;
// entry: Scale Y
// id: 11
// help: Scale in Y dimention
scale_y = 1.0;
alpha = 100;
// entry: Layer
// id: 12
layer = 2;
}
// section: Sky Sphere 2 (cloud layer)
ENTITY* sky00_02_sky =
{
flags2 = SKY|DOME|VISIBLE;
// entry: sky image
// id: 13
type = "sky_cloud.pcx";
// entry: Speed X
// id: 14
// help: Animation speed in x
speed_u = 3.5;
// entry: Speed Y
// id: 15
// help: Animation speed in y
speed_v = 4.0;
// entry: Scale X
// id: 16
// help: Scale in X dimention
scale_x = 1.0;
// entry: Scale Y
// id: 17
// help: Scale in Y dimention
scale_y = 1.0;
flags = OVERLAY|VISIBLE;//???|TRANSPARENT; // sky dome, black transparent, alpha
alpha = 75;
// entry: Layer
// id: 18
layer = 3;
}
// Section: Nighttime horizon
ENTITY* sky00_00_scene =
{
flags2 = SKY|SCENE|VISIBLE;
// entry: Scenemap image
// id: 19
type = "night_mount.pcx";
// entry: Scale X
// id: 20
// help: How much horizon is taken by one image (1 = full 360 degrees)
scale_x = 0.125;
// entry: Pan
// id: 21
// help: Rotate along the horizon (pan)
pan = 0;
// entry: Tilt
// id: 22
// help: Rotate vertically (tilt)
tilt = -3; // moves it
// entry: Layer
// id: 23
layer = 4; // display above sky entities with lower layers
}
// section: Daytime horizon
ENTITY* sky00_01_scene =
{
flags2 = SKY|SCENE;
flags = VISIBLE;//???|TRANSPARENT; // backdrop scene, alpha, visible
// entry: scenemap image
// id: 24
type = "sky_mount.pcx";
// entry: Scale X
// id: 25
// help: How much horizon is taken by one image (1 = full 360 degrees)
scale_x = 0.125;
// entry: Pan
// id: 26
// help: Rotate along the horizon (pan)
pan = 0;
// entry: Tilt
// id: 27
// help: Rotate vertically (tilt)
tilt = -3; // moves it
// entry: Layer
// id: 28
layer = 5; // display above sky entities with lower layers
alpha = 100;
}
// ---------------------------------------------------------------------
// Local Vars
var sky00_day_or_night = 1; // 1 for day, 0 for night, otherwise trans
// ---------------------------------------------------------------------
// Functions
void Sky00_Load_startup()
{
diag("\nWDL-Loaded:Sky00.wdl");
}
// desc: transition from daytime (sky01) to nighttime (sky00) in the time
// given by duration.
void Sky00_Day_To_Night(var duration)
{
var trans;
// not day or transitioning
if(sky00_day_or_night != 1) { return(-1); }
// turn on night layers
set(sky00_00_sky,VISIBLE); // nighttime sky
set(sky00_00_scene,VISIBLE); // nighttime horizon
if(duration > 0) // make sure duration is valid
{
sky00_day_or_night = 0.5; // flag that we are transitioning
trans = duration;
// fade to night
while(trans > 0)
{
sky00_01_sky.alpha = 100*(trans/duration);
sky00_01_scene.alpha = sky00_01_sky.alpha;
trans -= time_step;
wait(1);
}
sky00_day_or_night = 0; // flag that we are in night mode
}
// turn off day layers
sky00_01_sky.alpha = 0;
sky00_01_scene.alpha = 0;
reset(sky00_01_sky,VISIBLE);
reset(sky00_01_scene,VISIBLE);
}
// desc: transition from nighttime (sky00) to daytime (sky01) in the time
// given by duration.
void Sky00_Night_To_Day(var duration)
{
var trans;
// not night or transitioning
if(sky00_day_or_night != 0) { return(-1); }
// turn on day layers
set(sky00_01_sky,VISIBLE); // nighttime sky
set(sky00_01_scene,VISIBLE); // nighttime horizon
// catch invalid values
if(duration > 0)
{
sky00_day_or_night = 0.5; // flag that we are transitioning
trans = 0;
// fade to day
while(trans < duration)
{
sky00_01_sky.alpha = 100*(trans/duration);
sky00_01_scene.alpha = sky00_01_sky.alpha;
trans += time_step;
wait(1);
}
sky00_day_or_night = 1; // flag that we are in day mode
}
sky00_01_sky.alpha = 100;
sky00_01_scene.alpha = 100;
// turn off night
reset(sky00_00_sky,VISIBLE);
reset(sky00_00_scene,VISIBLE);
}
// desc: Fade the cloud layer from its current alpha to a target alpha in
// the time given by duration.
void Sky00_Fade_Clouds(var targetAlpha, var duration)
{
var trans;
var delta;
var start;
// catch invalid values
if(targetAlpha < 0) { targetAlpha = 0; } // min alpha
if(targetAlpha > 100) { targetAlpha = 100; } // max alpha
if(duration <= 0) // duration not valid
{
sky00_02_sky.alpha = targetAlpha;
return;
}
trans = 0;
start = sky00_02_sky.alpha;
delta = targetAlpha - sky00_02_sky.alpha; // change in alpha
while(trans < duration)
{
sky00_02_sky.alpha = start + delta*(trans/duration);
trans += time_step;
wait(1);
}
sky00_02_sky.alpha = targetAlpha;
}
#endif