Skip to content

Commit b9de3f9

Browse files
committed
Feat: Added default camera. Refactoring Renamed displayInfoText to
displayInfo Fix: fpsGraph hide
1 parent c28e778 commit b9de3f9

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/main/java/engine/application/BasicApplication.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package engine.application;
22

33
import engine.Timer;
4+
import engine.components.FlyByCameraControl;
45
import engine.debug.DebugInfoUpdater;
56
import engine.debug.DebugOverlay;
67
import engine.debug.FpsGraph;
@@ -10,13 +11,14 @@
1011
import engine.processing.ProcessingApplication;
1112
import engine.scene.Scene;
1213
import engine.scene.SceneNode;
14+
import engine.scene.camera.PerspectiveCamera;
1315
import workspace.ui.Graphics;
1416

1517
public abstract class BasicApplication implements Application {
1618

1719
private boolean launched;
1820

19-
private boolean displayInfoText = true;
21+
private boolean displayInfo = true;
2022

2123
private boolean isPaused = false;
2224

@@ -74,6 +76,18 @@ public void initialize() {
7476
initializeDebugOverlay();
7577
fpsGraph = new FpsGraph(new FpsHistory());
7678
onInitialize();
79+
setupDefaultCamera();
80+
}
81+
82+
private void setupDefaultCamera() {
83+
if (activeScene == null) return;
84+
if (activeScene.getActiveCamera() != null) return;
85+
86+
PerspectiveCamera defaultCamera = new PerspectiveCamera();
87+
activeScene.setActiveCamera(defaultCamera);
88+
SceneNode cameraNode = new SceneNode("DefaultCamera");
89+
cameraNode.addComponent(new FlyByCameraControl(input, defaultCamera));
90+
activeScene.addNode(cameraNode);
7791
}
7892

7993
private void initializeDebugOverlay() {
@@ -110,7 +124,7 @@ public void update() {
110124
}
111125

112126
@Override
113-
public void render(Graphics g) {
127+
public void render(Graphics g) {
114128
if (activeScene != null) {
115129
activeScene.render(g);
116130
}
@@ -124,7 +138,7 @@ public void render(Graphics g) {
124138
g.strokeWeight(1);
125139
renderUi(g);
126140
renderDebugUi(g);
127-
fpsGraph.render(g);
141+
128142

129143
g.enableDepthTest();
130144
}
@@ -134,8 +148,9 @@ private void renderUi(Graphics g) {
134148
}
135149

136150
private void renderDebugUi(Graphics g) {
137-
if (!displayInfoText) return;
151+
if (!displayInfo) return;
138152
debugOverlay.render(g);
153+
fpsGraph.render(g);
139154
}
140155

141156
@Override
@@ -170,8 +185,8 @@ public Scene getActiveScene() {
170185
public void setActiveScene(Scene activeScene) {
171186
this.activeScene = activeScene;
172187
}
173-
174-
public void setDisplayInfoText(boolean displayInfoText) {
175-
this.displayInfoText = displayInfoText;
188+
189+
public void setDisplayInfo(boolean displayInfo) {
190+
this.displayInfo = displayInfo;
176191
}
177192
}

0 commit comments

Comments
 (0)