particle work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-08-18 10:36:46 -04:00
parent 0eb002df82
commit b2f7a3a232
6 changed files with 142 additions and 39 deletions

View File

@ -0,0 +1,3 @@
@page conspiracy Conspiracy
The main points to work on with conspiracies is coming up with ideas for conspiracies, and coming up with ways to redirect in the middle points of conspiracies. We don't want to immediately reveal the whole conspiracy off the bat.

View File

@ -1,3 +1,5 @@
@page narrativearcdesign Narrative Arc Design @page narrativearcdesign Narrative Arc Design
Use the idea of conspiracy to create mystery eventually leading to a big series of confrontations and narrative payoff Use the idea of conspiracy to create mystery eventually leading to a big series of confrontations and narrative payoff
The primary challenge with this is coming up with ways to redirect the eventual conspiracy
IE, you don't want to introduce the ultimate bad guy at the start, there need to be middle men that you work towards defeating prior to capturing the big bad

View File

@ -235,7 +235,7 @@ public class EntityDataStrings {
particle behavior tree particle behavior tree
*/ */
public static final String IS_PARTICLE = "isParticle"; public static final String IS_PARTICLE = "isParticle";
public static final String PARTICLE_TREE = "particleTree"; public static final String TREE_CLIENTPARTICLETREE = "treeClientParticleTree";
/* /*

View File

@ -0,0 +1,98 @@
package electrosphere.entity.state.particle;
import org.joml.Vector3d;
import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
/**
* Particle component for a client-side particle
*/
public class ClientParticleTree implements BehaviorTree {
//The parent entity
Entity parent;
//used to toggle life simulation
boolean hasLife = true;
//max life
int maxLife;
//current life
int lifeCurrent;
//The destination of the particle
Vector3f destination;
//the velocity of the particle
float velocity;
//the acceleration of the particle
float acceleration;
private ClientParticleTree(Entity parent, Object ... params){
//int maxLife, Vector3f destination, float velocity, float acceleration, boolean hasLife
this.parent = parent;
this.maxLife = maxLife;
this.destination = destination;
this.velocity = velocity;
this.acceleration = acceleration;
this.hasLife = hasLife;
lifeCurrent = maxLife;
}
public int getMaxLife() {
return maxLife;
}
public int getLifeCurrent() {
return lifeCurrent;
}
public Vector3f getDestination() {
return destination;
}
public float getVelocity() {
return velocity;
}
public float getAcceleration() {
return acceleration;
}
@Override
public void simulate(float deltaTime){
Vector3d parentPosition = EntityUtils.getPosition(parent);
parentPosition.add(new Vector3f(destination).mul(velocity));
velocity = velocity - acceleration;
if(velocity < 0){
velocity = 0;
acceleration = 0;
}
if(hasLife){
lifeCurrent--;
if(lifeCurrent <= 0){
EntityUtils.cleanUpEntity(parent);
}
}
}
/**
* Attaches the client particle tree to the given entity
* @param parent The parent entity
* @param params The params
*/
public static ClientParticleTree attachTree(Entity parent, Object ... params){
ClientParticleTree rVal = new ClientParticleTree(parent,params);
parent.putData(EntityDataStrings.TREE_CLIENTPARTICLETREE, rVal);
Globals.clientSceneWrapper.getScene().registerBehaviorTree(rVal);
return rVal;
}
}

View File

@ -22,23 +22,23 @@ public class ParticleUtils {
public static Entity clientSpawnBillboardProjectileParticle(String texture, int maxLife, Vector3f destination, float velocity, float acceleration){ // public static Entity clientSpawnBillboardProjectileParticle(String texture, int maxLife, Vector3f destination, float velocity, float acceleration){
Entity rVal = EntityCreationUtils.createClientSpatialEntity(); // Entity rVal = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(rVal, Globals.particleBillboardModel); // EntityCreationUtils.makeEntityDrawable(rVal, Globals.particleBillboardModel);
EntityUtils.getActor(rVal).setTextureOverride(texture); // EntityUtils.getActor(rVal).setTextureOverride(texture);
Globals.assetManager.addTexturePathtoQueue(texture); // Globals.assetManager.addTexturePathtoQueue(texture);
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.TREE_CLIENTPARTICLETREE, particleTree);
rVal.putData(EntityDataStrings.IS_PARTICLE, true); // rVal.putData(EntityDataStrings.IS_PARTICLE, true);
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.PARTICLE); // Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.PARTICLE);
return rVal; // return rVal;
} // }
public static Entity clientSpawnStaticBillboardParticle(){ public static Entity clientSpawnStaticBillboardParticle(){
Entity rVal = EntityCreationUtils.createClientSpatialEntity(); Entity rVal = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(rVal, Globals.particleBillboardModel); EntityCreationUtils.makeEntityDrawable(rVal, Globals.particleBillboardModel);
ParticleTree particleTree = new ParticleTree(rVal, 10, new Vector3f(0,0,0), 0, 0, false); ParticleTree particleTree = new ParticleTree(rVal, 10, new Vector3f(0,0,0), 0, 0, false);
rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree); rVal.putData(EntityDataStrings.TREE_CLIENTPARTICLETREE, particleTree);
rVal.putData(EntityDataStrings.IS_PARTICLE, true); rVal.putData(EntityDataStrings.IS_PARTICLE, true);
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.PARTICLE); Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.PARTICLE);
return rVal; return rVal;
@ -56,6 +56,6 @@ public class ParticleUtils {
} }
public static ParticleTree getParticleTree(Entity particle){ public static ParticleTree getParticleTree(Entity particle){
return (ParticleTree)particle.getData(EntityDataStrings.PARTICLE_TREE); return (ParticleTree)particle.getData(EntityDataStrings.TREE_CLIENTPARTICLETREE);
} }
} }

