// define 21 lensflares
// abused the pan value for the pivot value
ENTITY* lensflare_01 = {
type = "lens_01.DDS";
layer = 2;
view = camera;
pan = -0.139;
}
// lensflares 02 - 20
// (...)
ENTITY* lensflare_21 = {
type = "lens_21.DDS";
layer = 2;
view = camera;
pan = 1;
}
// place a lensflare on the sun position and correct the position according to the pivot value
function lensPlace(ENTITY* lens) {
VECTOR* temp = vector(0,0,0);
vec_set(temp,sun_pos);
if (vec_to_screen(temp,camera) != NULL) { // sun is visible
lens.flags2 |= VISIBLE;
temp.x = temp.x + 2 * lens.pan * ((screen_size.x / 2) - temp.x);
temp.y = temp.y + 2 * lens.pan * ((screen_size.y / 2) - temp.y);
temp.z = 2000; // 2000 quants to depth
vec_set(lens.x,temp);
rel_for_screen(lens.x,camera); // lens flare to sun position
} else { // sun not visible
lens.flags2 &= ~(VISIBLE);
}
}
// at least start the action somewhere
function lensflare_starter() {
// values for my test level
sun_angle.pan = 193;
sun_angle.tilt = 10;
while(1) {
lensPlace(lensflare_01);
// lensflare 02 - 20
// (...)
lensPlace(lensflare_21);
wait(1);
}