use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class ParticlesModifier method postMeshCreationApply.
@Override
public void postMeshCreationApply(Node node, BlenderContext blenderContext) {
LOGGER.log(Level.FINE, "Applying particles modifier to: {0}", node);
MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class);
ParticleEmitter emitter = particleEmitter.clone();
// veryfying the alpha function for particles' texture
Integer alphaFunction = MaterialHelper.ALPHA_MASK_HYPERBOLE;
char nameSuffix = emitter.getName().charAt(emitter.getName().length() - 1);
if (nameSuffix == 'B' || nameSuffix == 'N') {
alphaFunction = MaterialHelper.ALPHA_MASK_NONE;
}
// removing the type suffix from the name
emitter.setName(emitter.getName().substring(0, emitter.getName().length() - 1));
// applying emitter shape
EmitterShape emitterShape = emitter.getShape();
List<Mesh> meshes = new ArrayList<Mesh>();
for (Spatial spatial : node.getChildren()) {
if (spatial instanceof Geometry) {
Mesh mesh = ((Geometry) spatial).getMesh();
if (mesh != null) {
meshes.add(mesh);
Material material = materialHelper.getParticlesMaterial(((Geometry) spatial).getMaterial(), alphaFunction, blenderContext);
// TODO: divide into several pieces
emitter.setMaterial(material);
}
}
}
if (meshes.size() > 0 && emitterShape instanceof EmitterMeshVertexShape) {
((EmitterMeshVertexShape) emitterShape).setMeshes(meshes);
}
node.attachChild(emitter);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class CharacterControl method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
enabled = ic.readBoolean("enabled", true);
useViewDirection = ic.readBoolean("viewDirectionEnabled", true);
viewDirection = (Vector3f) ic.readSavable("viewDirection", new Vector3f(Vector3f.UNIT_Z));
applyLocal = ic.readBoolean("applyLocalPhysics", false);
spatial = (Spatial) ic.readSavable("spatial", null);
setUserObject(spatial);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class GhostControl method write.
@Override
public void write(JmeExporter ex) throws IOException {
super.write(ex);
OutputCapsule oc = ex.getCapsule(this);
oc.write(enabled, "enabled", true);
oc.write(applyLocal, "applyLocalPhysics", false);
oc.write(spatial, "spatial", null);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class AbstractPhysicsControl method write.
@Override
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
oc.write(enabled, "enabled", true);
oc.write(applyLocal, "applyLocalPhysics", false);
oc.write(spatial, "spatial", null);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class AbstractPhysicsControl method read.
@Override
public void read(JmeImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this);
enabled = ic.readBoolean("enabled", true);
spatial = (Spatial) ic.readSavable("spatial", null);
applyLocal = ic.readBoolean("applyLocalPhysics", false);
}
Aggregations