Package com.jme3.anim

Class SkinningControl

All Implemented Interfaces:
Savable, Control, JmeCloneable, Cloneable

public class SkinningControl extends AbstractControl implements JmeCloneable
The `SkinningControl` deforms a 3D model according to an Armature. It manages the computation of deformation matrices and applies these transformations to the mesh, supporting both software and hardware-accelerated skinning.

**Software Skinning:** Performed on the CPU, offering broader compatibility but potentially lower performance for complex models.

**Hardware Skinning:** Utilizes the GPU for deformation, providing significantly better performance but requiring shader support and having a limit on the number of bones (typically 255 in common shaders).

  • Constructor Details

    • SkinningControl

      protected SkinningControl()
      Serialization only. Do not use.
    • SkinningControl

      public SkinningControl(Armature armature)
      Creates a new `SkinningControl` for the given armature.
      Parameters:
      armature - The armature that drives the deformation (not null).
  • Method Details

    • setHardwareSkinningPreferred

      public void setHardwareSkinningPreferred(boolean preferred)
      Specifies if hardware skinning is preferred. If it is preferred and supported by GPU, it shall be enabled. If it's not preferred, or not supported by GPU, then it shall be disabled.
      Parameters:
      preferred - true to prefer hardware skinning, false to prefer software skinning (default=true)
      See Also:
    • isHardwareSkinningPreferred

      public boolean isHardwareSkinningPreferred()
      Returns:
      True if hardware skinning is preferable to software skinning. Set to false by default.
      See Also:
    • isHardwareSkinningUsed

      public boolean isHardwareSkinningUsed()
      Returns:
      True is hardware skinning is activated and is currently used, false otherwise.
    • setSpatial

      public void setSpatial(Spatial spatial)
      Specified by:
      setSpatial in interface Control
      Overrides:
      setSpatial in class AbstractControl
      Parameters:
      spatial - the spatial to be controlled. This should not be called from user code.
    • controlRender

      protected void controlRender(RenderManager rm, ViewPort vp)
      Description copied from class: AbstractControl
      To be implemented in subclass.
      Specified by:
      controlRender in class AbstractControl
      Parameters:
      rm - the RenderManager rendering the controlled Spatial (not null)
      vp - the ViewPort being rendered (not null)
    • controlUpdate

      protected void controlUpdate(float tpf)
      Description copied from class: AbstractControl
      To be implemented in subclass.
      Specified by:
      controlUpdate in class AbstractControl
      Parameters:
      tpf - time per frame (in seconds)
    • jmeClone

      public Object jmeClone()
      Description copied from interface: JmeCloneable
      Performs a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)

      This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.

      Specified by:
      jmeClone in interface JmeCloneable
      Overrides:
      jmeClone in class AbstractControl
      Returns:
      a new instance
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Description copied from interface: JmeCloneable
      Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.

      Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.

      Specified by:
      cloneFields in interface JmeCloneable
      Overrides:
      cloneFields in class AbstractControl
      Parameters:
      cloner - The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
      original - The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
    • getAttachmentsNode

      public Node getAttachmentsNode(String jointName)
      Provides access to the attachment node for a specific joint in the armature. If an attachment node does not already exist for the named joint, one will be created and attached to the scene graph. Models or effects attached to this node will follow the motion of the corresponding bone.
      Parameters:
      jointName - the name of the joint
      Returns:
      the attachments node of the joint
    • getArmature

      public Armature getArmature()
      Returns the armature associated with this skinning control.
      Returns:
      The pre-existing `Armature` instance.
    • getTargets

      public Mesh[] getTargets()
      Returns an array containing all the target meshes that this control is currently affecting.
      Returns:
      A new array of `Mesh` objects.
    • write

      public void write(JmeExporter ex) throws IOException
      Serialize this Control to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Overrides:
      write in class AbstractControl
      Parameters:
      ex - the exporter to write to (not null)
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter im) throws IOException
      De-serialize this Control from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Overrides:
      read in class AbstractControl
      Parameters:
      im - the importer to read from (not null)
      Throws:
      IOException - from the importer