master
王宇洋 3 years ago
parent 50dbab9508
commit 2a5e062e6a

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 KiB

After

Width:  |  Height:  |  Size: 363 KiB

@ -57,7 +57,7 @@ public class Book extends SceneObject {
@Override
public void draw() {
public void draw(Integer frame_delta) {
Color.white.bind();
glRotatef(yRotation, 0, 1, 0);
getTextures().get("warped_door_bottom").bind();

@ -33,7 +33,7 @@ public class BookShelf extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
Color.white.bind();
getTextures().get("bookshelf").bind();
GL11.glTexParameteri(

@ -76,9 +76,9 @@ public class BunnyTestObject extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
timePassed = Engine.getTimePassed()/10000.0f;
float speed = 0.1f;
float speed = frame_delta/160f;
if((int) (timePassed % 4) == 0){
move(new Vector4f(speed,0,0,0));
angle_target = 90;

@ -70,7 +70,7 @@ public class BunnyTestObject2 extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
GL11.glDisable(GL_TEXTURE_2D);
timePassed = Engine.getTimePassed()/10000.0f;
float speed = 0.1f;

@ -39,7 +39,7 @@ public class CarportObject extends SceneObject {
@Override
public void draw() {
public void draw(Integer frame_delta) {
Color.white.bind();
glCallList(base.objects3D.CarportObject.getHouseDisplayList());
Color.white.bind();

@ -17,23 +17,23 @@ import java.util.HashMap;
* @Package: Scene.Objects
* @Description:
**/
public class Copyright extends SceneObject {
public class Copyleft extends SceneObject {
private TexCube cube = new TexCube();
public Copyright(Point4f origin, Point4f position, Vector4f scale) {
public Copyleft(Point4f origin, Point4f position, Vector4f scale) {
super(origin, position, scale);
}
public Copyright(Point4f origin, Point4f position, Vector4f scale, HashMap<String, Texture> textures) {
public Copyleft(Point4f origin, Point4f position, Vector4f scale, HashMap<String, Texture> textures) {
super(origin, position, scale, textures);
}
public Copyright(Point4f origin, Point4f position, Vector4f scale, Vector4f rotation, HashMap<String, Texture> textures) {
public Copyleft(Point4f origin, Point4f position, Vector4f scale, Vector4f rotation, HashMap<String, Texture> textures) {
super(origin, position, scale, rotation, textures);
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
GL11.GL_REPEAT);
@ -42,7 +42,7 @@ public class Copyright extends SceneObject {
GL11.GL_REPEAT);
Color.white.bind();
//bind texture
getTextures().get("copyright").bind();
getTextures().get("copyleft").bind();
;
// GL11.glDisable(GL11.GL_LIGHTING); // switch lighting off
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

@ -33,7 +33,7 @@ public class Cube extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
GL11.GL_REPEAT);

@ -38,7 +38,7 @@ public class Ground extends SceneObject {
@Override
public void draw() {
public void draw(Integer frame_delta) {
;
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,

@ -29,7 +29,7 @@ public class LAVA_Door extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
Color.white.bind();
getTextures().get("default_lava").bind();

@ -172,9 +172,9 @@ public class NPC extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
timePassed = Engine.getTimePassed()/10000.0f;
float speed = 0.1f;
float speed = frame_delta/160f;
// System.out.println(speed);
walk();
if((int) (timePassed % 4) == 0){

@ -49,6 +49,7 @@ public class Player extends SceneObject {
private Boolean isJumping = false;
private float jump_height = 0f;
public static Integer frame_delta = 0;
DisplayListTexSphere s1 = new DisplayListTexSphere(0.5f, 32, 32, getTextures().get("wool_pink"));
@ -177,8 +178,8 @@ public class Player extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
Player.frame_delta = frame_delta;
GL11.glTranslatef(0, jump_height, 0);
Boolean GoodAnimation = true;
float theta_face = (float) (delta * 2 * Math.PI);
@ -696,7 +697,7 @@ public class Player extends SceneObject {
Boolean KEY_D = Keyboard.isKeyDown(Keyboard.KEY_D);
Player player = (Player) this;
Integer speed = 10;
float speed = Player.frame_delta/1.6f;
float speedX = speed / player.getScale().x;
float speedY = speed / player.getScale().y;
float speedZ = speed / player.getScale().z;

@ -31,7 +31,7 @@ public class TNT_Door extends SceneObject {
@Override
public void draw() {
public void draw(Integer frame_delta) {
;
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
Color.white.bind();

@ -32,7 +32,7 @@ public class Table extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
Color.white.bind();
getTextures().get("enchanting_table_top").bind();
GL11.glTexParameteri(

@ -32,7 +32,7 @@ public class TestObj extends SceneObject {
}
@Override
public void draw() {
public void draw(Integer frame_delta) {
Color.black.bind();
oval.DrawOval(1, 32);
}

@ -34,7 +34,7 @@ public class Wall extends SceneObject {
@Override
public void draw() {
public void draw(Integer frame_delta) {
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,

@ -61,14 +61,14 @@ public class Scene {
// .setParticleLifeTime(300)
// .createParticleEmitter();
//
// private static ParticleEmitter backParticleEmitter = new ParticleEmitterBuilder()
// .setLocation(new Vector3f(0,12900,-2.5f))
// .setEnable3D(true)
// .setInitialVelocity(new Vector3f(0, 0, 0))
// .setGravity(new Vector3f(0, -0.4f, 0))
// .setSpawningRate(20)
// .setParticleLifeTime(300)
// .createParticleEmitter();
private static ParticleEmitter backParticleEmitter = new ParticleEmitterBuilder()
.setLocation(new Vector3f(0,12900,-2.5f))
.setEnable3D(true)
.setInitialVelocity(new Vector3f(0, 0, 0))
.setGravity(new Vector3f(0, -0.4f, 0))
.setSpawningRate(10)
.setParticleLifeTime(200)
.createParticleEmitter();
public static void initScene(SceneManager sceneManager, HashMap textures) {
@ -393,14 +393,14 @@ public class Scene {
textures
));
sceneManager.addSceneObject(new Copyright(
sceneManager.addSceneObject(new Copyleft(
new Point4f(-5000, 3500, 0, 0),
new Point4f(0, 0, 0, 0),
new Vector4f(100, 2000, 3000, 0),
new Vector4f(1, 0, 0, 180),
textures
));
sceneManager.addSceneObject(new Copyright(
sceneManager.addSceneObject(new Copyleft(
new Point4f(5000, 3500, 0, 0),
new Point4f(0, 0, 0, 0),
new Vector4f(100, 2000, 3000, 0),
@ -439,10 +439,10 @@ public class Scene {
bookParticleEmitter.draw();
// rightParticleEmitter.draw();
// leftParticleEmitter.draw();
// backParticleEmitter.draw();
backParticleEmitter.draw();
GL11.glPopMatrix();
}
});
}, delta);
frontParticleEmitter.update();
bookParticleEmitter.update();
@ -450,7 +450,7 @@ public class Scene {
bookParticleEmitter.colorVec = new Vector3f(random.nextFloat() + 0.5f, random.nextFloat() + 0.5f, random.nextFloat() + 0.5f);
// rightParticleEmitter.update();
// leftParticleEmitter.update();
// backParticleEmitter.update();
backParticleEmitter.update();
}
public static void drawScene(SceneManager sceneManager, Integer delta) {
@ -464,7 +464,7 @@ public class Scene {
public void afterEachDraw(SceneObject object) {
GL11.glPopMatrix();
}
});
}, delta);
}
}

@ -8,6 +8,6 @@ package Scene.base;
* @Description:
**/
public interface IDrawable {
void draw(IDrawListener listener);
void draw();
void draw(IDrawListener listener, Integer delta);
void draw(Integer delta);
}

@ -12,9 +12,9 @@ import java.util.ArrayList;
public class SceneManager {
private ArrayList<SceneObject> sceneObjects = new ArrayList<>();
public void drawAll(IDrawListener listener){
public void drawAll(IDrawListener listener, Integer delta){
for(int i = 0; i < sceneObjects.size(); i++){
sceneObjects.get(i).draw(listener);
sceneObjects.get(i).draw(listener, delta);
}
}

@ -66,7 +66,7 @@ public abstract class SceneObject implements IDrawable, IMovable, IScalable, IHi
}
@Override
public void draw(IDrawListener listener) {
public void draw(IDrawListener listener, Integer delta) {
//move object to correct position
listener.beforeEachDraw(this);
glDisable(GL_TEXTURE_GEN_S);
@ -78,7 +78,7 @@ public abstract class SceneObject implements IDrawable, IMovable, IScalable, IHi
GL11.glRotatef(rotation.a, rotation.x, rotation.y, rotation.z);
GL11.glScalef(scale.x, scale.y, scale.z);
GL11.glTranslatef(position.x, position.y, position.z);
this.draw();
this.draw(delta);
listener.afterEachDraw(this);
//
glEnable(GL_TEXTURE_GEN_S);

@ -128,7 +128,7 @@ public class Skybox extends SceneObject {
@Override
public void draw() {
public void draw(Integer delta) {
// ;
GL11.glTexParameteri(

@ -314,7 +314,7 @@ public class OBJLoader {
boolean enableSmoothShading = !line.contains("off");
m.setSmoothShadingEnabled(enableSmoothShading);
} else {
System.err.println("[OBJ] Unknown Line: " + line);
// System.err.println("[OBJ] Unknown Line: " + line);
}
}
reader.close();

@ -53,27 +53,10 @@ public class Camera {
}
public void update() {
int WheelPosition = Mouse.getDWheel();
int MouseX = Mouse.getX();
int MouseY = Mouse.getY();
int MouseDX = Mouse.getDX();
int MouseDY = Mouse.getDY();
boolean MouseButtonPressed = Mouse.isButtonDown(0);
boolean isGrabbed = Mouse.isGrabbed();
if (WheelPosition > 0) {
OrthoNumber += 10;
}
if (WheelPosition < 0) {
OrthoNumber -= 10;
}
float speed = Player.frame_delta/1.6f;
if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
Vector4f move = new Vector4f();
move = move.PlusVector(new Vector4f(0, 0, -10, 0));
move = move.PlusVector(new Vector4f(0, 0, -speed, 0));
// position.z -= 10f;
float angle = rotation.y - 180;
float new_x = (float) (move.length() * Math.sin(Math.toRadians(angle)));
@ -86,7 +69,7 @@ public class Camera {
// move = move.PlusVector(new Vector4f(10, 0, 0, 0));
// position.x += 10f;
Vector4f move = new Vector4f();
move = move.PlusVector(new Vector4f(10, 0, 0, 0));
move = move.PlusVector(new Vector4f(speed, 0, 0, 0));
// position.z -= 10f;
float angle = 180 - rotation.y + 90;
float new_x = (float) (move.length() * Math.sin(Math.toRadians(angle)));
@ -97,7 +80,7 @@ public class Camera {
}
if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
Vector4f move = new Vector4f();
move = move.PlusVector(new Vector4f(0, 0, 10, 0));
move = move.PlusVector(new Vector4f(0, 0, speed, 0));
// position.z += 10f;
float angle = rotation.y - 180;
float new_x = (float) (move.length() * Math.sin(Math.toRadians(angle)));
@ -109,7 +92,7 @@ public class Camera {
if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
// move = move.PlusVector(new Vector4f(-10, 0, 0, 0));
Vector4f move = new Vector4f();
move = move.PlusVector(new Vector4f(-10, 0, 0, 0));
move = move.PlusVector(new Vector4f(-speed, 0, 0, 0));
// position.z -= 10f;
float angle = 180 - rotation.y - 90;
float new_x = (float) (move.length() * Math.sin(Math.toRadians(angle)));
@ -121,10 +104,44 @@ public class Camera {
if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) {
position.y -= 10f;
position.y -= speed;
}
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
position.y += 10f;
position.y += speed;
}
// GL11.glMatrixMode(GL11.GL_MODELVIEW);
// FloatBuffer CurrentMatrix = BufferUtils.createFloatBuffer(16);
// GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, CurrentMatrix);
// MyArcball.getMatrix(CurrentMatrix);
// GL11.glMultMatrix(CurrentMatrix);
}
public static void setPosition(Vector4f position) {
Camera.position = position;
}
public void update_mouse() {
int WheelPosition = Mouse.getDWheel();
int MouseX = Mouse.getX();
int MouseY = Mouse.getY();
int MouseDX = Mouse.getDX();
int MouseDY = Mouse.getDY();
boolean MouseButtonPressed = Mouse.isButtonDown(0);
boolean isGrabbed = Mouse.isGrabbed();
if (WheelPosition > 0) {
OrthoNumber += 10;
}
if (WheelPosition < 0) {
OrthoNumber -= 10;
}
while (Mouse.next()) {
@ -158,17 +175,5 @@ public class Camera {
Player.angle_target = 180 - (int) rotation.y;
// GL11.glMatrixMode(GL11.GL_MODELVIEW);
// FloatBuffer CurrentMatrix = BufferUtils.createFloatBuffer(16);
// GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, CurrentMatrix);
// MyArcball.getMatrix(CurrentMatrix);
// GL11.glMultMatrix(CurrentMatrix);
}
public static void setPosition(Vector4f position) {
Camera.position = position;
}
}

@ -90,7 +90,7 @@ public class Engine {
* The distance where fog starts appearing.
*/
private static final float fogNear = zNear;
private static float zFar = 30000f;
private static float zFar = 50000f;
/**
* The distance where the fog stops appearing (fully black here)
*/
@ -494,6 +494,7 @@ public class Engine {
}
}
}
camera.update_mouse();
if (!ishit)
camera.update();

@ -459,40 +459,40 @@ public class MainWindow {
// GLU.gluLookAt(2f, -1f, -1f, 0f, 0f, 0f, 0f, 1f, 0f);
// }
sceneManager.drawAll(new IDrawListener() {
@Override
public void beforeEachDraw(SceneObject object) {
GL11.glPushMatrix();
if (object instanceof Player) {
Player player = (Player) object;
Integer speed = 10;
float speedX = speed/ player.getScale().x;
float speedY = speed/ player.getScale().y;
float speedZ = speed/ player.getScale().z;
if((Keyboard.isKeyDown(Keyboard.KEY_W))){
player.move(new Vector4f(0,0,speedZ,0));
}
if((Keyboard.isKeyDown(Keyboard.KEY_A))){
player.move(new Vector4f(-speedX,0,0,0));
}
if((Keyboard.isKeyDown(Keyboard.KEY_S))){
player.move(new Vector4f(0,0,-speedZ,0));
}
if((Keyboard.isKeyDown(Keyboard.KEY_D))){
player.move(new Vector4f(speedX,0,0,0));
}
// human.setPosition(new Point4f(posn_x * 3.0f, 0.0f, posn_y * 3.0f, 0));
player.setDelta(delta);
}
}
@Override
public void afterEachDraw(SceneObject object) {
GL11.glPopMatrix();
}
});
//
// sceneManager.drawAll(new IDrawListener() {
// @Override
// public void beforeEachDraw(SceneObject object) {
// GL11.glPushMatrix();
// if (object instanceof Player) {
// Player player = (Player) object;
// Integer speed = 10;
// float speedX = speed/ player.getScale().x;
// float speedY = speed/ player.getScale().y;
// float speedZ = speed/ player.getScale().z;
// if((Keyboard.isKeyDown(Keyboard.KEY_W))){
// player.move(new Vector4f(0,0,speedZ,0));
// }
// if((Keyboard.isKeyDown(Keyboard.KEY_A))){
// player.move(new Vector4f(-speedX,0,0,0));
// }
// if((Keyboard.isKeyDown(Keyboard.KEY_S))){
// player.move(new Vector4f(0,0,-speedZ,0));
// }
// if((Keyboard.isKeyDown(Keyboard.KEY_D))){
// player.move(new Vector4f(speedX,0,0,0));
// }
//// human.setPosition(new Point4f(posn_x * 3.0f, 0.0f, posn_y * 3.0f, 0));
// player.setDelta(delta);
// }
// }
//
// @Override
// public void afterEachDraw(SceneObject object) {
// GL11.glPopMatrix();
// }
// });
//
/*

@ -35,7 +35,7 @@ public class TextureLoader {
loadTexture("warped_door_bottom.png");
loadTexture("enchanting_table_side.png");
loadTexture("enchanting_table_top.png");
loadTexture("copyright.png");
loadTexture("copyleft.png");
//sky box
loadTexture("skybox/back.png");

Loading…
Cancel
Save