Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
78 lines
1.9 KiB
Java
78 lines
1.9 KiB
Java
package electrosphere.client.entity.particle;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
import electrosphere.engine.signal.Signal;
|
|
import electrosphere.engine.signal.SignalServiceImpl;
|
|
import electrosphere.renderer.actor.instance.StridedInstanceData;
|
|
import electrosphere.renderer.buffer.HomogenousUniformBuffer.HomogenousBufferTypes;
|
|
|
|
/**
|
|
* The particle service
|
|
*/
|
|
public class ParticleService extends SignalServiceImpl {
|
|
|
|
/**
|
|
* The maximum number of particles
|
|
*/
|
|
static final int MAX_PARTICLES = 1000;
|
|
|
|
/**
|
|
* Path to the vertex shader
|
|
*/
|
|
static final String VERTEX_SHADER_PATH = "";
|
|
|
|
/**
|
|
* Path to the fragment shader
|
|
*/
|
|
static final String FRAGMENT_SHADER_PATH = "";
|
|
|
|
|
|
|
|
/**
|
|
* The instance data for the particles
|
|
*/
|
|
StridedInstanceData particleInstanceData;
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public ParticleService() {
|
|
super("ParticleService");
|
|
}
|
|
|
|
@Override
|
|
public void destroy() {
|
|
super.destroy();
|
|
if(particleInstanceData != null){
|
|
particleInstanceData.destroy();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean handle(Signal signal){
|
|
boolean rVal = false;
|
|
switch(signal.getType()){
|
|
case RENDERING_ENGINE_READY: {
|
|
List<HomogenousBufferTypes> types = Arrays.asList(new HomogenousBufferTypes[]{
|
|
//position
|
|
HomogenousBufferTypes.VEC3D,
|
|
//rotation
|
|
HomogenousBufferTypes.VEC4D,
|
|
//scale
|
|
HomogenousBufferTypes.VEC3D,
|
|
//texture index
|
|
HomogenousBufferTypes.INT,
|
|
});
|
|
this.particleInstanceData = new StridedInstanceData(MAX_PARTICLES,types,VERTEX_SHADER_PATH,FRAGMENT_SHADER_PATH);
|
|
rVal = true;
|
|
} break;
|
|
default: {
|
|
} break;
|
|
}
|
|
return rVal;
|
|
}
|
|
|
|
}
|