Modifiers refactoring. Common reference to loaded modifier to all classes deriving from 'Modifier' was dropped.
Now all modifiers hold their own data and do not give acces to them. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8243 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
6bbf141b9f
commit
7a44519bac
@ -45,6 +45,8 @@ import com.jme3.util.BufferUtils;
|
|||||||
/* package */class ArmatureModifier extends Modifier {
|
/* package */class ArmatureModifier extends Modifier {
|
||||||
private static final int MAXIMUM_WEIGHTS_PER_VERTEX = 4; // have no idea why 4, could someone please explain ?
|
private static final int MAXIMUM_WEIGHTS_PER_VERTEX = 4; // have no idea why 4, could someone please explain ?
|
||||||
|
|
||||||
|
/** Loaded animation data. */
|
||||||
|
private AnimData animData;
|
||||||
/** Old memory address of the armature's object. */
|
/** Old memory address of the armature's object. */
|
||||||
private Long armatureObjectOMA;
|
private Long armatureObjectOMA;
|
||||||
/** Old memory address of the mesh that will have the skeleton applied. */
|
/** Old memory address of the mesh that will have the skeleton applied. */
|
||||||
@ -124,7 +126,7 @@ import com.jme3.util.BufferUtils;
|
|||||||
animations.add(boneAnimation);
|
animations.add(boneAnimation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jmeModifierRepresentation = new AnimData(new Skeleton(bones), animations);
|
animData = new AnimData(new Skeleton(bones), animations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +134,7 @@ import com.jme3.util.BufferUtils;
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Node apply(Node node, DataRepository dataRepository) {
|
public Node apply(Node node, DataRepository dataRepository) {
|
||||||
if(jmeModifierRepresentation == null) {
|
if(animData == null) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,8 +149,7 @@ import com.jme3.util.BufferUtils;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimData ad = (AnimData) jmeModifierRepresentation;
|
ArrayList<Animation> animList = animData.anims;
|
||||||
ArrayList<Animation> animList = ad.anims;
|
|
||||||
if (animList != null && animList.size() > 0) {
|
if (animList != null && animList.size() > 0) {
|
||||||
List<Constraint> constraints = dataRepository.getConstraints(this.armatureObjectOMA);
|
List<Constraint> constraints = dataRepository.getConstraints(this.armatureObjectOMA);
|
||||||
HashMap<String, Animation> anims = new HashMap<String, Animation>();
|
HashMap<String, Animation> anims = new HashMap<String, Animation>();
|
||||||
@ -158,7 +159,7 @@ import com.jme3.util.BufferUtils;
|
|||||||
// baking constraints into animations
|
// baking constraints into animations
|
||||||
if (constraints != null && constraints.size() > 0) {
|
if (constraints != null && constraints.size() > 0) {
|
||||||
for (Constraint constraint : constraints) {
|
for (Constraint constraint : constraints) {
|
||||||
constraint.affectAnimation(ad.skeleton, boneAnimation);
|
constraint.affectAnimation(animData.skeleton, boneAnimation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,8 +180,8 @@ import com.jme3.util.BufferUtils;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// applying the control to the node
|
// applying the control to the node
|
||||||
SkeletonControl skeletonControl = new SkeletonControl(meshes, ad.skeleton);
|
SkeletonControl skeletonControl = new SkeletonControl(meshes, animData.skeleton);
|
||||||
AnimControl control = new AnimControl(ad.skeleton);
|
AnimControl control = new AnimControl(animData.skeleton);
|
||||||
|
|
||||||
control.setAnimations(anims);
|
control.setAnimations(anims);
|
||||||
node.addControl(control);
|
node.addControl(control);
|
||||||
|
@ -33,6 +33,9 @@ import com.jme3.scene.shape.Curve;
|
|||||||
/*package*/ class ArrayModifier extends Modifier {
|
/*package*/ class ArrayModifier extends Modifier {
|
||||||
private static final Logger LOGGER = Logger.getLogger(ArrayModifier.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ArrayModifier.class.getName());
|
||||||
|
|
||||||
|
/** Parameters of the modifier. */
|
||||||
|
private Map<String, Object> modifierData = new HashMap<String, Object>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor reads array data from the modifier structure. The
|
* This constructor reads array data from the modifier structure. The
|
||||||
* stored data is a map of parameters for array modifier. No additional data
|
* stored data is a map of parameters for array modifier. No additional data
|
||||||
@ -50,16 +53,14 @@ import com.jme3.scene.shape.Curve;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ArrayModifier(Structure modifier, DataRepository dataRepository) throws BlenderFileException {
|
public ArrayModifier(Structure modifier, DataRepository dataRepository) throws BlenderFileException {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
Number fittype = (Number) modifier.getFieldValue("fit_type");
|
Number fittype = (Number) modifier.getFieldValue("fit_type");
|
||||||
params.put("fittype", fittype);
|
modifierData.put("fittype", fittype);
|
||||||
switch (fittype.intValue()) {
|
switch (fittype.intValue()) {
|
||||||
case 0:// FIXED COUNT
|
case 0:// FIXED COUNT
|
||||||
params.put("count", modifier.getFieldValue("count"));
|
modifierData.put("count", modifier.getFieldValue("count"));
|
||||||
break;
|
break;
|
||||||
case 1:// FIXED LENGTH
|
case 1:// FIXED LENGTH
|
||||||
params.put("length", modifier.getFieldValue("length"));
|
modifierData.put("length", modifier.getFieldValue("length"));
|
||||||
break;
|
break;
|
||||||
case 2:// FITCURVE
|
case 2:// FITCURVE
|
||||||
Pointer pCurveOb = (Pointer) modifier.getFieldValue("curve_ob");
|
Pointer pCurveOb = (Pointer) modifier.getFieldValue("curve_ob");
|
||||||
@ -86,8 +87,8 @@ import com.jme3.scene.shape.Curve;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
params.put("length", Float.valueOf(length));
|
modifierData.put("length", Float.valueOf(length));
|
||||||
params.put("fittype", Integer.valueOf(1));// treat it like FIXED LENGTH
|
modifierData.put("fittype", Integer.valueOf(1));// treat it like FIXED LENGTH
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert false : "Unknown array modifier fit type: " + fittype;
|
assert false : "Unknown array modifier fit type: " + fittype;
|
||||||
@ -98,36 +99,33 @@ import com.jme3.scene.shape.Curve;
|
|||||||
if ((offsettype & 0x01) != 0) {// Constant offset
|
if ((offsettype & 0x01) != 0) {// Constant offset
|
||||||
DynamicArray<Number> offsetArray = (DynamicArray<Number>) modifier.getFieldValue("offset");
|
DynamicArray<Number> offsetArray = (DynamicArray<Number>) modifier.getFieldValue("offset");
|
||||||
float[] offset = new float[]{offsetArray.get(0).floatValue(), offsetArray.get(1).floatValue(), offsetArray.get(2).floatValue()};
|
float[] offset = new float[]{offsetArray.get(0).floatValue(), offsetArray.get(1).floatValue(), offsetArray.get(2).floatValue()};
|
||||||
params.put("offset", offset);
|
modifierData.put("offset", offset);
|
||||||
}
|
}
|
||||||
if ((offsettype & 0x02) != 0) {// Relative offset
|
if ((offsettype & 0x02) != 0) {// Relative offset
|
||||||
DynamicArray<Number> scaleArray = (DynamicArray<Number>) modifier.getFieldValue("scale");
|
DynamicArray<Number> scaleArray = (DynamicArray<Number>) modifier.getFieldValue("scale");
|
||||||
float[] scale = new float[]{scaleArray.get(0).floatValue(), scaleArray.get(1).floatValue(), scaleArray.get(2).floatValue()};
|
float[] scale = new float[]{scaleArray.get(0).floatValue(), scaleArray.get(1).floatValue(), scaleArray.get(2).floatValue()};
|
||||||
params.put("scale", scale);
|
modifierData.put("scale", scale);
|
||||||
}
|
}
|
||||||
if ((offsettype & 0x04) != 0) {// Object offset
|
if ((offsettype & 0x04) != 0) {// Object offset
|
||||||
Pointer pOffsetObject = (Pointer) modifier.getFieldValue("offset_ob");
|
Pointer pOffsetObject = (Pointer) modifier.getFieldValue("offset_ob");
|
||||||
if (pOffsetObject.isNotNull()) {
|
if (pOffsetObject.isNotNull()) {
|
||||||
params.put("offsetob", pOffsetObject);
|
modifierData.put("offsetob", pOffsetObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// start cap and end cap
|
// start cap and end cap
|
||||||
Pointer pStartCap = (Pointer) modifier.getFieldValue("start_cap");
|
Pointer pStartCap = (Pointer) modifier.getFieldValue("start_cap");
|
||||||
if (pStartCap.isNotNull()) {
|
if (pStartCap.isNotNull()) {
|
||||||
params.put("startcap", pStartCap);
|
modifierData.put("startcap", pStartCap);
|
||||||
}
|
}
|
||||||
Pointer pEndCap = (Pointer) modifier.getFieldValue("end_cap");
|
Pointer pEndCap = (Pointer) modifier.getFieldValue("end_cap");
|
||||||
if (pEndCap.isNotNull()) {
|
if (pEndCap.isNotNull()) {
|
||||||
params.put("endcap", pEndCap);
|
modifierData.put("endcap", pEndCap);
|
||||||
}
|
}
|
||||||
jmeModifierRepresentation = params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Node apply(Node node, DataRepository dataRepository) {
|
public Node apply(Node node, DataRepository dataRepository) {
|
||||||
Map<String, Object> modifierData = (Map<String, Object>) jmeModifierRepresentation;
|
|
||||||
int fittype = ((Number) modifierData.get("fittype")).intValue();
|
int fittype = ((Number) modifierData.get("fittype")).intValue();
|
||||||
float[] offset = (float[]) modifierData.get("offset");
|
float[] offset = (float[]) modifierData.get("offset");
|
||||||
if (offset == null) {// the node will be repeated several times in the same place
|
if (offset == null) {// the node will be repeated several times in the same place
|
||||||
|
@ -29,6 +29,9 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper;
|
|||||||
/*package*/ class MirrorModifier extends Modifier {
|
/*package*/ class MirrorModifier extends Modifier {
|
||||||
private static final Logger LOGGER = Logger.getLogger(MirrorModifier.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(MirrorModifier.class.getName());
|
||||||
|
|
||||||
|
/** Parameters of the modifier. */
|
||||||
|
private Map<String, Object> modifierData = new HashMap<String, Object>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor reads mirror data from the modifier structure. The
|
* This constructor reads mirror data from the modifier structure. The
|
||||||
* stored data is a map of parameters for mirror modifier. No additional data
|
* stored data is a map of parameters for mirror modifier. No additional data
|
||||||
@ -46,21 +49,16 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper;
|
|||||||
* corrupted
|
* corrupted
|
||||||
*/
|
*/
|
||||||
public MirrorModifier(Structure modifier, DataRepository dataRepository) {
|
public MirrorModifier(Structure modifier, DataRepository dataRepository) {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
modifierData.put("flag", modifier.getFieldValue("flag"));
|
||||||
|
modifierData.put("tolerance", modifier.getFieldValue("tolerance"));
|
||||||
params.put("flag", modifier.getFieldValue("flag"));
|
|
||||||
params.put("tolerance", modifier.getFieldValue("tolerance"));
|
|
||||||
Pointer pMirrorOb = (Pointer) modifier.getFieldValue("mirror_ob");
|
Pointer pMirrorOb = (Pointer) modifier.getFieldValue("mirror_ob");
|
||||||
if (pMirrorOb.isNotNull()) {
|
if (pMirrorOb.isNotNull()) {
|
||||||
params.put("mirrorob", pMirrorOb);
|
modifierData.put("mirrorob", pMirrorOb);
|
||||||
}
|
}
|
||||||
jmeModifierRepresentation = params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Node apply(Node node, DataRepository dataRepository) {
|
public Node apply(Node node, DataRepository dataRepository) {
|
||||||
Map<String, Object> modifierData = (Map<String, Object>) jmeModifierRepresentation;
|
|
||||||
int flag = ((Number) modifierData.get("flag")).intValue();
|
int flag = ((Number) modifierData.get("flag")).intValue();
|
||||||
float[] mirrorFactor = new float[]{
|
float[] mirrorFactor = new float[]{
|
||||||
(flag & 0x08) != 0 ? -1.0f : 1.0f,
|
(flag & 0x08) != 0 ? -1.0f : 1.0f,
|
||||||
|
@ -19,34 +19,6 @@ public abstract class Modifier {
|
|||||||
public static final String MIRROR_MODIFIER_DATA = "MirrorModifierData";
|
public static final String MIRROR_MODIFIER_DATA = "MirrorModifierData";
|
||||||
public static final String OBJECT_ANIMATION_MODIFIER_DATA = "ObjectAnimationModifierData";
|
public static final String OBJECT_ANIMATION_MODIFIER_DATA = "ObjectAnimationModifierData";
|
||||||
|
|
||||||
/**
|
|
||||||
* JME modifier representation object.
|
|
||||||
*/
|
|
||||||
protected Object jmeModifierRepresentation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Various additional data used by modifiers.
|
|
||||||
*/
|
|
||||||
protected Object additionalData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns JME modifier representation object.
|
|
||||||
*
|
|
||||||
* @return JME modifier representation object
|
|
||||||
*/
|
|
||||||
public Object getJmeModifierRepresentation() {
|
|
||||||
return jmeModifierRepresentation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns additional data stored in the modifier.
|
|
||||||
*
|
|
||||||
* @return the additional data stored in the modifier
|
|
||||||
*/
|
|
||||||
public Object getAdditionalData() {
|
|
||||||
return additionalData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method applies the modifier to the given node.
|
* This method applies the modifier to the given node.
|
||||||
*
|
*
|
||||||
|
@ -3,12 +3,14 @@ package com.jme3.scene.plugins.blender.modifiers;
|
|||||||
import com.jme3.animation.Animation;
|
import com.jme3.animation.Animation;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.jme3.animation.Bone;
|
import com.jme3.animation.Bone;
|
||||||
import com.jme3.animation.BoneAnimation;
|
import com.jme3.animation.BoneAnimation;
|
||||||
import com.jme3.animation.BoneTrack;
|
import com.jme3.animation.BoneTrack;
|
||||||
import com.jme3.animation.Skeleton;
|
import com.jme3.animation.Skeleton;
|
||||||
import com.jme3.math.Transform;
|
import com.jme3.math.Transform;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.plugins.blender.DataRepository;
|
import com.jme3.scene.plugins.blender.DataRepository;
|
||||||
import com.jme3.scene.plugins.blender.animations.Ipo;
|
import com.jme3.scene.plugins.blender.animations.Ipo;
|
||||||
import com.jme3.scene.plugins.blender.animations.IpoHelper;
|
import com.jme3.scene.plugins.blender.animations.IpoHelper;
|
||||||
@ -24,7 +26,13 @@ import com.jme3.scene.plugins.ogre.AnimData;
|
|||||||
*
|
*
|
||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
/* package */class ObjectAnimationModifier extends ArmatureModifier {
|
/* package */class ObjectAnimationModifier extends Modifier {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(ObjectAnimationModifier.class.getName());
|
||||||
|
|
||||||
|
/** Loaded animation data. */
|
||||||
|
private AnimData animData;
|
||||||
|
/** Old memory address of the object structure that will have the modifier applied. */
|
||||||
|
private Long objectOMA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor reads animation of the object itself (without bones) and
|
* This constructor reads animation of the object itself (without bones) and
|
||||||
@ -44,8 +52,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
|
|||||||
* this exception is thrown when the blender file is somehow
|
* this exception is thrown when the blender file is somehow
|
||||||
* corrupted
|
* corrupted
|
||||||
*/
|
*/
|
||||||
public ObjectAnimationModifier(Structure objectStructure,
|
public ObjectAnimationModifier(Structure objectStructure, DataRepository dataRepository) throws BlenderFileException {
|
||||||
DataRepository dataRepository) throws BlenderFileException {
|
|
||||||
Pointer pIpo = (Pointer) objectStructure.getFieldValue("ipo");
|
Pointer pIpo = (Pointer) objectStructure.getFieldValue("ipo");
|
||||||
if (pIpo.isNotNull()) {
|
if (pIpo.isNotNull()) {
|
||||||
// check if there is an action name connected with this ipo
|
// check if there is an action name connected with this ipo
|
||||||
@ -54,13 +61,9 @@ import com.jme3.scene.plugins.ogre.AnimData;
|
|||||||
.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00));
|
.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00));
|
||||||
for (FileBlockHeader actionBlock : actionBlocks) {
|
for (FileBlockHeader actionBlock : actionBlocks) {
|
||||||
Structure action = actionBlock.getStructure(dataRepository);
|
Structure action = actionBlock.getStructure(dataRepository);
|
||||||
List<Structure> actionChannels = ((Structure) action
|
List<Structure> actionChannels = ((Structure) action.getFieldValue("chanbase")).evaluateListBase(dataRepository);
|
||||||
.getFieldValue("chanbase"))
|
if (actionChannels.size() == 1) {// object's animtion action has only one channel
|
||||||
.evaluateListBase(dataRepository);
|
Pointer pChannelIpo = (Pointer) actionChannels.get(0).getFieldValue("ipo");
|
||||||
if (actionChannels.size() == 1) {// object's animtion action has
|
|
||||||
// only one channel
|
|
||||||
Pointer pChannelIpo = (Pointer) actionChannels.get(0)
|
|
||||||
.getFieldValue("ipo");
|
|
||||||
if (pChannelIpo.equals(pIpo)) {
|
if (pChannelIpo.equals(pIpo)) {
|
||||||
objectAnimationName = action.getName();
|
objectAnimationName = action.getName();
|
||||||
break;
|
break;
|
||||||
@ -69,20 +72,15 @@ import com.jme3.scene.plugins.ogre.AnimData;
|
|||||||
}
|
}
|
||||||
|
|
||||||
String objectName = objectStructure.getName();
|
String objectName = objectStructure.getName();
|
||||||
if (objectAnimationName == null) {// set the object's animation name
|
if (objectAnimationName == null) {// set the object's animation name to object's name
|
||||||
// to object's name
|
|
||||||
objectAnimationName = objectName;
|
objectAnimationName = objectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
IpoHelper ipoHelper = dataRepository.getHelper(IpoHelper.class);
|
IpoHelper ipoHelper = dataRepository.getHelper(IpoHelper.class);
|
||||||
Structure ipoStructure = pIpo.fetchData(
|
Structure ipoStructure = pIpo.fetchData(dataRepository.getInputStream()).get(0);
|
||||||
dataRepository.getInputStream()).get(0);
|
|
||||||
Ipo ipo = ipoHelper.createIpo(ipoStructure, dataRepository);
|
Ipo ipo = ipoHelper.createIpo(ipoStructure, dataRepository);
|
||||||
int[] animationFrames = dataRepository.getBlenderKey()
|
int[] animationFrames = dataRepository.getBlenderKey().getAnimationFrames(objectName, objectAnimationName);
|
||||||
.getAnimationFrames(objectName, objectAnimationName);
|
if (animationFrames == null) {// if the name was created here there are no frames set for the animation
|
||||||
if (animationFrames == null) {// if the name was created here there
|
|
||||||
// are no frames set for the
|
|
||||||
// animation
|
|
||||||
animationFrames = new int[] { 1, ipo.getLastFrame() };
|
animationFrames = new int[] { 1, ipo.getLastFrame() };
|
||||||
}
|
}
|
||||||
int fps = dataRepository.getBlenderKey().getFps();
|
int fps = dataRepository.getBlenderKey().getFps();
|
||||||
@ -91,31 +89,30 @@ import com.jme3.scene.plugins.ogre.AnimData;
|
|||||||
|
|
||||||
// calculating track for the only bone in this skeleton
|
// calculating track for the only bone in this skeleton
|
||||||
BoneTrack[] tracks = new BoneTrack[1];
|
BoneTrack[] tracks = new BoneTrack[1];
|
||||||
tracks[0] = ipo.calculateTrack(0, animationFrames[0],
|
tracks[0] = ipo.calculateTrack(0, animationFrames[0], animationFrames[1], fps);
|
||||||
animationFrames[1], fps);
|
|
||||||
|
|
||||||
BoneAnimation boneAnimation = new BoneAnimation(
|
BoneAnimation boneAnimation = new BoneAnimation(objectAnimationName, stop - start);
|
||||||
objectAnimationName, stop - start);
|
|
||||||
boneAnimation.setTracks(tracks);
|
boneAnimation.setTracks(tracks);
|
||||||
ArrayList<Animation> animations = new ArrayList<Animation>(
|
ArrayList<Animation> animations = new ArrayList<Animation>(1);
|
||||||
1);
|
|
||||||
animations.add(boneAnimation);
|
animations.add(boneAnimation);
|
||||||
|
|
||||||
// preparing the object's bone
|
// preparing the object's bone
|
||||||
ObjectHelper objectHelper = dataRepository
|
ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class);
|
||||||
.getHelper(ObjectHelper.class);
|
Transform t = objectHelper.getTransformation(objectStructure, dataRepository);
|
||||||
Transform t = objectHelper.getTransformation(objectStructure,
|
|
||||||
dataRepository);
|
|
||||||
Bone bone = new Bone(null);
|
Bone bone = new Bone(null);
|
||||||
bone.setBindTransforms(t.getTranslation(), t.getRotation(),
|
bone.setBindTransforms(t.getTranslation(), t.getRotation(), t.getScale());
|
||||||
t.getScale());
|
|
||||||
|
|
||||||
jmeModifierRepresentation = new AnimData(new Skeleton(
|
animData = new AnimData(new Skeleton(new Bone[] { bone }), animations);
|
||||||
new Bone[] { bone }), animations);
|
objectOMA = objectStructure.getOldMemoryAddress();
|
||||||
additionalData = objectStructure.getOldMemoryAddress();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Node apply(Node node, DataRepository dataRepository) {
|
||||||
|
LOGGER.warning("Object animation modifier not yet implemented!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return Modifier.OBJECT_ANIMATION_MODIFIER_DATA;
|
return Modifier.OBJECT_ANIMATION_MODIFIER_DATA;
|
||||||
|
@ -24,6 +24,7 @@ import com.jme3.scene.plugins.blender.particles.ParticlesHelper;
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
/* package */class ParticlesModifier extends Modifier {
|
/* package */class ParticlesModifier extends Modifier {
|
||||||
|
private ParticleEmitter particleEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor reads the particles system structure and stores it in
|
* This constructor reads the particles system structure and stores it in
|
||||||
@ -41,32 +42,25 @@ import com.jme3.scene.plugins.blender.particles.ParticlesHelper;
|
|||||||
throws BlenderFileException {
|
throws BlenderFileException {
|
||||||
Pointer pParticleSystem = (Pointer) modifier.getFieldValue("psys");
|
Pointer pParticleSystem = (Pointer) modifier.getFieldValue("psys");
|
||||||
if (pParticleSystem.isNotNull()) {
|
if (pParticleSystem.isNotNull()) {
|
||||||
ParticlesHelper particlesHelper = dataRepository
|
ParticlesHelper particlesHelper = dataRepository.getHelper(ParticlesHelper.class);
|
||||||
.getHelper(ParticlesHelper.class);
|
Structure particleSystem = pParticleSystem.fetchData(dataRepository.getInputStream()).get(0);
|
||||||
Structure particleSystem = pParticleSystem.fetchData(
|
particleEmitter = particlesHelper.toParticleEmitter(particleSystem, dataRepository);
|
||||||
dataRepository.getInputStream()).get(0);
|
|
||||||
jmeModifierRepresentation = particlesHelper.toParticleEmitter(
|
|
||||||
particleSystem, dataRepository);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node apply(Node node, DataRepository dataRepository) {
|
public Node apply(Node node, DataRepository dataRepository) {
|
||||||
MaterialHelper materialHelper = dataRepository
|
MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class);
|
||||||
.getHelper(MaterialHelper.class);
|
ParticleEmitter emitter = particleEmitter.clone();
|
||||||
ParticleEmitter emitter = (ParticleEmitter) jmeModifierRepresentation;
|
|
||||||
emitter = emitter.clone();
|
|
||||||
|
|
||||||
// veryfying the alpha function for particles' texture
|
// veryfying the alpha function for particles' texture
|
||||||
Integer alphaFunction = MaterialHelper.ALPHA_MASK_HYPERBOLE;
|
Integer alphaFunction = MaterialHelper.ALPHA_MASK_HYPERBOLE;
|
||||||
char nameSuffix = emitter.getName().charAt(
|
char nameSuffix = emitter.getName().charAt(emitter.getName().length() - 1);
|
||||||
emitter.getName().length() - 1);
|
|
||||||
if (nameSuffix == 'B' || nameSuffix == 'N') {
|
if (nameSuffix == 'B' || nameSuffix == 'N') {
|
||||||
alphaFunction = MaterialHelper.ALPHA_MASK_NONE;
|
alphaFunction = MaterialHelper.ALPHA_MASK_NONE;
|
||||||
}
|
}
|
||||||
// removing the type suffix from the name
|
// removing the type suffix from the name
|
||||||
emitter.setName(emitter.getName().substring(0,
|
emitter.setName(emitter.getName().substring(0, emitter.getName().length() - 1));
|
||||||
emitter.getName().length() - 1));
|
|
||||||
|
|
||||||
// applying emitter shape
|
// applying emitter shape
|
||||||
EmitterShape emitterShape = emitter.getShape();
|
EmitterShape emitterShape = emitter.getShape();
|
||||||
@ -77,10 +71,8 @@ import com.jme3.scene.plugins.blender.particles.ParticlesHelper;
|
|||||||
if (mesh != null) {
|
if (mesh != null) {
|
||||||
meshes.add(mesh);
|
meshes.add(mesh);
|
||||||
Material material = materialHelper.getParticlesMaterial(
|
Material material = materialHelper.getParticlesMaterial(
|
||||||
((Geometry) spatial).getMaterial(), alphaFunction,
|
((Geometry) spatial).getMaterial(), alphaFunction, dataRepository);
|
||||||
dataRepository);
|
emitter.setMaterial(material);// TODO: divide into several pieces
|
||||||
emitter.setMaterial(material);// TODO: divide into several
|
|
||||||
// pieces
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user