world generation
parent
56503a0ac2
commit
f8534e718a
|
@ -1,10 +1,45 @@
|
|||
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;
|
||||
|
||||
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.game.*;
|
||||
import com.github.hydos.ginger.engine.cameras.Camera;
|
||||
|
@ -18,14 +18,14 @@ import com.github.hydos.ginger.main.settings.Constants;
|
|||
|
||||
public class Litecraft extends Game
|
||||
{
|
||||
private Chunk exampleManualChunk;
|
||||
private World world;
|
||||
private Ginger ginger3D;
|
||||
private boolean isInWorld = false;
|
||||
|
||||
//temp stuff to test out fbo fixes
|
||||
int oldWindowWidth = Window.width;
|
||||
int oldWindowHeight = Window.height;
|
||||
|
||||
|
||||
public Litecraft()
|
||||
{
|
||||
Constants.movementSpeed = 0.00005f;
|
||||
|
@ -44,8 +44,16 @@ public class Litecraft extends Game
|
|||
data.handleGuis = false;
|
||||
ginger3D.setup(new MasterRenderer(camera), this);
|
||||
//YeS?
|
||||
exampleManualChunk = Chunk.generateChunk(0, 0, 0);
|
||||
exampleManualChunk.setRender(true);
|
||||
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);
|
||||
world.chunks.add(exampleManualChunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
|
||||
ginger3D.setGlobalFont(font);
|
||||
|
@ -55,8 +63,8 @@ public class Litecraft extends Game
|
|||
data.entities.add(player);
|
||||
TextureButton playButton = ginger3D.registerButton("/textures/guis/purpur.png", new Vector2f(0, 0), new Vector2f(0.25f, 0.1f));
|
||||
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);
|
||||
// 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);
|
||||
//start the game loop
|
||||
ginger3D.startGame();
|
||||
}
|
||||
|
@ -78,8 +86,7 @@ public class Litecraft extends Game
|
|||
oldWindowHeight = Window.height;
|
||||
ginger3D.masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
|
||||
if (isInWorld)
|
||||
{ ginger3D.renderWithoutTerrain(this); }
|
||||
exampleManualChunk.render(ginger3D.masterRenderer.entityRenderer);
|
||||
{ ginger3D.renderWithoutTerrain(this, world); }
|
||||
ginger3D.renderOverlays(this);
|
||||
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.TickListener;
|
||||
import com.github.halotroop.litecraft.world.World;
|
||||
import com.github.hydos.ginger.engine.api.game.*;
|
||||
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
|
||||
import com.github.hydos.ginger.engine.font.*;
|
||||
|
@ -74,11 +75,11 @@ public class Ginger
|
|||
TextMaster.render();
|
||||
}
|
||||
|
||||
public void renderWithoutTerrain(Game game)
|
||||
public void renderWithoutTerrain(Game game, World world)
|
||||
{
|
||||
GingerUtils.preRenderScene(masterRenderer);
|
||||
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);
|
||||
contrastFbo.unbindFBO();
|
||||
PostProcessing.doPostProcessing(contrastFbo.colorTexture);
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.*;
|
|||
import org.joml.Vector4f;
|
||||
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.elements.GuiTexture;
|
||||
import com.github.hydos.ginger.engine.elements.objects.*;
|
||||
|
@ -162,10 +163,11 @@ public class MasterRenderer
|
|||
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();
|
||||
renderEntities(entities, camera, lights);
|
||||
world.render(entityRenderer);
|
||||
renderNormalEntities(normalEntities, lights, camera, clipPlane);
|
||||
skyboxRenderer.render(camera);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue