world generation
parent
56503a0ac2
commit
f8534e718a
|
@ -1,10 +1,45 @@
|
||||||
package com.github.halotroop.litecraft.world;
|
package com.github.halotroop.litecraft.world;
|
||||||
|
|
||||||
import com.github.halotroop.litecraft.types.block.Block;
|
import java.util.*;
|
||||||
|
|
||||||
public class World //implements TileAccess
|
import com.github.hydos.ginger.engine.render.renderers.ObjectRenderer;
|
||||||
|
|
||||||
|
public class World
|
||||||
{
|
{
|
||||||
public World(long seed)
|
public List<Chunk> chunks;
|
||||||
{
|
|
||||||
|
public World() {
|
||||||
|
chunks = new ArrayList<Chunk>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void generateWorld() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void optimiseChunks() {
|
||||||
|
for(Chunk c: chunks) {
|
||||||
|
optimiseChunk(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void optimiseChunk(int ID) {
|
||||||
|
Chunk chunk = chunks.get(ID);
|
||||||
|
optimiseChunk(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
//used for model combining and culling
|
||||||
|
public Chunk optimiseChunk(Chunk chunk) {
|
||||||
|
//TODO: use this
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(ObjectRenderer entityRenderer)
|
||||||
|
{
|
||||||
|
for(Chunk chunk: chunks) {
|
||||||
|
chunk.render(entityRenderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.github.hydos.ginger;
|
package com.github.hydos.ginger;
|
||||||
|
|
||||||
import com.github.halotroop.litecraft.world.Chunk;
|
import com.github.halotroop.litecraft.world.*;
|
||||||
import com.github.hydos.ginger.engine.api.*;
|
import com.github.hydos.ginger.engine.api.*;
|
||||||
import com.github.hydos.ginger.engine.api.game.*;
|
import com.github.hydos.ginger.engine.api.game.*;
|
||||||
import com.github.hydos.ginger.engine.cameras.Camera;
|
import com.github.hydos.ginger.engine.cameras.Camera;
|
||||||
|
@ -18,7 +18,7 @@ import com.github.hydos.ginger.main.settings.Constants;
|
||||||
|
|
||||||
public class Litecraft extends Game
|
public class Litecraft extends Game
|
||||||
{
|
{
|
||||||
private Chunk exampleManualChunk;
|
private World world;
|
||||||
private Ginger ginger3D;
|
private Ginger ginger3D;
|
||||||
private boolean isInWorld = false;
|
private boolean isInWorld = false;
|
||||||
|
|
||||||
|
@ -44,8 +44,16 @@ public class Litecraft extends Game
|
||||||
data.handleGuis = false;
|
data.handleGuis = false;
|
||||||
ginger3D.setup(new MasterRenderer(camera), this);
|
ginger3D.setup(new MasterRenderer(camera), this);
|
||||||
//YeS?
|
//YeS?
|
||||||
exampleManualChunk = Chunk.generateChunk(0, 0, 0);
|
world = new World();
|
||||||
|
|
||||||
|
for(int i = 0; i<10;i++) {
|
||||||
|
for(int k = 0; k<10;k++) {
|
||||||
|
Chunk exampleManualChunk = Chunk.generateChunk(i, -1, k);
|
||||||
exampleManualChunk.setRender(true);
|
exampleManualChunk.setRender(true);
|
||||||
|
world.chunks.add(exampleManualChunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
|
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
|
||||||
ginger3D.setGlobalFont(font);
|
ginger3D.setGlobalFont(font);
|
||||||
|
@ -55,8 +63,8 @@ public class Litecraft extends Game
|
||||||
data.entities.add(player);
|
data.entities.add(player);
|
||||||
TextureButton playButton = ginger3D.registerButton("/textures/guis/purpur.png", new Vector2f(0, 0), new Vector2f(0.25f, 0.1f));
|
TextureButton playButton = ginger3D.registerButton("/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));
|
// 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);
|
// data.guis.add(title);
|
||||||
//start the game loop
|
//start the game loop
|
||||||
ginger3D.startGame();
|
ginger3D.startGame();
|
||||||
}
|
}
|
||||||
|
@ -78,8 +86,7 @@ public class Litecraft extends Game
|
||||||
oldWindowHeight = Window.height;
|
oldWindowHeight = Window.height;
|
||||||
ginger3D.masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
|
ginger3D.masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
|
||||||
if (isInWorld)
|
if (isInWorld)
|
||||||
{ ginger3D.renderWithoutTerrain(this); }
|
{ ginger3D.renderWithoutTerrain(this, world); }
|
||||||
exampleManualChunk.render(ginger3D.masterRenderer.entityRenderer);
|
|
||||||
ginger3D.renderOverlays(this);
|
ginger3D.renderOverlays(this);
|
||||||
ginger3D.postRender();
|
ginger3D.postRender();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.github.hydos.ginger.engine.api;
|
||||||
|
|
||||||
import com.github.halotroop.litecraft.logic.Timer;
|
import com.github.halotroop.litecraft.logic.Timer;
|
||||||
import com.github.halotroop.litecraft.logic.Timer.TickListener;
|
import com.github.halotroop.litecraft.logic.Timer.TickListener;
|
||||||
|
import com.github.halotroop.litecraft.world.World;
|
||||||
import com.github.hydos.ginger.engine.api.game.*;
|
import com.github.hydos.ginger.engine.api.game.*;
|
||||||
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
|
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
|
||||||
import com.github.hydos.ginger.engine.font.*;
|
import com.github.hydos.ginger.engine.font.*;
|
||||||
|
@ -74,11 +75,11 @@ public class Ginger
|
||||||
TextMaster.render();
|
TextMaster.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderWithoutTerrain(Game game)
|
public void renderWithoutTerrain(Game game, World world)
|
||||||
{
|
{
|
||||||
GingerUtils.preRenderScene(masterRenderer);
|
GingerUtils.preRenderScene(masterRenderer);
|
||||||
contrastFbo.bindFBO();
|
contrastFbo.bindFBO();
|
||||||
masterRenderer.renderSceneNoTerrain(game.data.entities, game.data.normalMapEntities, game.data.lights, game.data.camera, game.data.clippingPlane);
|
masterRenderer.renderSceneNoTerrain(game.data.entities, game.data.normalMapEntities, game.data.lights, game.data.camera, game.data.clippingPlane, world);
|
||||||
ParticleMaster.renderParticles(game.data.camera);
|
ParticleMaster.renderParticles(game.data.camera);
|
||||||
contrastFbo.unbindFBO();
|
contrastFbo.unbindFBO();
|
||||||
PostProcessing.doPostProcessing(contrastFbo.colorTexture);
|
PostProcessing.doPostProcessing(contrastFbo.colorTexture);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.*;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.lwjgl.opengl.*;
|
import org.lwjgl.opengl.*;
|
||||||
|
|
||||||
|
import com.github.halotroop.litecraft.world.World;
|
||||||
import com.github.hydos.ginger.engine.cameras.Camera;
|
import com.github.hydos.ginger.engine.cameras.Camera;
|
||||||
import com.github.hydos.ginger.engine.elements.GuiTexture;
|
import com.github.hydos.ginger.engine.elements.GuiTexture;
|
||||||
import com.github.hydos.ginger.engine.elements.objects.*;
|
import com.github.hydos.ginger.engine.elements.objects.*;
|
||||||
|
@ -162,10 +163,11 @@ public class MasterRenderer
|
||||||
skyboxRenderer.render(camera);
|
skyboxRenderer.render(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderSceneNoTerrain(List<RenderObject> entities, List<RenderObject> normalEntities, List<Light> lights, Camera camera, Vector4f clipPlane)
|
public void renderSceneNoTerrain(List<RenderObject> entities, List<RenderObject> normalEntities, List<Light> lights, Camera camera, Vector4f clipPlane, World world)
|
||||||
{
|
{
|
||||||
prepare();
|
prepare();
|
||||||
renderEntities(entities, camera, lights);
|
renderEntities(entities, camera, lights);
|
||||||
|
world.render(entityRenderer);
|
||||||
renderNormalEntities(normalEntities, lights, camera, clipPlane);
|
renderNormalEntities(normalEntities, lights, camera, clipPlane);
|
||||||
skyboxRenderer.render(camera);
|
skyboxRenderer.render(camera);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue