com.jme3.effect.ParticleMesh Java Examples
The following examples show how to use
com.jme3.effect.ParticleMesh.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestPostWater.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void createFire() { /** * Uses Texture from jme3-test-data library! */ ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); fire.setMaterial(mat_red); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f)); // red fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0)); fire.setStartSize(10f); fire.setEndSize(1f); fire.setGravity(0, 0, 0); fire.setLowLife(0.5f); fire.setHighLife(1.5f); fire.getParticleInfluencer().setVelocityVariation(0.3f); fire.setLocalTranslation(-600, 50, 300); fire.setQueueBucket(Bucket.Translucent); rootNode.attachChild(fire); }
Example #2
Source File: MyParticleEmitter.java From OpenRTS with MIT License | 6 votes |
/** * Sets the type of mesh used by the particle emitter. * @param meshType The mesh type to use */ @Override public void setMeshType(ParticleMesh.Type meshType) { this.meshType = meshType; switch (meshType) { case Point: particleMesh = new ParticlePointMesh(); this.setMesh(particleMesh); break; case Triangle: particleMesh = new ParticleTriMesh(); this.setMesh(particleMesh); break; default: throw new IllegalStateException("Unrecognized particle type: " + meshType); } this.setNumParticles2(particles.length); }
Example #3
Source File: MyParticleEmitter.java From OpenRTS with MIT License | 6 votes |
/** * Callback from Control.render(), do not use. * * @param rm * @param vp */ private void renderFromControl(RenderManager rm, ViewPort vp) { Camera cam = vp.getCamera(); if (meshType == ParticleMesh.Type.Point) { float C = cam.getProjectionMatrix().m00; C *= cam.getWidth() * 0.5f; // send attenuation params this.getMaterial().setFloat("Quadratic", C); } Matrix3f inverseRotation = Matrix3f.IDENTITY; TempVars vars = null; if (!worldSpace) { vars = TempVars.get(); inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal(); } particleMesh.updateParticleData(particles, cam, inverseRotation); if (!worldSpace) { vars.release(); } }
Example #4
Source File: TestPostWater.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void createFire() { /** Uses Texture from jme3-test-data library! */ ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); fire.setMaterial(mat_red); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f)); // red fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0)); fire.setStartSize(10f); fire.setEndSize(1f); fire.setGravity(0, 0, 0); fire.setLowLife(0.5f); fire.setHighLife(1.5f); fire.getParticleInfluencer().setVelocityVariation(0.3f); fire.setLocalTranslation(-350, 40, 430); fire.setQueueBucket(Bucket.Transparent); rootNode.attachChild(fire); }
Example #5
Source File: NewSpatialPopup.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void actionPerformed(ActionEvent e) { SceneApplication.getApplication().enqueue(new Callable<Void>() { public Void call() throws Exception { ParticleEmitter emit = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 200); emit.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f)); emit.setGravity(new Vector3f(0, 0, 0)); emit.setLowLife(5); emit.setHighLife(10); emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0)); emit.setImagesX(15); Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); emit.setMaterial(mat); node.attachChild(emit); addSpatialUndo(node, emit); setModified(); return null; } }); }
Example #6
Source File: MyParticleEmitter.java From OpenRTS with MIT License | 5 votes |
@Override public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.write(shape, "shape", DEFAULT_SHAPE); oc.write(meshType, "meshType", ParticleMesh.Type.Triangle); oc.write(enabled, "enabled", true); oc.write(particles.length, "numParticles", 0); oc.write(particlesPerSec, "particlesPerSec", 0); oc.write(lowLife, "lowLife", 0); oc.write(highLife, "highLife", 0); oc.write(gravity, "gravity", null); oc.write(imagesX, "imagesX", 1); oc.write(imagesY, "imagesY", 1); oc.write(startColor, "startColor", null); oc.write(endColor, "endColor", null); oc.write(startSize, "startSize", 0); oc.write(endSize, "endSize", 0); oc.write(worldSpace, "worldSpace", false); oc.write(facingVelocity, "facingVelocity", false); oc.write(faceNormal, "faceNormal", new Vector3f(Vector3f.NAN)); oc.write(selectRandomImage, "selectRandomImage", false); oc.write(randomAngle, "randomAngle", false); oc.write(rotateSpeed, "rotateSpeed", 0); oc.write(particleInfluencer, "influencer", DEFAULT_INFLUENCER); }
Example #7
Source File: CreateParticleEmitterAction.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@FxThread protected @NotNull ParticleEmitter createParticleEmitter() { return new ParticleEmitter("Default Emitter", ParticleMesh.Type.Triangle, 30); }
Example #8
Source File: HelloEffects.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat_red.setTexture("Texture", assetManager.loadTexture( "Effects/Explosion/flame.png")); fire.setMaterial(mat_red); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation fire.setEndColor( new ColorRGBA(1f, 0f, 0f, 1f)); // red fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0)); fire.setStartSize(1.5f); fire.setEndSize(0.1f); fire.setGravity(0, 0, 0); fire.setLowLife(1f); fire.setHighLife(3f); fire.getParticleInfluencer().setVelocityVariation(0.3f); rootNode.attachChild(fire); ParticleEmitter debris = new ParticleEmitter("Debris", ParticleMesh.Type.Triangle, 10); Material debris_mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); debris_mat.setTexture("Texture", assetManager.loadTexture( "Effects/Explosion/Debris.png")); debris.setMaterial(debris_mat); debris.setImagesX(3); debris.setImagesY(3); // 3x3 texture animation debris.setSelectRandomImage(true); debris.setRotateSpeed(4); debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 4, 0)); debris.setStartColor(ColorRGBA.White); debris.setGravity(0, 6, 0); debris.getParticleInfluencer().setVelocityVariation(.60f); rootNode.attachChild(debris); debris.emitAllParticles(); // ParticleEmitter water = // new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 20); // Material mat_blue = new Material(assetManager, // "Common/MatDefs/Misc/Particle.j3md"); // mat_blue.setTexture("Texture", assetManager.loadTexture( // "Effects/Explosion/flame.png")); // water.setMaterial(mat_blue); // water.setImagesX(2); // water.setImagesY(2); // 2x2 texture animation // water.setStartColor( ColorRGBA.Blue); // water.setEndColor( ColorRGBA.Cyan); // water.getParticleInfluencer().setInitialVelocity(new Vector3f(0, -4, 0)); // water.setStartSize(1f); // water.setEndSize(1.5f); // water.setGravity(0,1,0); // water.setLowLife(1f); // water.setHighLife(1f); // water.getParticleInfluencer().setVelocityVariation(0.1f); // water.setLocalTranslation(0, 6, 0); // rootNode.attachChild(water); }
Example #9
Source File: TestTransparentShadow.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(5.700248f, 6.161693f, 5.1404157f)); cam.setRotation(new Quaternion(-0.09441641f, 0.8993388f, -0.24089815f, -0.35248178f)); viewPort.setBackgroundColor(ColorRGBA.DarkGray); Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10)); TangentBinormalGenerator.generate(q); Geometry geom = new Geometry("floor", q); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(geom); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White.mult(0.7f)); rootNode.addLight(al); DirectionalLight dl1 = new DirectionalLight(); dl1.setDirection(new Vector3f(0, -1, 0.5f).normalizeLocal()); dl1.setColor(ColorRGBA.White.mult(1.5f)); rootNode.addLight(dl1); // create the geometry and attach it Spatial tree = assetManager.loadModel("Models/Tree/Tree.mesh.j3o"); tree.setQueueBucket(Bucket.Transparent); tree.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(tree); // Uses Texture from jme3-test-data library! ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); fire.setShadowMode(ShadowMode.Cast); fire.setMaterial(mat_red); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f)); // red fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0)); fire.setStartSize(0.6f); fire.setEndSize(0.1f); fire.setGravity(0, 0, 0); fire.setLowLife(0.5f); fire.setHighLife(1.5f); fire.getParticleInfluencer().setVelocityVariation(0.3f); fire.setLocalTranslation(5.0f, 0, 1.0f); fire.setLocalScale(0.3f); fire.setQueueBucket(Bucket.Translucent); rootNode.attachChild(fire); Material mat2 = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); Geometry ball = new Geometry("sphere", new Sphere(16, 16, 0.5f)); ball.setMaterial(mat2); ball.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(ball); ball.setLocalTranslation(-1.0f, 1.5f, 1.0f); final DirectionalLightShadowRenderer dlsRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 1); dlsRenderer.setLight(dl1); dlsRenderer.setLambda(0.55f); dlsRenderer.setShadowIntensity(0.8f); dlsRenderer.setShadowCompareMode(CompareMode.Software); dlsRenderer.setEdgeFilteringMode(EdgeFilteringMode.Nearest); dlsRenderer.displayDebug(); viewPort.addProcessor(dlsRenderer); inputManager.addMapping("stabilize", new KeyTrigger(KeyInput.KEY_B)); inputManager.addListener(new ActionListener() { @Override public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("stabilize") && isPressed) { dlsRenderer.setEnabledStabilization(!dlsRenderer.isEnabledStabilization()) ; } } }, "stabilize"); }
Example #10
Source File: TestSoftParticles.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void createParticles() { Material material = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); material.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); material.setFloat("Softness", 3f); // //Fire ParticleEmitter fire = new ParticleEmitter("Fire", ParticleMesh.Type.Triangle, 30); fire.setMaterial(material); fire.setShape(new EmitterSphereShape(Vector3f.ZERO, 0.1f)); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f)); // red fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow fire.setStartSize(0.6f); fire.setEndSize(0.01f); fire.setGravity(0, -0.3f, 0); fire.setLowLife(0.5f); fire.setHighLife(3f); fire.setLocalTranslation(0, 0.2f, 0); particleNode.attachChild(fire); ParticleEmitter smoke = new ParticleEmitter("Smoke", ParticleMesh.Type.Triangle, 30); smoke.setMaterial(material); smoke.setShape(new EmitterSphereShape(Vector3f.ZERO, 5)); smoke.setImagesX(1); smoke.setImagesY(1); // 2x2 texture animation smoke.setStartColor(new ColorRGBA(0.1f, 0.1f, 0.1f,1f)); // dark gray smoke.setEndColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.3f)); // gray smoke.setStartSize(3f); smoke.setEndSize(5f); smoke.setGravity(0, -0.001f, 0); smoke.setLowLife(100f); smoke.setHighLife(100f); smoke.setLocalTranslation(0, 0.1f, 0); smoke.emitAllParticles(); particleNode.attachChild(smoke); }
Example #11
Source File: ParticlePerformer.java From OpenRTS with MIT License | 4 votes |
private void createEmitter(ParticleActor actor){ ParticleEmitter emitter = new ParticleEmitter("", ParticleMesh.Type.Triangle, actor.maxCount); Material m = actorDrawer.getParticleMat(actor.spritePath); if(!actor.add) { m.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); } emitter.setMaterial(m); emitter.setParticlesPerSec(actor.perSecond); emitter.setImagesX(actor.nbRow); emitter.setImagesY(actor.nbCol); emitter.setStartColor(TranslateUtil.toColorRGBA(actor.startColor)); emitter.setEndColor(TranslateUtil.toColorRGBA(actor.endColor)); emitter.setStartSize((float)actor.startSize); emitter.setEndSize((float)actor.endSize); if(actor.gravity) { emitter.setGravity(0, 0, 4); } else { emitter.setGravity(0, 0, 0); } emitter.setLowLife((float)actor.minLife); emitter.setHighLife((float)actor.maxLife); emitter.setRotateSpeed((float)actor.rotationSpeed); if(actor.startVariation != 0) { emitter.setShape(new EmitterSphereShape(Vector3f.ZERO, (float)actor.startVariation)); } if(actor.facing == ParticleActor.Facing.Horizontal) { emitter.setFaceNormal(Vector3f.UNIT_Z); } if(actor.velocity != 0) { emitter.setFacingVelocity(true); } emitter.setQueueBucket(Bucket.Transparent); actorDrawer.mainNode.attachChild(emitter); actor.getViewElements().particleEmitter = emitter; }
Example #12
Source File: HelloEffects.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void simpleInitApp() { ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat_red.setTexture("Texture", assetManager.loadTexture( "Effects/Explosion/flame.png")); fire.setMaterial(mat_red); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation fire.setEndColor( new ColorRGBA(1f, 0f, 0f, 1f)); // red fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0)); fire.setStartSize(1.5f); fire.setEndSize(0.1f); fire.setGravity(0, 0, 0); fire.setLowLife(1f); fire.setHighLife(3f); fire.getParticleInfluencer().setVelocityVariation(0.3f); rootNode.attachChild(fire); ParticleEmitter debris = new ParticleEmitter("Debris", ParticleMesh.Type.Triangle, 10); Material debris_mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); debris_mat.setTexture("Texture", assetManager.loadTexture( "Effects/Explosion/Debris.png")); debris.setMaterial(debris_mat); debris.setImagesX(3); debris.setImagesY(3); // 3x3 texture animation debris.setSelectRandomImage(true); debris.setRotateSpeed(4); debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 4, 0)); debris.setStartColor(ColorRGBA.White); debris.setGravity(0, 6, 0); debris.getParticleInfluencer().setVelocityVariation(.60f); rootNode.attachChild(debris); debris.emitAllParticles(); // ParticleEmitter water = // new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 20); // Material mat_blue = new Material(assetManager, // "Common/MatDefs/Misc/Particle.j3md"); // mat_blue.setTexture("Texture", assetManager.loadTexture( // "Effects/Explosion/flame.png")); // water.setMaterial(mat_blue); // water.setImagesX(2); // water.setImagesY(2); // 2x2 texture animation // water.setStartColor( ColorRGBA.Blue); // water.setEndColor( ColorRGBA.Cyan); // water.getParticleInfluencer().setInitialVelocity(new Vector3f(0, -4, 0)); // water.setStartSize(1f); // water.setEndSize(1.5f); // water.setGravity(0,1,0); // water.setLowLife(1f); // water.setHighLife(1f); // water.getParticleInfluencer().setVelocityVariation(0.1f); // water.setLocalTranslation(0, 6, 0); // rootNode.attachChild(water); }
Example #13
Source File: JmeParticleEmitter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override protected Sheet createSheet() { //TODO: multithreading.. Sheet sheet = super.createSheet(); Sheet.Set set = Sheet.createPropertiesSet(); set.setDisplayName("ParticleEmitter"); set.setName(ParticleEmitter.class.getName()); ParticleEmitter obj = geom;//getLookup().lookup(Spatial.class); if (obj == null) { return sheet; } set.put(createButtonProperty()); set.put(makeProperty(obj, boolean.class, "isEnabled", "setEnabled", "Enabled")); set.put(makeProperty(obj, ParticleMesh.Type.class, "getMeshType", "setMeshType", "Mesh Type")); set.put(makeProperty(obj, EmitterShape.class, "getShape", "setShape", "Emitter Shape")); set.put(makeProperty(obj, int.class, "getMaxNumParticles", "setNumParticles", "Num Particles")); set.put(makeProperty(obj, float.class, "getParticlesPerSec", "setParticlesPerSec", "Particles Per Sec")); set.put(makeProperty(obj, ColorRGBA.class, "getStartColor", "setStartColor", "Start Color")); set.put(makeProperty(obj, ColorRGBA.class, "getEndColor", "setEndColor", "End Color")); set.put(makeProperty(obj, float.class, "getStartSize", "setStartSize", "Start Size")); set.put(makeProperty(obj, float.class, "getEndSize", "setEndSize", "End Size")); set.put(makeProperty(obj, float.class, "getHighLife", "setHighLife", "High Life")); set.put(makeProperty(obj, float.class, "getLowLife", "setLowLife", "Low Life")); set.put(makeProperty(obj, Vector3f.class, "getGravity", "setGravity", "Gravity")); set.put(makeEmbedProperty(obj.getParticleInfluencer(), ParticleInfluencer.class, Vector3f.class, "getInitialVelocity", "setInitialVelocity", "Initial Velocity")); set.put(makeEmbedProperty(obj.getParticleInfluencer(), ParticleInfluencer.class, float.class, "getVelocityVariation", "setVelocityVariation", "Velocity Variation")); set.put(makeProperty(obj, Vector3f.class, "getFaceNormal", "setFaceNormal", "Face Normal")); set.put(makeProperty(obj, boolean.class, "isFacingVelocity", "setFacingVelocity", "Facing Velocity")); set.put(makeProperty(obj, boolean.class, "isRandomAngle", "setRandomAngle", "Random Angle")); set.put(makeProperty(obj, boolean.class, "isInWorldSpace", "setInWorldSpace", "World Space")); set.put(makeProperty(obj, float.class, "getRotateSpeed", "setRotateSpeed", "Rotate Speed")); set.put(makeProperty(obj, boolean.class, "isSelectRandomImage", "setSelectRandomImage", "Select Random Image")); set.put(makeProperty(obj, int.class, "getImagesX", "setImagesX", "Images X")); set.put(makeProperty(obj, int.class, "getImagesY", "setImagesY", "Images Y")); sheet.put(set); return sheet; }
Example #14
Source File: MyParticleEmitter.java From OpenRTS with MIT License | 2 votes |
/** * Returns the mesh type used by the particle emitter. * * * @return the mesh type used by the particle emitter. * * @see #setMeshType(com.jme3.effect.ParticleMesh.Type) * @see ParticleEmitter#ParticleEmitter(java.lang.String, com.jme3.effect.ParticleMesh.Type, int) */ @Override public ParticleMesh.Type getMeshType() { return meshType; }