fix + docs + refactor mathutils
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-10-28 16:15:24 -04:00
parent 13d8878425
commit 4d6278d21f
25 changed files with 88 additions and 68 deletions

View File

@ -2,8 +2,8 @@
"gameplayGenerateWorld" : false, "gameplayGenerateWorld" : false,
"gameplayPhysicsCellRadius" : 2, "gameplayPhysicsCellRadius" : 2,
"displayWidth" : 2560, "displayWidth" : 1920,
"displayHeight" : 1600, "displayHeight" : 1080,
"displayFullscreen" : false, "displayFullscreen" : false,
"graphicsFOV" : 100.0, "graphicsFOV" : 100.0,
@ -15,8 +15,8 @@
"graphicsPerformanceOIT" : true, "graphicsPerformanceOIT" : true,
"graphicsViewRange" : 20000.0, "graphicsViewRange" : 20000.0,
"renderResolutionX": 2560, "renderResolutionX": 1920,
"renderResolutionY": 1600, "renderResolutionY": 1080,
"graphicsDebugDrawCollisionSpheresClient" : false, "graphicsDebugDrawCollisionSpheresClient" : false,
"graphicsDebugDrawCollisionSpheresServer" : false, "graphicsDebugDrawCollisionSpheresServer" : false,

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Mon Oct 21 09:58:24 EDT 2024 #Mon Oct 28 16:07:42 EDT 2024
buildNumber=363 buildNumber=364

View File

@ -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

View File

@ -3,4 +3,5 @@
[TOC] [TOC]
- @subpage biomeselection - @subpage biomeselection
- @subpage biomegenerationproblems - @subpage biomegenerationproblems
- @subpage terraingenerationprocess - @subpage terraingenerationprocess
- @subpage voxelgenideas

View File

@ -906,6 +906,14 @@ Chemistry system collision engine instance on server and client
(10/24/2024) (10/24/2024)
CraftingPanel implementation 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 # TODO

View File

@ -3,7 +3,7 @@ package electrosphere.audio;
import electrosphere.client.entity.camera.CameraEntityUtils; import electrosphere.client.entity.camera.CameraEntityUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
@ -197,8 +197,8 @@ public class AudioEngine {
listener.setPosition(cameraPos); listener.setPosition(cameraPos);
//orientation //orientation
Vector3d cameraEye = MathUtils.getOriginVector().rotate(CameraEntityUtils.getRotationQuat(Globals.playerCamera)).normalize(); Vector3d cameraEye = SpatialMathUtils.getOriginVector().rotate(CameraEntityUtils.getRotationQuat(Globals.playerCamera)).normalize();
Vector3d cameraUp = MathUtils.getUpVector().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)); listener.setOrientation(new Vector3f((float)cameraEye.x,(float)cameraEye.y,(float)cameraEye.z), new Vector3f((float)cameraUp.x,(float)cameraUp.y,(float)cameraUp.z));
} }
} }

View File

