};
public void initParticleLocation(final int index) {
final Particle p = _particles[index];
if (getParticleType() == ParticleType.GeomMesh && getParticleEmitter() instanceof MeshEmitter) {
final MeshEmitter emitter = (MeshEmitter) getParticleEmitter();
final Mesh mesh = emitter.getSource();
// Update the triangle model on each new particle creation.
final Vector3[] vertices = new Vector3[3];
final MeshData mData = mesh.getMeshData();
for (int x = 0; x < 3; x++) {
vertices[x] = new Vector3();
final int vertIndex = mData.getVertexIndex(index, x, 0);
BufferUtils.populateFromBuffer(vertices[x], mData.getVertexBuffer(), mData.getIndices() != null ? mData
.getIndices().get(vertIndex) : vertIndex);
}
Triangle t = p.getTriangleModel();
if (t == null) {
t = new Triangle(vertices[0], vertices[1], vertices[2]);
} else {
t.setA(vertices[0]);
t.setB(vertices[1]);
t.setC(vertices[2]);
}
// turn the triangle corners into vector offsets from center
for (int x = 0; x < 3; x++) {
vertices[x].subtract(t.getCenter(), vertices[x]);
t.set(x, vertices[x]);
}
p.setTriangleModel(t);
mesh.localToWorld(t.getCenter(), p.getPosition());
p.getPosition().multiplyLocal(getInvScale());
} else if (getParticleEmitter() instanceof MeshEmitter) {
final MeshEmitter emitter = (MeshEmitter) getParticleEmitter();
final Mesh mesh = emitter.getSource();
mesh.getMeshData().randomPointOnPrimitives(p.getPosition());
mesh.localToWorld(p.getPosition(), p.getPosition());
p.getPosition().multiplyLocal(getInvScale());
} else {
if (getParticleEmitter() != null) {