Plant launch lerp animation
This commit is contained in:
@@ -10,6 +10,10 @@ import mindustry.type.*;
|
||||
public class PlanetParams{
|
||||
/** Camera direction relative to the planet. Length is determined by zoom. */
|
||||
public Vec3 camPos = new Vec3(0f, 0f, 4f);
|
||||
/** If not null, this is the position of the "previous" planet for smooth camera movement. */
|
||||
public @Nullable Vec3 otherCamPos;
|
||||
/** Interpolation value for otherCamPos. */
|
||||
public float otherCamAlpha = 0f;
|
||||
/** Camera up vector. */
|
||||
public Vec3 camUp = new Vec3(0f, 1f, 0f);
|
||||
/** the unit length direction vector of the camera **/
|
||||
|
||||
@@ -69,7 +69,12 @@ public class PlanetRenderer implements Disposable{
|
||||
|
||||
cam.resize(w, h);
|
||||
params.camPos.setLength((params.planet.radius + params.planet.camRadius) * camLength + (params.zoom-1f) * (params.planet.radius + params.planet.camRadius) * 2);
|
||||
cam.position.set(params.planet.position).add(params.camPos);
|
||||
|
||||
if(params.otherCamPos != null){
|
||||
cam.position.set(params.otherCamPos).lerp(params.planet.position, params.otherCamAlpha).add(params.camPos);
|
||||
}else{
|
||||
cam.position.set(params.planet.position).add(params.camPos);
|
||||
}
|
||||
//cam.up.set(params.camUp); //TODO broken
|
||||
cam.lookAt(params.planet.position);
|
||||
cam.update();
|
||||
|
||||
@@ -276,7 +276,8 @@ public class Planet extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
launchCandidates = candidates;
|
||||
//TODO currently, mutual launch candidates are simply a nuisance.
|
||||
//launchCandidates = candidates;
|
||||
|
||||
clipRadius = Math.max(clipRadius, radius + atmosphereRadOut + 0.5f);
|
||||
}
|
||||
|
||||
@@ -172,6 +172,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
rebuildButtons();
|
||||
mode = look;
|
||||
state.otherCamPos = null;
|
||||
selected = hovered = launchSector = null;
|
||||
launching = false;
|
||||
|
||||
@@ -259,6 +260,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
//automatically select next planets; TODO pan!
|
||||
if(sector.planet.launchCandidates.size == 1){
|
||||
state.planet = sector.planet.launchCandidates.first();
|
||||
state.otherCamPos = sector.planet.position;
|
||||
state.otherCamAlpha = 0f;
|
||||
}
|
||||
|
||||
//TODO pan over to correct planet
|
||||
@@ -284,6 +287,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
zoom = 1f;
|
||||
state.zoom = 1f;
|
||||
state.uiAlpha = 0f;
|
||||
state.otherCamPos = null;
|
||||
launchSector = sector;
|
||||
|
||||
mode = select;
|
||||
@@ -669,6 +673,19 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
public void act(float delta){
|
||||
super.act(delta);
|
||||
|
||||
//update lerp
|
||||
if(state.otherCamPos != null){
|
||||
state.otherCamAlpha = Mathf.lerpDelta(state.otherCamAlpha, 1f, 0.05f);
|
||||
state.camPos.set(0f, camLength, 0.1f);
|
||||
|
||||
if(Mathf.equal(state.otherCamAlpha, 1f, 0.01f)){
|
||||
//cam.position.set(params.otherCamPos).lerp(params.planet.position, params.otherCamAlpha).add(params.camPos);
|
||||
state.camPos.set(Tmp.v31.set(state.otherCamPos).lerp(state.planet.position, state.otherCamAlpha).add(state.camPos).sub(state.planet.position));
|
||||
|
||||
state.otherCamPos = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(hovered != null && !mobile && state.planet.hasGrid()){
|
||||
addChild(hoverLabel);
|
||||
hoverLabel.toFront();
|
||||
|
||||
Reference in New Issue
Block a user