Flipped Y-axis in flat layers and cursor input. Now (0; 0) is lower left

This commit is contained in:
OLEGSHA 2020-08-15 22:35:45 +04:00
parent eb6945b017
commit 4370c523e6
7 changed files with 14 additions and 33 deletions

View File

@ -101,6 +101,7 @@ public class InputHandler {
double x, double y
) {
if (GraphicsBackend.getWindowHandle() != window) return;
y = GraphicsInterface.getFrameHeight() - y; // Flip y axis
InputTracker.initializeCursorPosition(x, y);

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Progressia
* Optica
* Copyright (C) 2020 Wind Corporation
*
* This program is free software: you can redistribute it and/or modify
@ -36,8 +36,8 @@ public abstract class FlatRenderHelper extends ShapeRenderHelper {
float width = GraphicsInterface.getFrameWidth();
float height = GraphicsInterface.getFrameHeight();
return finalTransform.identity().translate(-1, +1, 0)
.scale(2 / width, -2 / height, 1 / MAX_DEPTH)
return finalTransform.identity().translate(-1, -1, 0)
.scale(2 / width, 2 / height, 1 / MAX_DEPTH)
.mul(getTransform());
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Progressia
* Optica
* Copyright (C) 2020 Wind Corporation
*
* This program is free software: you can redistribute it and/or modify
@ -104,14 +104,6 @@ public class FlatRenderProgram extends ShapeRenderProgram {
masks.flip();
masksUniform.set(masks);
// for (int i = 0; i < pos; ++i) {
// if (i % TransformedMask.SIZE_IN_FLOATS == 0) {
// System.out.print(" | ");
// }
// System.out.print(masks.get(i) + "; ");
// }
// System.out.println();
masks.limit(limit);
masks.position(pos);
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Progressia
* Optica
* Copyright (C) 2020 Wind Corporation
*
* This program is free software: you can redistribute it and/or modify
@ -52,9 +52,9 @@ public class LayerTestUI extends AssembledFlatLayer {
final int boxShadowColor = flag ? 0x440000 : 0x444400;
int x = (getWidth() - WIDTH) / 2;
int y = getHeight() - HEIGHT - 2*BORDER;
int y = 2*BORDER;
target.fill(x + BORDER, y + BORDER, WIDTH, HEIGHT, boxShadowColor);
target.fill(x + BORDER, y - BORDER, WIDTH, HEIGHT, boxShadowColor);
target.fill(x - 1, y - 1, WIDTH + 2, HEIGHT + 2, boxShadowColor);
target.fill(x, y, WIDTH, HEIGHT, borderColor);
target.fill(x + BORDER, y + BORDER, WIDTH - 2*BORDER, HEIGHT - 2*BORDER, boxColor);
@ -67,7 +67,7 @@ public class LayerTestUI extends AssembledFlatLayer {
final Texture compassBg = SimpleTextures.get("compass_icon");
final Texture compassFg = SimpleTextures.get("compass_icon_arrow");
target.drawTexture(texShadow, texShadow, texSize, texSize, Colors.BLACK, compassBg);
target.drawTexture(texShadow, -texShadow, texSize, texSize, Colors.BLACK, compassBg);
target.drawTexture(0, 0, texSize, texSize, compassBg);
target.addCustomRenderer(new LambdaModel(LambdaModel.lambdaBuilder()

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Progressia
* Optica
* Copyright (C) 2020 Wind Corporation
*
* This program is free software: you can redistribute it and/or modify
@ -228,9 +228,9 @@ public class RenderTarget {
FlatRenderProgram.getDefault(),
texture,
createVectorFromRGBInt(color),
new Vec3(x, y + height, depth), // Flip
new Vec3(x, y, depth),
new Vec3(width, 0, 0),
new Vec3(0, -height, 0)
new Vec3(0, height, 0)
);
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Progressia
* Optica
* Copyright (C) 2020 Wind Corporation
*
* This program is free software: you can redistribute it and/or modify
@ -22,7 +22,6 @@ import java.nio.FloatBuffer;
import glm.mat._4.Mat4;
import glm.vec._2.Vec2;
import glm.vec._4.Vec4;
import ru.windcorp.progressia.client.graphics.backend.GraphicsInterface;
public class TransformedMask {
@ -92,8 +91,6 @@ public class TransformedMask {
transform.mul(startXendY);
transform.mul(endXstartY);
transform.mul(endXendY);
flipY();
}
private void ensureTemporaryVariablesExist() {
@ -105,15 +102,6 @@ public class TransformedMask {
}
}
private void flipY() {
float height = GraphicsInterface.getFrameHeight();
startXstartY.y = height - startXstartY.y;
startXendY.y = height - startXendY.y;
endXstartY.y = height - endXstartY.y;
endXendY.y = height - endXendY.y;
}
private void setFields() {
origin.set(
startXstartY.x,

View File

@ -190,7 +190,7 @@ public class LayerWorld extends Layer {
if (!flag) return;
final float yawScale = 0.002f;
final float pitchScale = yawScale;
final float pitchScale = -yawScale;
camera.turn(
(float) (event.getChangeY() * pitchScale),