|
@@ -3,6 +3,7 @@ package xyz.tbvns;
|
|
import com.badlogic.gdx.ApplicationAdapter;
|
|
import com.badlogic.gdx.ApplicationAdapter;
|
|
import com.badlogic.gdx.Gdx;
|
|
import com.badlogic.gdx.Gdx;
|
|
import com.badlogic.gdx.Input;
|
|
import com.badlogic.gdx.Input;
|
|
|
|
+import com.badlogic.gdx.InputProcessor;
|
|
import com.badlogic.gdx.graphics.Camera;
|
|
import com.badlogic.gdx.graphics.Camera;
|
|
import com.badlogic.gdx.graphics.GL20;
|
|
import com.badlogic.gdx.graphics.GL20;
|
|
import com.badlogic.gdx.graphics.PerspectiveCamera;
|
|
import com.badlogic.gdx.graphics.PerspectiveCamera;
|
|
@@ -14,6 +15,7 @@ import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
|
|
import com.badlogic.gdx.math.Vector3;
|
|
import com.badlogic.gdx.math.Vector3;
|
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
|
import xyz.tbvns.Inputs.Shortcut;
|
|
import xyz.tbvns.Inputs.Shortcut;
|
|
|
|
+import xyz.tbvns.Inputs.inputManager;
|
|
import xyz.tbvns.LWJGL3.CustomViewport;
|
|
import xyz.tbvns.LWJGL3.CustomViewport;
|
|
import xyz.tbvns.ui.Ui;
|
|
import xyz.tbvns.ui.Ui;
|
|
|
|
|
|
@@ -28,7 +30,7 @@ public class Main extends ApplicationAdapter {
|
|
private Model levelGrid;
|
|
private Model levelGrid;
|
|
private ModelInstance worldGridInstance;
|
|
private ModelInstance worldGridInstance;
|
|
private ModelInstance levelGridInstance;
|
|
private ModelInstance levelGridInstance;
|
|
- private CameraInputController cameraInputController;
|
|
|
|
|
|
+ private InputProcessor cameraInputController;
|
|
private Viewport viewport;
|
|
private Viewport viewport;
|
|
public static ModelCache modelCache;
|
|
public static ModelCache modelCache;
|
|
|
|
|
|
@@ -37,8 +39,8 @@ public class Main extends ApplicationAdapter {
|
|
Ui.initImGui();
|
|
Ui.initImGui();
|
|
batch = new ModelBatch();
|
|
batch = new ModelBatch();
|
|
camera = new PerspectiveCamera(80, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
camera = new PerspectiveCamera(80, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
- camera.far = Integer.MAX_VALUE;
|
|
|
|
- camera.near = 0.000000000001f;
|
|
|
|
|
|
+ camera.far = 1000;
|
|
|
|
+ camera.near = 0.01f;
|
|
viewport = new CustomViewport(camera);
|
|
viewport = new CustomViewport(camera);
|
|
|
|
|
|
image = new Texture("libgdx.png");
|
|
image = new Texture("libgdx.png");
|
|
@@ -53,11 +55,11 @@ public class Main extends ApplicationAdapter {
|
|
levelGridInstance.transform.setToRotation(new Vector3(1, 0, 0), 90);
|
|
levelGridInstance.transform.setToRotation(new Vector3(1, 0, 0), 90);
|
|
levelGridInstance.transform.setTranslation(new Vector3(0, 50, 0));
|
|
levelGridInstance.transform.setTranslation(new Vector3(0, 50, 0));
|
|
|
|
|
|
- cameraInputController = new CameraInputController(camera);
|
|
|
|
- cameraInputController.forwardKey = Input.Keys.W;
|
|
|
|
- cameraInputController.backwardKey = Input.Keys.S;
|
|
|
|
- cameraInputController.rotateRightKey = -1;
|
|
|
|
- cameraInputController.rotateLeftKey = -1;
|
|
|
|
|
|
+ cameraInputController = new inputManager(camera);
|
|
|
|
+// cameraInputController.forwardKey = Input.Keys.W;
|
|
|
|
+// cameraInputController.backwardKey = Input.Keys.S;
|
|
|
|
+// cameraInputController.rotateRightKey = -1;
|
|
|
|
+// cameraInputController.rotateLeftKey = -1;
|
|
Gdx.input.setInputProcessor(cameraInputController);
|
|
Gdx.input.setInputProcessor(cameraInputController);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -73,7 +75,7 @@ public class Main extends ApplicationAdapter {
|
|
|
|
|
|
Vector3 gridPos = new Vector3(camera.position);
|
|
Vector3 gridPos = new Vector3(camera.position);
|
|
gridPos.x = Math.round(gridPos.x);
|
|
gridPos.x = Math.round(gridPos.x);
|
|
- gridPos.y = 0;
|
|
|
|
|
|
+ gridPos.y = -0.01f;
|
|
gridPos.z = Math.round(gridPos.z);
|
|
gridPos.z = Math.round(gridPos.z);
|
|
|
|
|
|
worldGridInstance.transform.setTranslation(gridPos);
|
|
worldGridInstance.transform.setTranslation(gridPos);
|
|
@@ -85,13 +87,13 @@ public class Main extends ApplicationAdapter {
|
|
|
|
|
|
levelGridInstance.transform.setTranslation(gridPos);
|
|
levelGridInstance.transform.setTranslation(gridPos);
|
|
|
|
|
|
- cameraInputController.update();
|
|
|
|
|
|
+// cameraInputController.update();
|
|
batch.begin(camera);
|
|
batch.begin(camera);
|
|
- batch.render(worldGridInstance);
|
|
|
|
- batch.render(levelGridInstance);
|
|
|
|
if (modelCache != null) {
|
|
if (modelCache != null) {
|
|
batch.render(modelCache);
|
|
batch.render(modelCache);
|
|
}
|
|
}
|
|
|
|
+ batch.render(worldGridInstance);
|
|
|
|
+ batch.render(levelGridInstance);
|
|
batch.end();
|
|
batch.end();
|
|
Ui.render();
|
|
Ui.render();
|
|
Shortcut.check();
|
|
Shortcut.check();
|