fix focus bug & polish

This commit is contained in:
austin 2022-03-03 19:49:21 -05:00
parent 5fe7abf344
commit ec0ac741e5
11 changed files with 80 additions and 71221 deletions

View File

@ -63,19 +63,19 @@
{
"type" : "GROUND",
"acceleration" : 1000.0,
"maxVelocity" : 1.0,
"maxVelocity" : 2.0,
"animationStartup" : {
"name" : "Armature|Walk",
"name" : "Armature|Jog",
"length" : 1,
"loops" : false
},
"animationLoop" : {
"name" : "Armature|Walk",
"name" : "Armature|Jog",
"length" : 1,
"loops" : false
},
"animationWindDown" : {
"name" : "Armature|Walk",
"name" : "Armature|Jog",
"length" : 1,
"loops" : false
},

Binary file not shown.

BIN
assets/Models/crate2.fbx Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -257,6 +257,12 @@
"/Textures/campfire1.png",
"/Textures/campfire1.png"
]
},
"Models/crate2.fbx" : {
"Cube" : [
"/Textures/woodplanks1.png",
"/Textures/woodplanks1.png"
]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 KiB

View File

@ -40,6 +40,8 @@ import java.util.List;
import org.joml.Vector2f;
import org.joml.Vector3d;
import org.joml.Vector3f;
import org.lwjgl.glfw.GLFW;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.glfw.GLFW.glfwGetCursorPos;
import static org.lwjgl.glfw.GLFW.glfwGetMouseButton;
@ -133,6 +135,8 @@ public class ControlHandler {
boolean mouseIsVisible = true;
boolean shouldRecaptureScreen = false;
/*
Mouse event parsing related stuff
@ -374,7 +378,6 @@ public class ControlHandler {
cameraRotationVector.z = 0 + (float) Math.sin(yaw / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
cameraRotationVector.normalize();
}
CameraEntityUtils.setCameraEye(Globals.playerCamera, cameraRotationVector);
Globals.viewMatrix = CameraEntityUtils.getCameraViewMatrix(Globals.playerCamera);
@ -799,9 +802,15 @@ public class ControlHandler {
}});
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT));
controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setOnPress(new ControlMethod(){public void execute(){
// controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setOnPress(new ControlMethod(){public void execute(){
// // MenuCallbacks.backout(Globals.currentMenu);
// Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
// }});
controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setOnRelease(new ControlMethod(){public void execute(){
// MenuCallbacks.backout(Globals.currentMenu);
Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
}});
}
void setTypingControls(){
@ -1003,6 +1012,7 @@ public class ControlHandler {
}
public void hideMouse(){
glfwSetInputMode(Globals.window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
glfwSetInputMode(Globals.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
mouseIsVisible = false;
}
@ -1142,6 +1152,27 @@ public class ControlHandler {
return rVal;
}
public void setShouldRecapture(boolean shouldRecapture){
this.shouldRecaptureScreen = shouldRecapture;
}
public void recaptureIfNecessary(){
if(shouldRecaptureScreen){
//Makes the window that was just created the current OS-level window context
glfwMakeContextCurrent(Globals.window);
//Maximize it
glfwMaximizeWindow(Globals.window);
//grab focus
GLFW.glfwFocusWindow(Globals.window);
//apply mouse controls state
if(Globals.controlHandler.isMouseVisible()){
Globals.controlHandler.showMouse();
} else {
Globals.controlHandler.hideMouse();
}
shouldRecaptureScreen = false;
}
}
}

View File

@ -44,6 +44,7 @@ import electrosphere.net.server.Server;
import electrosphere.renderer.Mesh;
import electrosphere.renderer.Model;
import electrosphere.renderer.RenderUtils;
import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.actor.ActorTextureMask;
import electrosphere.renderer.actor.ActorUtils;
@ -197,7 +198,7 @@ public class LoadingThread extends Thread {
loadingWindow.setVisible(false);
RenderUtils.recaptureScreen();
Globals.controlHandler.setShouldRecapture(true);
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
@ -207,7 +208,7 @@ public class LoadingThread extends Thread {
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
LoggerInterface.loggerEngine.INFO("Finished loading");
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
break;
@ -283,7 +284,7 @@ public class LoadingThread extends Thread {
loadingWindow.setVisible(false);
RenderUtils.recaptureScreen();
Globals.controlHandler.setShouldRecapture(true);
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
@ -293,7 +294,7 @@ public class LoadingThread extends Thread {
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
LoggerInterface.loggerEngine.INFO("Finished loading");
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
break;
@ -664,11 +665,11 @@ public class LoadingThread extends Thread {
// Entity goblin = CreatureUtils.spawnBasicCreature("goblin");
// CollisionObjUtils.positionCharacter(goblin, new Vector3f(4, 0, 4));
// EntityUtils.getScale(goblin).set(0.005f);
// //give evil goblin sword
// Entity goblinSword = ItemUtils.spawnBasicItem("Katana");
// AttachUtils.attachEntityToEntityAtBone(goblin, goblinSword, "Bone.031");
//attach ai to evil goblin
// MindlessAttacker.attachToCreature(goblin);
// //give evil goblin sword
// Entity goblinSword = ItemUtils.spawnBasicItem("Katana");
// AttachUtils.attachEntityToEntityAtBone(goblin, goblinSword, "Bone.031");
// // attach ai to evil goblin
// MindlessAttacker.attachToCreature(goblin);
// OpportunisticAttacker.attachToCreature(goblin);
Entity sword = ItemUtils.spawnBasicItem("Katana");

View File

@ -211,7 +211,8 @@ public class Main {
//recapture the screen for rendering
LoggerInterface.loggerStartup.INFO("Recapture screen");
RenderUtils.recaptureScreen();
Globals.controlHandler.setShouldRecapture(true);
// RenderUtils.recaptureScreen();
///
/// C A M E R A C R E A T I O N
@ -265,6 +266,7 @@ public class Main {
//Poll controls
Globals.controlHandler.pollControls();
Globals.controlHandler.recaptureIfNecessary();
@ -304,73 +306,6 @@ public class Main {
///
/// C A M E R A S T U F F
///
//poll mouse variables and update camera variables
// if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT){
// updateMouseVariables();
// if(Crosshair.getCrosshairActive()){
// if(Globals.playerCharacter != null){
// Vector3d charPos = EntityUtils.getPosition(Globals.playerCharacter);
// CameraEntityUtils.setCameraCenter(Globals.playerCamera, new Vector3f((float)charPos.x,(float)charPos.y,(float)charPos.z));
// }
// Vector3d characterPos = EntityUtils.getPosition(Globals.playerCharacter);
// Vector3d targetPos = Crosshair.getTargetPosition();
// Vector3d diffed = new Vector3d(targetPos).sub(characterPos).mul(-1).normalize();
// cameraRotationVector.set((float)diffed.x, 0.5f, (float)diffed.z).normalize();
// yaw = (float)Math.toDegrees(Math.atan2(diffed.z, diffed.x));
// CameraEntityUtils.setCameraPitch(Globals.playerCamera, pitch);
// CameraEntityUtils.setCameraYaw(Globals.playerCamera, yaw);
// } else {
// CameraEntityUtils.setCameraPitch(Globals.playerCamera, pitch);
// CameraEntityUtils.setCameraYaw(Globals.playerCamera, yaw);
// if(Globals.playerCharacter != null){
// Vector3d charPos = EntityUtils.getPosition(Globals.playerCharacter);
// CameraEntityUtils.setCameraCenter(Globals.playerCamera, new Vector3f((float)charPos.x,(float)charPos.y,(float)charPos.z));
// }
// float cam_Player_Orbit_Magnitude = 5f;
// cameraRotationVector.x = 0 + (float) Math.cos(yaw / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
// cameraRotationVector.y = 0 + (float) Math.sin(pitch / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
// cameraRotationVector.z = 0 + (float) Math.sin(yaw / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
// cameraRotationVector.normalize();
// }
// CameraEntityUtils.setCameraEye(Globals.playerCamera, cameraRotationVector);
// // if(Crosshair.getCrosshairActive()){
// // CameraEntityUtils.setCameraEye(Globals.playerCamera, cameraRotationVector);
// // } else {
// // CameraEntityUtils.setCameraEye(Globals.playerCamera, cameraRotationVector);
// // }
// // if(Globals.playerCharacter != null){
// // Vector3f playerPos = EntityUtils.getPosition(Globals.playerCharacter);
// // if(posX == -1 && playerPos.x > 100){
// // posX = playerPos.x;
// // posZ = playerPos.z;
// // }
// // posX = posX - (cameraRotationVector.x * 0.01);
// // posZ = posZ - (cameraRotationVector.z * 0.01);
// // Vector3f moveVec = new Vector3f(-cameraRotationVector.x,0,-cameraRotationVector.z);
// // Quaternionf playerRot = new Quaternionf().rotationTo(new Vector3f(0,0,1), moveVec);
// // EntityUtils.getRotation(Globals.playerCharacter).set(playerRot);
// // EntityUtils.getPosition(Globals.playerCharacter).set((float)posX,playerPos.y,(float)posZ);
// // }
// Globals.viewMatrix = CameraEntityUtils.getCameraViewMatrix(Globals.playerCamera);
// }
Globals.renderingEngine.drawScreen();

View File

@ -8,7 +8,6 @@ import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.server.saves.SaveUtils;
import electrosphere.main.Globals;
import electrosphere.net.NetUtils;
import electrosphere.net.server.Server;
import electrosphere.renderer.ui.ClickableElement;
import electrosphere.renderer.ui.DrawableElement;
import electrosphere.renderer.ui.Element;
@ -26,7 +25,6 @@ import electrosphere.renderer.ui.events.DragEvent;
import electrosphere.renderer.ui.form.FormElement;
import java.util.List;
import org.joml.Vector3f;
/**
*
@ -109,7 +107,7 @@ public class MenuGenerators {
public static Element createWorldSelectMenu(){
FormElement rVal = new FormElement();
int screenTop = Globals.WINDOW_HEIGHT - 150;
// int screenTop = Globals.WINDOW_HEIGHT - 150;
List<String> saveNames = SaveUtils.getSaves();
int verticalPosition = 125;
for(String saveName : saveNames){
@ -156,7 +154,7 @@ public class MenuGenerators {
public static Element createWorldCreationMenu(){
FormElement rVal = new FormElement();
int screenTop = 150;
List<String> saveNames = SaveUtils.getSaves();
// List<String> saveNames = SaveUtils.getSaves();
int verticalPosition = 125;
//TODO: add text input to name world
@ -208,7 +206,7 @@ public class MenuGenerators {
public static Element createCharacterCreationMenu(){
FormElement rVal = new FormElement();
int screenTop = 150;
List<String> saveNames = SaveUtils.getSaves();
// List<String> saveNames = SaveUtils.getSaves();
int verticalPosition = 125;
//TODO: add text input to name world
@ -227,7 +225,7 @@ public class MenuGenerators {
public static Element createFinalizeSaveCreationMenu(){
FormElement rVal = new FormElement();
int screenTop = 150;
List<String> saveNames = SaveUtils.getSaves();
// List<String> saveNames = SaveUtils.getSaves();
int verticalPosition = 125;
//TODO: add text input to name world
@ -407,10 +405,10 @@ public class MenuGenerators {
}
public static Element createInGameMainMenu(){
int screenTop = Globals.WINDOW_HEIGHT - 150;
// int screenTop = Globals.WINDOW_HEIGHT - 150;
int width = 500;
int height = 500;
int screenLeft = (Globals.WINDOW_WIDTH - width)/2;
// int screenLeft = (Globals.WINDOW_WIDTH - width)/2;
FormElement rVal = new FormElement();
//black texture background
@ -435,10 +433,10 @@ public class MenuGenerators {
}
public static Element createNaturalInventoryMenu(UnrelationalInventoryState inventory){
int screenTop = Globals.WINDOW_HEIGHT - 150;
// int screenTop = Globals.WINDOW_HEIGHT - 150;
int width = 500;
int height = 500;
int screenLeft = (Globals.WINDOW_WIDTH - width)/2;
// int screenLeft = (Globals.WINDOW_WIDTH - width)/2;
Div rVal = new Div();
rVal.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){

View File

@ -14,6 +14,8 @@ import electrosphere.main.Globals;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFW;
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
import static org.lwjgl.glfw.GLFW.glfwMaximizeWindow;
import org.lwjgl.opengl.GL11;
@ -109,18 +111,20 @@ public class RenderUtils {
public static void recaptureScreen(){
//Makes the window that was just created the current OS-level window context
glfwMakeContextCurrent(Globals.window);
//Maximize it
glfwMaximizeWindow(Globals.window);
//apply mouse controls state
if(Globals.controlHandler.isMouseVisible()){
Globals.controlHandler.showMouse();
} else {
Globals.controlHandler.hideMouse();
}
}
// public static void recaptureScreen(){
// //Makes the window that was just created the current OS-level window context
// // glfwMakeContextCurrent(Globals.window);
// //Maximize it
// // glfwMaximizeWindow(Globals.window);
// //grab focus
// GLFW.glfwFocusWindow(Globals.window);
// //apply mouse controls state
// if(Globals.controlHandler.isMouseVisible()){
// Globals.controlHandler.showMouse();
// } else {
// Globals.controlHandler.hideMouse();
// }
// }