"Games done"

pull/1/head
hYdos 2020-02-24 06:30:08 +10:00
parent 2803856e95
commit 2b428fa829
789 changed files with 276 additions and 19 deletions

View File

@ -2,6 +2,7 @@ package io.github.hydos.ginger;
import io.github.hydos.ginger.engine.api.*; import io.github.hydos.ginger.engine.api.*;
import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.cameras.Camera;
import io.github.hydos.ginger.engine.elements.GuiTexture;
import io.github.hydos.ginger.engine.elements.buttons.TextureButton; import io.github.hydos.ginger.engine.elements.buttons.TextureButton;
import io.github.hydos.ginger.engine.elements.objects.*; import io.github.hydos.ginger.engine.elements.objects.*;
import io.github.hydos.ginger.engine.font.*; import io.github.hydos.ginger.engine.font.*;
@ -9,6 +10,7 @@ import io.github.hydos.ginger.engine.io.Window;
import io.github.hydos.ginger.engine.math.vectors.*; import io.github.hydos.ginger.engine.math.vectors.*;
import io.github.hydos.ginger.engine.obj.ModelLoader; import io.github.hydos.ginger.engine.obj.ModelLoader;
import io.github.hydos.ginger.engine.obj.normals.NormalMappedObjLoader; import io.github.hydos.ginger.engine.obj.normals.NormalMappedObjLoader;
import io.github.hydos.ginger.engine.obj.shapes.StaticCube;
import io.github.hydos.ginger.engine.particle.*; import io.github.hydos.ginger.engine.particle.*;
import io.github.hydos.ginger.engine.render.MasterRenderer; import io.github.hydos.ginger.engine.render.MasterRenderer;
import io.github.hydos.ginger.engine.render.models.TexturedModel; import io.github.hydos.ginger.engine.render.models.TexturedModel;
@ -29,19 +31,19 @@ public class Example extends Game{
Constants.gravity = -0.000000000005f; Constants.gravity = -0.000000000005f;
Constants.jumpPower = 0.000005f; Constants.jumpPower = 0.000005f;
Window.create(1200, 800, "Horse Game 1.0.0", 60); Window.create(1200, 800, "LiteCraft", 60);
GingerMain.init(); GingerMain.init();
Window.setBackgroundColour(0.2f, 0.2f, 0.8f); Window.setBackgroundColour(0.2f, 0.2f, 0.8f);
StaticCube.scaleCube(6);
TexturedModel tModel = ModelLoader.loadModel("Zebra.obj", "stallTexture.png"); TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/soil/dirt.png");
tModel.getTexture().setReflectivity(1f); dirtModel.getTexture().setReflectivity(10f);
tModel.getTexture().setShineDamper(7f); Player player = new Player(dirtModel, new Vector3f(0,0,-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f));
Player player = new Player(tModel, new Vector3f(0,0,-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f));
Camera camera = new Camera(new Vector3f(0,0.1f,0), player); Camera camera = new Camera(new Vector3f(0,0.1f,0), player);
ginger3D = new Ginger(); ginger3D = new Ginger();
data = new GameData(player, camera); data = new GameData(player, camera);
data.handleGuis = false; data.handleGuis = false;
ginger3D.setup(new MasterRenderer(data.camera), data); ginger3D.setup(new MasterRenderer(data.camera), data);
@ -49,8 +51,8 @@ public class Example extends Game{
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt"); FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
GUIText text = new GUIText("Horse Game", 3, font, new Vector2f(0,0), 1f, true); GUIText text = new GUIText("LiteCraft", 3, font, new Vector2f(0,0), 1f, true);
text.setColour(0, 1, 0); text.setColour(0, 0, 0);
Terrain terrain = handleFlatTerrain(); Terrain terrain = handleFlatTerrain();
@ -66,6 +68,8 @@ public class Example extends Game{
TextureButton playButton = new TextureButton("/textures/guis/purpur.png", new Vector2f(0, 0), new Vector2f(0.25f, 0.1f)); TextureButton playButton = new TextureButton("/textures/guis/purpur.png", new Vector2f(0, 0), new Vector2f(0.25f, 0.1f));
playButton.show(data.guis); playButton.show(data.guis);
GuiTexture title = new GuiTexture(Loader.loadTextureDirectly("/textures/guis/title.png"), new Vector2f(0, 0.8F), new Vector2f(0.25f, 0.1f));
data.guis.add(title);
while(!Window.closed()) { while(!Window.closed()) {

View File

@ -1,6 +1,6 @@
package io.github.hydos.ginger.engine.obj; package io.github.hydos.ginger.engine.obj;
public class ModelData { public class Mesh {
private float[] vertices; private float[] vertices;
private float[] textureCoords; private float[] textureCoords;
@ -8,7 +8,7 @@ public class ModelData {
private int[] indices; private int[] indices;
private float furthestPoint; private float furthestPoint;
public ModelData(float[] vertices, float[] textureCoords, float[] normals, int[] indices, public Mesh(float[] vertices, float[] textureCoords, float[] normals, int[] indices,
float furthestPoint) { float furthestPoint) {
this.vertices = vertices; this.vertices = vertices;
this.textureCoords = textureCoords; this.textureCoords = textureCoords;

View File

@ -1,5 +1,6 @@
package io.github.hydos.ginger.engine.obj; package io.github.hydos.ginger.engine.obj;
import io.github.hydos.ginger.engine.obj.shapes.StaticCube;
import io.github.hydos.ginger.engine.render.models.TexturedModel; import io.github.hydos.ginger.engine.render.models.TexturedModel;
import io.github.hydos.ginger.engine.render.texture.ModelTexture; import io.github.hydos.ginger.engine.render.texture.ModelTexture;
import io.github.hydos.ginger.engine.utils.Loader; import io.github.hydos.ginger.engine.utils.Loader;
@ -7,9 +8,15 @@ import io.github.hydos.ginger.engine.utils.Loader;
public class ModelLoader { public class ModelLoader {
public static TexturedModel loadModel(String objPath, String texturePath) { public static TexturedModel loadModel(String objPath, String texturePath) {
ModelData data = OBJFileLoader.loadModel(objPath, texturePath); Mesh data = OBJFileLoader.loadModel(objPath, texturePath);
TexturedModel tm = new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath)); TexturedModel tm = new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath));
return tm; return tm;
} }
public static TexturedModel loadGenericCube(String cubeTexture) {
Mesh data = StaticCube.getCube();
TexturedModel tm = new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(cubeTexture));
return tm;
}
} }

View File

@ -15,13 +15,13 @@ public class OBJFileLoader {
public static String resourceLocation = "C:/Users/Hayden/Desktop/Ginger3D/src/main/resources/models/"; public static String resourceLocation = "C:/Users/Hayden/Desktop/Ginger3D/src/main/resources/models/";
public static ModelData loadModel(String filePath, String texturePath) { public static Mesh loadModel(String filePath, String texturePath) {
AIScene scene = null; AIScene scene = null;
try { try {
scene = Assimp.aiImportFile(resourceLocation + filePath, Assimp.aiProcess_JoinIdenticalVertices | Assimp.aiProcess_Triangulate); scene = Assimp.aiImportFile(resourceLocation + filePath, Assimp.aiProcess_JoinIdenticalVertices | Assimp.aiProcess_Triangulate);
if (scene == null) { if (scene == null) {
return new ModelData(new float[0], new float[0], new float[0], new int[0], 1F); return new Mesh(new float[0], new float[0], new float[0], new int[0], 1F);
} }
AIMesh mesh = AIMesh.create(scene.mMeshes().get(0)); AIMesh mesh = AIMesh.create(scene.mMeshes().get(0));
@ -65,10 +65,10 @@ public class OBJFileLoader {
System.err.println("Couldnt load scene file!"); System.err.println("Couldnt load scene file!");
e.printStackTrace(); e.printStackTrace();
} }
return new ModelData(new float[0], new float[0], new float[0], new int[0], 1F); return new Mesh(new float[0], new float[0], new float[0], new int[0], 1F);
} }
private static ModelData parseMeshData(Vertex[] vertexList, int[] indicesList, Buffer normals) { private static Mesh parseMeshData(Vertex[] vertexList, int[] indicesList, Buffer normals) {
float[] verticies = new float[vertexList.length*3]; float[] verticies = new float[vertexList.length*3];
float[] textureCoords = new float[vertexList.length*2]; float[] textureCoords = new float[vertexList.length*2];
//texture coords where stored in the vertices so there should be as many as there are vertices //texture coords where stored in the vertices so there should be as many as there are vertices
@ -91,7 +91,7 @@ public class OBJFileLoader {
} }
return new ModelData(verticies, textureCoords, new float[normals.sizeof()], indicesList, i); return new Mesh(verticies, textureCoords, new float[normals.sizeof()], indicesList, i);
} }
} }

View File

@ -0,0 +1,102 @@
package io.github.hydos.ginger.engine.obj.shapes;
import io.github.hydos.ginger.engine.obj.Mesh;
public class StaticCube {
public static float[] vertices = {
-0.5f,0.5f,-0.5f,
-0.5f,-0.5f,-0.5f,
0.5f,-0.5f,-0.5f,
0.5f,0.5f,-0.5f,
-0.5f,0.5f,0.5f,
-0.5f,-0.5f,0.5f,
0.5f,-0.5f,0.5f,
0.5f,0.5f,0.5f,
0.5f,0.5f,-0.5f,
0.5f,-0.5f,-0.5f,
0.5f,-0.5f,0.5f,
0.5f,0.5f,0.5f,
-0.5f,0.5f,-0.5f,
-0.5f,-0.5f,-0.5f,
-0.5f,-0.5f,0.5f,
-0.5f,0.5f,0.5f,
-0.5f,0.5f,0.5f,
-0.5f,0.5f,-0.5f,
0.5f,0.5f,-0.5f,
0.5f,0.5f,0.5f,
-0.5f,-0.5f,0.5f,
-0.5f,-0.5f,-0.5f,
0.5f,-0.5f,-0.5f,
0.5f,-0.5f,0.5f
};
public static float[] textureCoords = {
0,0,
0,1,
1,1,
1,0,
0,0,
0,1,
1,1,
1,0,
0,0,
0,1,
1,1,
1,0,
0,0,
0,1,
1,1,
1,0,
0,0,
0,1,
1,1,
1,0,
0,0,
0,1,
1,1,
1,0
};
public static int[] indices = {
0,1,3,
3,1,2,
4,5,7,
7,5,6,
8,9,11,
11,9,10,
12,13,15,
15,13,14,
16,17,19,
19,17,18,
20,21,23,
23,21,22
};
private static Mesh mesh = null;
public static void scaleCube(float multiplier) {
for(int i = 0; i<vertices.length; i++) {
vertices[i] = vertices[i] * multiplier;
}
mesh = new Mesh(vertices, textureCoords, new float[vertices.length], indices, vertices.length);
}
public static Mesh getCube() {
if(mesh == null) {
mesh = new Mesh(vertices, textureCoords, new float[vertices.length], indices, vertices.length);
}
return mesh;
}
}

View File

@ -49,7 +49,7 @@ public class MasterRenderer {
private Map<TexturedModel, List<Entity>> entities = new HashMap<TexturedModel, List<Entity>>(); private Map<TexturedModel, List<Entity>> entities = new HashMap<TexturedModel, List<Entity>>();
private Map<TexturedModel, List<Entity>> normalMapEntities = new HashMap<TexturedModel, List<Entity>>(); private Map<TexturedModel, List<Entity>> normalMapEntities = new HashMap<TexturedModel, List<Entity>>();
public static final float FOV = 70f; public static final float FOV = 80f;
public static final float NEAR_PLANE = 0.1f; public static final float NEAR_PLANE = 0.1f;
private static final float FAR_PLANE = 1000f; private static final float FAR_PLANE = 1000f;
@ -73,8 +73,8 @@ public class MasterRenderer {
} }
public static void enableCulling() { public static void enableCulling() {
GL11.glEnable(GL11.GL_CULL_FACE); // GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glCullFace(GL11.GL_BACK); // GL11.glCullFace(GL11.GL_BACK);
} }
public static void disableCulling() { public static void disableCulling() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

View File

@ -0,0 +1,17 @@
[LocalizedFileNames]
concrete_powder_pink.png=@concrete_powder_pink.png,0
concrete_powder_magenta.png=@concrete_powder_magenta.png,0
concrete_powder_lime.png=@concrete_powder_lime.png,0
concrete_powder_light_blue.png=@concrete_powder_light_blue.png,0
concrete_powder_green.png=@concrete_powder_green.png,0
concrete_powder_gray.png=@concrete_powder_gray.png,0
concrete_powder_cyan.png=@concrete_powder_cyan.png,0
concrete_powder_brown.png=@concrete_powder_brown.png,0
concrete_powder_red.png=@concrete_powder_red.png,0
concrete_powder_black.png=@concrete_powder_black.png,0
concrete_powder_white.png=@concrete_powder_white.png,0
concrete_powder_blue.png=@concrete_powder_blue.png,0
concrete_powder_yellow.png=@concrete_powder_yellow.png,0
concrete_powder_silver.png=@concrete_powder_silver.png,0
concrete_powder_orange.png=@concrete_powder_orange.png,0
concrete_powder_purple.png=@concrete_powder_purple.png,0

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Some files were not shown because too many files have changed in this diff Show More