Other stuff
parent
d08a17bf83
commit
662fd9a8ef
|
@ -36,7 +36,7 @@ public class Litecraft extends Game
|
||||||
Window.create(1200, 800, "LiteCraft", 60);
|
Window.create(1200, 800, "LiteCraft", 60);
|
||||||
GingerUtils.init();
|
GingerUtils.init();
|
||||||
Window.setBackgroundColour(0.2f, 0.2f, 0.6f);
|
Window.setBackgroundColour(0.2f, 0.2f, 0.6f);
|
||||||
TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/soil/gravel.png");
|
TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/brick.png");
|
||||||
StaticCube.scaleCube(1);
|
StaticCube.scaleCube(1);
|
||||||
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(dirtModel, 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);
|
||||||
|
|
|
@ -5,17 +5,15 @@ import com.github.hydos.ginger.engine.render.models.TexturedModel;
|
||||||
|
|
||||||
public class Block
|
public class Block
|
||||||
{
|
{
|
||||||
|
public static final Block AIR = new Block(new Properties().visible(false));
|
||||||
|
public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties());
|
||||||
|
public static final Block STONE = new Block("block/cubes/stone/basic/gneiss.png", new Properties());
|
||||||
|
|
||||||
public static class Properties
|
public static class Properties
|
||||||
{ // add properties to this builder!
|
{ // add properties to this builder!
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
private boolean fullCube = true;
|
private boolean fullCube = true;
|
||||||
|
|
||||||
public Properties visible(boolean visible)
|
|
||||||
{
|
|
||||||
this.visible = visible;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Properties fullCube(boolean fullCube)
|
public Properties fullCube(boolean fullCube)
|
||||||
{
|
{
|
||||||
this.fullCube = fullCube;
|
this.fullCube = fullCube;
|
||||||
|
@ -27,14 +25,20 @@ public class Block
|
||||||
|
|
||||||
public boolean isVisible()
|
public boolean isVisible()
|
||||||
{ return visible; }
|
{ return visible; }
|
||||||
|
|
||||||
|
public Properties visible(boolean visible)
|
||||||
|
{
|
||||||
|
this.visible = visible;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Block AIR = new Block(new Properties().visible(false));
|
|
||||||
public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties());
|
|
||||||
public static final Block STONE = new Block("block/cubes/stone/cobblestone.png", new Properties());
|
|
||||||
public final TexturedModel model;
|
public final TexturedModel model;
|
||||||
public final boolean visible;
|
public final boolean visible;
|
||||||
|
|
||||||
|
protected Block(Properties properties)
|
||||||
|
{ this((TexturedModel) null, properties); }
|
||||||
|
|
||||||
protected Block(String texture, Properties properties)
|
protected Block(String texture, Properties properties)
|
||||||
{ this(ModelLoader.loadGenericCube(texture), properties); }
|
{ this(ModelLoader.loadGenericCube(texture), properties); }
|
||||||
|
|
||||||
|
@ -43,7 +47,4 @@ public class Block
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.visible = properties.visible;
|
this.visible = properties.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Block(Properties properties)
|
|
||||||
{ this((TexturedModel) null, properties); }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class FirstPersonCamera extends Camera
|
||||||
public FirstPersonCamera(Player player)
|
public FirstPersonCamera(Player player)
|
||||||
{
|
{
|
||||||
super(player);
|
super(player);
|
||||||
|
player.isVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPitch()
|
public float getPitch()
|
||||||
|
@ -35,6 +36,5 @@ public class FirstPersonCamera extends Camera
|
||||||
roll = player.getRotX();
|
roll = player.getRotX();
|
||||||
yaw = -player.getRotY() + 180;
|
yaw = -player.getRotY() + 180;
|
||||||
pitch = player.getRotZ();
|
pitch = player.getRotZ();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@ public class ModelLoader
|
||||||
|
|
||||||
public static TexturedModel loadModel(String objPath, String texturePath)
|
public static TexturedModel loadModel(String objPath, String texturePath)
|
||||||
{
|
{
|
||||||
Mesh data = OBJFileLoader.loadModel(objPath, texturePath);
|
Mesh data = OBJFileLoader.loadModel(objPath);
|
||||||
TexturedModel tm = new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath));
|
return new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(),data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath));
|
||||||
return tm;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import com.github.hydos.ginger.engine.math.vectors.*;
|
||||||
|
|
||||||
public class OBJFileLoader
|
public class OBJFileLoader
|
||||||
{
|
{
|
||||||
public static String resourceLocation = "C:/Users/Hayden/Desktop/Ginger3D/src/main/resources/models/";
|
public static String resourceLocation = "~/Desktop/Ginger3D/src/main/resources/models/";
|
||||||
|
|
||||||
public static Mesh loadModel(String filePath, String texturePath)
|
public static Mesh loadModel(String filePath)
|
||||||
{
|
{
|
||||||
AIScene scene = null;
|
AIScene scene = null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class ModelTexture
|
||||||
|
|
||||||
public ModelTexture(String file)
|
public ModelTexture(String file)
|
||||||
{
|
{
|
||||||
|
// TODO: Add a missing texture placholder in case of null file.
|
||||||
texture = Image.createImage("/textures/" + file);
|
texture = Image.createImage("/textures/" + file);
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textureID);
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textureID);
|
||||||
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 10241, 9729.0f);
|
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 10241, 9729.0f);
|
||||||
|
|
Loading…
Reference in New Issue