Skip to content

Commit c17fbee

Browse files
committed
Initial commit
0 parents  commit c17fbee

File tree

87 files changed

+5931
-0
lines changed

Some content is hidden

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

87 files changed

+5931
-0
lines changed

.classpath

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src"/>
9+
<classpathentry kind="lib" path="lib/lwjgl_util.jar">
10+
<attributes>
11+
<attribute name="module" value="true"/>
12+
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="world/lib/natives"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="lib" path="lib/lwjgl.jar">
16+
<attributes>
17+
<attribute name="module" value="true"/>
18+
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="world/lib/natives"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="lib" path="lib/power-voronoi-diagram.jar">
22+
<attributes>
23+
<attribute name="module" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="lib" path="lib/slick-util.jar">
27+
<attributes>
28+
<attribute name="module" value="true"/>
29+
</attributes>
30+
</classpathentry>
31+
<classpathentry kind="lib" path="lib/slick.jar">
32+
<attributes>
33+
<attribute name="module" value="true"/>
34+
</attributes>
35+
</classpathentry>
36+
<classpathentry kind="output" path="bin"/>
37+
</classpath>

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
10+
# Mobile Tools for Java (J2ME)
11+
.mtj.tmp/
12+
13+
# Package Files #
14+
*.jar
15+
*.war
16+
*.nar
17+
*.ear
18+
*.zip
19+
*.tar.gz
20+
*.rar
21+
22+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23+
hs_err_pid*

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>world</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=11
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.release=enabled
12+
org.eclipse.jdt.core.compiler.source=11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#version 330
2+
3+
in vec2 pass_textureCoords;
4+
5+
out vec4 out_colour;
6+
7+
uniform vec3 colour;
8+
uniform sampler2D fontAtlas;
9+
10+
void main(void){
11+
12+
out_colour = vec4(colour, texture(fontAtlas, pass_textureCoords).a);
13+
//out_colour = vec4(colour, 0);
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#version 330
2+
3+
in vec2 position;
4+
in vec2 textureCoords;
5+
6+
out vec2 pass_textureCoords;
7+
8+
uniform vec2 translation;
9+
10+
void main(void){
11+
12+
gl_Position = vec4(position + translation*vec2(2.0, -2.0) - vec2(1.0, 0.0), 0.0, 1.0);
13+
pass_textureCoords = textureCoords;
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#version 140
2+
3+
in vec2 textureCoords;
4+
5+
out vec4 out_Color;
6+
7+
uniform sampler2D guiTexture;
8+
uniform vec4 colour;
9+
10+
void main(void){
11+
12+
out_Color = texture(guiTexture,textureCoords);
13+
out_Color.a = colour.a;
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#version 140
2+
3+
in vec2 position;
4+
5+
out vec2 textureCoords;
6+
7+
uniform mat4 transformationMatrix;
8+
9+
void main(void){
10+
11+
gl_Position = transformationMatrix*vec4(position, 0.0, 1.0);
12+
textureCoords = vec2((position.x+1.0)/2.0, 1 - (position.y+1.0)/2.0);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#version 400 core
2+
3+
//in vec3 color;
4+
in vec2 passTextureCoords;
5+
in vec3 surfaceNormal;
6+
in vec3 toLightVector;
7+
in vec3 toCameraVector;
8+
9+
out vec4 outColor;
10+
11+
uniform sampler2D textureSampler;
12+
uniform vec3 lightColor;
13+
uniform float shineDamper;
14+
uniform float reflectness;
15+
16+
void main(void)
17+
{
18+
vec3 unitNormal = normalize(surfaceNormal);
19+
vec3 unitLightVector = normalize(toLightVector);
20+
21+
float nDot1 = dot(unitNormal, unitLightVector);
22+
float brightness = max(nDot1, 0.35);
23+
vec3 diffuse = brightness * lightColor;
24+
25+
vec3 unitToCameraVector = normalize(toCameraVector);
26+
vec3 lightDirection = -unitLightVector;
27+
vec3 reflectedLight = reflect(lightDirection, unitNormal);
28+
29+
float specular = dot(reflectedLight, unitToCameraVector);
30+
specular = max(specular, 0.0);
31+
float dampedFactor = pow(specular, shineDamper);
32+
vec3 finalSpecular = dampedFactor * reflectness * lightColor;
33+
34+
vec4 textureColor = texture(textureSampler, passTextureCoords);
35+
if (textureColor.a < 0.5)
36+
{
37+
discard;
38+
}
39+
40+
//outColor = vec4(color,1.0);
41+
//Linear interpolation of textures, by sampling the 2D texture by input coordinates
42+
outColor = vec4(diffuse,1.0) * texture(textureSampler, passTextureCoords) + vec4(finalSpecular, 1.0);
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#version 400 core
2+
3+
in vec3 position;
4+
in vec2 textureCoords;
5+
in vec3 normal;
6+
7+
//out vec3 color;
8+
out vec2 passTextureCoords;
9+
out vec3 surfaceNormal;
10+
out vec3 toLightVector;
11+
out vec3 toCameraVector;
12+
13+
uniform mat4 transformMatrix;
14+
uniform mat4 projectionMatrix;
15+
uniform mat4 viewMatrix;
16+
uniform vec3 lightPosition;
17+
18+
uniform float fastLighting;
19+
20+
void main(void)
21+
{
22+
vec4 worldPosition = transformMatrix * vec4(position,1.0);
23+
24+
gl_Position = projectionMatrix * viewMatrix * worldPosition;
25+
//color = vec3(position.x+0.5,1.0,position.y+0.5);
26+
passTextureCoords = textureCoords;
27+
28+
vec3 actualNormal = normal;
29+
if (fastLighting > 0.5)
30+
{
31+
actualNormal = vec3(0.0,1.0,0.0); //point upward
32+
}
33+
34+
surfaceNormal = (transformMatrix * vec4(actualNormal, 0.0)).xyz;
35+
toLightVector = lightPosition - worldPosition.xyz;
36+
toCameraVector = (inverse(viewMatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;
37+
}

lib/natives/OpenAL.dll

262 KB
Binary file not shown.

lib/natives/OpenAL32.dll

225 KB
Binary file not shown.

lib/natives/liblwjgl.dylib

812 KB
Binary file not shown.

lib/natives/liblwjgl.so

491 KB
Binary file not shown.

lib/natives/liblwjgl32.so

446 KB
Binary file not shown.

lib/natives/libopenal.dylib

498 KB
Binary file not shown.

lib/natives/libopenal.so

210 KB
Binary file not shown.

lib/natives/libopenal32.so

185 KB
Binary file not shown.

lib/natives/lwjgl.dll

362 KB
Binary file not shown.

lib/natives/lwjgl32.dll

347 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.github.dantetam.localdata;
2+
3+
public class ConstantData {
4+
5+
public static final String MOUSE_HIGHLIGHT_NO_CLICK = "_highlight";
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package io.github.dantetam.lwjglEngine.entities;
2+
3+
import org.lwjgl.glfw.GLFW;
4+
import org.lwjgl.util.vector.Vector3f;
5+
6+
import io.github.dantetam.lwjglEngine.gui.Keyboard;
7+
8+
//There is no real camera in OpenGL
9+
//Every object in the world must be moved in the opposite direction of the camera's movement
10+
11+
public class Camera {
12+
13+
public Vector3f position = new Vector3f(500, 100, 500);
14+
public float pitch = -10, yaw = 0, roll = 0; // High-low, left-right, tilt
15+
private float jerkPitch, jerkYaw;
16+
private int turnsPitch, turnsYaw;
17+
private static final float LOWER_BOUND_Y = 40, UPPER_BOUND_Y = 400;
18+
19+
public Camera() {
20+
21+
}
22+
// public Camera(Vector3f p, float a, float b, float c) {}
23+
24+
// Allow the user to focus on the point (x, z) from a top-view perspective
25+
public void focusCamera(float x, float z, float angPitch) {
26+
float distanceBack = Math.abs(position.y / (float) Math.tan(angPitch));
27+
position = new Vector3f(x, position.y, z + distanceBack);
28+
turnsPitch = 20;
29+
turnsYaw = 20;
30+
// jerkPitch =
31+
// -(pitch-(float)Math.toDegrees(Math.atan(position.y/20F)))/(float)turnsPitch;
32+
jerkPitch = -(pitch + angPitch) / (float) turnsPitch;
33+
jerkYaw = -(yaw) / (float) turnsYaw;
34+
// pitch = 0; yaw = 0; roll = 0;
35+
}
36+
37+
/**
38+
* Move the camera with either 'stored' movement or user key holds (from native JOGL bindings).
39+
* @return True if
40+
*/
41+
public boolean move() {
42+
if (turnsPitch > 0 || turnsYaw > 0) {
43+
if (turnsPitch > 0) {
44+
pitch += jerkPitch;
45+
turnsPitch--;
46+
}
47+
if (turnsYaw > 0) {
48+
yaw += jerkYaw;
49+
turnsYaw--;
50+
}
51+
return true; // Override keyboard when camera is being shifted
52+
}
53+
float step = 5f, tilt = 1f;
54+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_I)) {
55+
position.y -= step;
56+
if (position.y < LOWER_BOUND_Y) {
57+
position.y = LOWER_BOUND_Y;
58+
}
59+
}
60+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_O)) {
61+
position.y += step;
62+
if (position.y > UPPER_BOUND_Y) {
63+
position.y = UPPER_BOUND_Y;
64+
}
65+
}
66+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_A)) {
67+
position.x -= step * Math.cos(Math.toRadians(yaw));
68+
position.z -= step * Math.sin(Math.toRadians(yaw));
69+
}
70+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_D)) {
71+
position.x += step * Math.cos(Math.toRadians(yaw));
72+
position.z += step * Math.sin(Math.toRadians(yaw));
73+
}
74+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_S)) {
75+
// laziness, oops
76+
position.x -= step * Math.cos(Math.toRadians(yaw - 90));
77+
position.z -= step * Math.sin(Math.toRadians(yaw - 90));
78+
}
79+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_W)) {
80+
// +90 is clockwise, this is a right turn from pointing left (the 'a' command)
81+
position.x -= step * Math.cos(Math.toRadians(yaw + 90));
82+
position.z -= step * Math.sin(Math.toRadians(yaw + 90));
83+
}
84+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_Q))
85+
yaw -= tilt * 1f;
86+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_E))
87+
yaw += tilt * 1f;
88+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_H))
89+
yaw -= tilt * 1f;
90+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_K))
91+
yaw += tilt * 1f;
92+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_U))
93+
pitch -= tilt;
94+
if (Keyboard.isKeyDown(GLFW.GLFW_KEY_J))
95+
pitch += tilt;
96+
97+
int[] inputKeys = new int[] {GLFW.GLFW_KEY_A, GLFW.GLFW_KEY_D, GLFW.GLFW_KEY_S, GLFW.GLFW_KEY_W,
98+
GLFW.GLFW_KEY_Q, GLFW.GLFW_KEY_E, GLFW.GLFW_KEY_H, GLFW.GLFW_KEY_K, GLFW.GLFW_KEY_U, GLFW.GLFW_KEY_J,
99+
GLFW.GLFW_KEY_I, GLFW.GLFW_KEY_O};
100+
for (int inputKey: inputKeys) {
101+
if (Keyboard.isKeyDown(inputKey)) {
102+
return true;
103+
}
104+
}
105+
return false;
106+
}
107+
108+
}

0 commit comments

Comments
 (0)