Adding terrain
This commit is contained in:
parent
3434edebf0
commit
01fb472585
@ -136,6 +136,11 @@
|
|||||||
"isKey": true,
|
"isKey": true,
|
||||||
"isMouse": false,
|
"isMouse": false,
|
||||||
"keyValue": 89
|
"keyValue": 89
|
||||||
|
},
|
||||||
|
"placeTerrain": {
|
||||||
|
"isKey": true,
|
||||||
|
"isMouse": false,
|
||||||
|
"keyValue": 52
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,6 +23,6 @@
|
|||||||
"graphicsDebugDrawMovementVectors" : false,
|
"graphicsDebugDrawMovementVectors" : false,
|
||||||
"graphicsDebugDrawNavmesh" : false,
|
"graphicsDebugDrawNavmesh" : false,
|
||||||
|
|
||||||
"netRunNetMonitor" : true
|
"netRunNetMonitor" : false
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,8 @@
|
|||||||
package electrosphere.client.scene;
|
package electrosphere.client.scene;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
import org.joml.Vector3i;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -92,4 +94,20 @@ public class ClientWorldData {
|
|||||||
return convertChunkToRealSpace(world);
|
return convertChunkToRealSpace(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3i convertRealToChunkSpace(Vector3d position){
|
||||||
|
return new Vector3i(
|
||||||
|
convertRealToChunkSpace(position.x),
|
||||||
|
convertRealToChunkSpace(position.y),
|
||||||
|
convertRealToChunkSpace(position.z)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3i convertRealToVoxelSpace(Vector3d position){
|
||||||
|
return new Vector3i(
|
||||||
|
(int)Math.floor(position.x - convertChunkToRealSpace(convertRealToChunkSpace(position.x))),
|
||||||
|
(int)Math.floor(position.y - convertChunkToRealSpace(convertRealToChunkSpace(position.y))),
|
||||||
|
(int)Math.floor(position.z - convertChunkToRealSpace(convertRealToChunkSpace(position.z)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,5 +48,10 @@ public class ChunkData {
|
|||||||
this.voxelWeight = voxelWeight;
|
this.voxelWeight = voxelWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updatePosition(int localX, int localY, int localZ, float weight, int type){
|
||||||
|
voxelWeight[localX][localY][localZ] = weight;
|
||||||
|
voxelType[localX][localY][localZ] = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,35 +1,19 @@
|
|||||||
package electrosphere.client.terrain.cells;
|
package electrosphere.client.terrain.cells;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3i;
|
||||||
|
import org.ode4j.ode.DBody;
|
||||||
|
|
||||||
import electrosphere.client.terrain.cache.ChunkData;
|
import electrosphere.client.terrain.cache.ChunkData;
|
||||||
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
import electrosphere.collision.CollisionEngine;
|
||||||
import electrosphere.collision.PhysicsUtils;
|
|
||||||
import electrosphere.collision.collidable.Collidable;
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.ClientEntityUtils;
|
import electrosphere.entity.ClientEntityUtils;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityCreationUtils;
|
|
||||||
import electrosphere.entity.EntityDataStrings;
|
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.types.terrain.TerrainChunk;
|
import electrosphere.entity.types.terrain.TerrainChunk;
|
||||||
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
|
||||||
import electrosphere.renderer.Mesh;
|
|
||||||
import electrosphere.renderer.Model;
|
|
||||||
import electrosphere.renderer.ModelUtils;
|
|
||||||
import electrosphere.renderer.RenderUtils;
|
|
||||||
import electrosphere.renderer.ShaderProgram;
|
import electrosphere.renderer.ShaderProgram;
|
||||||
import electrosphere.renderer.actor.ActorTextureMask;
|
|
||||||
import electrosphere.renderer.texture.Texture;
|
import electrosphere.renderer.texture.Texture;
|
||||||
import electrosphere.util.Utilities;
|
import electrosphere.server.datacell.Realm;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.joml.Vector3i;
|
|
||||||
import org.ode4j.ode.DBody;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -138,9 +122,13 @@ public class DrawCell {
|
|||||||
// // System.out.println("generate physics");
|
// // System.out.println("generate physics");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// public void destroyPhysics(){
|
public void destroy(){
|
||||||
// Globals.clientSceneWrapper.getCollisionEngine().deregisterCollidableEntity(modelEntity);
|
Realm realm = Globals.realmManager.getEntityRealm(modelEntity);
|
||||||
// Globals.clientSceneWrapper.getCollisionEngine().deregisterRigidBody((RigidBody)physicsObject);
|
if(realm != null){
|
||||||
// }
|
CollisionEngine collisionEngine = Globals.realmManager.getEntityRealm(modelEntity).getCollisionEngine();
|
||||||
|
collisionEngine.destroyEntityThatHasPhysics(modelEntity);
|
||||||
|
}
|
||||||
|
EntityUtils.cleanUpEntity(modelEntity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,20 @@
|
|||||||
package electrosphere.client.terrain.cells;
|
package electrosphere.client.terrain.cells;
|
||||||
|
|
||||||
import electrosphere.client.scene.ClientWorldData;
|
|
||||||
import electrosphere.client.terrain.cache.ChunkData;
|
|
||||||
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
|
||||||
import electrosphere.engine.Globals;
|
|
||||||
import electrosphere.entity.EntityUtils;
|
|
||||||
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
|
||||||
import electrosphere.net.parser.net.message.TerrainMessage;
|
|
||||||
import electrosphere.renderer.ShaderProgram;
|
|
||||||
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.joml.Vector2i;
|
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.joml.Vector3i;
|
import org.joml.Vector3i;
|
||||||
|
|
||||||
|
import electrosphere.client.terrain.cache.ChunkData;
|
||||||
|
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.net.parser.net.message.TerrainMessage;
|
||||||
|
import electrosphere.renderer.ShaderProgram;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author satellite
|
* @author satellite
|
||||||
@ -208,6 +202,7 @@ public class DrawCellManager {
|
|||||||
// while(commonWorldData.getDynamicInterpolationRatio() % stride != 0){
|
// while(commonWorldData.getDynamicInterpolationRatio() % stride != 0){
|
||||||
// stride = stride + 1;
|
// stride = stride + 1;
|
||||||
// }
|
// }
|
||||||
|
keyCellMap.get(targetKey).destroy();
|
||||||
keyCellMap.get(targetKey).generateDrawableEntity();
|
keyCellMap.get(targetKey).generateDrawableEntity();
|
||||||
}
|
}
|
||||||
drawable.add(targetKey);
|
drawable.add(targetKey);
|
||||||
@ -400,6 +395,10 @@ public class DrawCellManager {
|
|||||||
return new Vector3i(Integer.parseInt(keyComponents[0]),Integer.parseInt(keyComponents[1]),Integer.parseInt(keyComponents[2]));
|
return new Vector3i(Integer.parseInt(keyComponents[0]),Integer.parseInt(keyComponents[1]),Integer.parseInt(keyComponents[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markUpdateable(int chunkX, int chunkY, int chunkZ){
|
||||||
|
updateable.add(getCellKey(chunkX, chunkY, chunkZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public
|
// public
|
||||||
|
|||||||
@ -1,5 +1,13 @@
|
|||||||
package electrosphere.client.terrain.manager;
|
package electrosphere.client.terrain.manager;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.FloatBuffer;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import electrosphere.client.scene.ClientWorldData;
|
import electrosphere.client.scene.ClientWorldData;
|
||||||
import electrosphere.client.terrain.cache.ChunkData;
|
import electrosphere.client.terrain.cache.ChunkData;
|
||||||
import electrosphere.client.terrain.cache.ClientTerrainCache;
|
import electrosphere.client.terrain.cache.ClientTerrainCache;
|
||||||
@ -11,14 +19,6 @@ import electrosphere.renderer.Model;
|
|||||||
import electrosphere.renderer.meshgen.TerrainChunkModelGeneration;
|
import electrosphere.renderer.meshgen.TerrainChunkModelGeneration;
|
||||||
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.FloatBuffer;
|
|
||||||
import java.nio.IntBuffer;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages terrain storage and access on the client
|
* Manages terrain storage and access on the client
|
||||||
*/
|
*/
|
||||||
@ -110,6 +110,22 @@ public class ClientTerrainManager {
|
|||||||
clientWorldData.convertRealToChunkSpace(z)
|
clientWorldData.convertRealToChunkSpace(z)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is only for short term testing and should be removed
|
||||||
|
* @param worldX
|
||||||
|
* @param worldY
|
||||||
|
* @param worldZ
|
||||||
|
* @param localX
|
||||||
|
* @param localY
|
||||||
|
* @param localZ
|
||||||
|
* @param weight
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
public void updateChunk(int worldX, int worldY, int worldZ, int localX, int localY, int localZ, float weight, int type){
|
||||||
|
terrainCache.getSubChunkDataAtPoint(worldX, worldY, worldZ).updatePosition(localX, localY, localZ, weight, type);
|
||||||
|
Globals.drawCellManager.markUpdateable(worldX, worldY, worldZ);
|
||||||
|
}
|
||||||
|
|
||||||
public ChunkData getChunkDataAtWorldPoint(int worldX, int worldY, int worldZ){
|
public ChunkData getChunkDataAtWorldPoint(int worldX, int worldY, int worldZ){
|
||||||
return terrainCache.getSubChunkDataAtPoint(worldX, worldY, worldZ);
|
return terrainCache.getSubChunkDataAtPoint(worldX, worldY, worldZ);
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package electrosphere.collision;
|
package electrosphere.collision;
|
||||||
|
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import static org.ode4j.ode.OdeConstants.dContactBounce;
|
||||||
import electrosphere.entity.Entity;
|
import static org.ode4j.ode.OdeConstants.dContactSoftCFM;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import static org.ode4j.ode.OdeConstants.dInfinity;
|
||||||
import electrosphere.entity.EntityUtils;
|
import static org.ode4j.ode.OdeHelper.areConnectedExcluding;
|
||||||
import electrosphere.entity.state.collidable.Impulse;
|
import static org.ode4j.ode.OdeMath.dCalcVectorLengthSquare3;
|
||||||
import electrosphere.entity.types.hitbox.HitboxData;
|
import static org.ode4j.ode.OdeMath.dSubtractVectors3;
|
||||||
|
import static org.ode4j.ode.internal.Common.dRecip;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -14,7 +15,6 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
import org.joml.Quaterniond;
|
import org.joml.Quaterniond;
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import org.ode4j.math.DMatrix3;
|
import org.ode4j.math.DMatrix3;
|
||||||
@ -22,23 +22,31 @@ import org.ode4j.math.DVector3;
|
|||||||
import org.ode4j.math.DVector4;
|
import org.ode4j.math.DVector4;
|
||||||
import org.ode4j.ode.DBody;
|
import org.ode4j.ode.DBody;
|
||||||
import org.ode4j.ode.DBox;
|
import org.ode4j.ode.DBox;
|
||||||
|
import org.ode4j.ode.DCapsule;
|
||||||
import org.ode4j.ode.DContact;
|
import org.ode4j.ode.DContact;
|
||||||
import org.ode4j.ode.DContactBuffer;
|
import org.ode4j.ode.DContactBuffer;
|
||||||
import org.ode4j.ode.DContactJoint;
|
import org.ode4j.ode.DContactJoint;
|
||||||
import org.ode4j.ode.DCylinder;
|
import org.ode4j.ode.DCylinder;
|
||||||
import org.ode4j.ode.DGeom;
|
import org.ode4j.ode.DGeom;
|
||||||
|
import org.ode4j.ode.DGeom.DNearCallback;
|
||||||
import org.ode4j.ode.DJoint;
|
import org.ode4j.ode.DJoint;
|
||||||
import org.ode4j.ode.DJointGroup;
|
import org.ode4j.ode.DJointGroup;
|
||||||
|
import org.ode4j.ode.DMass;
|
||||||
import org.ode4j.ode.DRay;
|
import org.ode4j.ode.DRay;
|
||||||
import org.ode4j.ode.DSpace;
|
import org.ode4j.ode.DSpace;
|
||||||
|
import org.ode4j.ode.DSphere;
|
||||||
import org.ode4j.ode.DTriMesh;
|
import org.ode4j.ode.DTriMesh;
|
||||||
import org.ode4j.ode.DTriMeshData;
|
import org.ode4j.ode.DTriMeshData;
|
||||||
import org.ode4j.ode.DWorld;
|
import org.ode4j.ode.DWorld;
|
||||||
import org.ode4j.ode.OdeHelper;
|
import org.ode4j.ode.OdeHelper;
|
||||||
import org.ode4j.ode.DGeom.DNearCallback;
|
|
||||||
|
|
||||||
import static org.ode4j.ode.OdeHelper.*;
|
import electrosphere.collision.RayCastCallback.RayCastCallbackData;
|
||||||
import static org.ode4j.ode.OdeMath.*;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.state.collidable.Impulse;
|
||||||
|
import electrosphere.entity.types.hitbox.HitboxData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -278,7 +286,11 @@ public class CollisionEngine {
|
|||||||
contact.surface.bounce_vel = 0.1;
|
contact.surface.bounce_vel = 0.1;
|
||||||
contact.surface.soft_cfm = 0.01;
|
contact.surface.soft_cfm = 0.01;
|
||||||
}
|
}
|
||||||
if(!(bodyPointerMap.get(b1).getType() == Collidable.TYPE_TERRAIN && bodyPointerMap.get(b2).getType() == Collidable.TYPE_TERRAIN)){
|
if(
|
||||||
|
bodyPointerMap.get(b1) != null &&
|
||||||
|
bodyPointerMap.get(b2) != null &&
|
||||||
|
!(bodyPointerMap.get(b1).getType() == Collidable.TYPE_TERRAIN &&
|
||||||
|
bodyPointerMap.get(b2).getType() == Collidable.TYPE_TERRAIN)){
|
||||||
//calculate collisions
|
//calculate collisions
|
||||||
int numc = OdeHelper.collide(o1,o2,MAX_CONTACTS,contacts.getGeomBuffer());
|
int numc = OdeHelper.collide(o1,o2,MAX_CONTACTS,contacts.getGeomBuffer());
|
||||||
//create DContacts based on each collision that occurs
|
//create DContacts based on each collision that occurs
|
||||||
@ -581,11 +593,71 @@ public class CollisionEngine {
|
|||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts a ray into the scene and returns the first entity that the ray collides with.
|
||||||
|
* This will collide with any type of collidable object.
|
||||||
|
* @param start THe start position of the ray
|
||||||
|
* @param direction The direction the ray will travel in
|
||||||
|
* @param length The length of the ray to cast
|
||||||
|
* @return The entity that the ray collides with if successful, null otherwise
|
||||||
|
*/
|
||||||
|
public Entity rayCast(Vector3d start, Vector3d direction, double length){
|
||||||
|
return rayCast(start,direction,length,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts a ray into the collision space and returns the first entity that the ray collides with.
|
||||||
|
* The type mask is a list of collidable types that are valid collisions.
|
||||||
|
* For instance, if the typeMask only contains Collidable.TYPE_TERRAIN, only entities with the type terrain will
|
||||||
|
* be returned from the raycast.
|
||||||
|
* @param start The start position of the way
|
||||||
|
* @param length The length to cast the ray out to
|
||||||
|
* @param typeMask The mask of types to collide the ray with
|
||||||
|
* @return The entity that the ray cast collided with. Will be null if no entity was collided with.
|
||||||
|
*/
|
||||||
|
public Entity rayCast(Vector3d start, Vector3d direction, double length, List<String> typeMask){
|
||||||
|
spaceLock.acquireUninterruptibly();
|
||||||
|
//create the ray
|
||||||
|
DRay ray = OdeHelper.createRay(space, length);
|
||||||
|
ray.set(start.x, start.y, start.z, direction.x, direction.y, direction.z);
|
||||||
|
//collide
|
||||||
|
RayCastCallbackData data = new RayCastCallbackData(bodyPointerMap, typeMask);
|
||||||
|
rayCastCallback.setLength(length);
|
||||||
|
space.collide2(space, data, rayCastCallback);
|
||||||
|
//destroy ray
|
||||||
|
ray.destroy();
|
||||||
|
spaceLock.release();
|
||||||
|
return data.collidedEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ray casts into the scene and gets the position of the closest collision's position in world space.
|
||||||
|
* Will collide with any collidable types including characters and items.
|
||||||
|
* @param start The start position of the ray to cast
|
||||||
|
* @param direction The direction of the ray to cast
|
||||||
|
* @param length The length of the ray to cast
|
||||||
|
* @return The position, in world coordinates, of the closest collision of the way, or null if it did not collide with anything.
|
||||||
|
*/
|
||||||
|
public Vector3d rayCastPosition(Vector3d start, Vector3d direction, double length){
|
||||||
|
spaceLock.acquireUninterruptibly();
|
||||||
|
//create the ray
|
||||||
|
DRay ray = OdeHelper.createRay(space, length);
|
||||||
|
ray.set(start.x, start.y, start.z, direction.x, direction.y, direction.z);
|
||||||
|
//collide
|
||||||
|
RayCastCallbackData data = new RayCastCallbackData(bodyPointerMap, null);
|
||||||
|
rayCastCallback.setLength(length);
|
||||||
|
space.collide2(ray, data, rayCastCallback);
|
||||||
|
//destroy ray
|
||||||
|
ray.destroy();
|
||||||
|
spaceLock.release();
|
||||||
|
return data.collisionPosition;
|
||||||
|
}
|
||||||
|
|
||||||
public void registerPhysicsObject(DBody body){
|
public void registerPhysicsObject(DBody body){
|
||||||
if(!bodies.contains(body)){
|
if(!bodies.contains(body)){
|
||||||
bodies.add(body);
|
bodies.add(body);
|
||||||
OdeHelper.createBody(world);
|
// OdeHelper.createBody(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,34 +734,85 @@ public class CollisionEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a cube dbody. Dimensions vector control the total length of the x, y, and z dimensions respectively.
|
* Creates a cube geometry. Dimensions vector control the total length of the x, y, and z dimensions respectively.
|
||||||
* @param dimensions The dimensions of the box
|
* @param dimensions The dimensions of the box
|
||||||
|
* @return The DBox
|
||||||
|
*/
|
||||||
|
protected DBox createCubeGeom(Vector3d dimensions){
|
||||||
|
spaceLock.acquireUninterruptibly();
|
||||||
|
DBox boxGeom = OdeHelper.createBox(space, dimensions.x, dimensions.y, dimensions.z);
|
||||||
|
spaceLock.release();
|
||||||
|
return boxGeom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a cylinder geometry in the physics space
|
||||||
|
* @param dimensions The dimensions of the cylinder. X is the radius, y is the total height.
|
||||||
|
* @return The cylinder geometry
|
||||||
|
*/
|
||||||
|
protected DCylinder createCylinderGeom(double radius, double length){
|
||||||
|
spaceLock.acquireUninterruptibly();
|
||||||
|
DCylinder cylinderGeom = OdeHelper.createCylinder(space, radius, length);
|
||||||
|
spaceLock.release();
|
||||||
|
return cylinderGeom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a sphere geometry in the physics space
|
||||||
|
* @param radius The radius of the sphere
|
||||||
|
* @return The sphere geometry
|
||||||
|
*/
|
||||||
|
protected DSphere createSphereGeom(double radius){
|
||||||
|
spaceLock.acquireUninterruptibly();
|
||||||
|
DSphere sphereGeom = OdeHelper.createSphere(space, radius);
|
||||||
|
spaceLock.release();
|
||||||
|
return sphereGeom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a capsule geometry in the physics space
|
||||||
|
* @param radius The radius of the capsule
|
||||||
|
* @param length The length of the capsule
|
||||||
|
* @return The capsule geometry
|
||||||
|
*/
|
||||||
|
protected DCapsule createCapsuleGeom(double radius, double length){
|
||||||
|
spaceLock.acquireUninterruptibly();
|
||||||
|
DCapsule capsuleGeom = OdeHelper.createCapsule(space, radius, length);
|
||||||
|
spaceLock.release();
|
||||||
|
return capsuleGeom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a DBody. Can optionally be passed DGeom objects to be attached to the body when it is created.
|
||||||
|
* @param geom The geometry objects to attach to the body on creation
|
||||||
* @return The DBody
|
* @return The DBody
|
||||||
*/
|
*/
|
||||||
protected DBody createCubeGeom(Vector3d dimensions){
|
protected DBody createDBody(DGeom ...geom){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.acquireUninterruptibly();
|
||||||
DBody body = OdeHelper.createBody(world);
|
DBody body = OdeHelper.createBody(world);
|
||||||
|
if(geom != null){
|
||||||
DBox boxGeom = OdeHelper.createBox(space, dimensions.x, dimensions.y, dimensions.z);
|
for(int i = 0; i < geom.length; i++){
|
||||||
boxGeom.setBody(body);
|
if(geom != null){
|
||||||
|
geom[i].setBody(body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
spaceLock.release();
|
spaceLock.release();
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a cylinder dbody
|
* Creates a DMass and attaches a body to it
|
||||||
* @param dimensions The dimensions of the cylinder. X is the radius, y is the total height.
|
* @param massValue The amount of mass for the object
|
||||||
* @return The Dbody
|
* @param body The DBody to attach the mass to
|
||||||
|
* @return The DMass
|
||||||
*/
|
*/
|
||||||
protected DBody createCylinderGeom(Vector3d dimensions){
|
protected DMass createDMass(double massValue, DBody body){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.acquireUninterruptibly();
|
||||||
DBody body = OdeHelper.createBody(world);
|
DMass mass = OdeHelper.createMass();
|
||||||
|
body.setMass(mass);
|
||||||
System.out.println(dimensions.y);
|
|
||||||
DCylinder cylinderGeom = OdeHelper.createCylinder(space, dimensions.x, dimensions.y);
|
|
||||||
cylinderGeom.setBody(body);
|
|
||||||
spaceLock.release();
|
spaceLock.release();
|
||||||
return body;
|
return mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,23 +1,9 @@
|
|||||||
package electrosphere.collision;
|
package electrosphere.collision;
|
||||||
|
|
||||||
import electrosphere.collision.collidable.Collidable;
|
|
||||||
import electrosphere.engine.Globals;
|
|
||||||
import electrosphere.server.datacell.Realm;
|
|
||||||
import electrosphere.entity.Entity;
|
|
||||||
import electrosphere.entity.EntityDataStrings;
|
|
||||||
import electrosphere.entity.EntityUtils;
|
|
||||||
import electrosphere.entity.ServerEntityUtils;
|
|
||||||
import electrosphere.entity.types.terrain.TerrainChunkData;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.FloatBuffer;
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
import org.joml.Quaterniond;
|
import org.joml.Quaterniond;
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.lwjgl.PointerBuffer;
|
import org.lwjgl.PointerBuffer;
|
||||||
import org.lwjgl.assimp.AIFace;
|
import org.lwjgl.assimp.AIFace;
|
||||||
import org.lwjgl.assimp.AIMesh;
|
import org.lwjgl.assimp.AIMesh;
|
||||||
@ -28,15 +14,20 @@ import org.ode4j.math.DQuaternionC;
|
|||||||
import org.ode4j.ode.DBody;
|
import org.ode4j.ode.DBody;
|
||||||
import org.ode4j.ode.DBox;
|
import org.ode4j.ode.DBox;
|
||||||
import org.ode4j.ode.DCylinder;
|
import org.ode4j.ode.DCylinder;
|
||||||
import org.ode4j.ode.DGeom;
|
import org.ode4j.ode.DMass;
|
||||||
import org.ode4j.ode.DJointGroup;
|
|
||||||
import org.ode4j.ode.DPlane;
|
import org.ode4j.ode.DPlane;
|
||||||
import org.ode4j.ode.DSpace;
|
import org.ode4j.ode.DSphere;
|
||||||
import org.ode4j.ode.DTriMesh;
|
import org.ode4j.ode.DTriMesh;
|
||||||
import org.ode4j.ode.DTriMeshData;
|
|
||||||
import org.ode4j.ode.DWorld;
|
|
||||||
import org.ode4j.ode.OdeHelper;
|
import org.ode4j.ode.OdeHelper;
|
||||||
|
|
||||||
|
import electrosphere.collision.collidable.Collidable;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.types.terrain.TerrainChunkData;
|
||||||
|
import electrosphere.server.datacell.Realm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
@ -172,8 +163,7 @@ public class PhysicsUtils {
|
|||||||
* @return The DBody
|
* @return The DBody
|
||||||
*/
|
*/
|
||||||
private static DBody generateBodyFromTerrainData(CollisionEngine collisionEngine, TerrainChunkData data){
|
private static DBody generateBodyFromTerrainData(CollisionEngine collisionEngine, TerrainChunkData data){
|
||||||
//create body
|
DBody body = null;
|
||||||
DBody body = OdeHelper.createBody(collisionEngine.getDWorld());
|
|
||||||
|
|
||||||
//create data
|
//create data
|
||||||
int numberTriangles = data.getFaceElements().size() / 3;
|
int numberTriangles = data.getFaceElements().size() / 3;
|
||||||
@ -197,7 +187,7 @@ public class PhysicsUtils {
|
|||||||
//create trimesh
|
//create trimesh
|
||||||
if(vertices.length > 0){
|
if(vertices.length > 0){
|
||||||
DTriMesh triMesh = collisionEngine.createTrimeshGeom(vertices,indices);
|
DTriMesh triMesh = collisionEngine.createTrimeshGeom(vertices,indices);
|
||||||
triMesh.setBody(body);
|
body = collisionEngine.createDBody(triMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
@ -338,8 +328,9 @@ public class PhysicsUtils {
|
|||||||
* @param dimensions The dimensions of the plane
|
* @param dimensions The dimensions of the plane
|
||||||
* @return The DBody
|
* @return The DBody
|
||||||
*/
|
*/
|
||||||
public static DBody createPlaneGeom(CollisionEngine collisionEngine, Vector3d dimensions){
|
public static DBody createPlaneBody(CollisionEngine collisionEngine, Vector3d dimensions){
|
||||||
return collisionEngine.createCubeGeom(new Vector3d(dimensions.x,PLANE_WIDTH,dimensions.z));
|
DBox geom = collisionEngine.createCubeGeom(new Vector3d(dimensions.x,PLANE_WIDTH,dimensions.z));
|
||||||
|
return collisionEngine.createDBody(geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -348,8 +339,9 @@ public class PhysicsUtils {
|
|||||||
* @param dimensions The dimensions of the cube
|
* @param dimensions The dimensions of the cube
|
||||||
* @return The DBody
|
* @return The DBody
|
||||||
*/
|
*/
|
||||||
public static DBody createCubeGeom(CollisionEngine collisionEngine, Vector3d dimensions){
|
public static DBody createCubeBody(CollisionEngine collisionEngine, Vector3d dimensions){
|
||||||
return collisionEngine.createCubeGeom(dimensions);
|
DBox geom = collisionEngine.createCubeGeom(new Vector3d(dimensions));
|
||||||
|
return collisionEngine.createDBody(geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -358,8 +350,31 @@ public class PhysicsUtils {
|
|||||||
* @param dimensions The dimensions of the cube
|
* @param dimensions The dimensions of the cube
|
||||||
* @return The DBody
|
* @return The DBody
|
||||||
*/
|
*/
|
||||||
public static DBody createCylinderGeom(CollisionEngine collisionEngine, Vector3d dimensions){
|
public static DBody createCylinderBody(CollisionEngine collisionEngine, double radius, double length){
|
||||||
return collisionEngine.createCylinderGeom(dimensions);
|
DCylinder geom = collisionEngine.createCylinderGeom(radius,length);
|
||||||
|
return collisionEngine.createDBody(geom);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a sphere body in the collision engine
|
||||||
|
* @param collisionEngine The collision engine
|
||||||
|
* @param radius The radius of the sphere
|
||||||
|
* @return The DBody
|
||||||
|
*/
|
||||||
|
public static DBody createSphereBody(CollisionEngine collisionEngine, double radius){
|
||||||
|
DSphere geom = collisionEngine.createSphereGeom(radius);
|
||||||
|
return collisionEngine.createDBody(geom);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a mass in the physics space from the body and mass value input
|
||||||
|
* @param collisionEngine The collision engine to create the mass in
|
||||||
|
* @param body The DBody to give mass to
|
||||||
|
* @param mass The amount of mass to give to the DBody
|
||||||
|
* @return THe DMass wrapping the DBody with a given mass value
|
||||||
|
*/
|
||||||
|
public static DMass createMassFromBody(CollisionEngine collisionEngine, DBody body, double mass){
|
||||||
|
return collisionEngine.createDMass(mass, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,28 +1,25 @@
|
|||||||
package electrosphere.collision;
|
package electrosphere.collision;
|
||||||
|
|
||||||
import org.ode4j.math.DMatrix3;
|
import static org.ode4j.ode.OdeConstants.dContactBounce;
|
||||||
import org.ode4j.math.DVector3;
|
import static org.ode4j.ode.OdeConstants.dContactSoftCFM;
|
||||||
|
import static org.ode4j.ode.OdeConstants.dInfinity;
|
||||||
|
import static org.ode4j.ode.OdeHelper.areConnectedExcluding;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
import org.ode4j.ode.DBody;
|
import org.ode4j.ode.DBody;
|
||||||
import org.ode4j.ode.DBox;
|
|
||||||
import org.ode4j.ode.DContact;
|
import org.ode4j.ode.DContact;
|
||||||
import org.ode4j.ode.DContactBuffer;
|
import org.ode4j.ode.DContactBuffer;
|
||||||
import org.ode4j.ode.DContactJoint;
|
import org.ode4j.ode.DContactJoint;
|
||||||
import org.ode4j.ode.DCylinder;
|
|
||||||
import org.ode4j.ode.DGeom;
|
import org.ode4j.ode.DGeom;
|
||||||
import org.ode4j.ode.DJoint;
|
|
||||||
import org.ode4j.ode.DJointGroup;
|
|
||||||
import org.ode4j.ode.DRay;
|
|
||||||
import org.ode4j.ode.DSpace;
|
|
||||||
import org.ode4j.ode.DTriMesh;
|
|
||||||
import org.ode4j.ode.DTriMeshData;
|
|
||||||
import org.ode4j.ode.DWorld;
|
|
||||||
import org.ode4j.ode.OdeHelper;
|
|
||||||
import org.ode4j.ode.DGeom.DNearCallback;
|
import org.ode4j.ode.DGeom.DNearCallback;
|
||||||
|
import org.ode4j.ode.DRay;
|
||||||
|
import org.ode4j.ode.OdeHelper;
|
||||||
|
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
import static org.ode4j.ode.OdeHelper.*;
|
|
||||||
import static org.ode4j.ode.OdeMath.*;
|
|
||||||
|
|
||||||
public class RayCastCallback implements DNearCallback {
|
public class RayCastCallback implements DNearCallback {
|
||||||
|
|
||||||
@ -47,10 +44,18 @@ void RayCallback(void *Data, dGeomID Geometry1, dGeomID Geometry2) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//For the current execution, this stores the shortest length that has currently been encountered.
|
||||||
|
//This is used to keep track of the closest body so that there doesn't need to be contact join creation.
|
||||||
|
//This should be reset every time a ray cast is called in collision engine by calling setLength in this object.
|
||||||
|
double shortestLength = 1000000;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(Object data, DGeom o1, DGeom o2) {
|
public void call(Object data, DGeom o1, DGeom o2) {
|
||||||
// if (o1->body && o2->body) return;
|
// if (o1->body && o2->body) return;
|
||||||
|
RayCastCallbackData rayCastData = (RayCastCallbackData)data;
|
||||||
|
//null out potentially previous results
|
||||||
|
// rayCastData.collisionPosition = null;
|
||||||
|
// rayCastData.collidedEntity = null;
|
||||||
// exit without doing anything if the two bodies are connected by a joint
|
// exit without doing anything if the two bodies are connected by a joint
|
||||||
DBody b1 = o1.getBody();
|
DBody b1 = o1.getBody();
|
||||||
DBody b2 = o2.getBody();
|
DBody b2 = o2.getBody();
|
||||||
@ -67,47 +72,73 @@ void RayCallback(void *Data, dGeomID Geometry1, dGeomID Geometry2) {
|
|||||||
contact.surface.bounce_vel = 0.1;
|
contact.surface.bounce_vel = 0.1;
|
||||||
contact.surface.soft_cfm = 0.01;
|
contact.surface.soft_cfm = 0.01;
|
||||||
}
|
}
|
||||||
if(!(bodyPointerMap.get(b1).getType() == Collidable.TYPE_TERRAIN && bodyPointerMap.get(b2).getType() == Collidable.TYPE_TERRAIN)){
|
Collidable collidable1 = rayCastData.bodyEntityMap.get(b1);
|
||||||
|
Collidable collidable2 = rayCastData.bodyEntityMap.get(b2);
|
||||||
|
if(
|
||||||
|
(
|
||||||
|
rayCastData.collidableTypeMask != null &&
|
||||||
|
(
|
||||||
|
(o1 instanceof DRay && rayCastData.collidableTypeMask.contains(collidable2.getType())) ||
|
||||||
|
(o2 instanceof DRay && rayCastData.collidableTypeMask.contains(collidable1.getType()))
|
||||||
|
)
|
||||||
|
) ||
|
||||||
|
rayCastData.collidableTypeMask == null
|
||||||
|
){
|
||||||
//calculate collisions
|
//calculate collisions
|
||||||
int numc = OdeHelper.collide(o1,o2,MAX_CONTACTS,contacts.getGeomBuffer());
|
int numc = OdeHelper.collide(o1,o2,MAX_CONTACTS,contacts.getGeomBuffer());
|
||||||
//create DContacts based on each collision that occurs
|
//create DContacts based on each collision that occurs
|
||||||
if (numc != 0) {
|
if (numc != 0) {
|
||||||
DMatrix3 RI = new DMatrix3();
|
|
||||||
RI.setIdentity ();
|
|
||||||
for (int i=0; i<numc; i++) {
|
for (int i=0; i<numc; i++) {
|
||||||
DContact contact = contacts.get(i);
|
DContact contact = contacts.get(i);
|
||||||
//special code for ray casting
|
double depth = contact.geom.depth;
|
||||||
if (o1 instanceof DRay || o2 instanceof DRay){
|
|
||||||
DMatrix3 Rotation = new DMatrix3();
|
|
||||||
Rotation.setIdentity();
|
|
||||||
// dsDrawSphere(contact.geom.pos, Rotation, (0.01));
|
|
||||||
|
|
||||||
DVector3 End = new DVector3();
|
//check if should be stored in ray cast data return
|
||||||
End.eqSum( contact.geom.pos, contact.geom.normal, contact.geom.depth );
|
if(depth < shortestLength){
|
||||||
|
shortestLength = depth;
|
||||||
// dsDrawLine(contact.geom.pos, End);
|
if(collidable1 != null){
|
||||||
continue;
|
rayCastData.collidedEntity = collidable1.getParent();
|
||||||
|
rayCastData.collisionPosition = new Vector3d(contact.geom.pos.get0(),contact.geom.pos.get1(),contact.geom.pos.get2());
|
||||||
|
} else if(collidable2 != null) {
|
||||||
|
rayCastData.collidedEntity = collidable2.getParent();
|
||||||
|
rayCastData.collisionPosition = new Vector3d(contact.geom.pos.get0(),contact.geom.pos.get1(),contact.geom.pos.get2());
|
||||||
|
} else if(rayCastData.collidableTypeMask == null){
|
||||||
|
rayCastData.collisionPosition = new Vector3d(contact.geom.pos.get0(),contact.geom.pos.get1(),contact.geom.pos.get2());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// contact.geom.pos
|
|
||||||
resolveCollision(
|
|
||||||
bodyPointerMap.get(o1.getBody()),
|
|
||||||
bodyPointerMap.get(o2.getBody()),
|
|
||||||
PhysicsUtils.odeVecToJomlVec(contact.geom.normal).mul(-1.0),
|
|
||||||
PhysicsUtils.odeVecToJomlVec(contact.fdir1).mul(-1.0),
|
|
||||||
PhysicsUtils.odeVecToJomlVec(contact.geom.pos),
|
|
||||||
(float)contact.geom.depth
|
|
||||||
);
|
|
||||||
resolveCollision(
|
|
||||||
bodyPointerMap.get(o2.getBody()),
|
|
||||||
bodyPointerMap.get(o1.getBody()),
|
|
||||||
PhysicsUtils.odeVecToJomlVec(contact.geom.normal),
|
|
||||||
PhysicsUtils.odeVecToJomlVec(contact.fdir1),
|
|
||||||
PhysicsUtils.odeVecToJomlVec(contact.geom.pos),
|
|
||||||
(float)contact.geom.depth
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the length that the ray should travel
|
||||||
|
* @param length The length
|
||||||
|
*/
|
||||||
|
protected void setLength(double length){
|
||||||
|
this.shortestLength = length + 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data object that contains the information for a ray cast check
|
||||||
|
*/
|
||||||
|
static class RayCastCallbackData {
|
||||||
|
//The map of ode DBody -> collidable
|
||||||
|
Map<DBody,Collidable> bodyEntityMap;
|
||||||
|
//The mask of collidable types to filter collisions by. Can be null.
|
||||||
|
List<String> collidableTypeMask;
|
||||||
|
//The entity that the ray cast collided with. If null, no entity was collided with.
|
||||||
|
Entity collidedEntity = null;
|
||||||
|
//The position in world space that the collision happened
|
||||||
|
Vector3d collisionPosition = null;
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param bodyEntityMap The map of ode DBody -> collidable
|
||||||
|
* @param collidableTypeMask The mask of collidable types to filter collisions by. Can be null.
|
||||||
|
*/
|
||||||
|
public RayCastCallbackData(Map<DBody,Collidable> bodyEntityMap,List<String> collidableTypeMask){
|
||||||
|
this.bodyEntityMap = bodyEntityMap;
|
||||||
|
this.collidableTypeMask = collidableTypeMask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,10 +69,13 @@ import java.util.List;
|
|||||||
import org.joml.Vector2f;
|
import org.joml.Vector2f;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
import org.joml.Vector3i;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import electrosphere.audio.AudioUtils;
|
import electrosphere.audio.AudioUtils;
|
||||||
import electrosphere.client.targeting.crosshair.Crosshair;
|
import electrosphere.client.targeting.crosshair.Crosshair;
|
||||||
|
import electrosphere.client.terrain.cache.ChunkData;
|
||||||
|
import electrosphere.collision.CollisionEngine;
|
||||||
import electrosphere.controls.Control.ControlMethod;
|
import electrosphere.controls.Control.ControlMethod;
|
||||||
import electrosphere.controls.Control.ControlType;
|
import electrosphere.controls.Control.ControlType;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
@ -130,6 +133,7 @@ public class ControlHandler {
|
|||||||
public static final String INPUT_CODE_INVENTORY_OPEN = "inventoryOpen";
|
public static final String INPUT_CODE_INVENTORY_OPEN = "inventoryOpen";
|
||||||
public static final String INPUT_CODE_CHARACTER_OPEN = "characterOpen";
|
public static final String INPUT_CODE_CHARACTER_OPEN = "characterOpen";
|
||||||
public static final String INPUT_CODE_IRON_SIGHT = "ironSight";
|
public static final String INPUT_CODE_IRON_SIGHT = "ironSight";
|
||||||
|
public static final String INPUT_CODE_PLACE_TERRAIN = "placeTerrain";
|
||||||
|
|
||||||
public static final String DATA_STRING_INPUT_CODE_MENU_NAVIGATE_FORWARD = "menuNavigateForward";
|
public static final String DATA_STRING_INPUT_CODE_MENU_NAVIGATE_FORWARD = "menuNavigateForward";
|
||||||
public static final String DATA_STRING_INPUT_CODE_MENU_NAVIGATE_BACKWARDS = "menuNavigateBackwards";
|
public static final String DATA_STRING_INPUT_CODE_MENU_NAVIGATE_BACKWARDS = "menuNavigateBackwards";
|
||||||
@ -320,6 +324,11 @@ public class ControlHandler {
|
|||||||
handler.addControl(INPUT_CODE_INVENTORY_ITEM_MANIPULATE, new Control(ControlType.MOUSE_BUTTON,GLFW_MOUSE_BUTTON_1));
|
handler.addControl(INPUT_CODE_INVENTORY_ITEM_MANIPULATE, new Control(ControlType.MOUSE_BUTTON,GLFW_MOUSE_BUTTON_1));
|
||||||
handler.addControl(INPUT_CODE_INVENTORY_ITEM_DRAG, new Control(ControlType.MOUSE_MOVEMENT,0));
|
handler.addControl(INPUT_CODE_INVENTORY_ITEM_DRAG, new Control(ControlType.MOUSE_MOVEMENT,0));
|
||||||
|
|
||||||
|
/**
|
||||||
|
Terrain controls
|
||||||
|
*/
|
||||||
|
handler.addControl(INPUT_CODE_PLACE_TERRAIN, new Control(ControlType.KEY,GLFW_KEY_T));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
framestep controls
|
framestep controls
|
||||||
*/
|
*/
|
||||||
@ -922,6 +931,62 @@ public class ControlHandler {
|
|||||||
}});
|
}});
|
||||||
controls.get(INPUT_CODE_CHARACTER_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
controls.get(INPUT_CODE_CHARACTER_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|
||||||
|
mainGameControlList.add(controls.get(INPUT_CODE_PLACE_TERRAIN));
|
||||||
|
controls.get(INPUT_CODE_PLACE_TERRAIN).setOnPress(new ControlMethod(){public void execute(){
|
||||||
|
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
|
||||||
|
Entity camera = Globals.playerCamera;
|
||||||
|
if(
|
||||||
|
collisionEngine != null &&
|
||||||
|
camera != null
|
||||||
|
){
|
||||||
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||||
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||||
|
Vector3d cursorPos = collisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), 5.0);
|
||||||
|
int[] xOffsetSet = new int[]{
|
||||||
|
0,1,0,1,0,1,0,1,
|
||||||
|
};
|
||||||
|
int[] yOffsetSet = new int[]{
|
||||||
|
0,0,0,0,1,1,1,1,
|
||||||
|
};
|
||||||
|
int[] zOffsetSet = new int[]{
|
||||||
|
0,0,1,1,0,0,1,1,
|
||||||
|
};
|
||||||
|
if(cursorPos != null){
|
||||||
|
Vector3i chunkPos = Globals.clientWorldData.convertRealToChunkSpace(cursorPos);
|
||||||
|
Vector3i voxelPos = Globals.clientWorldData.convertRealToVoxelSpace(cursorPos);
|
||||||
|
for(int i = 0; i < 8; i++){
|
||||||
|
Vector3i actualPos = new Vector3i(
|
||||||
|
voxelPos.x + xOffsetSet[i],
|
||||||
|
voxelPos.y + yOffsetSet[i],
|
||||||
|
voxelPos.z + zOffsetSet[i]
|
||||||
|
);
|
||||||
|
if(
|
||||||
|
actualPos.x < ChunkData.CHUNK_SIZE &&
|
||||||
|
actualPos.y < ChunkData.CHUNK_SIZE &&
|
||||||
|
actualPos.z < ChunkData.CHUNK_SIZE
|
||||||
|
){
|
||||||
|
Globals.clientTerrainManager.updateChunk(
|
||||||
|
chunkPos.x, chunkPos.y, chunkPos.z,
|
||||||
|
actualPos.x, actualPos.y, actualPos.z,
|
||||||
|
1.0f, 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Globals.clientTerrainManager.getChunkDataAtWorldPoint(chunkPos.x, chunkPos.y, chunkPos.z)
|
||||||
|
// .updatePosition(voxelPos.x, voxelPos.y, voxelPos.z, 1.0f, 1);
|
||||||
|
// Globals.clientTerrainManager.updateChunk(
|
||||||
|
// chunkPos.x, chunkPos.y, chunkPos.z,
|
||||||
|
// voxelPos.x, voxelPos.y, voxelPos.z,
|
||||||
|
// 1.0f, 1
|
||||||
|
// );
|
||||||
|
// System.out.println("Terrain");
|
||||||
|
// System.out.println(Globals.clientWorldData.convertRealToChunkSpace(cursorPos));
|
||||||
|
// System.out.println(Globals.clientWorldData.convertRealToVoxelSpace(cursorPos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}});
|
||||||
|
controls.get(INPUT_CODE_PLACE_TERRAIN).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInGameDebugControls(){
|
void setInGameDebugControls(){
|
||||||
|
|||||||
@ -3,13 +3,21 @@ package electrosphere.engine.loadingthreads;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.joml.Quaterniond;
|
import org.joml.Quaterniond;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import electrosphere.client.culling.ClientEntityCullingManager;
|
||||||
|
import electrosphere.client.foliagemanager.ClientFoliageManager;
|
||||||
|
import electrosphere.client.sim.ClientSimulation;
|
||||||
|
import electrosphere.client.targeting.crosshair.Crosshair;
|
||||||
|
import electrosphere.client.terrain.cells.DrawCellManager;
|
||||||
|
import electrosphere.collision.CollisionEngine;
|
||||||
|
import electrosphere.controls.ControlHandler;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityCreationUtils;
|
import electrosphere.entity.EntityCreationUtils;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.movement.ApplyRotationTree;
|
import electrosphere.entity.state.movement.ApplyRotationTree;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
@ -20,12 +28,6 @@ import electrosphere.menu.WindowUtils;
|
|||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
import electrosphere.net.client.ClientNetworking;
|
import electrosphere.net.client.ClientNetworking;
|
||||||
import electrosphere.renderer.ui.Window;
|
import electrosphere.renderer.ui.Window;
|
||||||
import electrosphere.client.culling.ClientEntityCullingManager;
|
|
||||||
import electrosphere.client.foliagemanager.ClientFoliageManager;
|
|
||||||
import electrosphere.client.sim.ClientSimulation;
|
|
||||||
import electrosphere.client.targeting.crosshair.Crosshair;
|
|
||||||
import electrosphere.client.terrain.cells.DrawCellManager;
|
|
||||||
import electrosphere.controls.ControlHandler;
|
|
||||||
|
|
||||||
public class ClientLoading {
|
public class ClientLoading {
|
||||||
|
|
||||||
@ -206,6 +208,28 @@ public class ClientLoading {
|
|||||||
Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001)));
|
Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001)));
|
||||||
Globals.assetManager.queueOverrideMeshShader("Models/cloudRing.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs");
|
Globals.assetManager.queueOverrideMeshShader("Models/cloudRing.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs");
|
||||||
|
|
||||||
|
Entity cursorTracker = EntityCreationUtils.createClientSpatialEntity();
|
||||||
|
EntityCreationUtils.makeEntityDrawable(cursorTracker, "Models/unitsphere_1.fbx");
|
||||||
|
EntityUtils.getScale(cursorTracker).set(0.3f);
|
||||||
|
Globals.clientSceneWrapper.getScene().registerBehaviorTree(new BehaviorTree() {
|
||||||
|
@Override
|
||||||
|
public void simulate(float deltaTime) {
|
||||||
|
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
|
||||||
|
Entity camera = Globals.playerCamera;
|
||||||
|
if(
|
||||||
|
collisionEngine != null &&
|
||||||
|
camera != null
|
||||||
|
){
|
||||||
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||||
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||||
|
Vector3d cursorPos = collisionEngine.rayCastPosition(centerPos, new Vector3d(eyePos).mul(-1.0), 5.0);
|
||||||
|
if(cursorPos != null){
|
||||||
|
EntityUtils.getPosition(cursorTracker).set(cursorPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initDrawCellManager(){
|
static void initDrawCellManager(){
|
||||||
|
|||||||
@ -111,6 +111,7 @@ public class EntityDataStrings {
|
|||||||
public static final String PHYSICS_MODEL_TEMPLATE = "physicsModelTemplate";
|
public static final String PHYSICS_MODEL_TEMPLATE = "physicsModelTemplate";
|
||||||
public static final String PHYSICS_MASS = "physicsMass";
|
public static final String PHYSICS_MASS = "physicsMass";
|
||||||
public static final String PHYSICS_INVERSE_INERTIA_TENSOR = "physicsInverseInertiaTensor";
|
public static final String PHYSICS_INVERSE_INERTIA_TENSOR = "physicsInverseInertiaTensor";
|
||||||
|
public static final String PHYSICS_ENGINE_AUTHORITATIVE_TRANSFORM = "physicsEngineAuthoritativeTransform"; // The physics engine is authoritative abound transforms of object (eg position, rotation)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gravity Entity
|
Gravity Entity
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
package electrosphere.entity.state.collidable;
|
package electrosphere.entity.state.collidable;
|
||||||
|
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Quaterniond;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector4d;
|
||||||
|
import org.ode4j.ode.DBody;
|
||||||
|
|
||||||
import electrosphere.collision.PhysicsUtils;
|
import electrosphere.collision.PhysicsUtils;
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
@ -9,20 +15,9 @@ import electrosphere.entity.EntityUtils;
|
|||||||
import electrosphere.entity.state.BehaviorTree;
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.gravity.ClientGravityTree;
|
import electrosphere.entity.state.gravity.ClientGravityTree;
|
||||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
|
||||||
import electrosphere.entity.types.debug.DebugVisualizerUtils;
|
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
import electrosphere.game.data.creature.type.CollidableTemplate;
|
import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Quaterniond;
|
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.joml.Vector4d;
|
|
||||||
import org.joml.Vector4f;
|
|
||||||
import org.ode4j.ode.DBody;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
package electrosphere.entity.types.collision;
|
package electrosphere.entity.types.collision;
|
||||||
|
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Quaterniond;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
import org.ode4j.ode.DBody;
|
||||||
|
|
||||||
import electrosphere.collision.CollisionEngine;
|
import electrosphere.collision.CollisionEngine;
|
||||||
import electrosphere.collision.PhysicsUtils;
|
import electrosphere.collision.PhysicsUtils;
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
@ -10,16 +16,6 @@ import electrosphere.entity.EntityDataStrings;
|
|||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.types.attach.AttachUtils;
|
import electrosphere.entity.types.attach.AttachUtils;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Quaterniond;
|
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.ode4j.ode.DBody;
|
|
||||||
import org.ode4j.ode.DSpace;
|
|
||||||
import org.ode4j.ode.DWorld;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -32,7 +28,7 @@ public class CollisionObjUtils {
|
|||||||
|
|
||||||
float mass = 1.0f;
|
float mass = 1.0f;
|
||||||
|
|
||||||
DBody planeObject = PhysicsUtils.createPlaneGeom(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale));
|
DBody planeObject = PhysicsUtils.createPlaneBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale));
|
||||||
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, planeObject);
|
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, planeObject);
|
||||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(planeObject, collidable);
|
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(planeObject, collidable);
|
||||||
@ -59,7 +55,7 @@ public class CollisionObjUtils {
|
|||||||
|
|
||||||
float mass = 1.0f;
|
float mass = 1.0f;
|
||||||
|
|
||||||
DBody planeObject = PhysicsUtils.createPlaneGeom(realm.getCollisionEngine(),new Vector3d(scale));
|
DBody planeObject = PhysicsUtils.createPlaneBody(realm.getCollisionEngine(),new Vector3d(scale));
|
||||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, planeObject);
|
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, planeObject);
|
||||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||||
realm.getCollisionEngine().registerCollisionObject(planeObject, collidable);
|
realm.getCollisionEngine().registerCollisionObject(planeObject, collidable);
|
||||||
@ -87,7 +83,7 @@ public class CollisionObjUtils {
|
|||||||
|
|
||||||
float mass = 1.0f;
|
float mass = 1.0f;
|
||||||
|
|
||||||
DBody cubeObject = PhysicsUtils.createCubeGeom(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale));
|
DBody cubeObject = PhysicsUtils.createCubeBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale));
|
||||||
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
|
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
|
||||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||||
@ -114,7 +110,7 @@ public class CollisionObjUtils {
|
|||||||
|
|
||||||
float mass = 1.0f;
|
float mass = 1.0f;
|
||||||
|
|
||||||
DBody cubeObject = PhysicsUtils.createCubeGeom(realm.getCollisionEngine(),new Vector3d(scale));
|
DBody cubeObject = PhysicsUtils.createCubeBody(realm.getCollisionEngine(),new Vector3d(scale));
|
||||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
|
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
|
||||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||||
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||||
@ -140,7 +136,7 @@ public class CollisionObjUtils {
|
|||||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||||
|
|
||||||
float mass = 1.0f;
|
float mass = 1.0f;
|
||||||
DBody cubeObject = PhysicsUtils.createCylinderGeom(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale));
|
DBody cubeObject = PhysicsUtils.createCylinderBody(Globals.clientSceneWrapper.getCollisionEngine(),scale.x,scale.y);
|
||||||
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
|
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
|
||||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||||
@ -169,7 +165,7 @@ public class CollisionObjUtils {
|
|||||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, new Vector3d(position));
|
Entity rVal = EntityCreationUtils.createServerEntity(realm, new Vector3d(position));
|
||||||
|
|
||||||
float mass = 1.0f;
|
float mass = 1.0f;
|
||||||
DBody cubeObject = PhysicsUtils.createCylinderGeom(realm.getCollisionEngine(),new Vector3d(scale));
|
DBody cubeObject = PhysicsUtils.createCylinderBody(realm.getCollisionEngine(),scale.x,scale.y);
|
||||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
|
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
|
||||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||||
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||||
|
|||||||
@ -1,26 +1,21 @@
|
|||||||
package electrosphere.entity.types.creature;
|
package electrosphere.entity.types.creature;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
import org.ode4j.ode.DBody;
|
||||||
|
|
||||||
import electrosphere.collision.PhysicsUtils;
|
import electrosphere.collision.PhysicsUtils;
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.Main;
|
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityCreationUtils;
|
import electrosphere.entity.EntityCreationUtils;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
import electrosphere.entity.EntityTags;
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.Scene;
|
|
||||||
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
|
||||||
import electrosphere.entity.state.movement.FallTree;
|
|
||||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
|
||||||
import electrosphere.entity.state.movement.ServerGroundMovementTree;
|
|
||||||
import electrosphere.entity.state.movement.JumpTree;
|
|
||||||
import electrosphere.entity.state.movement.ServerFallTree;
|
|
||||||
import electrosphere.entity.state.movement.ServerJumpTree;
|
|
||||||
import electrosphere.entity.state.movement.ServerSprintTree;
|
|
||||||
import electrosphere.entity.types.hitbox.HitboxData;
|
|
||||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
|
||||||
import electrosphere.game.data.creature.type.CreatureType;
|
|
||||||
import electrosphere.entity.state.BehaviorTree;
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.attack.AttackTree;
|
import electrosphere.entity.state.attack.AttackTree;
|
||||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||||
@ -36,16 +31,26 @@ import electrosphere.entity.state.inventory.InventoryUtils;
|
|||||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||||
import electrosphere.entity.state.inventory.ServerInventoryState;
|
import electrosphere.entity.state.inventory.ServerInventoryState;
|
||||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
|
||||||
import electrosphere.entity.state.life.LifeState;
|
import electrosphere.entity.state.life.LifeState;
|
||||||
|
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
||||||
|
import electrosphere.entity.state.movement.FallTree;
|
||||||
|
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||||
|
import electrosphere.entity.state.movement.JumpTree;
|
||||||
|
import electrosphere.entity.state.movement.ServerFallTree;
|
||||||
|
import electrosphere.entity.state.movement.ServerGroundMovementTree;
|
||||||
|
import electrosphere.entity.state.movement.ServerJumpTree;
|
||||||
|
import electrosphere.entity.state.movement.ServerSprintTree;
|
||||||
import electrosphere.entity.state.movement.SprintTree;
|
import electrosphere.entity.state.movement.SprintTree;
|
||||||
import electrosphere.entity.state.rotator.RotatorHierarchyNode;
|
import electrosphere.entity.state.rotator.RotatorHierarchyNode;
|
||||||
import electrosphere.entity.state.rotator.RotatorTree;
|
import electrosphere.entity.state.rotator.RotatorTree;
|
||||||
import electrosphere.entity.state.rotator.ServerRotatorTree;
|
import electrosphere.entity.state.rotator.ServerRotatorTree;
|
||||||
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||||
|
import electrosphere.entity.types.hitbox.HitboxData;
|
||||||
|
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||||
import electrosphere.game.data.creature.type.CollidableTemplate;
|
import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||||
|
import electrosphere.game.data.creature.type.CreatureType;
|
||||||
import electrosphere.game.data.creature.type.SprintSystem;
|
import electrosphere.game.data.creature.type.SprintSystem;
|
||||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
|
||||||
import electrosphere.game.data.creature.type.movement.AirplaneMovementSystem;
|
import electrosphere.game.data.creature.type.movement.AirplaneMovementSystem;
|
||||||
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
|
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
|
||||||
import electrosphere.game.data.creature.type.movement.GroundMovementSystem;
|
import electrosphere.game.data.creature.type.movement.GroundMovementSystem;
|
||||||
@ -61,34 +66,17 @@ import electrosphere.net.NetUtils;
|
|||||||
import electrosphere.net.parser.net.message.EntityMessage;
|
import electrosphere.net.parser.net.message.EntityMessage;
|
||||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||||
import electrosphere.net.server.player.Player;
|
import electrosphere.net.server.player.Player;
|
||||||
import electrosphere.renderer.Model;
|
|
||||||
import electrosphere.renderer.actor.Actor;
|
import electrosphere.renderer.actor.Actor;
|
||||||
import electrosphere.renderer.actor.ActorBoneRotator;
|
import electrosphere.renderer.actor.ActorBoneRotator;
|
||||||
import electrosphere.renderer.actor.ActorStaticMorph;
|
import electrosphere.renderer.actor.ActorStaticMorph;
|
||||||
import electrosphere.renderer.actor.ActorUtils;
|
import electrosphere.renderer.actor.ActorUtils;
|
||||||
import electrosphere.renderer.light.PointLight;
|
|
||||||
import electrosphere.renderer.loading.ModelLoader;
|
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.datacell.ServerDataCell;
|
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
|
||||||
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
|
||||||
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.server.poseactor.PoseActorUtils;
|
import electrosphere.server.poseactor.PoseActorUtils;
|
||||||
import electrosphere.util.Utilities;
|
import electrosphere.util.Utilities;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.ode4j.ode.DBody;
|
|
||||||
import org.ode4j.ode.DSpace;
|
|
||||||
import org.ode4j.ode.DWorld;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
@ -175,9 +163,10 @@ public class CreatureUtils {
|
|||||||
Vector3f scale;
|
Vector3f scale;
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER": {
|
case "CYLINDER": {
|
||||||
rigidBody = PhysicsUtils.createCylinderGeom(
|
rigidBody = PhysicsUtils.createCylinderBody(
|
||||||
Globals.clientSceneWrapper.getCollisionEngine(),
|
Globals.clientSceneWrapper.getCollisionEngine(),
|
||||||
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
physicsTemplate.getDimension1(),
|
||||||
|
physicsTemplate.getDimension2()
|
||||||
);
|
);
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
||||||
ClientCollidableTree tree = new ClientCollidableTree(rVal,collidable,rigidBody);
|
ClientCollidableTree tree = new ClientCollidableTree(rVal,collidable,rigidBody);
|
||||||
@ -203,7 +192,7 @@ public class CreatureUtils {
|
|||||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
Globals.clientScene.registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
||||||
} break;
|
} break;
|
||||||
case "CUBE": {
|
case "CUBE": {
|
||||||
rigidBody = PhysicsUtils.createCubeGeom(
|
rigidBody = PhysicsUtils.createCubeBody(
|
||||||
Globals.clientSceneWrapper.getCollisionEngine(),
|
Globals.clientSceneWrapper.getCollisionEngine(),
|
||||||
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
||||||
);
|
);
|
||||||
@ -532,7 +521,11 @@ public class CreatureUtils {
|
|||||||
Vector3f scale;
|
Vector3f scale;
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER": {
|
case "CYLINDER": {
|
||||||
rigidBody = PhysicsUtils.createCylinderGeom(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.createCylinderBody(
|
||||||
|
realm.getCollisionEngine(),
|
||||||
|
physicsTemplate.getDimension1(),
|
||||||
|
physicsTemplate.getDimension2()
|
||||||
|
);
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
||||||
ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody);
|
ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
@ -557,7 +550,7 @@ public class CreatureUtils {
|
|||||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.COLLIDABLE);
|
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.COLLIDABLE);
|
||||||
} break;
|
} break;
|
||||||
case "CUBE": {
|
case "CUBE": {
|
||||||
rigidBody = PhysicsUtils.createCubeGeom(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.createCubeBody(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
||||||
ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody);
|
ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
|
|||||||
@ -1,5 +1,15 @@
|
|||||||
package electrosphere.entity.types.item;
|
package electrosphere.entity.types.item;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
import org.ode4j.ode.DBody;
|
||||||
|
import org.ode4j.ode.DSpace;
|
||||||
|
import org.ode4j.ode.DWorld;
|
||||||
|
|
||||||
import electrosphere.collision.PhysicsUtils;
|
import electrosphere.collision.PhysicsUtils;
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
@ -12,37 +22,21 @@ import electrosphere.entity.state.collidable.ClientCollidableTree;
|
|||||||
import electrosphere.entity.state.collidable.ServerCollidableTree;
|
import electrosphere.entity.state.collidable.ServerCollidableTree;
|
||||||
import electrosphere.entity.state.gravity.ClientGravityTree;
|
import electrosphere.entity.state.gravity.ClientGravityTree;
|
||||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
|
||||||
import electrosphere.entity.types.attach.AttachUtils;
|
|
||||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
|
||||||
import electrosphere.entity.types.hitbox.HitboxData;
|
import electrosphere.entity.types.hitbox.HitboxData;
|
||||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||||
import electrosphere.game.data.creature.type.CollidableTemplate;
|
import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||||
import electrosphere.game.data.creature.type.CreatureType;
|
|
||||||
import electrosphere.game.data.item.type.EquipWhitelist;
|
import electrosphere.game.data.item.type.EquipWhitelist;
|
||||||
import electrosphere.game.data.item.type.Item;
|
import electrosphere.game.data.item.type.Item;
|
||||||
import electrosphere.game.data.item.type.WeaponData;
|
import electrosphere.game.data.item.type.WeaponData;
|
||||||
import electrosphere.net.parser.net.message.EntityMessage;
|
import electrosphere.net.parser.net.message.EntityMessage;
|
||||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||||
import electrosphere.net.server.player.Player;
|
import electrosphere.net.server.player.Player;
|
||||||
import electrosphere.renderer.Model;
|
|
||||||
import electrosphere.renderer.actor.Actor;
|
import electrosphere.renderer.actor.Actor;
|
||||||
import electrosphere.renderer.actor.ActorUtils;
|
import electrosphere.renderer.actor.ActorUtils;
|
||||||
import electrosphere.server.datacell.Realm;
|
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 java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.ode4j.ode.DBody;
|
|
||||||
import org.ode4j.ode.DSpace;
|
|
||||||
import org.ode4j.ode.DWorld;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
@ -81,9 +75,10 @@ public class ItemUtils {
|
|||||||
DSpace dSpace = Globals.clientSceneWrapper.getCollisionEngine().getSpace();
|
DSpace dSpace = Globals.clientSceneWrapper.getCollisionEngine().getSpace();
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER":
|
case "CYLINDER":
|
||||||
rigidBody = PhysicsUtils.createCylinderGeom(
|
rigidBody = PhysicsUtils.createCylinderBody(
|
||||||
Globals.clientSceneWrapper.getCollisionEngine(),
|
Globals.clientSceneWrapper.getCollisionEngine(),
|
||||||
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
physicsTemplate.getDimension1(),
|
||||||
|
physicsTemplate.getDimension2()
|
||||||
);
|
);
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_ITEM);
|
collidable = new Collidable(rVal, Collidable.TYPE_ITEM);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
@ -108,7 +103,7 @@ public class ItemUtils {
|
|||||||
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
||||||
break;
|
break;
|
||||||
case "CUBE":
|
case "CUBE":
|
||||||
rigidBody = PhysicsUtils.createCubeGeom(
|
rigidBody = PhysicsUtils.createCubeBody(
|
||||||
Globals.clientSceneWrapper.getCollisionEngine(),
|
Globals.clientSceneWrapper.getCollisionEngine(),
|
||||||
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
||||||
);
|
);
|
||||||
@ -209,7 +204,11 @@ public class ItemUtils {
|
|||||||
Vector3f scale;
|
Vector3f scale;
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER":
|
case "CYLINDER":
|
||||||
rigidBody = PhysicsUtils.createCylinderGeom(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.createCylinderBody(
|
||||||
|
realm.getCollisionEngine(),
|
||||||
|
physicsTemplate.getDimension1(),
|
||||||
|
physicsTemplate.getDimension2()
|
||||||
|
);
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_ITEM);
|
collidable = new Collidable(rVal, Collidable.TYPE_ITEM);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
@ -233,7 +232,7 @@ public class ItemUtils {
|
|||||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.COLLIDABLE);
|
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.COLLIDABLE);
|
||||||
break;
|
break;
|
||||||
case "CUBE":
|
case "CUBE":
|
||||||
rigidBody = PhysicsUtils.createCubeGeom(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.createCubeBody(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_ITEM);
|
collidable = new Collidable(rVal, Collidable.TYPE_ITEM);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
|
|||||||
@ -4,8 +4,6 @@ import org.joml.Matrix4f;
|
|||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import org.ode4j.ode.DBody;
|
import org.ode4j.ode.DBody;
|
||||||
import org.ode4j.ode.DSpace;
|
|
||||||
import org.ode4j.ode.DWorld;
|
|
||||||
|
|
||||||
import electrosphere.collision.PhysicsUtils;
|
import electrosphere.collision.PhysicsUtils;
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
@ -26,7 +24,6 @@ import electrosphere.entity.state.inventory.InventoryState;
|
|||||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||||
import electrosphere.entity.state.inventory.ServerInventoryState;
|
import electrosphere.entity.state.inventory.ServerInventoryState;
|
||||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||||
import electrosphere.entity.state.life.LifeState;
|
|
||||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||||
import electrosphere.game.data.creature.type.CollidableTemplate;
|
import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||||
import electrosphere.game.data.object.type.ObjectData;
|
import electrosphere.game.data.object.type.ObjectData;
|
||||||
@ -85,9 +82,10 @@ public class ObjectUtils {
|
|||||||
Vector3f scale;
|
Vector3f scale;
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER": {
|
case "CYLINDER": {
|
||||||
rigidBody = PhysicsUtils.createCylinderGeom(
|
rigidBody = PhysicsUtils.createCylinderBody(
|
||||||
Globals.clientSceneWrapper.getCollisionEngine(),
|
Globals.clientSceneWrapper.getCollisionEngine(),
|
||||||
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
physicsTemplate.getDimension1(),
|
||||||
|
physicsTemplate.getDimension2()
|
||||||
);
|
);
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
@ -112,7 +110,7 @@ public class ObjectUtils {
|
|||||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(rigidBody, collidable);
|
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(rigidBody, collidable);
|
||||||
} break;
|
} break;
|
||||||
case "CUBE": {
|
case "CUBE": {
|
||||||
rigidBody = PhysicsUtils.createCubeGeom(
|
rigidBody = PhysicsUtils.createCubeBody(
|
||||||
Globals.clientSceneWrapper.getCollisionEngine(),
|
Globals.clientSceneWrapper.getCollisionEngine(),
|
||||||
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
||||||
);
|
);
|
||||||
@ -238,7 +236,11 @@ public class ObjectUtils {
|
|||||||
Vector3f scale;
|
Vector3f scale;
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER": {
|
case "CYLINDER": {
|
||||||
rigidBody = PhysicsUtils.createCylinderGeom(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.createCylinderBody(
|
||||||
|
realm.getCollisionEngine(),
|
||||||
|
physicsTemplate.getDimension1(),
|
||||||
|
physicsTemplate.getDimension2()
|
||||||
|
);
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
@ -262,7 +264,10 @@ public class ObjectUtils {
|
|||||||
realm.getCollisionEngine().registerCollisionObject(rigidBody, collidable);
|
realm.getCollisionEngine().registerCollisionObject(rigidBody, collidable);
|
||||||
} break;
|
} break;
|
||||||
case "CUBE": {
|
case "CUBE": {
|
||||||
rigidBody = PhysicsUtils.createCubeGeom(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.createCubeBody(
|
||||||
|
realm.getCollisionEngine(),
|
||||||
|
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3())
|
||||||
|
);
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
|||||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
|
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
|
||||||
import static org.lwjgl.opengl.GL11.GL_LESS;
|
import static org.lwjgl.opengl.GL11.GL_LESS;
|
||||||
import static org.lwjgl.opengl.GL11.GL_LEQUAL;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE;
|
import static org.lwjgl.opengl.GL11.GL_ONE;
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_COLOR;
|
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_COLOR;
|
||||||
@ -75,8 +74,6 @@ import org.lwjgl.opengl.GL15;
|
|||||||
import org.lwjgl.opengl.GL20;
|
import org.lwjgl.opengl.GL20;
|
||||||
import org.lwjgl.opengl.GL30;
|
import org.lwjgl.opengl.GL30;
|
||||||
|
|
||||||
import electrosphere.controls.ControlCallback;
|
|
||||||
import electrosphere.controls.MouseCallback;
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
@ -195,7 +192,7 @@ public class RenderingEngine {
|
|||||||
glfwInit();
|
glfwInit();
|
||||||
//Gives hints to glfw to control how opengl will be used
|
//Gives hints to glfw to control how opengl will be used
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
// glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent
|
// glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent
|
||||||
// glfwWindowHint(GLFW_OPACITY, 23);
|
// glfwWindowHint(GLFW_OPACITY, 23);
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.renderer.Mesh;
|
import electrosphere.renderer.Mesh;
|
||||||
@ -71,7 +72,7 @@ public class ActorMeshMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Mesh> getToDrawMeshes(){
|
public List<Mesh> getToDrawMeshes(){
|
||||||
return toDrawMesh.values().stream().toList();
|
return toDrawMesh.values().stream().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ejectMeshToDraw(String name){
|
public void ejectMeshToDraw(String name){
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import java.nio.DoubleBuffer;
|
|||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL33;
|
||||||
import org.lwjgl.opengl.GL45;
|
import org.lwjgl.opengl.GL45;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
@ -210,10 +211,10 @@ public class HomogenousInstancedArray {
|
|||||||
} break;
|
} break;
|
||||||
case MAT4F: {
|
case MAT4F: {
|
||||||
FloatBuffer buffer = (FloatBuffer)object;
|
FloatBuffer buffer = (FloatBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer, startIndex, buffer);
|
// GL45.glNamedBufferSubData(bufferPointer, startIndex, buffer);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
//unbind the buffer
|
//unbind the buffer
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, 0);
|
GL33.glBindBuffer(GL45.GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public class TestRunner {
|
|||||||
|
|
||||||
//run tests
|
//run tests
|
||||||
for(Class classObject : classes){
|
for(Class classObject : classes){
|
||||||
System.out.println("CLASS " + classObject.descriptorString());
|
System.out.println("CLASS " + classObject.getCanonicalName());
|
||||||
Result result = JUnitCore.runClasses(classObject);
|
Result result = JUnitCore.runClasses(classObject);
|
||||||
for(Failure failure : result.getFailures()){
|
for(Failure failure : result.getFailures()){
|
||||||
failures.add(failure);
|
failures.add(failure);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user