Home | History | Annotate | Download | only in modifiers
      1 package com.jme3.scene.plugins.blender.modifiers;
      2 
      3 import com.jme3.scene.Node;
      4 import com.jme3.scene.plugins.blender.BlenderContext;
      5 import com.jme3.scene.plugins.blender.file.Pointer;
      6 import com.jme3.scene.plugins.blender.file.Structure;
      7 
      8 /**
      9  * This class represents an object's modifier. The modifier object can be varied
     10  * and the user needs to know what is the type of it for the specified type
     11  * name. For example "ArmatureModifierData" type specified in blender is
     12  * represented by AnimData object from jMonkeyEngine.
     13  *
     14  * @author Marcin Roguski (Kaelthas)
     15  */
     16 public abstract class Modifier {
     17 
     18 	public static final String ARRAY_MODIFIER_DATA = "ArrayModifierData";
     19 	public static final String ARMATURE_MODIFIER_DATA = "ArmatureModifierData";
     20 	public static final String PARTICLE_MODIFIER_DATA = "ParticleSystemModifierData";
     21 	public static final String MIRROR_MODIFIER_DATA = "MirrorModifierData";
     22 	public static final String SUBSURF_MODIFIER_DATA = "SubsurfModifierData";
     23 	public static final String OBJECT_ANIMATION_MODIFIER_DATA = "ObjectAnimationModifierData";
     24 
     25 	/** This variable indicates if the modifier is invalid (<b>true</b>) or not (<b>false</b>). */
     26 	protected boolean invalid;
     27 
     28 	/**
     29 	 * This method applies the modifier to the given node.
     30 	 *
     31 	 * @param node
     32 	 *            the node that will have modifier applied
     33 	 * @param blenderContext
     34 	 *            the blender context
     35 	 * @return the node with applied modifier
     36 	 */
     37 	public abstract Node apply(Node node, BlenderContext blenderContext);
     38 
     39 	/**
     40 	 * This method returns blender's type of modifier.
     41 	 *
     42 	 * @return blender's type of modifier
     43 	 */
     44 	public abstract String getType();
     45 
     46 	protected boolean validate(Structure modifierStructure, BlenderContext blenderContext) {
     47 		Structure modifierData = (Structure)modifierStructure.getFieldValue("modifier");
     48 		Pointer pError = (Pointer) modifierData.getFieldValue("error");
     49 		invalid = pError.isNotNull();
     50 		return !invalid;
     51 	}
     52 }
     53