none: fix some issues with spacecraft camera

- default shader path update #288
- attitude indicator texture
parent f3fa5870
Pipeline #72227767 passed with stage
in 2 minutes and 25 seconds
......@@ -180,7 +180,7 @@ public class SpacecraftGui extends AbstractGui {
aiAntivelDec = Decal.newDecal(new TextureRegion(aiAntivelTex));
Material mat = new Material(new TextureAttribute(TextureAttribute.Diffuse, aiTexture), new ColorAttribute(ColorAttribute.Specular, 0.3f, 0.3f, 0.3f, 1f));
aiModel = new IntModelBuilder().createSphere(1 * GlobalConf.SCALE_FACTOR, 30, 30, false, mat, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
aiModel = new IntModelBuilder().createSphere(1 * GlobalConf.SCALE_FACTOR, 30, 30, false, mat, Usage.Position | Usage.Normal | Usage.Tangent | Usage.BiNormal | Usage.TextureCoordinates);
aiTransform = new Matrix4();
aiModelInstance = new IntModelInstance(aiModel, aiTransform);
aiViewport = new ExtendViewport(indicatorw, indicatorh, aiCam);
......@@ -196,7 +196,7 @@ public class SpacecraftGui extends AbstractGui {
float factor = GlobalConf.SCALE_FACTOR;
/** BUTTONS **/
buttonContainer = new Container<HorizontalGroup>();
buttonContainer = new Container<>();
buttonRow = new HorizontalGroup();
buttonRow.pad(0, 70 * factor, 5 * factor, 0);
buttonRow.space(3 * factor);
......@@ -208,15 +208,12 @@ public class SpacecraftGui extends AbstractGui {
stabilise.setName("stabilise");
if (sc != null)
stabilise.setChecked(sc.isStabilising());
stabilise.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (event instanceof ChangeEvent) {
EventManager.instance.post(Events.SPACECRAFT_STABILISE_CMD, stabilise.isChecked());
return true;
}
return false;
stabilise.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.instance.post(Events.SPACECRAFT_STABILISE_CMD, stabilise.isChecked());
return true;
}
return false;
});
stabilise.addListener(new TextTooltip(I18n.txt("gui.tooltip.sc.stabilise"), skin));
......@@ -273,29 +270,21 @@ public class SpacecraftGui extends AbstractGui {
enginePlus = new OwnImageButton(skin, "sc-engine-power-up");
enginePlus.addListener(new TextTooltip(I18n.txt("gui.tooltip.sc.powerup"), skin));
enginePlus.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (event instanceof ChangeEvent) {
EventManager.instance.post(Events.SPACECRAFT_THRUST_INCREASE_CMD);
return true;
}
return false;
enginePlus.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.instance.post(Events.SPACECRAFT_THRUST_INCREASE_CMD);
return true;
}
return false;
});
engineMinus = new OwnImageButton(skin, "sc-engine-power-down");
enginePlus.addListener(new TextTooltip(I18n.txt("gui.tooltip.sc.powerdown"), skin));
engineMinus.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (event instanceof ChangeEvent) {
EventManager.instance.post(Events.SPACECRAFT_THRUST_DECREASE_CMD);
return true;
}
return false;
engineMinus.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.instance.post(Events.SPACECRAFT_THRUST_DECREASE_CMD);
return true;
}
return false;
});
Group engineLabelRotated = new Group();
......
......@@ -89,9 +89,7 @@ public abstract class AbstractCamera implements ICamera {
@Override
public void updateAngleEdge(int width, int height) {
ar = (float) width / (float) height;
float h = camera.fieldOfView;
float w = h * ar;
angleEdgeRad = (float) (Math.toRadians(Math.sqrt(h * h + w * w))) / 2f;
angleEdgeRad = getAngleEdge(width, height, camera.fieldOfView);
}
public float getAngleEdge(int width, int height, float angle) {
......
......@@ -169,8 +169,6 @@ public class SpacecraftCamera extends AbstractCamera implements IObserver {
return 1;
}
double lastangle = 0;
public void update(double dt, ITimeFrameProvider time) {
/* FUTURE POS OF SC */
......@@ -301,6 +299,7 @@ public class SpacecraftCamera extends AbstractCamera implements IObserver {
firstTime = false;
}
updateAngleEdge(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
});
} else {
if (sc != null)
......
......@@ -24,8 +24,12 @@ package gaia.cu9.ari.gaiaorbit.util.gdx.contrib.utils;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import gaia.cu9.ari.gaiaorbit.assets.ShaderTemplatingLoader;
import gaia.cu9.ari.gaiaorbit.util.Logger;
import gaia.cu9.ari.gaiaorbit.util.Logger.Log;
public final class ShaderLoader {
private static Log logger = Logger.getLogger(ShaderLoader.class);
public static String BasePath = "";
public static boolean Pedantic = true;
......@@ -39,7 +43,7 @@ public final class ShaderLoader {
log += " w/ (" + defines.replace("\n", ", ") + ")";
}
log += "...";
Gdx.app.debug("ShaderLoader", "Compiling " + log);
logger.debug("Compiling " + log);
String vpSrc = Gdx.files.internal(BasePath + vertexFileName + ".vertex").readString();
String fpSrc = Gdx.files.internal(BasePath + fragmentFileName + ".fragment").readString();
......@@ -61,8 +65,8 @@ public final class ShaderLoader {
ShaderProgram shader = new ShaderProgram(insertDefines(vertex, defines), insertDefines(fragment, defines));
if (!shader.isCompiled()) {
Gdx.app.error("ShaderLoader", "Compile error: " + vertexName + "/" + fragmentName);
Gdx.app.error("ShaderLoader", shader.getLog());
logger.error("Compile error: " + vertexName + "/" + fragmentName);
logger.error(shader.getLog());
System.exit(-1);
}
......
......@@ -41,6 +41,7 @@ import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.GdxRuntimeException;
import gaia.cu9.ari.gaiaorbit.GaiaSky;
import gaia.cu9.ari.gaiaorbit.assets.ShaderTemplatingLoader;
import gaia.cu9.ari.gaiaorbit.util.gdx.IntRenderable;
public class DefaultIntShader extends BaseIntShader {
......@@ -387,7 +388,7 @@ public class DefaultIntShader extends BaseIntShader {
public static String getDefaultVertexShader () {
if (defaultVertexShader == null)
defaultVertexShader = Gdx.files.classpath("com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl").readString();
defaultVertexShader = ShaderTemplatingLoader.load(Gdx.files.internal("shader/normal.vertex.glsl"));
return defaultVertexShader;
}
......@@ -395,7 +396,7 @@ public class DefaultIntShader extends BaseIntShader {
public static String getDefaultFragmentShader () {
if (defaultFragmentShader == null)
defaultFragmentShader = Gdx.files.classpath("com/badlogic/gdx/graphics/g3d/shaders/default.fragment.glsl").readString();
defaultFragmentShader = ShaderTemplatingLoader.load(Gdx.files.internal("shader/normal.fragment.glsl"));
return defaultFragmentShader;
}
......@@ -515,7 +516,7 @@ public class DefaultIntShader extends BaseIntShader {
public DefaultIntShader(final IntRenderable renderable, final Config config, final String prefix, final String vertexShader,
final String fragmentShader) {
this(renderable, config, new ExtShaderProgram(prefix + vertexShader, prefix + fragmentShader));
this(renderable, config, new ExtShaderProgram(ShaderProgramProvider.getShaderCode(prefix, vertexShader), ShaderProgramProvider.getShaderCode(prefix, fragmentShader)));
}
public DefaultIntShader(final IntRenderable renderable, final Config config, final ExtShaderProgram shaderProgram) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment