made the night sky more beautiful with stars

stable-5.3
Tobias Zwick 2012-10-30 00:10:00 +01:00
parent 0d37166baf
commit d2bd18b7d8
18 changed files with 43 additions and 40 deletions

View File

@ -9,7 +9,7 @@ protected func Initialize()
SetClrModulation(RGBa(255,255,255,alpha));
SetAction("Be");
Update();
this["Parallaxity"] = [40,40];
this["Parallaxity"] = [30,30];
}
public func NextMoonPhase()

View File

@ -58,7 +58,7 @@ protected func Initialize()
SunsetEnd = 75600, // 21:00
};
// Add effect that controls time cycle.
// Add effect that controls time cycle.a
advance_seconds_per_tick = 30;
AddEffect("IntTimeCycle", this, 100, 10, this);
@ -68,8 +68,8 @@ protected func Initialize()
// Create moon and stars.
if (FindObject(Find_ID(Environment_Celestial)))
{
CreateObject(Moon, LandscapeWidth() / 2, LandscapeHeight() / 6);
PlaceStars();
CreateObject(Moon, LandscapeWidth() / 2, LandscapeHeight() / 6);
}
return;
}
@ -94,17 +94,26 @@ public func IsNight()
private func PlaceStars()
{
// since stars are almost completely parallax (=in screen coordinates), we only need
// to place stars for max. a reasonable maximum resolution. Lets say 1600x1200
var lw = Min(LandscapeWidth(), 1600);
var lh = Min(LandscapeHeight(),1200);
//Star Creation
var maxamount = LandscapeWidth() * LandscapeHeight() / 40000;
var amount = 0;
var maxfailedtries = lw * lh / 40000;
var failed = 0;
while (amount != maxamount)
while (failed != maxfailedtries)
{
var pos;
if (pos = FindPosInMat("Sky", 0, 0, LandscapeWidth(), LandscapeHeight()))
CreateObject(Star, pos[0], pos[1]);
amount++;
var pos = [Random(lw), Random(lh)];
if(!FindObject(Find_ID(Stars),Find_AtPoint(pos[0],pos[1])))
{
CreateObject(Stars, pos[0], pos[1]);
continue;
}
failed++;
}
return;
}

View File

@ -1,11 +0,0 @@
[DefCore]
id=Star
Version=5,2,0,1
Category=C4D_StaticBack|C4D_Background
Width=2
Height=2
Offset=-1,1
Vertices=1
VertexY=0
Mass=1
StretchGrowth=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 618 B

View File

@ -1,17 +0,0 @@
/*-- Star --*/
protected func Initialize()
{
DoCon(-30+Random(50));
SetR(Random(359));
var alpha=0;
if(GetTime()<300 || GetTime()>1140) alpha=255;
SetClrModulation(RGBa(255,255,255,alpha));
this["Parallaxity"] = [10,10];
SetCategory(GetCategory() | C4D_Parallax | C4D_Background);
}
public func IsCelestial() { return true; }
local Name = "$Name$";

View File

@ -0,0 +1,7 @@
[DefCore]
id=Stars
Version=5,2,0,1
Category=C4D_StaticBack|C4D_Background|C4D_Parallax
Width=128
Height=128
Offset=-64,64

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,17 @@
/*-- Stars --*/
protected func Initialize()
{
var alpha=0;
if(GetTime()<300 || GetTime()>1140) alpha=255;
var g = RandomX(1,9);
if(g > 1) SetGraphics(Format("%d",g));
SetClrModulation(RGBa(255,255,255,alpha));
SetObjectBlitMode(GFX_BLIT_Additive);
var parallax = RandomX(5,8);
this["Parallaxity"] = [parallax,parallax];
}
public func IsCelestial() { return true; }
local Name = "Stars";