|
|
@ -52,18 +52,19 @@ import com.jme3.scene.shape.Curve; |
|
|
|
* corrupted |
|
|
|
* corrupted |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
public ArrayModifier(Structure modifier, BlenderContext blenderContext) throws BlenderFileException { |
|
|
|
public ArrayModifier(Structure modifierStructure, BlenderContext blenderContext) throws BlenderFileException { |
|
|
|
Number fittype = (Number) modifier.getFieldValue("fit_type"); |
|
|
|
if(this.validate(modifierStructure, blenderContext)) { |
|
|
|
|
|
|
|
Number fittype = (Number) modifierStructure.getFieldValue("fit_type"); |
|
|
|
modifierData.put("fittype", fittype); |
|
|
|
modifierData.put("fittype", fittype); |
|
|
|
switch (fittype.intValue()) { |
|
|
|
switch (fittype.intValue()) { |
|
|
|
case 0:// FIXED COUNT
|
|
|
|
case 0:// FIXED COUNT
|
|
|
|
modifierData.put("count", modifier.getFieldValue("count")); |
|
|
|
modifierData.put("count", modifierStructure.getFieldValue("count")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1:// FIXED LENGTH
|
|
|
|
case 1:// FIXED LENGTH
|
|
|
|
modifierData.put("length", modifier.getFieldValue("length")); |
|
|
|
modifierData.put("length", modifierStructure.getFieldValue("length")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2:// FITCURVE
|
|
|
|
case 2:// FITCURVE
|
|
|
|
Pointer pCurveOb = (Pointer) modifier.getFieldValue("curve_ob"); |
|
|
|
Pointer pCurveOb = (Pointer) modifierStructure.getFieldValue("curve_ob"); |
|
|
|
float length = 0; |
|
|
|
float length = 0; |
|
|
|
if (pCurveOb.isNotNull()) { |
|
|
|
if (pCurveOb.isNotNull()) { |
|
|
|
Structure curveStructure = pCurveOb.fetchData(blenderContext.getInputStream()).get(0); |
|
|
|
Structure curveStructure = pCurveOb.fetchData(blenderContext.getInputStream()).get(0); |
|
|
@ -95,37 +96,42 @@ import com.jme3.scene.shape.Curve; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// offset parameters
|
|
|
|
// offset parameters
|
|
|
|
int offsettype = ((Number) modifier.getFieldValue("offset_type")).intValue(); |
|
|
|
int offsettype = ((Number) modifierStructure.getFieldValue("offset_type")).intValue(); |
|
|
|
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>) modifierStructure.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()}; |
|
|
|
modifierData.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>) modifierStructure.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()}; |
|
|
|
modifierData.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) modifierStructure.getFieldValue("offset_ob"); |
|
|
|
if (pOffsetObject.isNotNull()) { |
|
|
|
if (pOffsetObject.isNotNull()) { |
|
|
|
modifierData.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) modifierStructure.getFieldValue("start_cap"); |
|
|
|
if (pStartCap.isNotNull()) { |
|
|
|
if (pStartCap.isNotNull()) { |
|
|
|
modifierData.put("startcap", pStartCap); |
|
|
|
modifierData.put("startcap", pStartCap); |
|
|
|
} |
|
|
|
} |
|
|
|
Pointer pEndCap = (Pointer) modifier.getFieldValue("end_cap"); |
|
|
|
Pointer pEndCap = (Pointer) modifierStructure.getFieldValue("end_cap"); |
|
|
|
if (pEndCap.isNotNull()) { |
|
|
|
if (pEndCap.isNotNull()) { |
|
|
|
modifierData.put("endcap", pEndCap); |
|
|
|
modifierData.put("endcap", pEndCap); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Node apply(Node node, BlenderContext blenderContext) { |
|
|
|
public Node apply(Node node, BlenderContext blenderContext) { |
|
|
|
|
|
|
|
if(invalid) { |
|
|
|
|
|
|
|
LOGGER.log(Level.WARNING, "Array modifier is invalid! Cannot be applied to: {0}", node.getName()); |
|
|
|
|
|
|
|
return node; |
|
|
|
|
|
|
|
} |
|
|
|
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
|
|
|
|