예제 #1
0
 public static void setBonesSuchAs(AnimControl animControl, String animationName) {
   Animation animation = animControl.getAnim(animationName);
   int size = animControl.getSkeleton().getBoneCount();
   for (int index = 0; index < size; index++) {
     Bone bone = animControl.getSkeleton().getBone(index);
     BoneTrack boneTrack = getFirstTrackForBone(animation, index);
     if (boneTrack != null) {
       Quaternion rotation = boneTrack.getRotations()[0];
       Vector3f translation = boneTrack.getTranslations()[0];
       Vector3f scale = boneTrack.getScales()[0];
       System.out.println("Bone = " + bone.getName());
       System.out.println("\tRotation = " + rotation);
       System.out.println("\tTranslation = " + translation);
       System.out.println("\tScale = " + scale);
       bone.setUserControl(true);
       bone.setUserTransforms(translation, rotation, scale);
       bone.updateWorldVectors();
       bone.setUserControl(false);
     }
   }
 }
  private void scanSpatial(Spatial model) {
    AnimControl animControl = model.getControl(AnimControl.class);
    Map<Integer, List<Float>> pointsMap = null;
    if (weightThreshold == -1.0f) {
      pointsMap = RagdollUtils.buildPointMap(model);
    }

    skeleton = animControl.getSkeleton();
    skeleton.resetAndUpdate();
    for (int i = 0; i < skeleton.getRoots().length; i++) {
      Bone childBone = skeleton.getRoots()[i];
      if (childBone.getParent() == null) {
        logger.log(Level.INFO, "Found root bone in skeleton {0}", skeleton);
        baseRigidBody =
            new PhysicsRigidBody(new BoxCollisionShape(Vector3f.UNIT_XYZ.mult(0.1f)), 1);
        baseRigidBody.setKinematic(mode == Mode.Kinematic);
        boneRecursion(model, childBone, baseRigidBody, 1, pointsMap);
      }
    }
  }
예제 #3
0
 private static BoneTrack getFirstTrackForBone(
     AnimControl animControl, Animation animation, String boneName) {
   int boneIndex = animControl.getSkeleton().getBoneIndex(boneName);
   return getFirstTrackForBone(animation, boneIndex);
 }