Skip to content

Commit dc55420

Browse files
Merge pull request #76 from ArtifactForms/working2
Working2
2 parents a70c2f2 + 19166a7 commit dc55420

65 files changed

Lines changed: 5016 additions & 668 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 102 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,104 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<groupId>MeshLibCore</groupId>
6-
<artifactId>MeshLibCore</artifactId>
7-
<version>0.0.1-SNAPSHOT</version>
8-
<build>
9-
<sourceDirectory>src/main/java</sourceDirectory>
10-
<testSourceDirectory>src/test/java</testSourceDirectory>
11-
<plugins>
12-
<plugin>
13-
<artifactId>maven-compiler-plugin</artifactId>
14-
<version>3.8.1</version>
15-
<configuration>
16-
<release>15</release>
17-
</configuration>
18-
</plugin>
19-
<plugin>
20-
<groupId>org.apache.maven.plugins</groupId>
21-
<artifactId>maven-surefire-plugin</artifactId>
22-
<version>2.22.2</version>
23-
<configuration>
24-
</configuration>
25-
</plugin>
26-
</plugins>
27-
</build>
28-
<repositories>
29-
<repository>
30-
<name>JoGL Distrib</name>
31-
<id>org.jogamp</id>
32-
<url>https://www.jogamp.org/deployment/maven/</url>
33-
</repository>
34-
</repositories>
35-
<distributionManagement>
36-
<repository>
37-
<id>github</id>
38-
<name>GitHub ArtifactForms Apache Maven Packages</name>
39-
<url>https://maven.pkg.github.com/ArtifactForms/MeshLibCore/master</url>
40-
<releases>
41-
<enabled>true</enabled>
42-
</releases>
43-
<snapshots>
44-
<enabled>true</enabled>
45-
</snapshots>
46-
</repository>
47-
</distributionManagement>
48-
<dependencies>
49-
<dependency>
50-
<groupId>org.processing</groupId>
51-
<artifactId>core</artifactId>
52-
<version>4.3.1</version>
53-
</dependency>
54-
<dependency>
55-
<groupId>org.jogamp.gluegen</groupId>
56-
<artifactId>gluegen-rt-main</artifactId>
57-
<version>2.5.0</version>
58-
</dependency>
59-
<dependency>
60-
<groupId>org.jogamp.jogl</groupId>
61-
<artifactId>jogl-all-main</artifactId>
62-
<version>2.5.0</version>
63-
</dependency>
64-
<dependency>
65-
<groupId>org.junit.platform</groupId>
66-
<artifactId>junit-platform-runner</artifactId>
67-
<version>1.2.0</version>
68-
<scope>test</scope>
69-
</dependency>
70-
<dependency>
71-
<groupId>org.junit.jupiter</groupId>
72-
<artifactId>junit-jupiter-engine</artifactId>
73-
<version>5.4.0</version>
74-
<scope>test</scope>
75-
</dependency>
76-
<dependency>
77-
<groupId>org.junit.jupiter</groupId>
78-
<artifactId>junit-jupiter-params</artifactId>
79-
<version>5.4.0</version>
80-
<scope>test</scope>
81-
</dependency>
82-
<dependency>
83-
<groupId>org.junit.jupiter</groupId>
84-
<artifactId>junit-jupiter-api</artifactId>
85-
<version>5.4.0</version>
86-
<scope>test</scope>
87-
</dependency>
88-
<dependency>
89-
<groupId>org.jacoco</groupId>
90-
<artifactId>jacoco-maven-plugin</artifactId>
91-
<version>0.8.10</version>
92-
</dependency>
93-
</dependencies>
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>MeshLibCore</groupId>
6+
<artifactId>MeshLibCore</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<build>
9+
<sourceDirectory>src/main/java</sourceDirectory>
10+
<testSourceDirectory>src/test/java</testSourceDirectory>
11+
<plugins>
12+
<plugin>
13+
<artifactId>maven-compiler-plugin</artifactId>
14+
<version>3.8.1</version>
15+
<configuration>
16+
<release>15</release>
17+
</configuration>
18+
</plugin>
19+
<plugin>
20+
<groupId>org.apache.maven.plugins</groupId>
21+
<artifactId>maven-surefire-plugin</artifactId>
22+
<version>2.22.2</version>
23+
<configuration>
24+
</configuration>
25+
</plugin>
26+
</plugins>
27+
</build>
28+
<repositories>
29+
<repository>
30+
<name>JoGL Distrib</name>
31+
<id>org.jogamp</id>
32+
<url>https://www.jogamp.org/deployment/maven/</url>
33+
</repository>
34+
</repositories>
35+
<distributionManagement>
36+
<repository>
37+
<id>github</id>
38+
<name>GitHub ArtifactForms Apache Maven Packages</name>
39+
<url>https://maven.pkg.github.com/ArtifactForms/MeshLibCore/master</url>
40+
<releases>
41+
<enabled>true</enabled>
42+
</releases>
43+
<snapshots>
44+
<enabled>true</enabled>
45+
</snapshots>
46+
</repository>
47+
</distributionManagement>
48+
<dependencies>
49+
<dependency>
50+
<groupId>org.processing</groupId>
51+
<artifactId>core</artifactId>
52+
<version>3.3.7</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.jogamp.gluegen</groupId>
56+
<artifactId>gluegen-rt-main</artifactId>
57+
<version>2.5.0</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.jogamp.jogl</groupId>
61+
<artifactId>jogl-all-main</artifactId>
62+
<version>2.5.0</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.junit.platform</groupId>
66+
<artifactId>junit-platform-runner</artifactId>
67+
<version>1.2.0</version>
68+
<scope>test</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.junit.jupiter</groupId>
72+
<artifactId>junit-jupiter-engine</artifactId>
73+
<version>5.4.0</version>
74+
<scope>test</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.junit.jupiter</groupId>
78+
<artifactId>junit-jupiter-params</artifactId>
79+
<version>5.4.0</version>
80+
<scope>test</scope>
81+
</dependency>
82+
<dependency>
83+
<groupId>org.junit.jupiter</groupId>
84+
<artifactId>junit-jupiter-api</artifactId>
85+
<version>5.4.0</version>
86+
<scope>test</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>org.jacoco</groupId>
90+
<artifactId>jacoco-maven-plugin</artifactId>
91+
<version>0.8.10</version>
92+
</dependency>
93+
<dependency>
94+
<groupId>com.google.code.gson</groupId>
95+
<artifactId>gson</artifactId>
96+
<version>2.10.1</version>
97+
</dependency>
98+
<dependency>
99+
<groupId>net.java.jinput</groupId>
100+
<artifactId>jinput</artifactId>
101+
<version>2.0.9</version>
102+
</dependency>
103+
</dependencies>
94104
</project>

