human-rotate
After Width: | Height: | Size: 429 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 776 KiB |
After Width: | Height: | Size: 382 KiB |
After Width: | Height: | Size: 816 KiB |
After Width: | Height: | Size: 709 KiB |
After Width: | Height: | Size: 504 KiB |
After Width: | Height: | Size: 203 KiB |
After Width: | Height: | Size: 605 KiB |
After Width: | Height: | Size: 379 KiB |
After Width: | Height: | Size: 708 KiB |
After Width: | Height: | Size: 415 KiB |
@ -0,0 +1,52 @@
|
||||
package Scene.Objects;
|
||||
|
||||
import Scene.base.SceneObject;
|
||||
import base.GraphicsObjects.Point4f;
|
||||
import base.GraphicsObjects.Vector4f;
|
||||
import base.objects3D.TexCube;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/5-23:09
|
||||
* @Project: Assignment3
|
||||
* @Package: Scene.Objects
|
||||
* @Description:
|
||||
**/
|
||||
public class Cube extends SceneObject {
|
||||
private TexCube cube = new TexCube();
|
||||
|
||||
public Cube(Point4f origin, Point4f position, Vector4f scale) {
|
||||
super(origin, position, scale);
|
||||
}
|
||||
|
||||
public Cube(Point4f origin, Point4f position, Vector4f scale, HashMap<String, Texture> textures) {
|
||||
super(origin, position, scale, textures);
|
||||
}
|
||||
|
||||
public Cube(Point4f origin, Point4f position, Vector4f scale, Vector4f rotation, HashMap<String, Texture> textures) {
|
||||
super(origin, position, scale, rotation, textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
GL11.glTexParameteri(
|
||||
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
|
||||
GL11.GL_REPEAT);
|
||||
GL11.glTexParameteri(
|
||||
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
|
||||
GL11.GL_REPEAT);
|
||||
Color.white.bind();
|
||||
//bind texture
|
||||
getTextures().get("default_dirt").bind();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
cube.DrawTexCube(1f);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package Scene.base;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/5-22:33
|
||||
* @Project: Assignment3
|
||||
* @Package: Scene.base
|
||||
* @Description:
|
||||
**/
|
||||
public interface IHittable {
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package Scene.skybox;
|
||||
|
||||
import Scene.base.SceneObject;
|
||||
import base.GraphicsObjects.Point4f;
|
||||
import base.GraphicsObjects.Vector4f;
|
||||
import base.objects3D.TexCube;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/5-22:43
|
||||
* @Project: Assignment3
|
||||
* @Package: Scene.skybox
|
||||
* @Description:
|
||||
**/
|
||||
public class Skybox extends SceneObject {
|
||||
private TexCube cube = new TexCube();
|
||||
|
||||
public Skybox(Point4f origin, Point4f position, Vector4f scale) {
|
||||
super(origin, position, scale);
|
||||
init();
|
||||
}
|
||||
|
||||
public Skybox(Point4f origin, Point4f position, Vector4f scale, HashMap<String, Texture> textures) {
|
||||
super(origin, position, scale, textures);
|
||||
init();
|
||||
}
|
||||
|
||||
public Skybox(Point4f origin, Point4f position, Vector4f scale, Vector4f rotation, HashMap<String, Texture> textures) {
|
||||
super(origin, position, scale, rotation, textures);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
|
||||
GL11.glTexParameteri(
|
||||
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
|
||||
GL11.GL_REPEAT);
|
||||
GL11.glTexParameteri(
|
||||
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
|
||||
GL11.GL_REPEAT);
|
||||
Color.white.bind();
|
||||
//bind texture
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
getTextures().get("skybox/down").bind();
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glTexCoord2f(1, 1);
|
||||
GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(1, 0);
|
||||
GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(0, 0);
|
||||
GL11.glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(0, 1);
|
||||
GL11.glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
GL11.glEnd();
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
getTextures().get("skybox/front").bind();
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glTexCoord2f(1, 1);
|
||||
GL11.glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(0, 1);
|
||||
GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(0, 0);
|
||||
GL11.glVertex3f(-0.5f, 0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(1, 0);
|
||||
GL11.glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
GL11.glEnd();
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
getTextures().get("skybox/right").bind();
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glTexCoord2f(1, 1);
|
||||
GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(0, 1);
|
||||
GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(0, 0);
|
||||
GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(1, 0);
|
||||
GL11.glVertex3f(-0.5f, 0.5f, -0.5f);
|
||||
GL11.glEnd();
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
getTextures().get("skybox/left").bind();
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glTexCoord2f(1, 1);
|
||||
GL11.glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(0, 1);
|
||||
GL11.glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(0, 0);
|
||||
GL11.glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(1, 0);
|
||||
GL11.glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
GL11.glEnd();
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
getTextures().get("skybox/back").bind();
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glTexCoord2f(1, 1);
|
||||
GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(0, 1);
|
||||
GL11.glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(0, 0);
|
||||
GL11.glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(1, 0);
|
||||
GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||
GL11.glEnd();
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
getTextures().get("skybox/up").bind();
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glTexCoord2f(1, 1);
|
||||
GL11.glVertex3f(-0.5f, 0.5f, -0.5f);
|
||||
GL11.glTexCoord2f(0, 1);
|
||||
GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(0, 0);
|
||||
GL11.glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
GL11.glTexCoord2f(1, 0);
|
||||
GL11.glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
GL11.glEnd();
|
||||
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package main;
|
||||
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
import org.newdawn.slick.util.ResourceLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/5-22:46
|
||||
* @Project: Assignment3
|
||||
* @Package: main
|
||||
* @Description:
|
||||
**/
|
||||
public class TextureLoader {
|
||||
private static HashMap<String, Texture> textures_map;
|
||||
|
||||
public static void loadTexture(HashMap<String, Texture> textures) {
|
||||
//LOAD textures
|
||||
textures_map = textures;
|
||||
try {
|
||||
loadTexture("awesomeface.png");
|
||||
loadTexture("default_dirt.png");
|
||||
loadTexture("earthspace.png");
|
||||
loadTexture("tnt_side.png");
|
||||
loadTexture("farming_wheat_8.png");
|
||||
loadTexture("wool_pink.png");
|
||||
loadTexture("default_lava.png");
|
||||
loadTexture("default_stone.png");
|
||||
loadTexture("default_cobble.png");
|
||||
|
||||
//sky box
|
||||
loadTexture("skybox/back.png");
|
||||
loadTexture("skybox/down.png");
|
||||
loadTexture("skybox/front.png");
|
||||
loadTexture("skybox/left.png");
|
||||
loadTexture("skybox/right.png");
|
||||
loadTexture("skybox/up.png");
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadTexture(String filename) throws IOException {
|
||||
String key_name = filename.split("\\.")[0];
|
||||
textures_map.put(
|
||||
key_name,
|
||||
org.newdawn.slick.opengl.TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/" + filename))
|
||||
);
|
||||
}
|
||||
}
|