View File

@ -12,29 +12,29 @@ import org.joml.Vector3f;
public class ParticleEffects { public class ParticleEffects {
public static void spawnSparks(Vector3f position, int min, int max){ // public static void spawnSparks(Vector3f position, int min, int max){
Random rand = new Random(); // Random rand = new Random();
int num = (int)(rand.nextFloat() * (max - min)) + min; // int num = (int)(rand.nextFloat() * (max - min)) + min;
for(int i = 0; i < num; i++){ // for(int i = 0; i < num; i++){
Vector3f direction = new Vector3f(rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f).normalize(); // Vector3f direction = new Vector3f(rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f).normalize();
float velocity = rand.nextFloat() * 0.01f; // float velocity = rand.nextFloat() * 0.01f;
float acceleration = 0.005f; // float acceleration = 0.005f;
Entity spark = ParticleUtils.clientSpawnBillboardProjectileParticle("Textures/spark1.png", 15, direction, velocity, acceleration); // Entity spark = ParticleUtils.clientSpawnBillboardProjectileParticle("Textures/spark1.png", 15, direction, velocity, acceleration);
EntityUtils.getPosition(spark).set(position); // EntityUtils.getPosition(spark).set(position);
EntityUtils.getScale(spark).mul(0.03f); // EntityUtils.getScale(spark).mul(0.03f);
} // }
} // }
public static void spawnBloodsplats(Vector3f position, int min, int max){ // public static void spawnBloodsplats(Vector3f position, int min, int max){
Random rand = new Random(); // Random rand = new Random();
int num = (int)(rand.nextFloat() * (max - min)) + min; // int num = (int)(rand.nextFloat() * (max - min)) + min;
for(int i = 0; i < num; i++){ // for(int i = 0; i < num; i++){
Vector3f direction = new Vector3f(rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f).normalize(); // Vector3f direction = new Vector3f(rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f).normalize();
float velocity = rand.nextFloat() * 0.001f; // float velocity = rand.nextFloat() * 0.001f;
float acceleration = 0.000005f; // float acceleration = 0.000005f;
Entity spark = ParticleUtils.clientSpawnBillboardProjectileParticle("Textures/bloodsplat1.png", 90, direction, velocity, acceleration); // Entity spark = ParticleUtils.clientSpawnBillboardProjectileParticle("Textures/bloodsplat1.png", 90, direction, velocity, acceleration);
EntityUtils.getPosition(spark).set(position); // EntityUtils.getPosition(spark).set(position);
EntityUtils.getScale(spark).mul(0.1f); // EntityUtils.getScale(spark).mul(0.1f);
} // }
} // }
} }