1package com.jme3.effect.shapes;
2
3import com.jme3.math.FastMath;
4import com.jme3.math.Vector3f;
5import com.jme3.scene.Mesh;
6import 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 */
14public class EmitterMeshConvexHullShape extends EmitterMeshFaceShape {
15
16    /**
17     * Empty constructor. Sets nothing.
18     */
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     */
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
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
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