diff --git a/assets/Config/settings.json b/assets/Config/settings.json index 68d178d7..74162155 100644 --- a/assets/Config/settings.json +++ b/assets/Config/settings.json @@ -2,8 +2,8 @@ "gameplayGenerateWorld" : false, "gameplayPhysicsCellRadius" : 2, - "displayWidth" : 2560, - "displayHeight" : 1600, + "displayWidth" : 1920, + "displayHeight" : 1080, "displayFullscreen" : false, "graphicsFOV" : 100.0, @@ -15,8 +15,8 @@ "graphicsPerformanceOIT" : true, "graphicsViewRange" : 20000.0, - "renderResolutionX": 2560, - "renderResolutionY": 1600, + "renderResolutionX": 1920, + "renderResolutionY": 1080, "graphicsDebugDrawCollisionSpheresClient" : false, "graphicsDebugDrawCollisionSpheresServer" : false, diff --git a/buildNumber.properties b/buildNumber.properties index 62d16ddf..eaad655c 100644 --- a/buildNumber.properties +++ b/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Mon Oct 21 09:58:24 EDT 2024 -buildNumber=363 +#Mon Oct 28 16:07:42 EDT 2024 +buildNumber=364 diff --git a/docs/src/architecture/generation/voxelgenideas.md b/docs/src/architecture/generation/voxelgenideas.md new file mode 100644 index 00000000..476b878e --- /dev/null +++ b/docs/src/architecture/generation/voxelgenideas.md @@ -0,0 +1,11 @@ +@page voxelgenideas + +techniques to consider: + +adding different types of noise +gradients of different types of noise +fractal brownian noise +sines pulling from sines +noise functions pulling from sines +applying 2d values to the surface (top) of a 3d noise map +subtracting true 3d noise from a 2d heightmap to account for cave entrances diff --git a/docs/src/architecture/generation/worldgenerationindex.md b/docs/src/architecture/generation/worldgenerationindex.md index 4649da55..b816c16a 100644 --- a/docs/src/architecture/generation/worldgenerationindex.md +++ b/docs/src/architecture/generation/worldgenerationindex.md @@ -3,4 +3,5 @@ [TOC] - @subpage biomeselection - @subpage biomegenerationproblems -- @subpage terraingenerationprocess \ No newline at end of file +- @subpage terraingenerationprocess +- @subpage voxelgenideas \ No newline at end of file diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 9e70631a..a0a81df3 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -906,6 +906,14 @@ Chemistry system collision engine instance on server and client (10/24/2024) CraftingPanel implementation +(10/27/2024) +World gen docs + ideas +Update default resolution in config + +(10/28/2024) +Fix main menu ui test +Refactor math utils to spatial math utils to make room for more fundamental utils + # TODO diff --git a/src/main/java/electrosphere/audio/AudioEngine.java b/src/main/java/electrosphere/audio/AudioEngine.java index 7c9b247c..598187ec 100644 --- a/src/main/java/electrosphere/audio/AudioEngine.java +++ b/src/main/java/electrosphere/audio/AudioEngine.java @@ -3,7 +3,7 @@ package electrosphere.audio; import electrosphere.client.entity.camera.CameraEntityUtils; import electrosphere.engine.Globals; import electrosphere.logger.LoggerInterface; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -197,8 +197,8 @@ public class AudioEngine { listener.setPosition(cameraPos); //orientation - Vector3d cameraEye = MathUtils.getOriginVector().rotate(CameraEntityUtils.getRotationQuat(Globals.playerCamera)).normalize(); - Vector3d cameraUp = MathUtils.getUpVector().rotate(CameraEntityUtils.getRotationQuat(Globals.playerCamera)).normalize(); + Vector3d cameraEye = SpatialMathUtils.getOriginVector().rotate(CameraEntityUtils.getRotationQuat(Globals.playerCamera)).normalize(); + Vector3d cameraUp = SpatialMathUtils.getUpVector().rotate(CameraEntityUtils.getRotationQuat(Globals.playerCamera)).normalize(); listener.setOrientation(new Vector3f((float)cameraEye.x,(float)cameraEye.y,(float)cameraEye.z), new Vector3f((float)cameraUp.x,(float)cameraUp.y,(float)cameraUp.z)); } } diff --git a/src/main/java/electrosphere/audio/AudioListener.java b/src/main/java/electrosphere/audio/AudioListener.java index 85f46ac8..16db4cb1 100644 --- a/src/main/java/electrosphere/audio/AudioListener.java +++ b/src/main/java/electrosphere/audio/AudioListener.java @@ -5,7 +5,7 @@ import org.joml.Vector3f; import org.lwjgl.openal.AL11; import electrosphere.engine.Globals; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; import static org.lwjgl.openal.AL10.*; @@ -18,7 +18,7 @@ public class AudioListener { Vector3d position = new Vector3d(); //eye vector for listener - Vector3f eye = MathUtils.getOriginVectorf(); + Vector3f eye = SpatialMathUtils.getOriginVectorf(); //up vector for listener Vector3f up = new Vector3f(0,1,0); diff --git a/src/main/java/electrosphere/client/entity/camera/CameraEntityUtils.java b/src/main/java/electrosphere/client/entity/camera/CameraEntityUtils.java index 7c91b047..437acafd 100644 --- a/src/main/java/electrosphere/client/entity/camera/CameraEntityUtils.java +++ b/src/main/java/electrosphere/client/entity/camera/CameraEntityUtils.java @@ -8,7 +8,7 @@ import electrosphere.entity.EntityUtils; import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.types.common.CommonEntityUtils; import electrosphere.game.data.common.CommonEntityType; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; import org.joml.Matrix4d; import org.joml.Matrix4f; @@ -70,7 +70,7 @@ public class CameraEntityUtils { */ public static Entity spawnPlayerEntityTrackingCameraEntity(){ Vector3f center = new Vector3f(0,0,0); - Vector3f eye = MathUtils.getOriginVectorf(); + Vector3f eye = SpatialMathUtils.getOriginVectorf(); Entity rVal = EntityCreationUtils.createClientSpatialEntity(); rVal.putData(EntityDataStrings.DATA_STRING_CAMERA_TYPE, EntityDataStrings.DATA_STRING_CAMERA_TYPE_ORBIT); rVal.putData(EntityDataStrings.DATA_STRING_CAMERA_CENTER, center); @@ -125,7 +125,7 @@ public class CameraEntityUtils { if(Globals.controlHandler.cameraIsThirdPerson()){ Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityTrackingCameraEntity(); } else { - Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityTrackingCameraFirstPersonEntity(new Vector3f(0,0,0), MathUtils.getOriginVectorf()); + Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityTrackingCameraFirstPersonEntity(new Vector3f(0,0,0), SpatialMathUtils.getOriginVectorf()); } } @@ -196,7 +196,7 @@ public class CameraEntityUtils { * @return The quaternion */ public static Quaternionf getPitchQuat(double pitch){ - Quaternionf pitchQuat = new Quaternionf().fromAxisAngleDeg(MathUtils.getLeftVectorf(), -(float)pitch); + Quaternionf pitchQuat = new Quaternionf().fromAxisAngleDeg(SpatialMathUtils.getLeftVectorf(), -(float)pitch); return pitchQuat; } @@ -206,7 +206,7 @@ public class CameraEntityUtils { * @return The quaternion */ public static Quaternionf getYawQuat(double yaw){ - Quaternionf yawQuat = new Quaternionf().fromAxisAngleDeg(MathUtils.getUpVectorf(), -(float)yaw); + Quaternionf yawQuat = new Quaternionf().fromAxisAngleDeg(SpatialMathUtils.getUpVectorf(), -(float)yaw); return yawQuat; } @@ -219,7 +219,7 @@ public class CameraEntityUtils { public static Matrix4f getCameraViewMatrix(Entity camera){ Vector3f cameraCenter = new Vector3f(0,0,0);//getViewMatrixCenterOffset(camera); Vector3f cameraEye = new Vector3f(cameraCenter).add(getCameraEye(camera)); - Vector3f cameraUp = MathUtils.getUpVectorf(); + Vector3f cameraUp = SpatialMathUtils.getUpVectorf(); //!!before you make the same mistake I made, cameraEye is NOT NECESSARILY normalized/unit vector //the orbital distance and offset are included in this vector //TODO: refactor this to some other matrix of transforms or something?? @@ -318,7 +318,7 @@ public class CameraEntityUtils { Quaternionf quatRaw = CameraEntityUtils.getYawQuat(yaw).mul(CameraEntityUtils.getPitchQuat(pitch)).mul(new Quaternionf().rotateY((float)Math.PI)); Quaterniond quatd = new Quaterniond(quatRaw).normalize(); Matrix4d rotationMat = new Matrix4d().rotate(quatd); - Vector4d rotationVecRaw = MathUtils.getOriginVector4(); + Vector4d rotationVecRaw = SpatialMathUtils.getOriginVector4(); rotationVecRaw = rotationMat.transform(rotationVecRaw); return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z); } @@ -334,7 +334,7 @@ public class CameraEntityUtils { Quaternionf quatRaw = CameraEntityUtils.getYawQuat(yaw).mul(CameraEntityUtils.getPitchQuat(pitch)).mul(new Quaternionf().rotateY((float)Math.PI)); Quaterniond quatd = new Quaterniond(quatRaw).normalize(); Matrix4d rotationMat = new Matrix4d().rotate(quatd); - Vector4d rotationVecRaw = MathUtils.getOriginVector4(); + Vector4d rotationVecRaw = SpatialMathUtils.getOriginVector4(); rotationVecRaw = rotationMat.transform(rotationVecRaw); return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z); } @@ -347,10 +347,10 @@ public class CameraEntityUtils { public static Vector3d getFacingVec(Quaterniond rotation){ //quaternion is multiplied by pi because we want to point away from the eye of the camera, NOT towards it Matrix4d rotationMat = new Matrix4d().rotate(rotation); - Vector4d rotationVecRaw = MathUtils.getOriginVector4(); + Vector4d rotationVecRaw = SpatialMathUtils.getOriginVector4(); rotationVecRaw = rotationMat.transform(rotationVecRaw); if(rotationVecRaw.length() < 0.001){ - rotationVecRaw.set(MathUtils.getOriginVector4()); + rotationVecRaw.set(SpatialMathUtils.getOriginVector4()); } return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z); } diff --git a/src/main/java/electrosphere/client/entity/debug/DebugVisualizerUtils.java b/src/main/java/electrosphere/client/entity/debug/DebugVisualizerUtils.java index 16a8a153..0db0e30a 100644 --- a/src/main/java/electrosphere/client/entity/debug/DebugVisualizerUtils.java +++ b/src/main/java/electrosphere/client/entity/debug/DebugVisualizerUtils.java @@ -10,7 +10,7 @@ import electrosphere.entity.Entity; import electrosphere.entity.EntityCreationUtils; import electrosphere.entity.EntityUtils; import electrosphere.entity.btree.BehaviorTree; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * Debug tools for visualizing things in the game engine @@ -43,7 +43,7 @@ public class DebugVisualizerUtils { */ public static Entity clientSpawnVectorVisualizer(Vector3d point1, Vector3d point2){ Vector3d position = point1; - Quaterniond rotation = MathUtils.calculateRotationFromPointToPoint(point1, point2); + Quaterniond rotation = SpatialMathUtils.calculateRotationFromPointToPoint(point1, point2); Vector3d scale = new Vector3d(point1.distance(point2)); return clientSpawnVectorVisualizer(position, rotation, scale); } diff --git a/src/main/java/electrosphere/controls/CameraHandler.java b/src/main/java/electrosphere/controls/CameraHandler.java index f60e5a23..03621ed5 100644 --- a/src/main/java/electrosphere/controls/CameraHandler.java +++ b/src/main/java/electrosphere/controls/CameraHandler.java @@ -12,7 +12,7 @@ import electrosphere.entity.Entity; import electrosphere.entity.EntityUtils; import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.renderer.ui.events.MouseEvent; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * Handler for camera-related events and controls @@ -109,13 +109,13 @@ public class CameraHandler { // CameraEntityUtils.setCameraCenter(Globals.playerCamera, new Vector3f((float)charPos.x,(float)charPos.y,(float)charPos.z)); // } - Quaternionf pitchQuat = new Quaternionf().fromAxisAngleDeg(MathUtils.getLeftVectorf(), -pitch); - Quaternionf yawQuat = new Quaternionf().fromAxisAngleDeg(MathUtils.getUpVectorf(), -yaw); + Quaternionf pitchQuat = new Quaternionf().fromAxisAngleDeg(SpatialMathUtils.getLeftVectorf(), -pitch); + Quaternionf yawQuat = new Quaternionf().fromAxisAngleDeg(SpatialMathUtils.getUpVectorf(), -yaw); // float yawRad = yaw / 180.0f * (float)Math.PI; // float pitchRad = pitch / 180.0f * (float)Math.PI; // float rollRad = 0.0f; // pitchQuat.mul(yawQuat); - cameraRotationVector = pitchQuat.transform(MathUtils.getOriginVectorf()); + cameraRotationVector = pitchQuat.transform(SpatialMathUtils.getOriginVectorf()); cameraRotationVector = yawQuat.transform(cameraRotationVector); cameraRotationVector.normalize(); diff --git a/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java b/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java index 16ebec51..c17323da 100644 --- a/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java +++ b/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java @@ -12,7 +12,7 @@ import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.game.data.particle.ParticleData; import electrosphere.game.data.particle.ParticleEmitter; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * A component that causes the entity to emit particles @@ -81,10 +81,10 @@ public class ClientParticleEmitterComponent implements BehaviorTree { Quaterniond rot = new Quaterniond(); Vector3d cross = null; Vector3d normalizedVelocity = new Vector3d(initialVelocity).normalize(); - if(Math.abs(normalizedVelocity.dot(MathUtils.getOriginVector())) < 0.8){ - cross = MathUtils.getOriginVector().cross(normalizedVelocity); + if(Math.abs(normalizedVelocity.dot(SpatialMathUtils.getOriginVector())) < 0.8){ + cross = SpatialMathUtils.getOriginVector().cross(normalizedVelocity); } else { - cross = MathUtils.getUpVector().cross(normalizedVelocity); + cross = SpatialMathUtils.getUpVector().cross(normalizedVelocity); } rot.rotateAxis(Math.PI * 2 * particleRand.nextFloat(), normalizedVelocity); rot.rotateAxis((particleRand.nextFloat() * this.particleEmitter.getSpread()) / 180.0 * Math.PI, cross); diff --git a/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java b/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java index e68b190e..8da689a0 100644 --- a/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java +++ b/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java @@ -26,7 +26,7 @@ import electrosphere.entity.state.hitbox.HitboxCollectionState.HitboxState.Hitbo import electrosphere.game.data.collidable.HitboxData; import electrosphere.game.data.utils.DataFormatUtil; import electrosphere.logger.LoggerInterface; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * The state of the collection of all hitboxes on this entity @@ -405,7 +405,7 @@ public class HitboxCollectionState { //the second quaternion is a rotation along the x axis. This is used to put the hitbox rotation into ode's space //ode is Z-axis-up if(previousWorldPos.distance(worldPosition) > 0.0){ - worldRotation = MathUtils.calculateRotationFromPointToPoint(previousWorldPos,worldPosition).mul(new Quaterniond(0,0.707,0,0.707)); + worldRotation = SpatialMathUtils.calculateRotationFromPointToPoint(previousWorldPos,worldPosition).mul(new Quaterniond(0,0.707,0,0.707)); } //create new capsule diff --git a/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java b/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java index 6ce89296..98a2fde6 100644 --- a/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java @@ -21,7 +21,7 @@ import electrosphere.net.synchronization.annotation.SynchronizableEnum; import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree; import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums; import electrosphere.renderer.anim.Animation; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; import java.util.concurrent.CopyOnWriteArrayList; @@ -226,14 +226,14 @@ public class ClientEditorMovementTree implements BehaviorTree { movementVector.rotateY((float)(-135 * Math.PI / 180)).normalize(); break; case UP: { - movementVector = MathUtils.getUpVector(); + movementVector = SpatialMathUtils.getUpVector(); } break; case DOWN: { - movementVector = MathUtils.getUpVector().mul(-1); + movementVector = SpatialMathUtils.getUpVector().mul(-1); } break; } } - Quaterniond movementQuaternion = new Quaterniond().rotationTo(MathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); + Quaterniond movementQuaternion = new Quaterniond().rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); Quaterniond rotation = EntityUtils.getRotation(parent); //parse attached network messages diff --git a/src/main/java/electrosphere/entity/state/movement/editor/ServerEditorMovementTree.java b/src/main/java/electrosphere/entity/state/movement/editor/ServerEditorMovementTree.java index 300e7627..51771fcf 100644 --- a/src/main/java/electrosphere/entity/state/movement/editor/ServerEditorMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/editor/ServerEditorMovementTree.java @@ -29,7 +29,7 @@ import electrosphere.renderer.anim.Animation; import electrosphere.script.utils.AccessTransforms; import electrosphere.server.datacell.utils.DataCellSearchUtils; import electrosphere.server.utils.ServerScriptUtils; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; import java.util.concurrent.CopyOnWriteArrayList; @@ -194,14 +194,14 @@ public class ServerEditorMovementTree implements BehaviorTree { movementVector.rotateY((float)(-135 * Math.PI / 180)).normalize(); break; case UP: { - movementVector = MathUtils.getUpVector(); + movementVector = SpatialMathUtils.getUpVector(); } break; case DOWN: { - movementVector = MathUtils.getUpVector().mul(-1); + movementVector = SpatialMathUtils.getUpVector().mul(-1); } break; } } - Quaterniond movementQuaternion = new Quaterniond().rotationTo(MathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); + Quaterniond movementQuaternion = new Quaterniond().rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); Quaterniond rotation = EntityUtils.getRotation(parent); //TODO: optimize away and document (I know for the moment if this exception isn't here it will bite me in the ass later) if(facingVector.length() == 0){ diff --git a/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java b/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java index 99366d0b..43bea2bf 100644 --- a/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java @@ -29,7 +29,7 @@ import electrosphere.net.synchronization.annotation.SynchronizableEnum; import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree; import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums; import electrosphere.renderer.anim.Animation; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; import electrosphere.renderer.actor.Actor; import java.util.concurrent.CopyOnWriteArrayList; @@ -239,7 +239,7 @@ public class ClientGroundMovementTree implements BehaviorTree { break; } } - Quaterniond movementQuaternion = new Quaterniond().rotationTo(MathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); + Quaterniond movementQuaternion = new Quaterniond().rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); Quaterniond rotation = EntityUtils.getRotation(parent); //parse attached network messages diff --git a/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java b/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java index 10f9e8d2..a720fae0 100644 --- a/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java @@ -33,7 +33,7 @@ import electrosphere.script.utils.AccessTransforms; import electrosphere.server.datacell.utils.DataCellSearchUtils; import electrosphere.server.poseactor.PoseActor; import electrosphere.server.utils.ServerScriptUtils; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; import java.util.concurrent.CopyOnWriteArrayList; @@ -207,7 +207,7 @@ public class ServerGroundMovementTree implements BehaviorTree { break; } } - Quaterniond movementQuaternion = new Quaterniond().rotationTo(MathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); + Quaterniond movementQuaternion = new Quaterniond().rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); Quaterniond rotation = EntityUtils.getRotation(parent); //TODO: optimize away and document (I know for the moment if this exception isn't here it will bite me in the ass later) if(facingVector.length() == 0){ diff --git a/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java b/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java index 2c00f07f..97c1b8d5 100644 --- a/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java +++ b/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java @@ -15,7 +15,7 @@ import electrosphere.entity.state.physicssync.ServerPhysicsSyncTree; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; public class ServerAlwaysUprightTree implements BehaviorTree { @@ -48,7 +48,7 @@ public class ServerAlwaysUprightTree implements BehaviorTree { //calculate rotation based on facing vector if(CreatureUtils.getFacingVector(parent) != null){ Vector3d facingVector = CreatureUtils.getFacingVector(parent); - sourceRotation = new Quaterniond().rotationTo(MathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); + sourceRotation = new Quaterniond().rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(facingVector.x,0,facingVector.z)).normalize(); } EntityUtils.getPosition(parent).set(position); diff --git a/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java b/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java index 8e11d8e6..97cdb0dc 100644 --- a/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java +++ b/src/main/java/electrosphere/entity/types/common/CommonEntityUtils.java @@ -85,7 +85,7 @@ import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; import electrosphere.server.datacell.utils.ServerEntityTagUtils; import electrosphere.server.poseactor.PoseActor; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * Utilities for creating all entity types @@ -220,7 +220,7 @@ public class CommonEntityUtils { } //round out end of move system entity.putData(EntityDataStrings.CLIENT_MOVEMENT_BT, moveTree); - CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector()); + CreatureUtils.setFacingVector(entity, SpatialMathUtils.getOriginVector()); entity.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity()); entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration()); entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f); @@ -340,7 +340,7 @@ public class CommonEntityUtils { } break; case "UNIT_CONTROLS": { ClientAlwaysUprightTree.attachTree(entity); - CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector()); + CreatureUtils.setFacingVector(entity, SpatialMathUtils.getOriginVector()); } break; case "TERRAIN_COLLISION": { CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN); @@ -515,7 +515,7 @@ public class CommonEntityUtils { } //round out end of move system entity.putData(EntityDataStrings.SERVER_MOVEMENT_BT, moveTree); - CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector()); + CreatureUtils.setFacingVector(entity, SpatialMathUtils.getOriginVector()); entity.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity()); entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration()); entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f); @@ -634,7 +634,7 @@ public class CommonEntityUtils { } break; case "UNIT_CONTROLS": { ServerAlwaysUprightTree.attachTree(entity); - CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector()); + CreatureUtils.setFacingVector(entity, SpatialMathUtils.getOriginVector()); } break; case "TERRAIN_COLLISION": { CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN); diff --git a/src/main/java/electrosphere/entity/types/projectile/ProjectileUtils.java b/src/main/java/electrosphere/entity/types/projectile/ProjectileUtils.java index f5a16b4c..4ab29b23 100644 --- a/src/main/java/electrosphere/entity/types/projectile/ProjectileUtils.java +++ b/src/main/java/electrosphere/entity/types/projectile/ProjectileUtils.java @@ -19,7 +19,7 @@ import electrosphere.game.data.collidable.HitboxData; import electrosphere.game.data.projectile.ProjectileType; import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; public class ProjectileUtils { @@ -39,7 +39,7 @@ public class ProjectileUtils { Globals.assetManager.addModelPathToQueue(model); ProjectileTree tree = new ProjectileTree(rVal,maxLife,new Vector3d(initialVector),velocity); EntityUtils.getPosition(rVal).set(initialPosition); - EntityUtils.getRotation(rVal).rotationTo(MathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); + EntityUtils.getRotation(rVal).rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); Globals.clientSceneWrapper.getScene().registerBehaviorTree(tree); return rVal; } @@ -60,7 +60,7 @@ public class ProjectileUtils { ProjectileTree tree = new ProjectileTree(rVal,maxLife,new Vector3d(initialVector),velocity); EntityUtils.getPosition(rVal).set(initialPosition); // EntityUtils.getRotation(currentEntity).rotationTo(MathUtils.ORIGIN_VECTORF, new Vector3f((float)facingAngle.x,(float)facingAngle.y,(float)facingAngle.z)).mul(parentActor.getBoneRotation(targetBone)).normalize(); - EntityUtils.getRotation(rVal).rotationTo(MathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); + EntityUtils.getRotation(rVal).rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); // ParticleTree particleTree = new ParticleTree(rVal, maxLife, destination, velocity, acceleration, true); // rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree); // rVal.putData(EntityDataStrings.IS_PARTICLE, true); @@ -82,7 +82,7 @@ public class ProjectileUtils { Entity rVal = EntityCreationUtils.createClientSpatialEntity(); EntityCreationUtils.makeEntityDrawable(rVal, rawType.getModelPath()); //initial coordinates - EntityUtils.getRotation(rVal).rotationTo(MathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); + EntityUtils.getRotation(rVal).rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); EntityUtils.getPosition(rVal).set(initialPosition); //projectile behavior tree ProjectileTree tree = new ProjectileTree(rVal,rawType.getMaxLife(),initialVector,rawType.getVelocity(), rawType.getDamage()); @@ -117,7 +117,7 @@ public class ProjectileUtils { ProjectileType rawType = Globals.gameConfigCurrent.getProjectileMap().getType(projectileType); Entity rVal = EntityCreationUtils.createServerEntity(realm, initialPosition); //initial coordinates - EntityUtils.getRotation(rVal).rotationTo(MathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); + EntityUtils.getRotation(rVal).rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(initialVector.x,initialVector.y,initialVector.z)).normalize(); EntityUtils.getPosition(rVal).set(initialPosition); //projectile behavior tree ProjectileTree tree = new ProjectileTree(rVal,rawType.getMaxLife(),initialVector,rawType.getVelocity(), rawType.getDamage()); diff --git a/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java b/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java index d45c98ec..97052dbb 100644 --- a/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java +++ b/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java @@ -16,7 +16,7 @@ import electrosphere.renderer.OpenGLState; import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderingEngine; import electrosphere.renderer.actor.Actor; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * Shadow map pipeline @@ -76,7 +76,7 @@ public class ShadowMapPipeline implements RenderPipeline { Matrix4f lightView = new Matrix4f().setLookAt( new Vector3f(eyeX, eyeY, eyeZ), new Vector3f( 0.0f, 0.0f, 0.0f), - MathUtils.getUpVectorf() + SpatialMathUtils.getUpVectorf() ); Globals.lightDepthMatrix = lightProjection.mul(lightView); diff --git a/src/main/java/electrosphere/script/ScriptEngine.java b/src/main/java/electrosphere/script/ScriptEngine.java index f37e207d..472455ca 100644 --- a/src/main/java/electrosphere/script/ScriptEngine.java +++ b/src/main/java/electrosphere/script/ScriptEngine.java @@ -22,7 +22,7 @@ import electrosphere.engine.Main; import electrosphere.logger.LoggerInterface; import electrosphere.script.translation.JSServerUtils; import electrosphere.util.FileUtils; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * Interface for executing scripts in the game engine @@ -91,7 +91,7 @@ public class ScriptEngine { //The classes that will be provided to the scripting engine //https://stackoverflow.com/a/65942034 static final Object[][] staticClasses = new Object[][]{ - {"mathUtils",MathUtils.class}, + {"mathUtils",SpatialMathUtils.class}, {"simulation",Main.class}, {"tutorialUtils",TutorialMenus.class}, {"serverUtils",JSServerUtils.class}, diff --git a/src/main/java/electrosphere/server/ai/nodes/actions/move/FaceTargetNode.java b/src/main/java/electrosphere/server/ai/nodes/actions/move/FaceTargetNode.java index 2285ccf6..39ab6a6f 100644 --- a/src/main/java/electrosphere/server/ai/nodes/actions/move/FaceTargetNode.java +++ b/src/main/java/electrosphere/server/ai/nodes/actions/move/FaceTargetNode.java @@ -10,7 +10,7 @@ import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.server.ai.blackboard.Blackboard; import electrosphere.server.ai.nodes.AITreeNode; import electrosphere.server.ai.nodes.actions.combat.MeleeTargetingNode; -import electrosphere.util.math.MathUtils; +import electrosphere.util.math.SpatialMathUtils; /** * Faces the target @@ -29,7 +29,7 @@ public class FaceTargetNode implements AITreeNode { Entity target = MeleeTargetingNode.getTarget(blackboard); Vector3d parentPos = EntityUtils.getPosition(entity); Vector3d targetPos = EntityUtils.getPosition(target); - Quaterniond rotation = MathUtils.calculateRotationFromPointToPoint(parentPos, targetPos); + Quaterniond rotation = SpatialMathUtils.calculateRotationFromPointToPoint(parentPos, targetPos); EntityUtils.getRotation(entity).set(rotation); CreatureUtils.setFacingVector(entity, CameraEntityUtils.getFacingVec(rotation)); return AITreeNodeResult.SUCCESS; diff --git a/src/main/java/electrosphere/util/math/MathBones.java b/src/main/java/electrosphere/util/math/MathBones.java index 8fbd34a7..9ff7e3f3 100644 --- a/src/main/java/electrosphere/util/math/MathBones.java +++ b/src/main/java/electrosphere/util/math/MathBones.java @@ -45,11 +45,11 @@ public class MathBones { Vector3d facingAngle = CreatureUtils.getFacingVector(actorEntity); if(facingAngle == null){ - facingAngle = MathUtils.getOriginVector(); + facingAngle = SpatialMathUtils.getOriginVector(); } //calculate rotation of model return new Quaterniond() - .rotationTo(MathUtils.getOriginVector(), new Vector3d(facingAngle.x,facingAngle.y,facingAngle.z)) + .rotationTo(SpatialMathUtils.getOriginVector(), new Vector3d(facingAngle.x,facingAngle.y,facingAngle.z)) .mul(localRot) .normalize(); } diff --git a/src/main/java/electrosphere/util/math/MathUtils.java b/src/main/java/electrosphere/util/math/SpatialMathUtils.java similarity index 95% rename from src/main/java/electrosphere/util/math/MathUtils.java rename to src/main/java/electrosphere/util/math/SpatialMathUtils.java index 979e5f07..fcc3a71b 100644 --- a/src/main/java/electrosphere/util/math/MathUtils.java +++ b/src/main/java/electrosphere/util/math/SpatialMathUtils.java @@ -10,7 +10,7 @@ import electrosphere.logger.LoggerInterface; /** * Utility functions for doing math */ -public class MathUtils { +public class SpatialMathUtils { /** @@ -90,7 +90,7 @@ public class MathUtils { * @return The up rotation */ public static Quaterniond getUpRotation(){ - return MathUtils.calculateRotationFromPointToPoint(MathUtils.getOriginVector(), MathUtils.getUpVector()); + return SpatialMathUtils.calculateRotationFromPointToPoint(SpatialMathUtils.getOriginVector(), SpatialMathUtils.getUpVector()); } diff --git a/test/java/renderer/ui/test_Screencapture_Match.png b/test/java/renderer/ui/test_Screencapture_Match.png index 1055fc38..04b65f77 100644 Binary files a/test/java/renderer/ui/test_Screencapture_Match.png and b/test/java/renderer/ui/test_Screencapture_Match.png differ