diff --git a/src/main/java/io/github/hydos/ginger/Example.java b/src/main/java/io/github/hydos/ginger/Example.java index 53d41ed..b8c26cb 100644 --- a/src/main/java/io/github/hydos/ginger/Example.java +++ b/src/main/java/io/github/hydos/ginger/Example.java @@ -1,60 +1,35 @@ package io.github.hydos.ginger; -import java.util.ArrayList; -import java.util.List; - -import org.joml.Vector4f; -import org.lwjgl.glfw.GLFW; - -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; -import io.github.hydos.ginger.engine.elements.GuiTexture; +import io.github.hydos.ginger.engine.api.*; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.elements.buttons.TextureButton; -import io.github.hydos.ginger.engine.elements.objects.Entity; -import io.github.hydos.ginger.engine.elements.objects.Light; -import io.github.hydos.ginger.engine.elements.objects.Player; -import io.github.hydos.ginger.engine.font.FontType; -import io.github.hydos.ginger.engine.font.GUIText; -import io.github.hydos.ginger.engine.font.TextMaster; +import io.github.hydos.ginger.engine.elements.objects.*; +import io.github.hydos.ginger.engine.font.*; import io.github.hydos.ginger.engine.io.Window; -import io.github.hydos.ginger.engine.math.vectors.Vector2f; -import io.github.hydos.ginger.engine.math.vectors.Vector3f; +import io.github.hydos.ginger.engine.math.vectors.*; import io.github.hydos.ginger.engine.obj.ModelLoader; import io.github.hydos.ginger.engine.obj.normals.NormalMappedObjLoader; -import io.github.hydos.ginger.engine.particle.ParticleMaster; -import io.github.hydos.ginger.engine.particle.ParticleSystem; -import io.github.hydos.ginger.engine.particle.ParticleTexture; -import io.github.hydos.ginger.engine.postprocessing.Fbo; -import io.github.hydos.ginger.engine.postprocessing.PostProcessing; +import io.github.hydos.ginger.engine.particle.*; import io.github.hydos.ginger.engine.render.MasterRenderer; 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.tools.MousePicker; -import io.github.hydos.ginger.engine.terrain.Terrain; -import io.github.hydos.ginger.engine.terrain.TerrainTexture; -import io.github.hydos.ginger.engine.terrain.TerrainTexturePack; +import io.github.hydos.ginger.engine.terrain.*; import io.github.hydos.ginger.engine.utils.Loader; import io.github.hydos.ginger.main.GingerMain; import io.github.hydos.ginger.main.settings.Constants; -public class Example { - - private MasterRenderer masterRenderer; - - private List terrains = new ArrayList(); - - private List guis = new ArrayList(); - - private List lights = new ArrayList(); - - private List entities = new ArrayList(); - - private List normalMapEntities = new ArrayList(); +public class Example extends Game{ + private Ginger ginger3D; public void main(String[] args) { + //Render Player's constant variables + Constants.movementSpeed = 0.000005f; + Constants.turnSpeed = 0.00002f; + Constants.gravity = -0.000000000005f; + Constants.jumpPower = 0.000005f; - - Window.create(1200, 800, "Ginger Example", 60); + Window.create(1200, 800, "Simple Ginger Example", 60); GingerMain.init(); @@ -64,13 +39,11 @@ public class Example { TexturedModel tModel = ModelLoader.loadModel("stall.obj", "stallTexture.png"); tModel.getTexture().setReflectivity(1f); tModel.getTexture().setShineDamper(7f); - Player entity = new Player(tModel, new Vector3f(0,0,-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f)); - Constants.movementSpeed = 0.000005f; - Constants.turnSpeed = 0.00002f; - Constants.gravity = -0.000000000005f; - Constants.jumpPower = 0.000005f; - ThirdPersonCamera camera = new ThirdPersonCamera(new Vector3f(0,0.1f,0), entity); - masterRenderer = new MasterRenderer(camera); + 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); + ginger3D = new Ginger(); + data = new GameData(player, camera); + ginger3D.setup(new MasterRenderer(data.camera), data); FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt"); @@ -78,7 +51,7 @@ public class Example { GUIText text = new GUIText("german", 3, font, new Vector2f(0,0), 1f, true); text.setColour(0, 1, 0); - ParticleMaster.init(masterRenderer.getProjectionMatrix()); + ParticleMaster.init(ginger3D.masterRenderer.getProjectionMatrix()); @@ -90,7 +63,7 @@ public class Example { Light sun = new Light(new Vector3f(100,105,-100), new Vector3f(1.3f, 1.3f, 1.3f), new Vector3f(0.0001f, 0.0001f, 0.0001f)); - lights.add(sun); + data.lights.add(sun); TexturedModel tgrass = ModelLoader.loadModel("grass.obj", "grass.png"); tgrass.getTexture().setTransparency(true); @@ -109,10 +82,7 @@ public class Example { Entity dragon = new Entity(dragonMdl, new Vector3f(3,terrain.getHeightOfTerrain(3, -3),-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f)); Entity grassEntity = new Entity(tgrass, new Vector3f(-3,terrain.getHeightOfTerrain(-3, -3),-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f)); - entities.add(grassEntity); - - MousePicker picker = new MousePicker(camera, masterRenderer.getProjectionMatrix(), terrain); - + data.entities.add(grassEntity); TexturedModel barrelModel = new TexturedModel(NormalMappedObjLoader.loadOBJ("barrel.obj"), new ModelTexture("barrel.png")); barrelModel.getTexture().setNormalMap(new ModelTexture("modelNormals/barrelNormal.png").getTextureID()); @@ -120,80 +90,61 @@ public class Example { barrelModel.getTexture().setReflectivity(0.5f); Entity barrel = new Entity(barrelModel, new Vector3f(1,terrain.getHeightOfTerrain(1, 1),1), 0, 0, 0, new Vector3f(0.25f,0.25f,0.25f)); - normalMapEntities.add(barrel); - entities.add(entity); - entities.add(dragon); + data.normalMapEntities.add(barrel); + data.entities.add(player); + data.entities.add(dragon); - float colour = 0; - terrains.add(terrain); + data.flatTerrains.add(terrain); - ParticleTexture particleTexture = new ParticleTexture(Loader.loadTexture("particles/smoke.png"), 8); + ParticleSystem system = setupParticles(); TextureButton button = new TextureButton("/textures/guis/ginger.png", new Vector2f(0.8f, 0), new Vector2f(0.1f, 0.1f)); - button.show(guis); + button.show(data.guis); + + Window.lockMouse(); + + while(!Window.closed()) { + + if(Window.isUpdating()) { + ginger3D.update(data); + + ginger3D.masterRenderer.renderShadowMap(data.entities, sun); + + camera.move(); + player.move(terrain); + + system.generateParticles(new Vector3f(0,-2,0)); + + ginger3D.render(data, this); + + dragon.increaseRotation(0,1,0); + barrel.increaseRotation(0, 1, 0); + + button.update(); + if(button.isClicked()) { + System.out.println("click"); + button.hide(data.guis); + } + + ginger3D.postRender(); + } + + } + + } + + + private ParticleSystem setupParticles() { + ParticleTexture particleTexture = new ParticleTexture(Loader.loadTexture("particles/smoke.png"), 8); + + ParticleSystem system = new ParticleSystem(particleTexture, 100, 10f, 0.3f, 4, 3f); system.randomizeRotation(); system.setDirection(new Vector3f(0,0.001f,0), 0.00001f); system.setLifeError(0); system.setSpeedError(0); system.setScaleError(1f); - - Fbo fbo = new Fbo(); - PostProcessing.init(); - - while(!Window.closed()) { - - if(Window.isUpdating()) { - Window.update(); - GingerMain.update(); - colour = colour + 0.001f; - picker.update(); - ParticleMaster.update(camera); - - masterRenderer.renderShadowMap(entities, sun); - - camera.move(); - entity.move(terrain); - - Vector3f terrainPoint = picker.getCurrentTerrainPoint(); - if(terrainPoint!=null) { - barrel.setPosition(terrainPoint); - if(Window.isMouseDown(GLFW.GLFW_MOUSE_BUTTON_1)) { - normalMapEntities.add(new Entity(barrelModel, terrainPoint, 0, 0, 0, new Vector3f(0.25f,0.25f,0.25f))); - } - } - system.generateParticles(new Vector3f(0,-2,0)); - - dragon.increaseRotation(0,1,0); - barrel.increaseRotation(0, 1, 0); - - GingerMain.preRenderScene(masterRenderer); - ParticleMaster.renderParticles(camera); - fbo.bindFBO(); - masterRenderer.renderScene(entities, normalMapEntities, terrains, lights, camera, new Vector4f(0, -1, 0, 100000)); - fbo.unbindFBO(); - PostProcessing.doPostProcessing(fbo.colorTexture); -// TODO: get fbo's working - button.update(); - if(button.isClicked()) { - System.out.println("click"); - button.hide(guis); - } -// masterRenderer.renderScene(entities, normalMapEntities, terrains, lights, camera, new Vector4f(0, -1, 0, 100000)); - masterRenderer.renderGuis(guis); - TextMaster.render(); - - Window.swapBuffers(); - } - - } - Window.stop(); - PostProcessing.cleanUp(); - ParticleMaster.cleanUp(); - masterRenderer.cleanUp(); - TextMaster.cleanUp(); - Loader.cleanUp(); - System.exit(0); + return system; } diff --git a/src/main/java/io/github/hydos/ginger/engine/api/Game.java b/src/main/java/io/github/hydos/ginger/engine/api/Game.java new file mode 100644 index 0000000..6579c81 --- /dev/null +++ b/src/main/java/io/github/hydos/ginger/engine/api/Game.java @@ -0,0 +1,7 @@ +package io.github.hydos.ginger.engine.api; + +public abstract class Game { + + public GameData data; + +} diff --git a/src/main/java/io/github/hydos/ginger/engine/api/GameData.java b/src/main/java/io/github/hydos/ginger/engine/api/GameData.java new file mode 100644 index 0000000..01dea7d --- /dev/null +++ b/src/main/java/io/github/hydos/ginger/engine/api/GameData.java @@ -0,0 +1,38 @@ +package io.github.hydos.ginger.engine.api; + +import java.util.*; + +import org.joml.Vector4f; + +import io.github.hydos.ginger.engine.cameras.Camera; +import io.github.hydos.ginger.engine.elements.GuiTexture; +import io.github.hydos.ginger.engine.elements.objects.*; +import io.github.hydos.ginger.engine.terrain.Terrain; + +/* + * Used for storing essential engine game data so main class isn't messy + * Also in general used with Game Class + */ +public class GameData { + + public List guis; + public List entities; + public List lights; + public List normalMapEntities; + public List flatTerrains; + public Player player; + public Camera camera; + public Vector4f clippingPlane; + + public GameData(Player player, Camera camera) { + clippingPlane = new Vector4f(0, -1, 0, 100000); + guis = new ArrayList(); + entities = new ArrayList(); + lights = new ArrayList(); + normalMapEntities = new ArrayList(); + flatTerrains = new ArrayList(); + this.player = player; + this.camera = camera; + } + +} diff --git a/src/main/java/io/github/hydos/ginger/engine/api/Ginger.java b/src/main/java/io/github/hydos/ginger/engine/api/Ginger.java new file mode 100644 index 0000000..2d4a2c3 --- /dev/null +++ b/src/main/java/io/github/hydos/ginger/engine/api/Ginger.java @@ -0,0 +1,60 @@ +package io.github.hydos.ginger.engine.api; + +import io.github.hydos.ginger.engine.font.TextMaster; +import io.github.hydos.ginger.engine.io.Window; +import io.github.hydos.ginger.engine.particle.ParticleMaster; +import io.github.hydos.ginger.engine.postprocessing.*; +import io.github.hydos.ginger.engine.render.MasterRenderer; +import io.github.hydos.ginger.engine.render.tools.MousePicker; +import io.github.hydos.ginger.engine.utils.Loader; +import io.github.hydos.ginger.main.GingerMain; + +public class Ginger { + + public MasterRenderer masterRenderer; + + MousePicker picker; + + public Fbo contrastFbo; + + public void setup(MasterRenderer masterRenderer, GameData data) { + contrastFbo = new Fbo(); + this.masterRenderer = masterRenderer; + picker = new MousePicker(data.camera, masterRenderer.getProjectionMatrix(), null); + PostProcessing.init(); + } + + public void update(GameData data) { + data.camera.move(); + data.player.move(null); + Window.update(); + GingerMain.update(); + picker.update(); + ParticleMaster.update(data.camera); + } + + public void render(GameData data, Game game) { + GingerMain.preRenderScene(masterRenderer); + ParticleMaster.renderParticles(data.camera); + contrastFbo.bindFBO(); + masterRenderer.renderScene(data.entities, data.normalMapEntities, data.flatTerrains, data.lights, data.camera, data.clippingPlane); + contrastFbo.unbindFBO(); + PostProcessing.doPostProcessing(contrastFbo.colorTexture); + masterRenderer.renderGuis(data.guis); + TextMaster.render(); + } + + public void postRender() { + Window.swapBuffers(); + } + + public void cleanup() { + Window.stop(); + PostProcessing.cleanUp(); + ParticleMaster.cleanUp(); + masterRenderer.cleanUp(); + TextMaster.cleanUp(); + Loader.cleanUp(); + } + +} diff --git a/src/main/java/io/github/hydos/ginger/engine/api/ResourceManager.java b/src/main/java/io/github/hydos/ginger/engine/api/ResourceManager.java new file mode 100644 index 0000000..5077fb1 --- /dev/null +++ b/src/main/java/io/github/hydos/ginger/engine/api/ResourceManager.java @@ -0,0 +1,12 @@ +package io.github.hydos.ginger.engine.api; + +/* + * make your own resource manager if you want! + */ +public abstract class ResourceManager { + + public abstract String getResourcePath(String path); + + public abstract boolean getResourceInternally(String path); + +} diff --git a/src/main/java/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera.java b/src/main/java/io/github/hydos/ginger/engine/cameras/Camera.java similarity index 94% rename from src/main/java/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera.java rename to src/main/java/io/github/hydos/ginger/engine/cameras/Camera.java index d962c94..122d130 100644 --- a/src/main/java/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera.java +++ b/src/main/java/io/github/hydos/ginger/engine/cameras/Camera.java @@ -7,7 +7,7 @@ import io.github.hydos.ginger.engine.elements.objects.Player; import io.github.hydos.ginger.engine.io.Window; import io.github.hydos.ginger.engine.math.vectors.Vector3f; -public class ThirdPersonCamera { +public class Camera { private float distanceFromPlayer = 5; private float angleAroundPlayer = 0; @@ -21,12 +21,12 @@ public class ThirdPersonCamera { private Player player; - public ThirdPersonCamera(Player player) { + public Camera(Player player) { this.player = player; } - public ThirdPersonCamera(Vector3f vector3f, Player player) { + public Camera(Vector3f vector3f, Player player) { this.position = vector3f; this.player = player; diff --git a/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java b/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java index 3a26dd5..a5fb7f9 100644 --- a/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java +++ b/src/main/java/io/github/hydos/ginger/engine/elements/objects/Player.java @@ -25,19 +25,22 @@ public class Player extends Entity{ public void move(Terrain t) { checkInputs(); - super.increaseRotation(0, (float) ((currentTurn) * Window.getTime() ), 0); - float distance = (float) ((currentSpeed) * (Window.getTime())); - float dx = (float) (distance * Math.sin(Math.toRadians(super.getRotY()))); - float dz = (float) (distance * Math.cos(Math.toRadians(super.getRotY()))); - super.increasePosition(dx, 0, dz); - super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime())), 0); - terrainHeight = t.getHeightOfTerrain(super.getPosition().x, super.getPosition().z); - upwardsSpeed += Constants.gravity * Window.getTime(); - if(super.getPosition().y < terrainHeight) { - isInAir = false; - upwardsSpeed = 0; - super.getPosition().y = terrainHeight; + if(t != null) { + super.increaseRotation(0, (float) ((currentTurn) * Window.getTime() ), 0); + float distance = (float) ((currentSpeed) * (Window.getTime())); + float dx = (float) (distance * Math.sin(Math.toRadians(super.getRotY()))); + float dz = (float) (distance * Math.cos(Math.toRadians(super.getRotY()))); + super.increasePosition(dx, 0, dz); + super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime())), 0); + terrainHeight = t.getHeightOfTerrain(super.getPosition().x, super.getPosition().z); + upwardsSpeed += Constants.gravity * Window.getTime(); + if(super.getPosition().y < terrainHeight) { + isInAir = false; + upwardsSpeed = 0; + super.getPosition().y = terrainHeight; + } } + } diff --git a/src/main/java/io/github/hydos/ginger/engine/math/Maths.java b/src/main/java/io/github/hydos/ginger/engine/math/Maths.java index f294b2f..676d5de 100644 --- a/src/main/java/io/github/hydos/ginger/engine/math/Maths.java +++ b/src/main/java/io/github/hydos/ginger/engine/math/Maths.java @@ -1,6 +1,6 @@ package io.github.hydos.ginger.engine.math; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; import io.github.hydos.ginger.engine.math.vectors.Vector2f; import io.github.hydos.ginger.engine.math.vectors.Vector3f; @@ -18,7 +18,7 @@ public class Maths { return matrix; } - public static Matrix4f createViewMatrix(ThirdPersonCamera camera) { + public static Matrix4f createViewMatrix(Camera camera) { Matrix4f viewMatrix = new Matrix4f(); viewMatrix.setIdentity(); Matrix4f.rotate((float) Math.toRadians(camera.getPitch()), new Vector3f(1, 0, 0), viewMatrix, viewMatrix); diff --git a/src/main/java/io/github/hydos/ginger/engine/particle/Particle.java b/src/main/java/io/github/hydos/ginger/engine/particle/Particle.java index 7339f67..25b442a 100644 --- a/src/main/java/io/github/hydos/ginger/engine/particle/Particle.java +++ b/src/main/java/io/github/hydos/ginger/engine/particle/Particle.java @@ -1,6 +1,6 @@ package io.github.hydos.ginger.engine.particle; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.io.Window; import io.github.hydos.ginger.engine.math.vectors.Vector2f; import io.github.hydos.ginger.engine.math.vectors.Vector3f; @@ -70,7 +70,7 @@ public class Particle { return blend; } - public boolean update(ThirdPersonCamera camera) { + public boolean update(Camera camera) { float time = (float) Window.getTime() / 1000000; velocity.y += Constants.gravity * gravityEffect * time; Vector3f change = new Vector3f(velocity); diff --git a/src/main/java/io/github/hydos/ginger/engine/particle/ParticleMaster.java b/src/main/java/io/github/hydos/ginger/engine/particle/ParticleMaster.java index 77f2b0e..9619b96 100644 --- a/src/main/java/io/github/hydos/ginger/engine/particle/ParticleMaster.java +++ b/src/main/java/io/github/hydos/ginger/engine/particle/ParticleMaster.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; import io.github.hydos.ginger.engine.render.renderers.ParticleRenderer; @@ -21,7 +21,7 @@ public class ParticleMaster { } - public static void update(ThirdPersonCamera camera) { + public static void update(Camera camera) { Iterator>> mapIterator = particles.entrySet().iterator(); while(mapIterator.hasNext()) { List list = mapIterator.next().getValue(); @@ -40,7 +40,7 @@ public class ParticleMaster { } } - public static void renderParticles(ThirdPersonCamera camera) { + public static void renderParticles(Camera camera) { particleRenderer.render(particles, camera); } diff --git a/src/main/java/io/github/hydos/ginger/engine/render/MasterRenderer.java b/src/main/java/io/github/hydos/ginger/engine/render/MasterRenderer.java index d9d5181..602f86e 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/MasterRenderer.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/MasterRenderer.java @@ -9,7 +9,7 @@ import org.joml.Vector4f; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.elements.GuiTexture; import io.github.hydos.ginger.engine.elements.objects.Entity; import io.github.hydos.ginger.engine.elements.objects.Light; @@ -53,7 +53,7 @@ public class MasterRenderer { public static final float NEAR_PLANE = 0.1f; private static final float FAR_PLANE = 1000f; - public MasterRenderer(ThirdPersonCamera camera) { + public MasterRenderer(Camera camera) { createProjectionMatrix(); entityShader = new StaticShader(); entityRenderer = new EntityRenderer(entityShader, projectionMatrix); @@ -86,7 +86,7 @@ public class MasterRenderer { GL11.glBindTexture(GL11.GL_TEXTURE_2D, shadowMapRenderer.getShadowMap()); } - public void renderScene(List entities, List normalEntities, List terrains, List lights, ThirdPersonCamera camera, Vector4f clipPlane) { + public void renderScene(List entities, List normalEntities, List terrains, List lights, Camera camera, Vector4f clipPlane) { prepare(); renderEntities(entities, camera, lights); renderNormalEntities(normalEntities, lights, camera, clipPlane); @@ -96,7 +96,7 @@ public class MasterRenderer { } - private void renderNormalEntities(List normalEntities, List lights, ThirdPersonCamera camera, Vector4f clipPlane) { + private void renderNormalEntities(List normalEntities, List lights, Camera camera, Vector4f clipPlane) { for(Entity entity: normalEntities) { processEntityWithNormal(entity); } @@ -107,7 +107,7 @@ public class MasterRenderer { guiRenderer.render(guis); } - private void renderTerrains(List terrains, List lights, ThirdPersonCamera camera) { + private void renderTerrains(List terrains, List lights, Camera camera) { terrainShader.start(); terrainShader.loadSkyColour(Window.getColour()); terrainShader.loadLights(lights); @@ -116,7 +116,7 @@ public class MasterRenderer { terrainShader.stop(); } - private void renderEntities(List entities, ThirdPersonCamera camera, List lights) { + private void renderEntities(List entities, Camera camera, List lights) { for(Entity entity: entities) { processEntity(entity); } diff --git a/src/main/java/io/github/hydos/ginger/engine/render/renderers/NormalMappingRenderer.java b/src/main/java/io/github/hydos/ginger/engine/render/renderers/NormalMappingRenderer.java index ecb7b34..da1feb4 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/renderers/NormalMappingRenderer.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/renderers/NormalMappingRenderer.java @@ -9,7 +9,7 @@ import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.elements.objects.Entity; import io.github.hydos.ginger.engine.elements.objects.Light; import io.github.hydos.ginger.engine.io.Window; @@ -33,7 +33,7 @@ public class NormalMappingRenderer { shader.stop(); } - public void render(Map> entities, Vector4f clipPlane, List lights, ThirdPersonCamera camera) { + public void render(Map> entities, Vector4f clipPlane, List lights, Camera camera) { shader.start(); prepare(clipPlane, lights, camera); for (TexturedModel model : entities.keySet()) { @@ -87,7 +87,7 @@ public class NormalMappingRenderer { shader.loadOffset(0, 0); } - private void prepare(Vector4f clipPlane, List lights, ThirdPersonCamera camera) { + private void prepare(Vector4f clipPlane, List lights, Camera camera) { shader.loadClipPlane(clipPlane); //need to be public variables in MasterRenderer shader.loadSkyColour(Window.getColour()); diff --git a/src/main/java/io/github/hydos/ginger/engine/render/renderers/ParticleRenderer.java b/src/main/java/io/github/hydos/ginger/engine/render/renderers/ParticleRenderer.java index 092a7d7..94287cf 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/renderers/ParticleRenderer.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/renderers/ParticleRenderer.java @@ -11,7 +11,7 @@ import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; import org.lwjgl.opengl.GL31; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.math.Maths; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; import io.github.hydos.ginger.engine.math.vectors.Vector3f; @@ -50,7 +50,7 @@ public class ParticleRenderer { shader.stop(); } - public void render(Map> particles, ThirdPersonCamera camera){ + public void render(Map> particles, Camera camera){ Matrix4f viewMatrix = Maths.createViewMatrix(camera); prepare(); for(ParticleTexture texture : particles.keySet()) { diff --git a/src/main/java/io/github/hydos/ginger/engine/render/renderers/SkyboxRenderer.java b/src/main/java/io/github/hydos/ginger/engine/render/renderers/SkyboxRenderer.java index b7ddb12..f601789 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/renderers/SkyboxRenderer.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/renderers/SkyboxRenderer.java @@ -5,7 +5,7 @@ import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; import io.github.hydos.ginger.engine.render.models.RawModel; import io.github.hydos.ginger.engine.render.shaders.SkyboxShader; @@ -75,7 +75,7 @@ public class SkyboxRenderer { shader.stop(); } - public void render(ThirdPersonCamera camera) { + public void render(Camera camera) { shader.start(); shader.loadViewMatrix(camera); GL30.glBindVertexArray(cube.getVaoID()); diff --git a/src/main/java/io/github/hydos/ginger/engine/render/shaders/SkyboxShader.java b/src/main/java/io/github/hydos/ginger/engine/render/shaders/SkyboxShader.java index cc829a7..950abd4 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/shaders/SkyboxShader.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/shaders/SkyboxShader.java @@ -1,6 +1,6 @@ package io.github.hydos.ginger.engine.render.shaders; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.math.Maths; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; @@ -17,7 +17,7 @@ public class SkyboxShader extends ShaderProgram{ super.loadMatrix(location_projectionMatrix, matrix); } - public void loadViewMatrix(ThirdPersonCamera camera){ + public void loadViewMatrix(Camera camera){ Matrix4f matrix = Maths.createViewMatrix(camera); matrix.m30 = 0; matrix.m31 = 0; diff --git a/src/main/java/io/github/hydos/ginger/engine/render/shaders/StaticShader.java b/src/main/java/io/github/hydos/ginger/engine/render/shaders/StaticShader.java index d79793a..86cc5d6 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/shaders/StaticShader.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/shaders/StaticShader.java @@ -2,7 +2,7 @@ package io.github.hydos.ginger.engine.render.shaders; import java.util.List; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.elements.objects.Light; import io.github.hydos.ginger.engine.math.Maths; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; @@ -65,7 +65,7 @@ public class StaticShader extends ShaderProgram{ super.loadMatrix(location_projectionMatrix, matrix); } - public void loadViewMatrix(ThirdPersonCamera camera) { + public void loadViewMatrix(Camera camera) { Matrix4f matrix = Maths.createViewMatrix(camera); super.loadMatrix(location_viewMatrix, matrix); } diff --git a/src/main/java/io/github/hydos/ginger/engine/render/shaders/TerrainShader.java b/src/main/java/io/github/hydos/ginger/engine/render/shaders/TerrainShader.java index 4b5faa0..d548550 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/shaders/TerrainShader.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/shaders/TerrainShader.java @@ -2,7 +2,7 @@ package io.github.hydos.ginger.engine.render.shaders; import java.util.List; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.elements.objects.Light; import io.github.hydos.ginger.engine.math.Maths; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; @@ -83,7 +83,7 @@ public class TerrainShader extends ShaderProgram{ super.loadMatrix(location_projectionMatrix, matrix); } - public void loadViewMatrix(ThirdPersonCamera camera) { + public void loadViewMatrix(Camera camera) { Matrix4f matrix = Maths.createViewMatrix(camera); super.loadMatrix(location_viewMatrix, matrix); } diff --git a/src/main/java/io/github/hydos/ginger/engine/render/tools/MousePicker.java b/src/main/java/io/github/hydos/ginger/engine/render/tools/MousePicker.java index 41c83a8..b84d4a9 100644 --- a/src/main/java/io/github/hydos/ginger/engine/render/tools/MousePicker.java +++ b/src/main/java/io/github/hydos/ginger/engine/render/tools/MousePicker.java @@ -2,7 +2,7 @@ package io.github.hydos.ginger.engine.render.tools; import org.joml.Vector4f; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.io.Window; import io.github.hydos.ginger.engine.math.Maths; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; @@ -19,12 +19,12 @@ public class MousePicker { private Matrix4f projectionMatrix; private Matrix4f viewMatrix; - private ThirdPersonCamera camera; + private Camera camera; private Terrain terrain; private Vector3f currentTerrainPoint; - public MousePicker(ThirdPersonCamera cam, Matrix4f projection, Terrain terrain) { + public MousePicker(Camera cam, Matrix4f projection, Terrain terrain) { camera = cam; projectionMatrix = projection; viewMatrix = Maths.createViewMatrix(camera); diff --git a/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowBox.java b/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowBox.java index c30593e..fc62084 100644 --- a/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowBox.java +++ b/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowBox.java @@ -2,7 +2,7 @@ package io.github.hydos.ginger.engine.shadow; import org.joml.Vector4f; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.io.Window; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; import io.github.hydos.ginger.engine.math.vectors.Vector3f; @@ -31,7 +31,7 @@ public class ShadowBox { private float minY, maxY; private float minZ, maxZ; private Matrix4f lightViewMatrix; - private ThirdPersonCamera cam; + private Camera cam; private float farHeight, farWidth, nearHeight, nearWidth; @@ -48,7 +48,7 @@ public class ShadowBox { * @param camera * - the in-game camera. */ - protected ShadowBox(Matrix4f lightViewMatrix, ThirdPersonCamera camera) { + protected ShadowBox(Matrix4f lightViewMatrix, Camera camera) { this.lightViewMatrix = lightViewMatrix; this.cam = camera; calculateWidthsAndHeights(); diff --git a/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.java b/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.java index 8a19620..f14a59b 100644 --- a/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.java +++ b/src/main/java/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.java @@ -5,7 +5,7 @@ import java.util.Map; import org.lwjgl.opengl.GL11; -import io.github.hydos.ginger.engine.cameras.ThirdPersonCamera; +import io.github.hydos.ginger.engine.cameras.Camera; import io.github.hydos.ginger.engine.elements.objects.Entity; import io.github.hydos.ginger.engine.elements.objects.Light; import io.github.hydos.ginger.engine.math.matrixes.Matrix4f; @@ -44,7 +44,7 @@ public class ShadowMapMasterRenderer { * @param camera * - the camera being used in the scene. */ - public ShadowMapMasterRenderer(ThirdPersonCamera camera) { + public ShadowMapMasterRenderer(Camera camera) { shader = new ShadowShader(); shadowBox = new ShadowBox(lightViewMatrix, camera); shadowFbo = new ShadowFrameBuffer(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE); diff --git a/target/classes/io/github/hydos/ginger/Example.class b/target/classes/io/github/hydos/ginger/Example.class index 24fbdc2..6130cd1 100644 Binary files a/target/classes/io/github/hydos/ginger/Example.class and b/target/classes/io/github/hydos/ginger/Example.class differ diff --git a/target/classes/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera$1.class b/target/classes/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera$1.class deleted file mode 100644 index e1f85cb..0000000 Binary files a/target/classes/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera$1.class and /dev/null differ diff --git a/target/classes/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera.class b/target/classes/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera.class deleted file mode 100644 index 36a17e2..0000000 Binary files a/target/classes/io/github/hydos/ginger/engine/cameras/ThirdPersonCamera.class and /dev/null differ diff --git a/target/classes/io/github/hydos/ginger/engine/particle/Particle.class b/target/classes/io/github/hydos/ginger/engine/particle/Particle.class index a750a68..c3c3ee3 100644 Binary files a/target/classes/io/github/hydos/ginger/engine/particle/Particle.class and b/target/classes/io/github/hydos/ginger/engine/particle/Particle.class differ diff --git a/target/classes/io/github/hydos/ginger/engine/particle/ParticleMaster.class b/target/classes/io/github/hydos/ginger/engine/particle/ParticleMaster.class index 0e9b1d8..087a713 100644 Binary files a/target/classes/io/github/hydos/ginger/engine/particle/ParticleMaster.class and b/target/classes/io/github/hydos/ginger/engine/particle/ParticleMaster.class differ diff --git a/target/classes/io/github/hydos/ginger/engine/shadow/ShadowBox.class b/target/classes/io/github/hydos/ginger/engine/shadow/ShadowBox.class index 270b113..3d661cd 100644 Binary files a/target/classes/io/github/hydos/ginger/engine/shadow/ShadowBox.class and b/target/classes/io/github/hydos/ginger/engine/shadow/ShadowBox.class differ diff --git a/target/classes/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.class b/target/classes/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.class index 92ff959..0d37466 100644 Binary files a/target/classes/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.class and b/target/classes/io/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.class differ