Refactoring: removing AnimData class use in blender importer to make it independent on the OGRE plugin (this way the usage of the importer will not require the presence of Ogre plugin in the classpath).

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10611 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 12 years ago
parent c1402b30e9
commit 217a1a6273
  1. 8
      engine/src/blender/com/jme3/asset/BlenderKey.java
  2. 8
      engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java
  3. 29
      engine/src/blender/com/jme3/scene/plugins/blender/animations/AnimationData.java
  4. 16
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
  5. 13
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ObjectAnimationModifier.java

@ -54,7 +54,7 @@ import com.jme3.scene.LightNode;
import com.jme3.scene.Node;
import com.jme3.scene.SceneGraphVisitor;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.ogre.AnimData;
import com.jme3.scene.plugins.blender.animations.AnimationData;
import com.jme3.texture.Texture;
/**
@ -541,7 +541,7 @@ public class BlenderKey extends ModelKey {
/** Textures from all objects. */
private List<Texture> textures;
/** Animations of all objects. */
private List<AnimData> animations;
private List<AnimationData> animations;
/** All cameras from the file. */
private List<CameraNode> cameras;
/** All lights from the file. */
@ -567,7 +567,7 @@ public class BlenderKey extends ModelKey {
}
}
if ((featuresToLoad & FeaturesToLoad.ANIMATIONS) != 0) {
animations = new ArrayList<AnimData>();
animations = new ArrayList<AnimationData>();
}
}
if ((featuresToLoad & FeaturesToLoad.CAMERAS) != 0) {
@ -689,7 +689,7 @@ public class BlenderKey extends ModelKey {
* This method returns all loaded animations.
* @return all loaded animations
*/
public List<AnimData> getAnimations() {
public List<AnimationData> getAnimations() {
return animations;
}

@ -47,6 +47,7 @@ import com.jme3.asset.BlenderKey;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Node;
import com.jme3.scene.plugins.blender.animations.AnimationData;
import com.jme3.scene.plugins.blender.animations.BoneContext;
import com.jme3.scene.plugins.blender.constraints.Constraint;
import com.jme3.scene.plugins.blender.file.BlenderInputStream;
@ -54,7 +55,6 @@ import com.jme3.scene.plugins.blender.file.DnaBlockData;
import com.jme3.scene.plugins.blender.file.FileBlockHeader;
import com.jme3.scene.plugins.blender.file.Structure;
import com.jme3.scene.plugins.blender.meshes.MeshContext;
import com.jme3.scene.plugins.ogre.AnimData;
/**
* The class that stores temporary data and manages it during loading the belnd
@ -103,7 +103,7 @@ public class BlenderContext {
/** A list of constraints for the specified object. */
protected Map<Long, List<Constraint>> constraints = new HashMap<Long, List<Constraint>>();
/** Anim data loaded for features. */
private Map<Long, AnimData> animData = new HashMap<Long, AnimData>();
private Map<Long, AnimationData> animData = new HashMap<Long, AnimationData>();
/** Loaded skeletons. */
private Map<Long, Skeleton> skeletons = new HashMap<Long, Skeleton>();
/** A map between skeleton and node it modifies. */
@ -406,7 +406,7 @@ public class BlenderContext {
* @param animData
* the animation data for the feature specified by ownerOMA
*/
public void setAnimData(Long ownerOMA, AnimData animData) {
public void setAnimData(Long ownerOMA, AnimationData animData) {
this.animData.put(ownerOMA, animData);
}
@ -417,7 +417,7 @@ public class BlenderContext {
* the old memory address of the animation data owner
* @return the animation data or null if none exists
*/
public AnimData getAnimData(Long ownerOMA) {
public AnimationData getAnimData(Long ownerOMA) {
return this.animData.get(ownerOMA);
}

@ -0,0 +1,29 @@
package com.jme3.scene.plugins.blender.animations;
import java.util.List;
import com.jme3.animation.Animation;
import com.jme3.animation.Skeleton;
/**
* A simple class that sotres animation data.
* If skeleton is null then we deal with object animation.
*
* @author Marcin Roguski (Kaelthas)
*/
public class AnimationData {
/** The skeleton. */
public final Skeleton skeleton;
/** The animations list. */
public final List<Animation> anims;
public AnimationData(List<Animation> anims) {
this.anims = anims;
skeleton = null;
}
public AnimationData(Skeleton skeleton, List<Animation> anims) {
this.skeleton = skeleton;
this.anims = anims;
}
}

@ -27,6 +27,7 @@ import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.VertexBuffer.Usage;
import com.jme3.scene.plugins.blender.BlenderContext;
import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType;
import com.jme3.scene.plugins.blender.animations.AnimationData;
import com.jme3.scene.plugins.blender.animations.ArmatureHelper;
import com.jme3.scene.plugins.blender.animations.BoneContext;
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
@ -35,7 +36,6 @@ import com.jme3.scene.plugins.blender.file.Pointer;
import com.jme3.scene.plugins.blender.file.Structure;
import com.jme3.scene.plugins.blender.meshes.MeshContext;
import com.jme3.scene.plugins.blender.objects.ObjectHelper;
import com.jme3.scene.plugins.ogre.AnimData;
import com.jme3.util.BufferUtils;
/**
@ -53,7 +53,7 @@ import com.jme3.util.BufferUtils;
private Structure meshStructure;
/** Loaded animation data. */
private AnimData animData;
private AnimationData animationData;
/** Old memory address of the mesh that will have the skeleton applied. */
private Long meshOMA;
@ -157,7 +157,7 @@ import com.jme3.util.BufferUtils;
}
}
animData = new AnimData(skeleton, animations);
animationData = new AnimationData(skeleton, animations);
// store the animation data for each bone
for (Bone bone : bones) {
@ -165,7 +165,7 @@ import com.jme3.util.BufferUtils;
BoneContext boneContext = blenderContext.getBoneContext(bone);
Long boneOma = boneContext.getBoneOma();
if (boneOma != null) {
blenderContext.setAnimData(boneOma, animData);
blenderContext.setAnimData(boneOma, animationData);
}
}
}
@ -181,7 +181,7 @@ import com.jme3.util.BufferUtils;
if (invalid) {
LOGGER.log(Level.WARNING, "Armature modifier is invalid! Cannot be applied to: {0}", node.getName());
}// if invalid, animData will be null
if (animData == null || skeleton == null) {
if (animationData == null || skeleton == null) {
return node;
}
@ -221,8 +221,8 @@ import com.jme3.util.BufferUtils;
}
// applying animations
AnimControl control = new AnimControl(animData.skeleton);
ArrayList<Animation> animList = animData.anims;
AnimControl control = new AnimControl(animationData.skeleton);
List<Animation> animList = animationData.anims;
if (animList != null && animList.size() > 0) {
HashMap<String, Animation> anims = new HashMap<String, Animation>(animList.size());
for (int i = 0; i < animList.size(); ++i) {
@ -232,7 +232,7 @@ import com.jme3.util.BufferUtils;
control.setAnimations(anims);
}
node.addControl(control);
node.addControl(new SkeletonControl(animData.skeleton));
node.addControl(new SkeletonControl(animationData.skeleton));
blenderContext.setNodeForSkeleton(skeleton, node);

@ -2,6 +2,7 @@ package com.jme3.scene.plugins.blender.modifiers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -12,9 +13,9 @@ import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.blender.BlenderContext;
import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType;
import com.jme3.scene.plugins.blender.animations.AnimationData;
import com.jme3.scene.plugins.blender.animations.Ipo;
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
import com.jme3.scene.plugins.ogre.AnimData;
/**
* This modifier allows to add animation to the object.
@ -25,7 +26,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
private static final Logger LOGGER = Logger.getLogger(ObjectAnimationModifier.class.getName());
/** Loaded animation data. */
private AnimData animData;
private AnimationData animationData;
/**
* This constructor reads animation of the object itself (without bones) and
@ -59,8 +60,8 @@ import com.jme3.scene.plugins.ogre.AnimData;
ArrayList<Animation> animations = new ArrayList<Animation>(1);
animations.add(animation);
animData = new AnimData(null, animations);
blenderContext.setAnimData(objectOMA, animData);
animationData = new AnimationData(animations);
blenderContext.setAnimData(objectOMA, animationData);
}
@Override
@ -68,10 +69,10 @@ import com.jme3.scene.plugins.ogre.AnimData;
if (invalid) {
LOGGER.log(Level.WARNING, "Armature modifier is invalid! Cannot be applied to: {0}", node.getName());
}// if invalid, animData will be null
if (animData != null) {
if (animationData != null) {
// INFO: constraints for this modifier are applied in the
// ObjectHelper when the whole object is loaded
ArrayList<Animation> animList = animData.anims;
List<Animation> animList = animationData.anims;
if (animList != null && animList.size() > 0) {
HashMap<String, Animation> anims = new HashMap<String, Animation>();
for (int i = 0; i < animList.size(); ++i) {

Loading…
Cancel
Save