Skip to content

Commit

Permalink
AvatarMask: implements Savable interface
Browse files Browse the repository at this point in the history
  • Loading branch information
capdevon committed Sep 17, 2024
1 parent d866494 commit 94c9334
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/main/java/com/capdevon/anim/AvatarMask.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package com.capdevon.anim;

import java.io.IOException;
import java.util.BitSet;

import com.jme3.anim.AnimationMask;
import com.jme3.anim.Joint;
import com.jme3.export.InputCapsule;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule;
import com.jme3.export.Savable;

/**
*
* @author capdevon
*/
public class AvatarMask implements AnimationMask {
public class AvatarMask implements AnimationMask, Savable {

private final BitSet affectedJoints = new BitSet();
private BitSet affectedJoints = new BitSet();

/**
* Instantiate a mask that affects no joints.
Expand All @@ -34,4 +40,16 @@ public boolean contains(Object target) {
return affectedJoints.get(joint.getId());
}

@Override
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
oc.write(affectedJoints, "affectedJoints", null);
}

@Override
public void read(JmeImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this);
affectedJoints = ic.readBitSet("affectedJoints", null);
}

}

0 comments on commit 94c9334

Please sign in to comment.