• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.jme3.effect.shapes;
2 
3 import com.jme3.math.FastMath;
4 import com.jme3.math.Vector3f;
5 import com.jme3.scene.Mesh;
6 import java.util.List;
7 
8 /**
9  * This emiter shape emits the particles from the given shape's interior constrained by its convex hull
10  * (a geometry that tightly wraps the mesh). So in case of multiple meshes some vertices may appear
11  * in a space between them.
12  * @author Marcin Roguski (Kaelthas)
13  */
14 public class EmitterMeshConvexHullShape extends EmitterMeshFaceShape {
15 
16     /**
17      * Empty constructor. Sets nothing.
18      */
EmitterMeshConvexHullShape()19     public EmitterMeshConvexHullShape() {
20     }
21 
22     /**
23      * Constructor. It stores a copy of vertex list of all meshes.
24      * @param meshes
25      *        a list of meshes that will form the emitter's shape
26      */
EmitterMeshConvexHullShape(List<Mesh> meshes)27     public EmitterMeshConvexHullShape(List<Mesh> meshes) {
28         super(meshes);
29     }
30 
31     /**
32      * This method fills the point with coordinates of randomly selected point inside a convex hull
33      * of randomly selected mesh.
34      * @param store
35      *        the variable to store with coordinates of randomly selected selected point inside a convex hull
36      *        of randomly selected mesh
37      */
38     @Override
getRandomPoint(Vector3f store)39     public void getRandomPoint(Vector3f store) {
40         super.getRandomPoint(store);
41         // now move the point from the meshe's face towards the center of the mesh
42         // the center is in (0, 0, 0) in the local coordinates
43         store.multLocal(FastMath.nextRandomFloat());
44     }
45 
46     /**
47      * This method fills the point with coordinates of randomly selected point inside a convex hull
48      * of randomly selected mesh.
49      * The normal param is not used.
50      * @param store
51      *        the variable to store with coordinates of randomly selected selected point inside a convex hull
52      *        of randomly selected mesh
53      * @param normal
54      *        not used in this class
55      */
56     @Override
getRandomPointAndNormal(Vector3f store, Vector3f normal)57     public void getRandomPointAndNormal(Vector3f store, Vector3f normal) {
58         super.getRandomPointAndNormal(store, normal);
59         // now move the point from the meshe's face towards the center of the mesh
60         // the center is in (0, 0, 0) in the local coordinates
61         store.multLocal(FastMath.nextRandomFloat());
62     }
63 }
64