11package engine .application ;
22
33import engine .Timer ;
4+ import engine .components .FlyByCameraControl ;
45import engine .debug .DebugInfoUpdater ;
56import engine .debug .DebugOverlay ;
67import engine .debug .FpsGraph ;
1011import engine .processing .ProcessingApplication ;
1112import engine .scene .Scene ;
1213import engine .scene .SceneNode ;
14+ import engine .scene .camera .PerspectiveCamera ;
1315import workspace .ui .Graphics ;
1416
1517public 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