Real-time lighting + solar system rendering
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package mindustry.game;
|
||||
|
||||
import arc.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Universe{
|
||||
private long seconds;
|
||||
@@ -11,6 +16,22 @@ public class Universe{
|
||||
load();
|
||||
}
|
||||
|
||||
public void updateGlobal(){
|
||||
//currently only updates one solar system
|
||||
updatePlanet(Planets.sun);
|
||||
}
|
||||
|
||||
private void updatePlanet(Planet planet){
|
||||
planet.position.setZero();
|
||||
planet.addParentOffset(planet.position);
|
||||
if(planet.parent != null){
|
||||
planet.position.add(planet.parent.position);
|
||||
}
|
||||
for(Planet child : planet.children){
|
||||
updatePlanet(child);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(){
|
||||
secondCounter += Time.delta() / 60f;
|
||||
if(secondCounter >= 1){
|
||||
@@ -22,6 +43,13 @@ public class Universe{
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
//update sector light
|
||||
float light = world.getSector().getLight();
|
||||
float alpha = Mathf.clamp(Mathf.map(light, 0f, 0.8f, 0.1f, 1f));
|
||||
//assign and map so darkness is not 100% dark
|
||||
state.rules.ambientLight.a = 1f - alpha;
|
||||
state.rules.lighting = !Mathf.equal(alpha, 1f);
|
||||
}
|
||||
|
||||
public float secondsMod(float mod, float scale){
|
||||
|
||||
Reference in New Issue
Block a user