src/main/java/engine/application/ApplicationSettings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class ApplicationSettings {
1616

1717
private String title;
1818

19+
private boolean useGamePadInput;
20+
1921
/**
2022
* Constructs an ApplicationSettings instance with default values:
2123
*
@@ -31,6 +33,7 @@ public ApplicationSettings() {
3133
this.height = 768;
3234
this.fullscreen = false;
3335
this.title = DEFAULT_TITLE;
36+
this.useGamePadInput = false;
3437
}
3538

3639
/**
@@ -132,4 +135,12 @@ public void setTitle(String title) {
132135
}
133136
this.title = title;
134137
}
138+
139+
public boolean isUseGamePadInput() {
140+
return useGamePadInput;
141+
}
142+
143+
public void setUseGamePadInput(boolean useGamePadInput) {
144+
this.useGamePadInput = useGamePadInput;
145+
}
135146
}

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

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

33
import engine.Timer;
4-
import engine.components.FlyByCameraControl;
54
import engine.components.SmoothFlyByCameraControl;
65
import engine.debug.DebugInfoUpdater;
76
import engine.debug.DebugOverlay;
@@ -14,10 +13,13 @@
1413
import engine.scene.Scene;
1514
import engine.scene.SceneNode;
1615
import engine.scene.camera.PerspectiveCamera;
16+
import math.Mathf;
1717
import workspace.ui.Graphics;
1818

1919
public abstract class BasicApplication implements Application {
2020

21+
private static final float MAX_TPF = 1f / 60f;
22+
2123
private boolean launched;
2224

2325
private boolean displayInfo = true;
@@ -38,6 +40,10 @@ public abstract class BasicApplication implements Application {
3840

3941
protected FpsGraph fpsGraph;
4042

43+
private Viewport viewport;
44+
45+
private ApplicationSettings settings;
46+
4147
public BasicApplication() {
4248
this.timer = new Timer();
4349
}
@@ -56,6 +62,7 @@ public void launch(ApplicationSettings settings) {
5662
if (launched) {
5763
throw new IllegalStateException("Application already launched.");
5864
}
65+
this.settings = settings;
5966
launched = true;
6067
ApplicationContainer container = new ApplicationContainer(this);
6168
ProcessingApplication.launchApplication(container, settings);
@@ -74,7 +81,8 @@ public void launch() {
7481

7582
@Override
7683
public void initialize() {
77-
rootUI = new SceneNode();
84+
viewport = new Viewport(0, 0, settings.getWidth(), settings.getHeight());
85+
rootUI = new SceneNode("RootUI");
7886
initializeDebugOverlay();
7987
fpsGraph = new FpsGraph(new FpsHistory());
8088
onInitialize();
@@ -107,20 +115,25 @@ public void update() {
107115

108116
lastZ = input.isKeyPressed(Key.Z);
109117
}
118+
110119
timer.update();
111120
input.update();
121+
input.updateKeyState();
122+
if (settings.isUseGamePadInput())
123+
input.updateGamepadState();
124+
112125
fpsGraph.update(timer);
113126
debugInfoUpdater.update(timer, activeScene, input);
114127

115128
float tpf = timer.getTimePerFrame();
116-
if (input != null) {
117-
input.update();
118-
}
129+
tpf = Mathf.clamp(tpf, 0, MAX_TPF);
130+
119131
if (!isPaused) {
120132
if (activeScene != null) {
121133
activeScene.update(tpf);
122134
}
123135
}
136+
124137
rootUI.update(tpf);
125138
onUpdate(tpf);
126139
}
@@ -191,4 +204,8 @@ public void setActiveScene(Scene activeScene) {
191204
public void setDisplayInfo(boolean displayInfo) {
192205
this.displayInfo = displayInfo;
193206
}
207+
208+
public Viewport getViewport() {
209+
return viewport;
210+
}
194211
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package engine.application;
2+
3+
public final class Viewport {
4+
5+
private int x;
6+
private int y;
7+
private int width;
8+
private int height;
9+
10+
public Viewport(int x, int y, int width, int height) {
11+
this.x = x;
12+
this.y = y;
13+
this.width = width;
14+
this.height = height;
15+
}
16+
17+
public int getX() {
18+
return x;
19+
}
20+
21+
public int getY() {
22+
return y;
23+
}
24+
25+
public int getWidth() {
26+
return width;
27+
}
28+
29+
public int getHeight() {
30+
return height;
31+
}
32+
33+
public float getAspectRatio() {
34+
return (float) width / (float) height;
35+
}
36+
37+
public boolean contains(int px, int py) {
38+
return px >= x && py >= y && px < x + width && py < y + height;
39+
}
40+
}

0 commit comments

Comments
 (0)