simpler renderer (very good 10/10 ngl)

pull/1/head
hYdos 2020-02-23 19:18:48 +10:00
parent 54ba0d5e07
commit 4026e407c6
27 changed files with 237 additions and 166 deletions

View File

@ -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<Terrain> terrains = new ArrayList<Terrain>();
private List<GuiTexture> guis = new ArrayList<GuiTexture>();
private List<Light> lights = new ArrayList<Light>();
private List<Entity> entities = new ArrayList<Entity>();
private List<Entity> normalMapEntities = new ArrayList<Entity>();
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;
}

View File

@ -0,0 +1,7 @@
package io.github.hydos.ginger.engine.api;
public abstract class Game {
public GameData data;
}

View File

@ -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<GuiTexture> guis;
public List<Entity> entities;
public List<Light> lights;
public List<Entity> normalMapEntities;
public List<Terrain> 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<GuiTexture>();
entities = new ArrayList<Entity>();
lights = new ArrayList<Light>();
normalMapEntities = new ArrayList<Entity>();
flatTerrains = new ArrayList<Terrain>();
this.player = player;
this.camera = camera;
}
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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<Entry<ParticleTexture, List<Particle>>> mapIterator = particles.entrySet().iterator();
while(mapIterator.hasNext()) {
List<Particle> 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);
}

View File

@ -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<Entity> entities, List<Entity> normalEntities, List<Terrain> terrains, List<Light> lights, ThirdPersonCamera camera, Vector4f clipPlane) {
public void renderScene(List<Entity> entities, List<Entity> normalEntities, List<Terrain> terrains, List<Light> 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<Entity> normalEntities, List<Light> lights, ThirdPersonCamera camera, Vector4f clipPlane) {
private void renderNormalEntities(List<Entity> normalEntities, List<Light> 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<Terrain> terrains, List<Light> lights, ThirdPersonCamera camera) {
private void renderTerrains(List<Terrain> terrains, List<Light> 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<Entity> entities, ThirdPersonCamera camera, List<Light> lights) {
private void renderEntities(List<Entity> entities, Camera camera, List<Light> lights) {
for(Entity entity: entities) {
processEntity(entity);
}

View File

@ -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<TexturedModel, List<Entity>> entities, Vector4f clipPlane, List<Light> lights, ThirdPersonCamera camera) {
public void render(Map<TexturedModel, List<Entity>> entities, Vector4f clipPlane, List<Light> 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<Light> lights, ThirdPersonCamera camera) {
private void prepare(Vector4f clipPlane, List<Light> lights, Camera camera) {
shader.loadClipPlane(clipPlane);
//need to be public variables in MasterRenderer
shader.loadSkyColour(Window.getColour());

View File

@ -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<ParticleTexture, List<Particle>> particles, ThirdPersonCamera camera){
public void render(Map<ParticleTexture, List<Particle>> particles, Camera camera){
Matrix4f viewMatrix = Maths.createViewMatrix(camera);
prepare();
for(ParticleTexture texture : particles.keySet()) {

View File

@ -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());

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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();

View File

@ -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);