@ -5,7 +5,7 @@ import org.joml.Vector3f;
import org.lwjgl.openal.AL11; import org.lwjgl.openal.AL11;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
import static org.lwjgl.openal.AL10.*; import static org.lwjgl.openal.AL10.*;
@ -18,7 +18,7 @@ public class AudioListener {
Vector3d position = new Vector3d(); Vector3d position = new Vector3d();
//eye vector for listener //eye vector for listener
Vector3f eye = MathUtils.getOriginVectorf(); Vector3f eye = SpatialMathUtils.getOriginVectorf();
//up vector for listener //up vector for listener
Vector3f up = new Vector3f(0,1,0); Vector3f up = new Vector3f(0,1,0);

View File

@ -8,7 +8,7 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.types.common.CommonEntityUtils; import electrosphere.entity.types.common.CommonEntityUtils;
import electrosphere.game.data.common.CommonEntityType; import electrosphere.game.data.common.CommonEntityType;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
import org.joml.Matrix4d; import org.joml.Matrix4d;
import org.joml.Matrix4f; import org.joml.Matrix4f;
@ -70,7 +70,7 @@ public class CameraEntityUtils {
*/ */
public static Entity spawnPlayerEntityTrackingCameraEntity(){ public static Entity spawnPlayerEntityTrackingCameraEntity(){
Vector3f center = new Vector3f(0,0,0); Vector3f center = new Vector3f(0,0,0);
Vector3f eye = MathUtils.getOriginVectorf(); Vector3f eye = SpatialMathUtils.getOriginVectorf();
Entity rVal = EntityCreationUtils.createClientSpatialEntity(); Entity rVal = EntityCreationUtils.createClientSpatialEntity();
rVal.putData(EntityDataStrings.DATA_STRING_CAMERA_TYPE, EntityDataStrings.DATA_STRING_CAMERA_TYPE_ORBIT); rVal.putData(EntityDataStrings.DATA_STRING_CAMERA_TYPE, EntityDataStrings.DATA_STRING_CAMERA_TYPE_ORBIT);
rVal.putData(EntityDataStrings.DATA_STRING_CAMERA_CENTER, center); rVal.putData(EntityDataStrings.DATA_STRING_CAMERA_CENTER, center);
@ -125,7 +125,7 @@ public class CameraEntityUtils {
if(Globals.controlHandler.cameraIsThirdPerson()){ if(Globals.controlHandler.cameraIsThirdPerson()){
Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityTrackingCameraEntity(); Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityTrackingCameraEntity();
} else { } 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 * @return The quaternion
*/ */
public static Quaternionf getPitchQuat(double pitch){ 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; return pitchQuat;
} }
@ -206,7 +206,7 @@ public class CameraEntityUtils {
* @return The quaternion * @return The quaternion
*/ */
public static Quaternionf getYawQuat(double yaw){ 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; return yawQuat;
} }
@ -219,7 +219,7 @@ public class CameraEntityUtils {
public static Matrix4f getCameraViewMatrix(Entity camera){ public static Matrix4f getCameraViewMatrix(Entity camera){
Vector3f cameraCenter = new Vector3f(0,0,0);//getViewMatrixCenterOffset(camera); Vector3f cameraCenter = new Vector3f(0,0,0);//getViewMatrixCenterOffset(camera);
Vector3f cameraEye = new Vector3f(cameraCenter).add(getCameraEye(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 //!!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 //the orbital distance and offset are included in this vector
//TODO: refactor this to some other matrix of transforms or something?? //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)); Quaternionf quatRaw = CameraEntityUtils.getYawQuat(yaw).mul(CameraEntityUtils.getPitchQuat(pitch)).mul(new Quaternionf().rotateY((float)Math.PI));
Quaterniond quatd = new Quaterniond(quatRaw).normalize(); Quaterniond quatd = new Quaterniond(quatRaw).normalize();
Matrix4d rotationMat = new Matrix4d().rotate(quatd); Matrix4d rotationMat = new Matrix4d().rotate(quatd);
Vector4d rotationVecRaw = MathUtils.getOriginVector4(); Vector4d rotationVecRaw = SpatialMathUtils.getOriginVector4();
rotationVecRaw = rotationMat.transform(rotationVecRaw); rotationVecRaw = rotationMat.transform(rotationVecRaw);
return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z); 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)); Quaternionf quatRaw = CameraEntityUtils.getYawQuat(yaw).mul(CameraEntityUtils.getPitchQuat(pitch)).mul(new Quaternionf().rotateY((float)Math.PI));
Quaterniond quatd = new Quaterniond(quatRaw).normalize(); Quaterniond quatd = new Quaterniond(quatRaw).normalize();
Matrix4d rotationMat = new Matrix4d().rotate(quatd); Matrix4d rotationMat = new Matrix4d().rotate(quatd);
Vector4d rotationVecRaw = MathUtils.getOriginVector4(); Vector4d rotationVecRaw = SpatialMathUtils.getOriginVector4();
rotationVecRaw = rotationMat.transform(rotationVecRaw); rotationVecRaw = rotationMat.transform(rotationVecRaw);
return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z); return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z);
} }
@ -347,10 +347,10 @@ public class CameraEntityUtils {
public static Vector3d getFacingVec(Quaterniond rotation){ 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 //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); Matrix4d rotationMat = new Matrix4d().rotate(rotation);
Vector4d rotationVecRaw = MathUtils.getOriginVector4(); Vector4d rotationVecRaw = SpatialMathUtils.getOriginVector4();
rotationVecRaw = rotationMat.transform(rotationVecRaw); rotationVecRaw = rotationMat.transform(rotationVecRaw);
if(rotationVecRaw.length() < 0.001){ if(rotationVecRaw.length() < 0.001){
rotationVecRaw.set(MathUtils.getOriginVector4()); rotationVecRaw.set(SpatialMathUtils.getOriginVector4());
} }
return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z); return new Vector3d(rotationVecRaw.x,0,rotationVecRaw.z);
} }

View File

@ -10,7 +10,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityCreationUtils; import electrosphere.entity.EntityCreationUtils;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
/** /**
* Debug tools for visualizing things in the game engine * Debug tools for visualizing things in the game engine
@ -43,7 +43,7 @@ public class DebugVisualizerUtils {
*/ */
public static Entity clientSpawnVectorVisualizer(Vector3d point1, Vector3d point2){ public static Entity clientSpawnVectorVisualizer(Vector3d point1, Vector3d point2){
Vector3d position = point1; Vector3d position = point1;
Quaterniond rotation = MathUtils.calculateRotationFromPointToPoint(point1, point2); Quaterniond rotation = SpatialMathUtils.calculateRotationFromPointToPoint(point1, point2);
Vector3d scale = new Vector3d(point1.distance(point2)); Vector3d scale = new Vector3d(point1.distance(point2));
return clientSpawnVectorVisualizer(position, rotation, scale); return clientSpawnVectorVisualizer(position, rotation, scale);
} }

View File

@ -12,7 +12,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.renderer.ui.events.MouseEvent; import electrosphere.renderer.ui.events.MouseEvent;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
/** /**
* Handler for camera-related events and controls * 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)); // CameraEntityUtils.setCameraCenter(Globals.playerCamera, new Vector3f((float)charPos.x,(float)charPos.y,(float)charPos.z));
// } // }
Quaternionf pitchQuat = new Quaternionf().fromAxisAngleDeg(MathUtils.getLeftVectorf(), -pitch); Quaternionf pitchQuat = new Quaternionf().fromAxisAngleDeg(SpatialMathUtils.getLeftVectorf(), -pitch);
Quaternionf yawQuat = new Quaternionf().fromAxisAngleDeg(MathUtils.getUpVectorf(), -yaw); Quaternionf yawQuat = new Quaternionf().fromAxisAngleDeg(SpatialMathUtils.getUpVectorf(), -yaw);
// float yawRad = yaw / 180.0f * (float)Math.PI; // float yawRad = yaw / 180.0f * (float)Math.PI;
// float pitchRad = pitch / 180.0f * (float)Math.PI; // float pitchRad = pitch / 180.0f * (float)Math.PI;
// float rollRad = 0.0f; // float rollRad = 0.0f;
// pitchQuat.mul(yawQuat); // pitchQuat.mul(yawQuat);
cameraRotationVector = pitchQuat.transform(MathUtils.getOriginVectorf()); cameraRotationVector = pitchQuat.transform(SpatialMathUtils.getOriginVectorf());
cameraRotationVector = yawQuat.transform(cameraRotationVector); cameraRotationVector = yawQuat.transform(cameraRotationVector);
cameraRotationVector.normalize(); cameraRotationVector.normalize();

View File

@ -12,7 +12,7 @@ import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.game.data.particle.ParticleData; import electrosphere.game.data.particle.ParticleData;
import electrosphere.game.data.particle.ParticleEmitter; 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 * A component that causes the entity to emit particles
@ -81,10 +81,10 @@ public class ClientParticleEmitterComponent implements BehaviorTree {
Quaterniond rot = new Quaterniond(); Quaterniond rot = new Quaterniond();
Vector3d cross = null; Vector3d cross = null;
Vector3d normalizedVelocity = new Vector3d(initialVelocity).normalize(); Vector3d normalizedVelocity = new Vector3d(initialVelocity).normalize();
if(Math.abs(normalizedVelocity.dot(MathUtils.getOriginVector())) < 0.8){ if(Math.abs(normalizedVelocity.dot(SpatialMathUtils.getOriginVector())) < 0.8){
cross = MathUtils.getOriginVector().cross(normalizedVelocity); cross = SpatialMathUtils.getOriginVector().cross(normalizedVelocity);
} else { } else {
cross = MathUtils.getUpVector().cross(normalizedVelocity); cross = SpatialMathUtils.getUpVector().cross(normalizedVelocity);
} }
rot.rotateAxis(Math.PI * 2 * particleRand.nextFloat(), normalizedVelocity); rot.rotateAxis(Math.PI * 2 * particleRand.nextFloat(), normalizedVelocity);
rot.rotateAxis((particleRand.nextFloat() * this.particleEmitter.getSpread()) / 180.0 * Math.PI, cross); rot.rotateAxis((particleRand.nextFloat() * this.particleEmitter.getSpread()) / 180.0 * Math.PI, cross);

View File

@ -26,7 +26,7 @@ import electrosphere.entity.state.hitbox.HitboxCollectionState.HitboxState.Hitbo
import electrosphere.game.data.collidable.HitboxData; import electrosphere.game.data.collidable.HitboxData;
import electrosphere.game.data.utils.DataFormatUtil; import electrosphere.game.data.utils.DataFormatUtil;
import electrosphere.logger.LoggerInterface; 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 * 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 //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 //ode is Z-axis-up
if(previousWorldPos.distance(worldPosition) > 0.0){ 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 //create new capsule

View File

@ -21,7 +21,7 @@ import electrosphere.net.synchronization.annotation.SynchronizableEnum;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree; import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums; import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.renderer.anim.Animation; import electrosphere.renderer.anim.Animation;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -226,14 +226,14 @@ public class ClientEditorMovementTree implements BehaviorTree {
movementVector.rotateY((float)(-135 * Math.PI / 180)).normalize(); movementVector.rotateY((float)(-135 * Math.PI / 180)).normalize();
break; break;
case UP: { case UP: {
movementVector = MathUtils.getUpVector(); movementVector = SpatialMathUtils.getUpVector();
} break; } break;
case DOWN: { case DOWN: {
movementVector = MathUtils.getUpVector().mul(-1); movementVector = SpatialMathUtils.getUpVector().mul(-1);
} break; } 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); Quaterniond rotation = EntityUtils.getRotation(parent);
//parse attached network messages //parse attached network messages

View File

@ -29,7 +29,7 @@ import electrosphere.renderer.anim.Animation;
import electrosphere.script.utils.AccessTransforms; import electrosphere.script.utils.AccessTransforms;
import electrosphere.server.datacell.utils.DataCellSearchUtils; import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.server.utils.ServerScriptUtils; import electrosphere.server.utils.ServerScriptUtils;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -194,14 +194,14 @@ public class ServerEditorMovementTree implements BehaviorTree {
movementVector.rotateY((float)(-135 * Math.PI / 180)).normalize(); movementVector.rotateY((float)(-135 * Math.PI / 180)).normalize();
break; break;
case UP: { case UP: {
movementVector = MathUtils.getUpVector(); movementVector = SpatialMathUtils.getUpVector();
} break; } break;
case DOWN: { case DOWN: {
movementVector = MathUtils.getUpVector().mul(-1); movementVector = SpatialMathUtils.getUpVector().mul(-1);
} break; } 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); 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) //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){ if(facingVector.length() == 0){

View File

@ -29,7 +29,7 @@ import electrosphere.net.synchronization.annotation.SynchronizableEnum;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree; import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums; import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.renderer.anim.Animation; import electrosphere.renderer.anim.Animation;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
import electrosphere.renderer.actor.Actor; import electrosphere.renderer.actor.Actor;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -239,7 +239,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
break; 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); Quaterniond rotation = EntityUtils.getRotation(parent);
//parse attached network messages //parse attached network messages

View File

@ -33,7 +33,7 @@ import electrosphere.script.utils.AccessTransforms;
import electrosphere.server.datacell.utils.DataCellSearchUtils; import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.server.poseactor.PoseActor; import electrosphere.server.poseactor.PoseActor;
import electrosphere.server.utils.ServerScriptUtils; import electrosphere.server.utils.ServerScriptUtils;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -207,7 +207,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
break; 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); 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) //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){ if(facingVector.length() == 0){

View File

@ -15,7 +15,7 @@ import electrosphere.entity.state.physicssync.ServerPhysicsSyncTree;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
public class ServerAlwaysUprightTree implements BehaviorTree { public class ServerAlwaysUprightTree implements BehaviorTree {
@ -48,7 +48,7 @@ public class ServerAlwaysUprightTree implements BehaviorTree {
//calculate rotation based on facing vector //calculate rotation based on facing vector
if(CreatureUtils.getFacingVector(parent) != null){ if(CreatureUtils.getFacingVector(parent) != null){
Vector3d facingVector = CreatureUtils.getFacingVector(parent); 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); EntityUtils.getPosition(parent).set(position);

View File

@ -85,7 +85,7 @@ import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.server.datacell.utils.ServerEntityTagUtils; import electrosphere.server.datacell.utils.ServerEntityTagUtils;
import electrosphere.server.poseactor.PoseActor; import electrosphere.server.poseactor.PoseActor;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
/** /**
* Utilities for creating all entity types * Utilities for creating all entity types
@ -220,7 +220,7 @@ public class CommonEntityUtils {
} }
//round out end of move system //round out end of move system
entity.putData(EntityDataStrings.CLIENT_MOVEMENT_BT, moveTree); 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_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration()); entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f); entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
@ -340,7 +340,7 @@ public class CommonEntityUtils {
} break; } break;
case "UNIT_CONTROLS": { case "UNIT_CONTROLS": {
ClientAlwaysUprightTree.attachTree(entity); ClientAlwaysUprightTree.attachTree(entity);
CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector()); CreatureUtils.setFacingVector(entity, SpatialMathUtils.getOriginVector());
} break; } break;
case "TERRAIN_COLLISION": { case "TERRAIN_COLLISION": {
CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN); CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN);
@ -515,7 +515,7 @@ public class CommonEntityUtils {
} }
//round out end of move system //round out end of move system
entity.putData(EntityDataStrings.SERVER_MOVEMENT_BT, moveTree); 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_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration()); entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f); entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
@ -634,7 +634,7 @@ public class CommonEntityUtils {
} break; } break;
case "UNIT_CONTROLS": { case "UNIT_CONTROLS": {
ServerAlwaysUprightTree.attachTree(entity); ServerAlwaysUprightTree.attachTree(entity);
CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector()); CreatureUtils.setFacingVector(entity, SpatialMathUtils.getOriginVector());
} break; } break;
case "TERRAIN_COLLISION": { case "TERRAIN_COLLISION": {
CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN); CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN);

View File

@ -19,7 +19,7 @@ import electrosphere.game.data.collidable.HitboxData;
import electrosphere.game.data.projectile.ProjectileType; import electrosphere.game.data.projectile.ProjectileType;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
public class ProjectileUtils { public class ProjectileUtils {
@ -39,7 +39,7 @@ public class ProjectileUtils {
Globals.assetManager.addModelPathToQueue(model); Globals.assetManager.addModelPathToQueue(model);
ProjectileTree tree = new ProjectileTree(rVal,maxLife,new Vector3d(initialVector),velocity); ProjectileTree tree = new ProjectileTree(rVal,maxLife,new Vector3d(initialVector),velocity);
EntityUtils.getPosition(rVal).set(initialPosition); 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); Globals.clientSceneWrapper.getScene().registerBehaviorTree(tree);
return rVal; return rVal;
} }
@ -60,7 +60,7 @@ public class ProjectileUtils {
ProjectileTree tree = new ProjectileTree(rVal,maxLife,new Vector3d(initialVector),velocity); ProjectileTree tree = new ProjectileTree(rVal,maxLife,new Vector3d(initialVector),velocity);
EntityUtils.getPosition(rVal).set(initialPosition); 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(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); // ParticleTree particleTree = new ParticleTree(rVal, maxLife, destination, velocity, acceleration, true);
// rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree); // rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree);
// rVal.putData(EntityDataStrings.IS_PARTICLE, true); // rVal.putData(EntityDataStrings.IS_PARTICLE, true);
@ -82,7 +82,7 @@ public class ProjectileUtils {
Entity rVal = EntityCreationUtils.createClientSpatialEntity(); Entity rVal = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(rVal, rawType.getModelPath()); EntityCreationUtils.makeEntityDrawable(rVal, rawType.getModelPath());
//initial coordinates //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); EntityUtils.getPosition(rVal).set(initialPosition);
//projectile behavior tree //projectile behavior tree
ProjectileTree tree = new ProjectileTree(rVal,rawType.getMaxLife(),initialVector,rawType.getVelocity(), rawType.getDamage()); 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); ProjectileType rawType = Globals.gameConfigCurrent.getProjectileMap().getType(projectileType);
Entity rVal = EntityCreationUtils.createServerEntity(realm, initialPosition); Entity rVal = EntityCreationUtils.createServerEntity(realm, initialPosition);
//initial coordinates //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); EntityUtils.getPosition(rVal).set(initialPosition);
//projectile behavior tree //projectile behavior tree
ProjectileTree tree = new ProjectileTree(rVal,rawType.getMaxLife(),initialVector,rawType.getVelocity(), rawType.getDamage()); ProjectileTree tree = new ProjectileTree(rVal,rawType.getMaxLife(),initialVector,rawType.getVelocity(), rawType.getDamage());

View File

@ -16,7 +16,7 @@ import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState; import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.RenderingEngine; import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.actor.Actor; import electrosphere.renderer.actor.Actor;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
/** /**
* Shadow map pipeline * Shadow map pipeline
@ -76,7 +76,7 @@ public class ShadowMapPipeline implements RenderPipeline {
Matrix4f lightView = new Matrix4f().setLookAt( Matrix4f lightView = new Matrix4f().setLookAt(
new Vector3f(eyeX, eyeY, eyeZ), new Vector3f(eyeX, eyeY, eyeZ),
new Vector3f( 0.0f, 0.0f, 0.0f), new Vector3f( 0.0f, 0.0f, 0.0f),
MathUtils.getUpVectorf() SpatialMathUtils.getUpVectorf()
); );
Globals.lightDepthMatrix = lightProjection.mul(lightView); Globals.lightDepthMatrix = lightProjection.mul(lightView);

View File

@ -22,7 +22,7 @@ import electrosphere.engine.Main;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.script.translation.JSServerUtils; import electrosphere.script.translation.JSServerUtils;
import electrosphere.util.FileUtils; import electrosphere.util.FileUtils;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
/** /**
* Interface for executing scripts in the game engine * 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 //The classes that will be provided to the scripting engine
//https://stackoverflow.com/a/65942034 //https://stackoverflow.com/a/65942034
static final Object[][] staticClasses = new Object[][]{ static final Object[][] staticClasses = new Object[][]{
{"mathUtils",MathUtils.class}, {"mathUtils",SpatialMathUtils.class},
{"simulation",Main.class}, {"simulation",Main.class},
{"tutorialUtils",TutorialMenus.class}, {"tutorialUtils",TutorialMenus.class},
{"serverUtils",JSServerUtils.class}, {"serverUtils",JSServerUtils.class},

View File

@ -10,7 +10,7 @@ import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.server.ai.blackboard.Blackboard; import electrosphere.server.ai.blackboard.Blackboard;
import electrosphere.server.ai.nodes.AITreeNode; import electrosphere.server.ai.nodes.AITreeNode;
import electrosphere.server.ai.nodes.actions.combat.MeleeTargetingNode; import electrosphere.server.ai.nodes.actions.combat.MeleeTargetingNode;
import electrosphere.util.math.MathUtils; import electrosphere.util.math.SpatialMathUtils;
/** /**
* Faces the target * Faces the target
@ -29,7 +29,7 @@ public class FaceTargetNode implements AITreeNode {
Entity target = MeleeTargetingNode.getTarget(blackboard); Entity target = MeleeTargetingNode.getTarget(blackboard);
Vector3d parentPos = EntityUtils.getPosition(entity); Vector3d parentPos = EntityUtils.getPosition(entity);
Vector3d targetPos = EntityUtils.getPosition(target); Vector3d targetPos = EntityUtils.getPosition(target);
Quaterniond rotation = MathUtils.calculateRotationFromPointToPoint(parentPos, targetPos); Quaterniond rotation = SpatialMathUtils.calculateRotationFromPointToPoint(parentPos, targetPos);
EntityUtils.getRotation(entity).set(rotation); EntityUtils.getRotation(entity).set(rotation);
CreatureUtils.setFacingVector(entity, CameraEntityUtils.getFacingVec(rotation)); CreatureUtils.setFacingVector(entity, CameraEntityUtils.getFacingVec(rotation));
return AITreeNodeResult.SUCCESS; return AITreeNodeResult.SUCCESS;

View File

@ -45,11 +45,11 @@ public class MathBones {
Vector3d facingAngle = CreatureUtils.getFacingVector(actorEntity); Vector3d facingAngle = CreatureUtils.getFacingVector(actorEntity);
if(facingAngle == null){ if(facingAngle == null){
facingAngle = MathUtils.getOriginVector(); facingAngle = SpatialMathUtils.getOriginVector();
} }
//calculate rotation of model //calculate rotation of model
return new Quaterniond() 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) .mul(localRot)
.normalize(); .normalize();
} }

View File

@ -10,7 +10,7 @@ import electrosphere.logger.LoggerInterface;
/** /**
* Utility functions for doing math * Utility functions for doing math
*/ */
public class MathUtils { public class SpatialMathUtils {
/** /**
@ -90,7 +90,7 @@ public class MathUtils {
* @return The up rotation * @return The up rotation
*/ */
public static Quaterniond getUpRotation(){ public static Quaterniond getUpRotation(){
return MathUtils.calculateRotationFromPointToPoint(MathUtils.getOriginVector(), MathUtils.getUpVector()); return SpatialMathUtils.calculateRotationFromPointToPoint(SpatialMathUtils.getOriginVector(), SpatialMathUtils.getUpVector());
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 30 KiB