Compare commits
No commits in common. "aecfb18d9dda20aff4b15bf0e531423b2d57bfe4" and "d3dce2074769fc868a76649cdde9ae88e841f0e6" have entirely different histories.
aecfb18d9d
...
d3dce20747
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 991 KiB |
Before Width: | Height: | Size: 938 KiB |
Before Width: | Height: | Size: 1003 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 24 KiB |
@ -154,7 +154,7 @@ public class MainGameLoop {
|
|||||||
guis.add(gui);
|
guis.add(gui);
|
||||||
|
|
||||||
GuiRenderer guiRenderer = new GuiRenderer(loader);
|
GuiRenderer guiRenderer = new GuiRenderer(loader);
|
||||||
MasterRenderer renderer = new MasterRenderer(loader);
|
MasterRenderer renderer = new MasterRenderer();
|
||||||
|
|
||||||
manager.setDrawer(new DisplayManagerDraw() {
|
manager.setDrawer(new DisplayManagerDraw() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,7 @@ public class GuiRenderer {
|
|||||||
|
|
||||||
public GuiRenderer(Loader loader) {
|
public GuiRenderer(Loader loader) {
|
||||||
float[] positions = {-1, 1, -1, -1, 1, 1, 1, -1};
|
float[] positions = {-1, 1, -1, -1, 1, 1, 1, -1};
|
||||||
quad = loader.loadToVAO(positions, 2);
|
quad = loader.loadToVAO(positions);
|
||||||
shader = new GuiShader();
|
shader = new GuiShader();
|
||||||
}
|
}
|
||||||
public void render(List<GuiTexture> guis) {
|
public void render(List<GuiTexture> guis) {
|
||||||
|
@ -15,11 +15,11 @@ import org.lwjgl.opengl.GL13;
|
|||||||
import org.lwjgl.opengl.GL15;
|
import org.lwjgl.opengl.GL15;
|
||||||
import org.lwjgl.opengl.GL20;
|
import org.lwjgl.opengl.GL20;
|
||||||
import org.lwjgl.opengl.GL30;
|
import org.lwjgl.opengl.GL30;
|
||||||
|
import org.lwjgl.openvr.Texture;
|
||||||
|
|
||||||
import de.matthiasmann.twl.utils.PNGDecoder;
|
import de.matthiasmann.twl.utils.PNGDecoder;
|
||||||
import de.matthiasmann.twl.utils.PNGDecoder.Format;
|
import de.matthiasmann.twl.utils.PNGDecoder.Format;
|
||||||
import models.RawModel;
|
import models.RawModel;
|
||||||
import textures.TextureData;
|
|
||||||
|
|
||||||
|
|
||||||
public class Loader {
|
public class Loader {
|
||||||
@ -49,12 +49,12 @@ public class Loader {
|
|||||||
unbindVAO();
|
unbindVAO();
|
||||||
return new RawModel(vaoID, indices.length);
|
return new RawModel(vaoID, indices.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RawModel loadToVAO(float[] positions, int dimentions) {
|
public RawModel loadToVAO(float[] positions) {
|
||||||
int vaoID = createVAO();
|
int vaoID = createVAO();
|
||||||
this.storeDataInAttributeList(0, dimentions, positions);
|
this.storeDataInAttributeList(0, 2, positions);
|
||||||
unbindVAO();
|
unbindVAO();
|
||||||
return new RawModel(vaoID, positions.length/dimentions);
|
return new RawModel(vaoID, positions.length/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int loadTexture(String filename) {
|
public int loadTexture(String filename) {
|
||||||
@ -65,29 +65,7 @@ public class Loader {
|
|||||||
return textureId;
|
return textureId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int loadCubeMap(String[] textureFiles) {
|
private int loadPNGTexture(String filename, int textureUnit) {
|
||||||
int texId = GL11.glGenTextures();
|
|
||||||
GL13.glActiveTexture(GL13.GL_TEXTURE0);
|
|
||||||
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texId);
|
|
||||||
for (int i=0; i<textureFiles.length; i++) {
|
|
||||||
TextureData data = decodeTextureFile("res/" + textureFiles[i] + ".png");
|
|
||||||
GL13.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0,
|
|
||||||
GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0,
|
|
||||||
GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
|
|
||||||
data.getBuffer());
|
|
||||||
}
|
|
||||||
// Setup what to do when the texture has to be scaled
|
|
||||||
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
|
|
||||||
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
|
||||||
|
|
||||||
//this.exitOnGLError("loadCubeMap");
|
|
||||||
textures.add(texId);
|
|
||||||
return texId;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private TextureData decodeTextureFile(String filename) {
|
|
||||||
ByteBuffer buf = null;
|
ByteBuffer buf = null;
|
||||||
int tWidth = 0;
|
int tWidth = 0;
|
||||||
int tHeight = 0;
|
int tHeight = 0;
|
||||||
@ -107,14 +85,9 @@ public class Loader {
|
|||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("try to load texture " + filename + ", didn't work");
|
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
return new TextureData(buf, tWidth, tHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int loadPNGTexture(String filename, int textureUnit) {
|
|
||||||
TextureData data = decodeTextureFile(filename);
|
|
||||||
// Create a new texture object in memory and bind it
|
// Create a new texture object in memory and bind it
|
||||||
int texId = GL11.glGenTextures();
|
int texId = GL11.glGenTextures();
|
||||||
GL13.glActiveTexture(textureUnit);
|
GL13.glActiveTexture(textureUnit);
|
||||||
@ -124,7 +97,7 @@ public class Loader {
|
|||||||
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
|
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
// Upload the texture data and generate mip maps (for scaling)
|
// Upload the texture data and generate mip maps (for scaling)
|
||||||
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data.getBuffer());
|
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, tWidth, tHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf);
|
||||||
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
|
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
|
||||||
|
|
||||||
// Setup the ST coordinate system
|
// Setup the ST coordinate system
|
||||||
@ -138,7 +111,7 @@ public class Loader {
|
|||||||
// GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
// GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
||||||
|
|
||||||
this.exitOnGLError("loadPNGTexture");
|
this.exitOnGLError("loadPNGTexture");
|
||||||
textures.add(texId);
|
|
||||||
return texId;
|
return texId;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -17,14 +17,13 @@ import entities.Light;
|
|||||||
import models.TexturedModel;
|
import models.TexturedModel;
|
||||||
import shaders.StaticShader;
|
import shaders.StaticShader;
|
||||||
import shaders.TerrainShader;
|
import shaders.TerrainShader;
|
||||||
import skybox.SkyboxRenderer;
|
|
||||||
import terrains.Terrain;
|
import terrains.Terrain;
|
||||||
|
|
||||||
public class MasterRenderer {
|
public class MasterRenderer {
|
||||||
private static final float FOV = 70;
|
private static final float FOV = 70;
|
||||||
private static final float NEAR_PLANE = 0.1f;
|
private static final float NEAR_PLANE = 0.1f;
|
||||||
private static final float FAR_PLANE = 10000;
|
private static final float FAR_PLANE = 10000;
|
||||||
private static final Vector3f SKY_COLOUR = new Vector3f(0.5444f, 0.62f, 0.69f);
|
private static final Vector3f SKY_COLOUR = new Vector3f(0.5f, 0.5f, 0.5f);
|
||||||
|
|
||||||
private Matrix4f projectionMatrix;
|
private Matrix4f projectionMatrix;
|
||||||
|
|
||||||
@ -37,16 +36,13 @@ public class MasterRenderer {
|
|||||||
private Map<TexturedModel, List<Entity>> entities = new HashMap<TexturedModel, List<Entity>>();
|
private Map<TexturedModel, List<Entity>> entities = new HashMap<TexturedModel, List<Entity>>();
|
||||||
private List<Terrain> terrains = new ArrayList<Terrain>();
|
private List<Terrain> terrains = new ArrayList<Terrain>();
|
||||||
|
|
||||||
private SkyboxRenderer skyboxRenderer;
|
public MasterRenderer() {
|
||||||
|
|
||||||
public MasterRenderer(Loader loader) {
|
|
||||||
enableCulling();
|
enableCulling();
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
createProjectionMatrix();
|
createProjectionMatrix();
|
||||||
renderer = new EntityRenderer(shader, projectionMatrix);
|
renderer = new EntityRenderer(shader, projectionMatrix);
|
||||||
terrainRenderer = new TerrainRenderer(terrainShader, projectionMatrix);
|
terrainRenderer = new TerrainRenderer(terrainShader, projectionMatrix);
|
||||||
skyboxRenderer = new SkyboxRenderer(loader, projectionMatrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void enableCulling() {
|
public static void enableCulling() {
|
||||||
@ -60,7 +56,6 @@ public class MasterRenderer {
|
|||||||
|
|
||||||
public void render(List<Light> lights, Camera camera) {
|
public void render(List<Light> lights, Camera camera) {
|
||||||
prepare();
|
prepare();
|
||||||
skyboxRenderer.render(camera, SKY_COLOUR);
|
|
||||||
shader.start();
|
shader.start();
|
||||||
shader.loadSkyColour(SKY_COLOUR);
|
shader.loadSkyColour(SKY_COLOUR);
|
||||||
shader.loadLights(lights);
|
shader.loadLights(lights);
|
||||||
|
@ -1,124 +0,0 @@
|
|||||||
package skybox;
|
|
||||||
|
|
||||||
import org.atriaSoft.etk.math.Matrix4f;
|
|
||||||
import org.atriaSoft.etk.math.Vector3f;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL13;
|
|
||||||
import org.lwjgl.opengl.GL20;
|
|
||||||
import org.lwjgl.opengl.GL30;
|
|
||||||
|
|
||||||
import entities.Camera;
|
|
||||||
import models.RawModel;
|
|
||||||
import renderEngine.DisplayManager;
|
|
||||||
import renderEngine.Loader;
|
|
||||||
|
|
||||||
public class SkyboxRenderer {
|
|
||||||
private static final float SIZE = 500f;
|
|
||||||
private static final float[] VERTICES = {
|
|
||||||
-SIZE, SIZE, -SIZE,
|
|
||||||
-SIZE, -SIZE, -SIZE,
|
|
||||||
SIZE, -SIZE, -SIZE,
|
|
||||||
SIZE, -SIZE, -SIZE,
|
|
||||||
SIZE, SIZE, -SIZE,
|
|
||||||
-SIZE, SIZE, -SIZE,
|
|
||||||
|
|
||||||
-SIZE, -SIZE, SIZE,
|
|
||||||
-SIZE, -SIZE, -SIZE,
|
|
||||||
-SIZE, SIZE, -SIZE,
|
|
||||||
-SIZE, SIZE, -SIZE,
|
|
||||||
-SIZE, SIZE, SIZE,
|
|
||||||
-SIZE, -SIZE, SIZE,
|
|
||||||
|
|
||||||
SIZE, -SIZE, -SIZE,
|
|
||||||
SIZE, -SIZE, SIZE,
|
|
||||||
SIZE, SIZE, SIZE,
|
|
||||||
SIZE, SIZE, SIZE,
|
|
||||||
SIZE, SIZE, -SIZE,
|
|
||||||
SIZE, -SIZE, -SIZE,
|
|
||||||
|
|
||||||
-SIZE, -SIZE, SIZE,
|
|
||||||
-SIZE, SIZE, SIZE,
|
|
||||||
SIZE, SIZE, SIZE,
|
|
||||||
SIZE, SIZE, SIZE,
|
|
||||||
SIZE, -SIZE, SIZE,
|
|
||||||
-SIZE, -SIZE, SIZE,
|
|
||||||
|
|
||||||
-SIZE, SIZE, -SIZE,
|
|
||||||
SIZE, SIZE, -SIZE,
|
|
||||||
SIZE, SIZE, SIZE,
|
|
||||||
SIZE, SIZE, SIZE,
|
|
||||||
-SIZE, SIZE, SIZE,
|
|
||||||
-SIZE, SIZE, -SIZE,
|
|
||||||
|
|
||||||
-SIZE, -SIZE, -SIZE,
|
|
||||||
-SIZE, -SIZE, SIZE,
|
|
||||||
SIZE, -SIZE, -SIZE,
|
|
||||||
SIZE, -SIZE, -SIZE,
|
|
||||||
-SIZE, -SIZE, SIZE,
|
|
||||||
SIZE, -SIZE, SIZE
|
|
||||||
};
|
|
||||||
|
|
||||||
private static String[] TEXTURE_FILES = { "skybox/right", "skybox/left", "skybox/top", "skybox/bottom", "skybox/back", "skybox/front"};
|
|
||||||
private static String[] TEXTURE_FILES2 = { "skybox2/right", "skybox2/left", "skybox2/top", "skybox2/bottom", "skybox2/back", "skybox2/front"};
|
|
||||||
|
|
||||||
private RawModel cube;
|
|
||||||
private int texture;
|
|
||||||
private int texture2;
|
|
||||||
private SkyboxShader shader;
|
|
||||||
private float time;
|
|
||||||
|
|
||||||
public SkyboxRenderer(Loader loader, Matrix4f projectionMatrix) {
|
|
||||||
cube = loader.loadToVAO(VERTICES, 3);
|
|
||||||
texture = loader.loadCubeMap(TEXTURE_FILES);
|
|
||||||
texture2 = loader.loadCubeMap(TEXTURE_FILES2);
|
|
||||||
shader = new SkyboxShader();
|
|
||||||
shader.start();
|
|
||||||
shader.connectTextureUnits();
|
|
||||||
shader.loadProjectionMatrix(projectionMatrix);
|
|
||||||
shader.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(Camera camera, Vector3f colour) {
|
|
||||||
shader.start();
|
|
||||||
shader.loadViewMatrix(camera);
|
|
||||||
shader.loadFogColour(colour);
|
|
||||||
GL30.glBindVertexArray(cube.getVaoID());
|
|
||||||
GL20.glEnableVertexAttribArray(0);
|
|
||||||
bindTextures();
|
|
||||||
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, cube.getVertexCount());
|
|
||||||
GL20.glDisableVertexAttribArray(0);
|
|
||||||
GL30.glBindVertexArray(0);
|
|
||||||
shader.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void bindTextures(){
|
|
||||||
time += DisplayManager.getFrameTimeSecconds() * 1000;
|
|
||||||
time %= 24000;
|
|
||||||
int texture1;
|
|
||||||
int texture2;
|
|
||||||
float blendFactor;
|
|
||||||
if(time >= 0 && time < 5000){
|
|
||||||
texture1 = this.texture2;
|
|
||||||
texture2 = this.texture2;
|
|
||||||
blendFactor = (time - 0)/(5000 - 0);
|
|
||||||
}else if(time >= 5000 && time < 8000){
|
|
||||||
texture1 = this.texture2;
|
|
||||||
texture2 = this.texture;
|
|
||||||
blendFactor = (time - 5000)/(8000 - 5000);
|
|
||||||
}else if(time >= 8000 && time < 21000){
|
|
||||||
texture1 = this.texture;
|
|
||||||
texture2 = this.texture;
|
|
||||||
blendFactor = (time - 8000)/(21000 - 8000);
|
|
||||||
}else{
|
|
||||||
texture1 = this.texture;
|
|
||||||
texture2 = this.texture2;
|
|
||||||
blendFactor = (time - 21000)/(24000 - 21000);
|
|
||||||
}
|
|
||||||
GL13.glActiveTexture(GL13.GL_TEXTURE0);
|
|
||||||
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texture1);
|
|
||||||
GL13.glActiveTexture(GL13.GL_TEXTURE1);
|
|
||||||
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texture2);
|
|
||||||
shader.loadBlendFactor(blendFactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
package skybox;
|
|
||||||
|
|
||||||
import org.atriaSoft.etk.math.Matrix4f;
|
|
||||||
import org.atriaSoft.etk.math.Vector3f;
|
|
||||||
|
|
||||||
import entities.Camera;
|
|
||||||
import renderEngine.DisplayManager;
|
|
||||||
import shaders.ShaderProgram;
|
|
||||||
import toolbox.Maths;
|
|
||||||
|
|
||||||
public class SkyboxShader extends ShaderProgram {
|
|
||||||
|
|
||||||
private static final String VERTEX_FILE = "src/skybox/skyboxVertexShader.txt";
|
|
||||||
private static final String FRAGMENT_FILE = "src/skybox/skyboxFragmentShader.txt";
|
|
||||||
|
|
||||||
private static final float ROTATE_SPEED = 0.02f;
|
|
||||||
|
|
||||||
private int location_projectionMatrix;
|
|
||||||
private int location_viewMatrix;
|
|
||||||
private int location_fogColour;
|
|
||||||
private int location_cubeMap;
|
|
||||||
private int location_cubeMap2;
|
|
||||||
private int location_blendFactor;
|
|
||||||
|
|
||||||
private float rotation = 0;
|
|
||||||
|
|
||||||
public SkyboxShader() {
|
|
||||||
super(VERTEX_FILE, FRAGMENT_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadProjectionMatrix(Matrix4f matrix){
|
|
||||||
super.loadMatrix(location_projectionMatrix, matrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadViewMatrix(Camera camera){
|
|
||||||
Matrix4f matrix = Maths.createViewMatrixNoTranslate(camera);
|
|
||||||
rotation += ROTATE_SPEED * DisplayManager.getFrameTimeSecconds();
|
|
||||||
matrix.rotate(new Vector3f(0,1,0), rotation);
|
|
||||||
super.loadMatrix(location_viewMatrix, matrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadFogColour(Vector3f colour) {
|
|
||||||
super.loadVector(location_fogColour, colour);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void connectTextureUnits() {
|
|
||||||
super.loadInt(location_cubeMap, 0);
|
|
||||||
super.loadInt(location_cubeMap2, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadBlendFactor(float factor) {
|
|
||||||
super.loadFloat(location_blendFactor, factor);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void getAllUniformLocations() {
|
|
||||||
location_projectionMatrix = super.getUniformLocation("projectionMatrix");
|
|
||||||
location_viewMatrix = super.getUniformLocation("viewMatrix");
|
|
||||||
location_fogColour = super.getUniformLocation("fogColour");
|
|
||||||
location_cubeMap = super.getUniformLocation("cubeMap");
|
|
||||||
location_cubeMap2 = super.getUniformLocation("cubeMap2");
|
|
||||||
location_blendFactor = super.getUniformLocation("blendFactor");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void bindAttributes() {
|
|
||||||
super.bindAttribute(0, "position");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#version 400
|
|
||||||
|
|
||||||
in vec3 textureCoords;
|
|
||||||
out vec4 out_Color;
|
|
||||||
|
|
||||||
uniform samplerCube cubeMap;
|
|
||||||
uniform samplerCube cubeMap2;
|
|
||||||
uniform float blendFactor;
|
|
||||||
uniform vec3 fogColour;
|
|
||||||
|
|
||||||
const float lowerLimit = 0.0;
|
|
||||||
const float upperLimit = 30.0;
|
|
||||||
|
|
||||||
void main(void){
|
|
||||||
vec4 texture1 = texture(cubeMap, textureCoords);
|
|
||||||
vec4 texture2 = texture(cubeMap2, textureCoords);
|
|
||||||
vec4 finalColour = mix(texture1, texture2, blendFactor);
|
|
||||||
float factor = (textureCoords.y - lowerLimit) / (upperLimit - lowerLimit);
|
|
||||||
factor = clamp(factor, 0.0, 1.0);
|
|
||||||
out_Color = mix(vec4(fogColour,1.0), finalColour, factor);
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
#version 400
|
|
||||||
|
|
||||||
in vec3 position;
|
|
||||||
out vec3 textureCoords;
|
|
||||||
|
|
||||||
uniform mat4 projectionMatrix;
|
|
||||||
uniform mat4 viewMatrix;
|
|
||||||
|
|
||||||
void main(void){
|
|
||||||
|
|
||||||
gl_Position = projectionMatrix * viewMatrix * vec4(position, 1.0);
|
|
||||||
textureCoords = position;
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package textures;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
public class TextureData {
|
|
||||||
private int width;
|
|
||||||
private int height;
|
|
||||||
private ByteBuffer buffer;
|
|
||||||
|
|
||||||
public TextureData(ByteBuffer buffer, int width, int height){
|
|
||||||
this.buffer = buffer;
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth(){
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight(){
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ByteBuffer getBuffer(){
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
}
|
|
@ -27,17 +27,13 @@ public class Maths {
|
|||||||
matrix.scale(scale);
|
matrix.scale(scale);
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
public static Matrix4f createViewMatrixNoTranslate(Camera camera) {
|
public static Matrix4f createViewMatrix(Camera camera) {
|
||||||
// Need to rework all of this this is really not optimum ...
|
// Need to rework all of this this is really not optimum ...
|
||||||
Matrix4f matrix = new Matrix4f();
|
Matrix4f matrix = new Matrix4f();
|
||||||
matrix.setIdentity();
|
matrix.setIdentity();
|
||||||
matrix.rotate(new Vector3f(1,0,0), camera.getPitch());
|
matrix.rotate(new Vector3f(1,0,0), camera.getPitch());
|
||||||
matrix.rotate(new Vector3f(0,1,0), camera.getYaw());
|
matrix.rotate(new Vector3f(0,1,0), camera.getYaw());
|
||||||
return matrix;
|
//matrix.rotate(new Vector3f(0,0,1), camera.getRoll());
|
||||||
}
|
|
||||||
public static Matrix4f createViewMatrix(Camera camera) {
|
|
||||||
// Need to rework all of this this is really not optimum ...
|
|
||||||
Matrix4f matrix = createViewMatrixNoTranslate(camera);
|
|
||||||
Vector3f camarePos = camera.getPosition();
|
Vector3f camarePos = camera.getPosition();
|
||||||
matrix.translate(new Vector3f(-camarePos.x,-camarePos.y,-camarePos.z));
|
matrix.translate(new Vector3f(-camarePos.x,-camarePos.y,-camarePos.z));
|
||||||
return matrix;
|
return matrix;
|
||||||
@ -49,5 +45,4 @@ public class Maths {
|
|||||||
matrix.scale(new Vector3f(scale.x, scale.y, 1f));
|
matrix.scale(new Vector3f(scale.x, scale.y, 1f));
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|