I use the whole model as a transmitter.
But I didn’t see any particle effects and I thought it was something I set up but when I looked closely I saw that the particles were there.
He’s very small in the middle of the model but you can see the particles surrounding the model and making A-POSE.
I wonder why this is.
Ideally, the particles should be all around the model, not in the middle
/**
*
* @author icyboxs
*/
public class ParticleEmitterEffects extends BaseAppState{
private AssetManager assetManager;
private SimpleApplication simpleApp;
private ParticleEmitter fire;
private Emitter emitter;
private Geometry collisionShape;
@Override
protected void initialize(Application app) {
assetManager=app.getAssetManager();
simpleApp=(SimpleApplication) app;
Node model = ((Node)((Node)((Node)simpleApp.getRootNode().getChild("character")).getChild("Scene")).getChild("Bip001"));
Geometry geometry=(Geometry)model.getChild("网格.004");
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");//Common/MatDefs/Light/Lighting.j3md Common/MatDefs/Misc/Particle.j3md
// Material mat1= new Material(assetManager, "Models/AYA/AYA.j3md");
mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
Texture tex = assetManager.loadTexture("Effects/Particles/part_light.png");//Models/Syana/Sn.j3o Effects/Particles/part_light.png
mat.setTexture("Texture", tex);
emitter = new Emitter("test", mat, 100,
new ColorInfluencer(),
new SizeInfluencer());
emitter.setStartSpeed(new ValueType(6.5f));
emitter.setLifeFixedDuration(2.0f);
// emitter.setEmissionsPerSecond(20);
// emitter.setParticlesPerEmission(1);
emitter.setShape(new EmitterMesh());
((EmitterMesh)emitter.getShape()).setShape(geometry.getMesh());
emitter.getInfluencer(ColorInfluencer.class).setColorOverTime(new ColorValueType(
new Gradient().addGradPoint(new ColorRGBA(0.8f, 0.6f, 0.0f, 0.6f), 0.0f)
.addGradPoint(new ColorRGBA(0.8f, 0.0f, 0.0f, 0.5f), 0.8f)
.addGradPoint(new ColorRGBA(0.2f, 0.2f, 0.2f, 0.0f), 1.0f)
));
emitter.getInfluencer(SizeInfluencer.class).setSizeOverTime(new ValueType(new Curve()
.addControlPoint(null, new Vector2f(0.0f, 1.0f), new Vector2f(0.3f, 1.0f))
.addControlPoint(new Vector2f(0.7f, 0.5f), new Vector2f(1.0f, 0.5f), null)
));
emitter.setStartSize(new ValueType(0.1f));
emitter.setStartSpeed(new ValueType(0.1f));
emitter.setLifeMinMax(new ValueType(1.0f), new ValueType(1.0f));
emitter.setEmissionsPerSecond(20);
emitter.setParticlesPerEmission(4);
Mesh box = new Box(1, 1, 1);
Geometry geom = new Geometry("Box");
geom.setMesh(box);
geom.setMaterial(mat);
//emitter.setParticleMeshType(ParticleDataTemplateMesh.class,geom.getMesh());
//emitter.setLocalTranslation(0, 0.5f, 0);
emitter.setDebug(assetManager, true, true);
model.attachChild(emitter);
// model.scale(2f);
//emitter.setParticlesFollowEmitter(false);
//simpleApp.getRootNode().attachChild(model);
}
@Override
protected void cleanup(Application app) {
}
@Override
protected void onEnable() {
}
@Override
protected void onDisable() {
}
@Override
public void update(float tpf) {
// emitter.setLocalTranslation(simpleApp.getRootNode().getChild("character").getWorldTranslation());
// System.err.println(simpleApp.getRootNode().getChild("character").getLocalTranslation());
// System.err.println(simpleApp.getRootNode().getChild("character").getWorldTranslation()+"(world)");
}
}
I use this code to set the particle effect
model file(I think it’s not my model problem).
(The above content will be translated using the translator, if you have any questions please point out thank you very much)