Refactoring: improved the usage and flow of blender context and blender input stream (will make the unit tests implementation easier).
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10953 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
6708cf0d7f
commit
1fcd9526b2
@ -69,7 +69,7 @@ public abstract class AbstractBlenderHelper {
|
|||||||
public AbstractBlenderHelper(String blenderVersion, BlenderContext blenderContext) {
|
public AbstractBlenderHelper(String blenderVersion, BlenderContext blenderContext) {
|
||||||
this.blenderVersion = Integer.parseInt(blenderVersion);
|
this.blenderVersion = Integer.parseInt(blenderVersion);
|
||||||
this.blenderContext = blenderContext;
|
this.blenderContext = blenderContext;
|
||||||
this.fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis();
|
fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis();
|
||||||
if (fixUpAxis) {
|
if (fixUpAxis) {
|
||||||
upAxisRotationQuaternion = new Quaternion().fromAngles(-FastMath.HALF_PI, 0, 0);
|
upAxisRotationQuaternion = new Quaternion().fromAngles(-FastMath.HALF_PI, 0, 0);
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public abstract class AbstractBlenderHelper {
|
|||||||
if (id != null) {
|
if (id != null) {
|
||||||
Pointer pProperties = (Pointer) id.getFieldValue("properties");
|
Pointer pProperties = (Pointer) id.getFieldValue("properties");
|
||||||
if (pProperties.isNotNull()) {
|
if (pProperties.isNotNull()) {
|
||||||
Structure propertiesStructure = pProperties.fetchData(blenderContext.getInputStream()).get(0);
|
Structure propertiesStructure = pProperties.fetchData().get(0);
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
properties.load(propertiesStructure, blenderContext);
|
properties.load(propertiesStructure, blenderContext);
|
||||||
}
|
}
|
||||||
|
@ -183,11 +183,11 @@ public class BlenderLoader implements AssetLoader {
|
|||||||
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
||||||
Node result = new Node(structure.getName());
|
Node result = new Node(structure.getName());
|
||||||
try {
|
try {
|
||||||
List<Structure> base = ((Structure) structure.getFieldValue("base")).evaluateListBase(blenderContext);
|
List<Structure> base = ((Structure) structure.getFieldValue("base")).evaluateListBase();
|
||||||
for (Structure b : base) {
|
for (Structure b : base) {
|
||||||
Pointer pObject = (Pointer) b.getFieldValue("object");
|
Pointer pObject = (Pointer) b.getFieldValue("object");
|
||||||
if (pObject.isNotNull()) {
|
if (pObject.isNotNull()) {
|
||||||
Structure objectStructure = pObject.fetchData(blenderContext.getInputStream()).get(0);
|
Structure objectStructure = pObject.fetchData().get(0);
|
||||||
|
|
||||||
Object object = objectHelper.toObject(objectStructure, blenderContext);
|
Object object = objectHelper.toObject(objectStructure, blenderContext);
|
||||||
if (object instanceof LightNode) {
|
if (object instanceof LightNode) {
|
||||||
|
@ -109,11 +109,11 @@ public class ArmatureHelper extends AbstractBlenderHelper {
|
|||||||
* this exception is thrown when the blender file is somehow
|
* this exception is thrown when the blender file is somehow
|
||||||
* corrupted
|
* corrupted
|
||||||
*/
|
*/
|
||||||
public Map<Integer, Integer> getGroupToBoneIndexMap(Structure defBaseStructure, Skeleton skeleton, BlenderContext blenderContext) throws BlenderFileException {
|
public Map<Integer, Integer> getGroupToBoneIndexMap(Structure defBaseStructure, Skeleton skeleton) throws BlenderFileException {
|
||||||
Map<Integer, Integer> result = null;
|
Map<Integer, Integer> result = null;
|
||||||
if (skeleton.getBoneCount() != 0) {
|
if (skeleton.getBoneCount() != 0) {
|
||||||
result = new HashMap<Integer, Integer>();
|
result = new HashMap<Integer, Integer>();
|
||||||
List<Structure> deformGroups = defBaseStructure.evaluateListBase(blenderContext);// bDeformGroup
|
List<Structure> deformGroups = defBaseStructure.evaluateListBase();// bDeformGroup
|
||||||
int groupIndex = 0;
|
int groupIndex = 0;
|
||||||
for (Structure deformGroup : deformGroups) {
|
for (Structure deformGroup : deformGroups) {
|
||||||
String deformGroupName = deformGroup.getFieldValue("name").toString();
|
String deformGroupName = deformGroup.getFieldValue("name").toString();
|
||||||
@ -165,19 +165,19 @@ public class ArmatureHelper extends AbstractBlenderHelper {
|
|||||||
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
||||||
int fps = blenderContext.getBlenderKey().getFps();
|
int fps = blenderContext.getBlenderKey().getFps();
|
||||||
Structure groups = (Structure) actionStructure.getFieldValue("groups");
|
Structure groups = (Structure) actionStructure.getFieldValue("groups");
|
||||||
List<Structure> actionGroups = groups.evaluateListBase(blenderContext);// bActionGroup
|
List<Structure> actionGroups = groups.evaluateListBase();// bActionGroup
|
||||||
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
|
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
|
||||||
for (Structure actionGroup : actionGroups) {
|
for (Structure actionGroup : actionGroups) {
|
||||||
String name = actionGroup.getFieldValue("name").toString();
|
String name = actionGroup.getFieldValue("name").toString();
|
||||||
int boneIndex = skeleton.getBoneIndex(name);
|
int boneIndex = skeleton.getBoneIndex(name);
|
||||||
if (boneIndex >= 0) {
|
if (boneIndex >= 0) {
|
||||||
List<Structure> channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase(blenderContext);
|
List<Structure> channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase();
|
||||||
BezierCurve[] bezierCurves = new BezierCurve[channels.size()];
|
BezierCurve[] bezierCurves = new BezierCurve[channels.size()];
|
||||||
int channelCounter = 0;
|
int channelCounter = 0;
|
||||||
for (Structure c : channels) {
|
for (Structure c : channels) {
|
||||||
int type = ipoHelper.getCurveType(c, blenderContext);
|
int type = ipoHelper.getCurveType(c, blenderContext);
|
||||||
Pointer pBezTriple = (Pointer) c.getFieldValue("bezt");
|
Pointer pBezTriple = (Pointer) c.getFieldValue("bezt");
|
||||||
List<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream());
|
List<Structure> bezTriples = pBezTriple.fetchData();
|
||||||
bezierCurves[channelCounter++] = new BezierCurve(type, bezTriples, 2);
|
bezierCurves[channelCounter++] = new BezierCurve(type, bezTriples, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ public class ArmatureHelper extends AbstractBlenderHelper {
|
|||||||
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
||||||
int fps = blenderContext.getBlenderKey().getFps();
|
int fps = blenderContext.getBlenderKey().getFps();
|
||||||
Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase");
|
Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase");
|
||||||
List<Structure> actionChannels = chanbase.evaluateListBase(blenderContext);// bActionChannel
|
List<Structure> actionChannels = chanbase.evaluateListBase();// bActionChannel
|
||||||
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
|
List<BoneTrack> tracks = new ArrayList<BoneTrack>();
|
||||||
for (Structure bActionChannel : actionChannels) {
|
for (Structure bActionChannel : actionChannels) {
|
||||||
String name = bActionChannel.getFieldValue("name").toString();
|
String name = bActionChannel.getFieldValue("name").toString();
|
||||||
@ -216,7 +216,7 @@ public class ArmatureHelper extends AbstractBlenderHelper {
|
|||||||
if (boneIndex >= 0) {
|
if (boneIndex >= 0) {
|
||||||
Pointer p = (Pointer) bActionChannel.getFieldValue("ipo");
|
Pointer p = (Pointer) bActionChannel.getFieldValue("ipo");
|
||||||
if (!p.isNull()) {
|
if (!p.isNull()) {
|
||||||
Structure ipoStructure = p.fetchData(blenderContext.getInputStream()).get(0);
|
Structure ipoStructure = p.fetchData().get(0);
|
||||||
|
|
||||||
Bone bone = skeleton.getBone(boneIndex);
|
Bone bone = skeleton.getBone(boneIndex);
|
||||||
Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext);
|
Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext);
|
||||||
|
@ -110,7 +110,7 @@ public class BoneContext {
|
|||||||
globalBoneMatrix = armatureWorldMatrix.mult(globalBoneMatrix);
|
globalBoneMatrix = armatureWorldMatrix.mult(globalBoneMatrix);
|
||||||
|
|
||||||
// create the children
|
// create the children
|
||||||
List<Structure> childbase = ((Structure) boneStructure.getFieldValue("childbase")).evaluateListBase(blenderContext);
|
List<Structure> childbase = ((Structure) boneStructure.getFieldValue("childbase")).evaluateListBase();
|
||||||
for (Structure child : childbase) {
|
for (Structure child : childbase) {
|
||||||
children.add(new BoneContext(child, armatureObjectOMA, this, blenderContext));
|
children.add(new BoneContext(child, armatureObjectOMA, this, blenderContext));
|
||||||
}
|
}
|
||||||
|
@ -55,13 +55,13 @@ public class IpoHelper extends AbstractBlenderHelper {
|
|||||||
|
|
||||||
// preparing bezier curves
|
// preparing bezier curves
|
||||||
Ipo result = null;
|
Ipo result = null;
|
||||||
List<Structure> curves = curvebase.evaluateListBase(blenderContext);// IpoCurve
|
List<Structure> curves = curvebase.evaluateListBase();// IpoCurve
|
||||||
if (curves.size() > 0) {
|
if (curves.size() > 0) {
|
||||||
BezierCurve[] bezierCurves = new BezierCurve[curves.size()];
|
BezierCurve[] bezierCurves = new BezierCurve[curves.size()];
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
for (Structure curve : curves) {
|
for (Structure curve : curves) {
|
||||||
Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt");
|
Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt");
|
||||||
List<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream());
|
List<Structure> bezTriples = pBezTriple.fetchData();
|
||||||
int type = ((Number) curve.getFieldValue("adrcode")).intValue();
|
int type = ((Number) curve.getFieldValue("adrcode")).intValue();
|
||||||
bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2);
|
bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2);
|
||||||
}
|
}
|
||||||
@ -87,13 +87,13 @@ public class IpoHelper extends AbstractBlenderHelper {
|
|||||||
*/
|
*/
|
||||||
public Ipo fromAction(Structure actionStructure, BlenderContext blenderContext) throws BlenderFileException {
|
public Ipo fromAction(Structure actionStructure, BlenderContext blenderContext) throws BlenderFileException {
|
||||||
Ipo result = null;
|
Ipo result = null;
|
||||||
List<Structure> curves = ((Structure) actionStructure.getFieldValue("curves")).evaluateListBase(blenderContext);// FCurve
|
List<Structure> curves = ((Structure) actionStructure.getFieldValue("curves")).evaluateListBase();// FCurve
|
||||||
if (curves.size() > 0) {
|
if (curves.size() > 0) {
|
||||||
BezierCurve[] bezierCurves = new BezierCurve[curves.size()];
|
BezierCurve[] bezierCurves = new BezierCurve[curves.size()];
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
for (Structure curve : curves) {
|
for (Structure curve : curves) {
|
||||||
Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt");
|
Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt");
|
||||||
List<Structure> bezTriples = pBezTriple.fetchData(blenderContext.getInputStream());
|
List<Structure> bezTriples = pBezTriple.fetchData();
|
||||||
int type = this.getCurveType(curve, blenderContext);
|
int type = this.getCurveType(curve, blenderContext);
|
||||||
bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2);
|
bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public abstract class Constraint {
|
|||||||
name = constraintStructure.getFieldValue("name").toString();
|
name = constraintStructure.getFieldValue("name").toString();
|
||||||
Pointer pData = (Pointer) constraintStructure.getFieldValue("data");
|
Pointer pData = (Pointer) constraintStructure.getFieldValue("data");
|
||||||
if (pData.isNotNull()) {
|
if (pData.isNotNull()) {
|
||||||
Structure data = pData.fetchData(blenderContext.getInputStream()).get(0);
|
Structure data = pData.fetchData().get(0);
|
||||||
constraintDefinition = ConstraintDefinitionFactory.createConstraintDefinition(data, ownerOMA, blenderContext);
|
constraintDefinition = ConstraintDefinitionFactory.createConstraintDefinition(data, ownerOMA, blenderContext);
|
||||||
Pointer pTar = (Pointer) data.getFieldValue("tar");
|
Pointer pTar = (Pointer) data.getFieldValue("tar");
|
||||||
if (pTar != null && pTar.isNotNull()) {
|
if (pTar != null && pTar.isNotNull()) {
|
||||||
|
@ -67,19 +67,19 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
Map<String, Map<String, Ipo>> constraintsIpos = new HashMap<String, Map<String, Ipo>>();
|
Map<String, Map<String, Ipo>> constraintsIpos = new HashMap<String, Map<String, Ipo>>();
|
||||||
Pointer pActions = (Pointer) objectStructure.getFieldValue("action");
|
Pointer pActions = (Pointer) objectStructure.getFieldValue("action");
|
||||||
if (pActions.isNotNull()) {
|
if (pActions.isNotNull()) {
|
||||||
List<Structure> actions = pActions.fetchData(blenderContext.getInputStream());
|
List<Structure> actions = pActions.fetchData();
|
||||||
for (Structure action : actions) {
|
for (Structure action : actions) {
|
||||||
Structure chanbase = (Structure) action.getFieldValue("chanbase");
|
Structure chanbase = (Structure) action.getFieldValue("chanbase");
|
||||||
List<Structure> actionChannels = chanbase.evaluateListBase(blenderContext);
|
List<Structure> actionChannels = chanbase.evaluateListBase();
|
||||||
for (Structure actionChannel : actionChannels) {
|
for (Structure actionChannel : actionChannels) {
|
||||||
Map<String, Ipo> ipos = new HashMap<String, Ipo>();
|
Map<String, Ipo> ipos = new HashMap<String, Ipo>();
|
||||||
Structure constChannels = (Structure) actionChannel.getFieldValue("constraintChannels");
|
Structure constChannels = (Structure) actionChannel.getFieldValue("constraintChannels");
|
||||||
List<Structure> constraintChannels = constChannels.evaluateListBase(blenderContext);
|
List<Structure> constraintChannels = constChannels.evaluateListBase();
|
||||||
for (Structure constraintChannel : constraintChannels) {
|
for (Structure constraintChannel : constraintChannels) {
|
||||||
Pointer pIpo = (Pointer) constraintChannel.getFieldValue("ipo");
|
Pointer pIpo = (Pointer) constraintChannel.getFieldValue("ipo");
|
||||||
if (pIpo.isNotNull()) {
|
if (pIpo.isNotNull()) {
|
||||||
String constraintName = constraintChannel.getFieldValue("name").toString();
|
String constraintName = constraintChannel.getFieldValue("name").toString();
|
||||||
Ipo ipo = ipoHelper.fromIpoStructure(pIpo.fetchData(blenderContext.getInputStream()).get(0), blenderContext);
|
Ipo ipo = ipoHelper.fromIpoStructure(pIpo.fetchData().get(0), blenderContext);
|
||||||
ipos.put(constraintName, ipo);
|
ipos.put(constraintName, ipo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
// loading constraints connected with the object's bones
|
// loading constraints connected with the object's bones
|
||||||
Pointer pPose = (Pointer) objectStructure.getFieldValue("pose");
|
Pointer pPose = (Pointer) objectStructure.getFieldValue("pose");
|
||||||
if (pPose.isNotNull()) {
|
if (pPose.isNotNull()) {
|
||||||
List<Structure> poseChannels = ((Structure) pPose.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("chanbase")).evaluateListBase(blenderContext);
|
List<Structure> poseChannels = ((Structure) pPose.fetchData().get(0).getFieldValue("chanbase")).evaluateListBase();
|
||||||
for (Structure poseChannel : poseChannels) {
|
for (Structure poseChannel : poseChannels) {
|
||||||
List<Constraint> constraintsList = new ArrayList<Constraint>();
|
List<Constraint> constraintsList = new ArrayList<Constraint>();
|
||||||
Long boneOMA = Long.valueOf(((Pointer) poseChannel.getFieldValue("bone")).getOldMemoryAddress());
|
Long boneOMA = Long.valueOf(((Pointer) poseChannel.getFieldValue("bone")).getOldMemoryAddress());
|
||||||
@ -100,7 +100,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
// the name is read directly from structure because bone might
|
// the name is read directly from structure because bone might
|
||||||
// not yet be loaded
|
// not yet be loaded
|
||||||
String name = blenderContext.getFileBlock(boneOMA).getStructure(blenderContext).getFieldValue("name").toString();
|
String name = blenderContext.getFileBlock(boneOMA).getStructure(blenderContext).getFieldValue("name").toString();
|
||||||
List<Structure> constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase(blenderContext);
|
List<Structure> constraints = ((Structure) poseChannel.getFieldValue("constraints")).evaluateListBase();
|
||||||
for (Structure constraint : constraints) {
|
for (Structure constraint : constraints) {
|
||||||
String constraintName = constraint.getFieldValue("name").toString();
|
String constraintName = constraint.getFieldValue("name").toString();
|
||||||
Map<String, Ipo> ipoMap = constraintsIpos.get(name);
|
Map<String, Ipo> ipoMap = constraintsIpos.get(name);
|
||||||
@ -116,10 +116,10 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loading constraints connected with the object itself
|
// loading constraints connected with the object itself
|
||||||
List<Structure> constraints = ((Structure) objectStructure.getFieldValue("constraints")).evaluateListBase(blenderContext);
|
List<Structure> constraints = ((Structure) objectStructure.getFieldValue("constraints")).evaluateListBase();
|
||||||
if (constraints != null && constraints.size() > 0) {
|
if (constraints != null && constraints.size() > 0) {
|
||||||
Pointer pData = (Pointer) objectStructure.getFieldValue("data");
|
Pointer pData = (Pointer) objectStructure.getFieldValue("data");
|
||||||
String dataType = pData.isNotNull() ? pData.fetchData(blenderContext.getInputStream()).get(0).getType() : null;
|
String dataType = pData.isNotNull() ? pData.fetchData().get(0).getType() : null;
|
||||||
List<Constraint> constraintsList = new ArrayList<Constraint>(constraints.size());
|
List<Constraint> constraintsList = new ArrayList<Constraint>(constraints.size());
|
||||||
|
|
||||||
for (Structure constraint : constraints) {
|
for (Structure constraint : constraints) {
|
||||||
|
@ -119,7 +119,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reading nurbs (and sorting them by material)
|
// reading nurbs (and sorting them by material)
|
||||||
List<Structure> nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase(blenderContext);
|
List<Structure> nurbStructures = ((Structure) curveStructure.getFieldValue("nurb")).evaluateListBase();
|
||||||
Map<Number, List<Structure>> nurbs = new HashMap<Number, List<Structure>>();
|
Map<Number, List<Structure>> nurbs = new HashMap<Number, List<Structure>>();
|
||||||
for (Structure nurb : nurbStructures) {
|
for (Structure nurb : nurbStructures) {
|
||||||
Number matNumber = (Number) nurb.getFieldValue("mat_nr");
|
Number matNumber = (Number) nurb.getFieldValue("mat_nr");
|
||||||
@ -148,8 +148,8 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
List<Geometry> bevelObject = null;
|
List<Geometry> bevelObject = null;
|
||||||
Pointer pBevelObject = (Pointer) curveStructure.getFieldValue("bevobj");
|
Pointer pBevelObject = (Pointer) curveStructure.getFieldValue("bevobj");
|
||||||
if (pBevelObject.isNotNull()) {
|
if (pBevelObject.isNotNull()) {
|
||||||
Pointer pBevelStructure = (Pointer) pBevelObject.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("data");
|
Pointer pBevelStructure = (Pointer) pBevelObject.fetchData().get(0).getFieldValue("data");
|
||||||
Structure bevelStructure = pBevelStructure.fetchData(blenderContext.getInputStream()).get(0);
|
Structure bevelStructure = pBevelStructure.fetchData().get(0);
|
||||||
bevelObject = this.toCurve(bevelStructure, blenderContext);
|
bevelObject = this.toCurve(bevelStructure, blenderContext);
|
||||||
} else {
|
} else {
|
||||||
int bevResol = ((Number) curveStructure.getFieldValue("bevresol")).intValue();
|
int bevResol = ((Number) curveStructure.getFieldValue("bevresol")).intValue();
|
||||||
@ -205,9 +205,9 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
Spline taperObject = null;
|
Spline taperObject = null;
|
||||||
Pointer pTaperObject = (Pointer) curveStructure.getFieldValue("taperobj");
|
Pointer pTaperObject = (Pointer) curveStructure.getFieldValue("taperobj");
|
||||||
if (bevelObject != null && pTaperObject.isNotNull()) {
|
if (bevelObject != null && pTaperObject.isNotNull()) {
|
||||||
Pointer pTaperStructure = (Pointer) pTaperObject.fetchData(blenderContext.getInputStream()).get(0).getFieldValue("data");
|
Pointer pTaperStructure = (Pointer) pTaperObject.fetchData().get(0).getFieldValue("data");
|
||||||
Structure taperStructure = pTaperStructure.fetchData(blenderContext.getInputStream()).get(0);
|
Structure taperStructure = pTaperStructure.fetchData().get(0);
|
||||||
taperObject = this.loadTaperObject(taperStructure, blenderContext);
|
taperObject = this.loadTaperObject(taperStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f loc = this.getLoc(curveStructure);
|
Vector3f loc = this.getLoc(curveStructure);
|
||||||
@ -275,7 +275,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
boolean cyclic = (((Number) nurb.getFieldValue("flagu")).intValue() & 0x01) != 0;
|
boolean cyclic = (((Number) nurb.getFieldValue("flagu")).intValue() & 0x01) != 0;
|
||||||
|
|
||||||
// creating the curve object
|
// creating the curve object
|
||||||
BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(blenderContext.getInputStream()), 3);
|
BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(), 3);
|
||||||
List<Vector3f> controlPoints = bezierCurve.getControlPoints();
|
List<Vector3f> controlPoints = bezierCurve.getControlPoints();
|
||||||
if (fixUpAxis) {
|
if (fixUpAxis) {
|
||||||
for (Vector3f v : controlPoints) {
|
for (Vector3f v : controlPoints) {
|
||||||
@ -361,7 +361,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
// loading control points and their weights
|
// loading control points and their weights
|
||||||
int pntsU = ((Number) nurb.getFieldValue("pntsu")).intValue();
|
int pntsU = ((Number) nurb.getFieldValue("pntsu")).intValue();
|
||||||
int pntsV = ((Number) nurb.getFieldValue("pntsv")).intValue();
|
int pntsV = ((Number) nurb.getFieldValue("pntsv")).intValue();
|
||||||
List<Structure> bPoints = ((Pointer) nurb.getFieldValue("bp")).fetchData(blenderContext.getInputStream());
|
List<Structure> bPoints = ((Pointer) nurb.getFieldValue("bp")).fetchData();
|
||||||
List<List<Vector4f>> controlPoints = new ArrayList<List<Vector4f>>(pntsV);
|
List<List<Vector4f>> controlPoints = new ArrayList<List<Vector4f>>(pntsV);
|
||||||
for (int i = 0; i < pntsV; ++i) {
|
for (int i = 0; i < pntsV; ++i) {
|
||||||
List<Vector4f> uControlPoints = new ArrayList<Vector4f>(pntsU);
|
List<Vector4f> uControlPoints = new ArrayList<Vector4f>(pntsU);
|
||||||
@ -793,19 +793,17 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
*
|
*
|
||||||
* @param taperStructure
|
* @param taperStructure
|
||||||
* the taper structure
|
* the taper structure
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @return the taper object
|
* @return the taper object
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
*/
|
*/
|
||||||
protected Spline loadTaperObject(Structure taperStructure, BlenderContext blenderContext) throws BlenderFileException {
|
protected Spline loadTaperObject(Structure taperStructure) throws BlenderFileException {
|
||||||
// reading nurbs
|
// reading nurbs
|
||||||
List<Structure> nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase(blenderContext);
|
List<Structure> nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase();
|
||||||
for (Structure nurb : nurbStructures) {
|
for (Structure nurb : nurbStructures) {
|
||||||
Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt");
|
Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt");
|
||||||
if (pBezierTriple.isNotNull()) {
|
if (pBezierTriple.isNotNull()) {
|
||||||
// creating the curve object
|
// creating the curve object
|
||||||
BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(blenderContext.getInputStream()), 3);
|
BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(), 3);
|
||||||
List<Vector3f> controlPoints = bezierCurve.getControlPoints();
|
List<Vector3f> controlPoints = bezierCurve.getControlPoints();
|
||||||
// removing the first and last handles
|
// removing the first and last handles
|
||||||
controlPoints.remove(0);
|
controlPoints.remove(0);
|
||||||
|
@ -180,13 +180,13 @@ class Field implements Cloneable {
|
|||||||
case STRUCTURE:
|
case STRUCTURE:
|
||||||
if (dataToRead == 1) {
|
if (dataToRead == 1) {
|
||||||
Structure structure = blenderContext.getDnaBlockData().getStructure(type);
|
Structure structure = blenderContext.getDnaBlockData().getStructure(type);
|
||||||
structure.fill(blenderInputStream);
|
structure.fill(blenderContext.getInputStream());
|
||||||
value = structure;
|
value = structure;
|
||||||
} else {
|
} else {
|
||||||
Structure[] data = new Structure[dataToRead];
|
Structure[] data = new Structure[dataToRead];
|
||||||
for (int i = 0; i < dataToRead; ++i) {
|
for (int i = 0; i < dataToRead; ++i) {
|
||||||
Structure structure = blenderContext.getDnaBlockData().getStructure(type);
|
Structure structure = blenderContext.getDnaBlockData().getStructure(type);
|
||||||
structure.fill(blenderInputStream);
|
structure.fill(blenderContext.getInputStream());
|
||||||
data[i] = structure;
|
data[i] = structure;
|
||||||
}
|
}
|
||||||
value = new DynamicArray<Structure>(tableSizes, data);
|
value = new DynamicArray<Structure>(tableSizes, data);
|
||||||
|
@ -31,11 +31,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.scene.plugins.blender.file;
|
package com.jme3.scene.plugins.blender.file;
|
||||||
|
|
||||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jme3.scene.plugins.blender.BlenderContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that represents a pointer of any level that can be stored in the file.
|
* A class that represents a pointer of any level that can be stored in the file.
|
||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
@ -78,13 +78,11 @@ public class Pointer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method fetches the data stored under the given address.
|
* This method fetches the data stored under the given address.
|
||||||
* @param inputStream
|
|
||||||
* the stream we read data from
|
|
||||||
* @return the data read from the file
|
* @return the data read from the file
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* this exception is thrown when the blend file structure is somehow invalid or corrupted
|
* this exception is thrown when the blend file structure is somehow invalid or corrupted
|
||||||
*/
|
*/
|
||||||
public List<Structure> fetchData(BlenderInputStream inputStream) throws BlenderFileException {
|
public List<Structure> fetchData() throws BlenderFileException {
|
||||||
if (oldMemoryAddress == 0) {
|
if (oldMemoryAddress == 0) {
|
||||||
throw new NullPointerException("The pointer points to nothing!");
|
throw new NullPointerException("The pointer points to nothing!");
|
||||||
}
|
}
|
||||||
@ -93,18 +91,19 @@ public class Pointer {
|
|||||||
if (dataFileBlock == null) {
|
if (dataFileBlock == null) {
|
||||||
throw new BlenderFileException("No data stored for address: " + oldMemoryAddress + ". Make sure you did not open the newer blender file with older blender version.");
|
throw new BlenderFileException("No data stored for address: " + oldMemoryAddress + ". Make sure you did not open the newer blender file with older blender version.");
|
||||||
}
|
}
|
||||||
|
BlenderInputStream inputStream = blenderContext.getInputStream();
|
||||||
if (pointerLevel > 1) {
|
if (pointerLevel > 1) {
|
||||||
int pointersAmount = dataFileBlock.getSize() / inputStream.getPointerSize() * dataFileBlock.getCount();
|
int pointersAmount = dataFileBlock.getSize() / inputStream.getPointerSize() * dataFileBlock.getCount();
|
||||||
for (int i = 0; i < pointersAmount; ++i) {
|
for (int i = 0; i < pointersAmount; ++i) {
|
||||||
inputStream.setPosition(dataFileBlock.getBlockPosition() + inputStream.getPointerSize() * i);
|
inputStream.setPosition(dataFileBlock.getBlockPosition() + inputStream.getPointerSize() * i);
|
||||||
long oldMemoryAddress = inputStream.readPointer();
|
long oldMemoryAddress = inputStream.readPointer();
|
||||||
if (oldMemoryAddress != 0L) {
|
if (oldMemoryAddress != 0L) {
|
||||||
Pointer p = new Pointer(pointerLevel - 1, this.function, blenderContext);
|
Pointer p = new Pointer(pointerLevel - 1, function, blenderContext);
|
||||||
p.oldMemoryAddress = oldMemoryAddress;
|
p.oldMemoryAddress = oldMemoryAddress;
|
||||||
if (structures == null) {
|
if (structures == null) {
|
||||||
structures = p.fetchData(inputStream);
|
structures = p.fetchData();
|
||||||
} else {
|
} else {
|
||||||
structures.addAll(p.fetchData(inputStream));
|
structures.addAll(p.fetchData());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// it is necessary to put null's if the pointer is null, ie. in materials array that is attached to the mesh, the index
|
// it is necessary to put null's if the pointer is null, ie. in materials array that is attached to the mesh, the index
|
||||||
@ -120,7 +119,7 @@ public class Pointer {
|
|||||||
structures = new ArrayList<Structure>(dataFileBlock.getCount());
|
structures = new ArrayList<Structure>(dataFileBlock.getCount());
|
||||||
for (int i = 0; i < dataFileBlock.getCount(); ++i) {
|
for (int i = 0; i < dataFileBlock.getCount(); ++i) {
|
||||||
Structure structure = blenderContext.getDnaBlockData().getStructure(dataFileBlock.getSdnaIndex());
|
Structure structure = blenderContext.getDnaBlockData().getStructure(dataFileBlock.getSdnaIndex());
|
||||||
structure.fill(inputStream);
|
structure.fill(blenderContext.getInputStream());
|
||||||
structures.add(structure);
|
structures.add(structure);
|
||||||
}
|
}
|
||||||
return structures;
|
return structures;
|
||||||
|
@ -45,8 +45,6 @@ import com.jme3.scene.plugins.blender.BlenderContext;
|
|||||||
*/
|
*/
|
||||||
public class Structure implements Cloneable {
|
public class Structure implements Cloneable {
|
||||||
|
|
||||||
/** The blender context. */
|
|
||||||
private BlenderContext blenderContext;
|
|
||||||
/** The address of the block that fills the structure. */
|
/** The address of the block that fills the structure. */
|
||||||
private transient Long oldMemoryAddress;
|
private transient Long oldMemoryAddress;
|
||||||
/** The type of the structure. */
|
/** The type of the structure. */
|
||||||
@ -60,18 +58,15 @@ public class Structure implements Cloneable {
|
|||||||
* Constructor that copies the data of the structure.
|
* Constructor that copies the data of the structure.
|
||||||
* @param structure
|
* @param structure
|
||||||
* the structure to copy.
|
* the structure to copy.
|
||||||
* @param blenderContext
|
|
||||||
* the blender context of the structure
|
|
||||||
* @throws CloneNotSupportedException
|
* @throws CloneNotSupportedException
|
||||||
* this exception should never be thrown
|
* this exception should never be thrown
|
||||||
*/
|
*/
|
||||||
private Structure(Structure structure, BlenderContext blenderContext) throws CloneNotSupportedException {
|
private Structure(Structure structure) throws CloneNotSupportedException {
|
||||||
type = structure.type;
|
type = structure.type;
|
||||||
fields = new Field[structure.fields.length];
|
fields = new Field[structure.fields.length];
|
||||||
for (int i = 0; i < fields.length; ++i) {
|
for (int i = 0; i < fields.length; ++i) {
|
||||||
fields[i] = (Field) structure.fields[i].clone();
|
fields[i] = (Field) structure.fields[i].clone();
|
||||||
}
|
}
|
||||||
this.blenderContext = blenderContext;
|
|
||||||
oldMemoryAddress = structure.oldMemoryAddress;
|
oldMemoryAddress = structure.oldMemoryAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +86,6 @@ public class Structure implements Cloneable {
|
|||||||
public Structure(BlenderInputStream inputStream, String[] names, String[] types, BlenderContext blenderContext) throws BlenderFileException {
|
public Structure(BlenderInputStream inputStream, String[] names, String[] types, BlenderContext blenderContext) throws BlenderFileException {
|
||||||
int nameIndex = inputStream.readShort();
|
int nameIndex = inputStream.readShort();
|
||||||
type = types[nameIndex];
|
type = types[nameIndex];
|
||||||
this.blenderContext = blenderContext;
|
|
||||||
int fieldsAmount = inputStream.readShort();
|
int fieldsAmount = inputStream.readShort();
|
||||||
if (fieldsAmount < 0) {
|
if (fieldsAmount < 0) {
|
||||||
throw new BlenderFileException("The amount of fields of " + type + " structure cannot be negative!");
|
throw new BlenderFileException("The amount of fields of " + type + " structure cannot be negative!");
|
||||||
@ -165,15 +159,13 @@ public class Structure implements Cloneable {
|
|||||||
/**
|
/**
|
||||||
* This methos should be used on structures that are of a 'ListBase' type. It creates a List of structures that are
|
* This methos should be used on structures that are of a 'ListBase' type. It creates a List of structures that are
|
||||||
* held by this structure within the blend file.
|
* held by this structure within the blend file.
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @return a list of filled structures
|
* @return a list of filled structures
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* this exception is thrown when the blend file structure is somehow invalid or corrupted
|
* this exception is thrown when the blend file structure is somehow invalid or corrupted
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* this exception is thrown if the type of the structure is not 'ListBase'
|
* this exception is thrown if the type of the structure is not 'ListBase'
|
||||||
*/
|
*/
|
||||||
public List<Structure> evaluateListBase(BlenderContext blenderContext) throws BlenderFileException {
|
public List<Structure> evaluateListBase() throws BlenderFileException {
|
||||||
if (!"ListBase".equals(type)) {
|
if (!"ListBase".equals(type)) {
|
||||||
throw new IllegalStateException("This structure is not of type: 'ListBase'");
|
throw new IllegalStateException("This structure is not of type: 'ListBase'");
|
||||||
}
|
}
|
||||||
@ -184,7 +176,7 @@ public class Structure implements Cloneable {
|
|||||||
List<Structure> result = new LinkedList<Structure>();
|
List<Structure> result = new LinkedList<Structure>();
|
||||||
while (currentAddress != lastAddress) {
|
while (currentAddress != lastAddress) {
|
||||||
currentAddress = first.getOldMemoryAddress();
|
currentAddress = first.getOldMemoryAddress();
|
||||||
Structure structure = first.fetchData(blenderContext.getInputStream()).get(0);
|
Structure structure = first.fetchData().get(0);
|
||||||
result.add(structure);
|
result.add(structure);
|
||||||
first = (Pointer) structure.getFlatFieldValue("next");
|
first = (Pointer) structure.getFlatFieldValue("next");
|
||||||
}
|
}
|
||||||
@ -264,7 +256,7 @@ public class Structure implements Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
return new Structure(this, blenderContext);
|
return new Structure(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -241,7 +241,7 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
|||||||
Pointer ppMaterials = (Pointer) structureWithMaterials.getFieldValue("mat");
|
Pointer ppMaterials = (Pointer) structureWithMaterials.getFieldValue("mat");
|
||||||
MaterialContext[] materials = null;
|
MaterialContext[] materials = null;
|
||||||
if (ppMaterials.isNotNull()) {
|
if (ppMaterials.isNotNull()) {
|
||||||
List<Structure> materialStructures = ppMaterials.fetchData(blenderContext.getInputStream());
|
List<Structure> materialStructures = ppMaterials.fetchData();
|
||||||
if (materialStructures != null && materialStructures.size() > 0) {
|
if (materialStructures != null && materialStructures.size() > 0) {
|
||||||
MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class);
|
MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class);
|
||||||
materials = new MaterialContext[materialStructures.size()];
|
materials = new MaterialContext[materialStructures.size()];
|
||||||
|
@ -136,7 +136,7 @@ public class MeshHelper extends AbstractBlenderHelper {
|
|||||||
LOGGER.fine("Reading vertices groups (from the Object structure).");
|
LOGGER.fine("Reading vertices groups (from the Object structure).");
|
||||||
Structure parent = blenderContext.peekParent();
|
Structure parent = blenderContext.peekParent();
|
||||||
Structure defbase = (Structure) parent.getFieldValue("defbase");
|
Structure defbase = (Structure) parent.getFieldValue("defbase");
|
||||||
List<Structure> defs = defbase.evaluateListBase(blenderContext);
|
List<Structure> defs = defbase.evaluateListBase();
|
||||||
String[] verticesGroups = new String[defs.size()];
|
String[] verticesGroups = new String[defs.size()];
|
||||||
int defIndex = 0;
|
int defIndex = 0;
|
||||||
for (Structure def : defs) {
|
for (Structure def : defs) {
|
||||||
|
@ -76,9 +76,9 @@ import com.jme3.util.BufferUtils;
|
|||||||
MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class);
|
MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class);
|
||||||
|
|
||||||
if (meshHelper.isBMeshCompatible(structure)) {
|
if (meshHelper.isBMeshCompatible(structure)) {
|
||||||
this.readBMesh(structure, blenderContext);
|
this.readBMesh(structure);
|
||||||
} else {
|
} else {
|
||||||
this.readTraditionalFaces(structure, blenderContext);
|
this.readTraditionalFaces(structure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,22 +138,20 @@ import com.jme3.util.BufferUtils;
|
|||||||
*
|
*
|
||||||
* @param meshStructure
|
* @param meshStructure
|
||||||
* the mesh structure
|
* the mesh structure
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* an exception is thrown when there are problems with the
|
* an exception is thrown when there are problems with the
|
||||||
* blender file
|
* blender file
|
||||||
*/
|
*/
|
||||||
private void readBMesh(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException {
|
private void readBMesh(Structure meshStructure) throws BlenderFileException {
|
||||||
LOGGER.fine("Reading BMesh.");
|
LOGGER.fine("Reading BMesh.");
|
||||||
Pointer pMLoop = (Pointer) meshStructure.getFieldValue("mloop");
|
Pointer pMLoop = (Pointer) meshStructure.getFieldValue("mloop");
|
||||||
Pointer pMPoly = (Pointer) meshStructure.getFieldValue("mpoly");
|
Pointer pMPoly = (Pointer) meshStructure.getFieldValue("mpoly");
|
||||||
Map<String, Vector2f[]> uvCoordinatesForFace = new HashMap<String, Vector2f[]>();
|
Map<String, Vector2f[]> uvCoordinatesForFace = new HashMap<String, Vector2f[]>();
|
||||||
|
|
||||||
if (pMPoly.isNotNull() && pMLoop.isNotNull()) {
|
if (pMPoly.isNotNull() && pMLoop.isNotNull()) {
|
||||||
Map<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, true, blenderContext);
|
Map<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, true);
|
||||||
List<Structure> polys = pMPoly.fetchData(blenderContext.getInputStream());
|
List<Structure> polys = pMPoly.fetchData();
|
||||||
List<Structure> loops = pMLoop.fetchData(blenderContext.getInputStream());
|
List<Structure> loops = pMLoop.fetchData();
|
||||||
int[] vertexColorIndex = verticesColors == null ? null : new int[3];
|
int[] vertexColorIndex = verticesColors == null ? null : new int[3];
|
||||||
for (Structure poly : polys) {
|
for (Structure poly : polys) {
|
||||||
int materialNumber = ((Number) poly.getFieldValue("mat_nr")).intValue();
|
int materialNumber = ((Number) poly.getFieldValue("mat_nr")).intValue();
|
||||||
@ -202,19 +200,17 @@ import com.jme3.util.BufferUtils;
|
|||||||
*
|
*
|
||||||
* @param meshStructure
|
* @param meshStructure
|
||||||
* the mesh structure
|
* the mesh structure
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* an exception is thrown when there are problems with the
|
* an exception is thrown when there are problems with the
|
||||||
* blender file
|
* blender file
|
||||||
*/
|
*/
|
||||||
private void readTraditionalFaces(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException {
|
private void readTraditionalFaces(Structure meshStructure) throws BlenderFileException {
|
||||||
LOGGER.fine("Reading traditional faces.");
|
LOGGER.fine("Reading traditional faces.");
|
||||||
Pointer pMFace = (Pointer) meshStructure.getFieldValue("mface");
|
Pointer pMFace = (Pointer) meshStructure.getFieldValue("mface");
|
||||||
List<Structure> mFaces = pMFace.isNotNull() ? pMFace.fetchData(blenderContext.getInputStream()) : null;
|
List<Structure> mFaces = pMFace.isNotNull() ? pMFace.fetchData() : null;
|
||||||
if (mFaces != null && mFaces.size() > 0) {
|
if (mFaces != null && mFaces.size() > 0) {
|
||||||
// indicates if the material with the specified number should have a texture attached
|
// indicates if the material with the specified number should have a texture attached
|
||||||
Map<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, false, blenderContext);
|
Map<String, List<Vector2f>> uvs = this.loadUVCoordinates(meshStructure, false);
|
||||||
Map<String, Vector2f[]> uvCoordinatesForFace = new HashMap<String, Vector2f[]>();
|
Map<String, Vector2f[]> uvCoordinatesForFace = new HashMap<String, Vector2f[]>();
|
||||||
int[] vertexColorIndex = verticesColors == null ? null : new int[3];
|
int[] vertexColorIndex = verticesColors == null ? null : new int[3];
|
||||||
for (int i = 0; i < mFaces.size(); ++i) {
|
for (int i = 0; i < mFaces.size(); ++i) {
|
||||||
@ -406,25 +402,23 @@ import com.jme3.util.BufferUtils;
|
|||||||
* the mesh structure
|
* the mesh structure
|
||||||
* @param useBMesh
|
* @param useBMesh
|
||||||
* tells if we should load the coordinates from loops of from faces
|
* tells if we should load the coordinates from loops of from faces
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @return a map that sorts UV coordinates between different UV sets
|
* @return a map that sorts UV coordinates between different UV sets
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* an exception is thrown when problems with blend file occur
|
* an exception is thrown when problems with blend file occur
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, List<Vector2f>> loadUVCoordinates(Structure meshStructure, boolean useBMesh, BlenderContext blenderContext) throws BlenderFileException {
|
private Map<String, List<Vector2f>> loadUVCoordinates(Structure meshStructure, boolean useBMesh) throws BlenderFileException {
|
||||||
Map<String, List<Vector2f>> result = new HashMap<String, List<Vector2f>>();
|
Map<String, List<Vector2f>> result = new HashMap<String, List<Vector2f>>();
|
||||||
if (useBMesh) {
|
if (useBMesh) {
|
||||||
// in this case the UV's are assigned to vertices (an array is the same length as the vertex array)
|
// in this case the UV's are assigned to vertices (an array is the same length as the vertex array)
|
||||||
Structure loopData = (Structure) meshStructure.getFieldValue("ldata");
|
Structure loopData = (Structure) meshStructure.getFieldValue("ldata");
|
||||||
Pointer pLoopDataLayers = (Pointer) loopData.getFieldValue("layers");
|
Pointer pLoopDataLayers = (Pointer) loopData.getFieldValue("layers");
|
||||||
List<Structure> loopDataLayers = pLoopDataLayers.fetchData(blenderContext.getInputStream());
|
List<Structure> loopDataLayers = pLoopDataLayers.fetchData();
|
||||||
for (Structure structure : loopDataLayers) {
|
for (Structure structure : loopDataLayers) {
|
||||||
Pointer p = (Pointer) structure.getFieldValue("data");
|
Pointer p = (Pointer) structure.getFieldValue("data");
|
||||||
if (p.isNotNull() && ((Number) structure.getFieldValue("type")).intValue() == MeshHelper.UV_DATA_LAYER_TYPE_BMESH) {
|
if (p.isNotNull() && ((Number) structure.getFieldValue("type")).intValue() == MeshHelper.UV_DATA_LAYER_TYPE_BMESH) {
|
||||||
String uvSetName = structure.getFieldValue("name").toString();
|
String uvSetName = structure.getFieldValue("name").toString();
|
||||||
List<Structure> uvsStructures = p.fetchData(blenderContext.getInputStream());
|
List<Structure> uvsStructures = p.fetchData();
|
||||||
List<Vector2f> uvs = new ArrayList<Vector2f>(uvsStructures.size());
|
List<Vector2f> uvs = new ArrayList<Vector2f>(uvsStructures.size());
|
||||||
for (Structure uvStructure : uvsStructures) {
|
for (Structure uvStructure : uvsStructures) {
|
||||||
DynamicArray<Number> loopUVS = (DynamicArray<Number>) uvStructure.getFieldValue("uv");
|
DynamicArray<Number> loopUVS = (DynamicArray<Number>) uvStructure.getFieldValue("uv");
|
||||||
@ -437,12 +431,12 @@ import com.jme3.util.BufferUtils;
|
|||||||
// in this case UV's are assigned to faces (the array has the same legnth as the faces count)
|
// in this case UV's are assigned to faces (the array has the same legnth as the faces count)
|
||||||
Structure facesData = (Structure) meshStructure.getFieldValue("fdata");
|
Structure facesData = (Structure) meshStructure.getFieldValue("fdata");
|
||||||
Pointer pFacesDataLayers = (Pointer) facesData.getFieldValue("layers");
|
Pointer pFacesDataLayers = (Pointer) facesData.getFieldValue("layers");
|
||||||
List<Structure> facesDataLayers = pFacesDataLayers.fetchData(blenderContext.getInputStream());
|
List<Structure> facesDataLayers = pFacesDataLayers.fetchData();
|
||||||
for (Structure structure : facesDataLayers) {
|
for (Structure structure : facesDataLayers) {
|
||||||
Pointer p = (Pointer) structure.getFieldValue("data");
|
Pointer p = (Pointer) structure.getFieldValue("data");
|
||||||
if (p.isNotNull() && ((Number) structure.getFieldValue("type")).intValue() == MeshHelper.UV_DATA_LAYER_TYPE_FMESH) {
|
if (p.isNotNull() && ((Number) structure.getFieldValue("type")).intValue() == MeshHelper.UV_DATA_LAYER_TYPE_FMESH) {
|
||||||
String uvSetName = structure.getFieldValue("name").toString();
|
String uvSetName = structure.getFieldValue("name").toString();
|
||||||
List<Structure> uvsStructures = p.fetchData(blenderContext.getInputStream());
|
List<Structure> uvsStructures = p.fetchData();
|
||||||
List<Vector2f> uvs = new ArrayList<Vector2f>(uvsStructures.size());
|
List<Vector2f> uvs = new ArrayList<Vector2f>(uvsStructures.size());
|
||||||
for (Structure uvStructure : uvsStructures) {
|
for (Structure uvStructure : uvsStructures) {
|
||||||
DynamicArray<Number> mFaceUVs = (DynamicArray<Number>) uvStructure.getFieldValue("uv");
|
DynamicArray<Number> mFaceUVs = (DynamicArray<Number>) uvStructure.getFieldValue("uv");
|
||||||
@ -477,7 +471,7 @@ import com.jme3.util.BufferUtils;
|
|||||||
// so we need to put them right
|
// so we need to put them right
|
||||||
boolean useBGRA = blenderContext.getBlenderVersion() < 263;
|
boolean useBGRA = blenderContext.getBlenderVersion() < 263;
|
||||||
if (pMCol.isNotNull()) {
|
if (pMCol.isNotNull()) {
|
||||||
List<Structure> mCol = pMCol.fetchData(blenderContext.getInputStream());
|
List<Structure> mCol = pMCol.fetchData();
|
||||||
verticesColors = new ArrayList<byte[]>(mCol.size());
|
verticesColors = new ArrayList<byte[]>(mCol.size());
|
||||||
for (Structure color : mCol) {
|
for (Structure color : mCol) {
|
||||||
byte r = ((Number) color.getFieldValue("r")).byteValue();
|
byte r = ((Number) color.getFieldValue("r")).byteValue();
|
||||||
|
@ -13,7 +13,6 @@ import com.jme3.scene.VertexBuffer;
|
|||||||
import com.jme3.scene.VertexBuffer.Format;
|
import com.jme3.scene.VertexBuffer.Format;
|
||||||
import com.jme3.scene.VertexBuffer.Type;
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
import com.jme3.scene.VertexBuffer.Usage;
|
import com.jme3.scene.VertexBuffer.Usage;
|
||||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
|
||||||
import com.jme3.scene.plugins.blender.file.BlenderFileException;
|
import com.jme3.scene.plugins.blender.file.BlenderFileException;
|
||||||
import com.jme3.scene.plugins.blender.file.Pointer;
|
import com.jme3.scene.plugins.blender.file.Pointer;
|
||||||
import com.jme3.scene.plugins.blender.file.Structure;
|
import com.jme3.scene.plugins.blender.file.Structure;
|
||||||
@ -58,17 +57,15 @@ import com.jme3.util.BufferUtils;
|
|||||||
* The method reads the mesh. It loads only edges that are marked as not belonging to any face in their flag field.
|
* The method reads the mesh. It loads only edges that are marked as not belonging to any face in their flag field.
|
||||||
* @param meshStructure
|
* @param meshStructure
|
||||||
* the mesh structure
|
* the mesh structure
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* an exception thrown when reading from the blend file fails
|
* an exception thrown when reading from the blend file fails
|
||||||
*/
|
*/
|
||||||
public void readMesh(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException {
|
public void readMesh(Structure meshStructure) throws BlenderFileException {
|
||||||
LOGGER.fine("Reading line mesh.");
|
LOGGER.fine("Reading line mesh.");
|
||||||
Pointer pMEdge = (Pointer) meshStructure.getFieldValue("medge");
|
Pointer pMEdge = (Pointer) meshStructure.getFieldValue("medge");
|
||||||
|
|
||||||
if (pMEdge.isNotNull()) {
|
if (pMEdge.isNotNull()) {
|
||||||
List<Structure> edges = pMEdge.fetchData(blenderContext.getInputStream());
|
List<Structure> edges = pMEdge.fetchData();
|
||||||
int vertexIndex = 0;//vertex index in the result mesh
|
int vertexIndex = 0;//vertex index in the result mesh
|
||||||
for (Structure edge : edges) {
|
for (Structure edge : edges) {
|
||||||
int flag = ((Number) edge.getFieldValue("flag")).intValue();
|
int flag = ((Number) edge.getFieldValue("flag")).intValue();
|
||||||
|
@ -30,14 +30,14 @@ public class MeshBuilder {
|
|||||||
|
|
||||||
public MeshBuilder(Structure meshStructure, MaterialContext[] materials, BlenderContext blenderContext) throws BlenderFileException {
|
public MeshBuilder(Structure meshStructure, MaterialContext[] materials, BlenderContext blenderContext) throws BlenderFileException {
|
||||||
fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis();
|
fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis();
|
||||||
Vector3f[][] verticesAndNormals = this.getVerticesAndNormals(meshStructure, blenderContext);
|
Vector3f[][] verticesAndNormals = this.getVerticesAndNormals(meshStructure);
|
||||||
|
|
||||||
faceMeshBuilder = new FaceMeshBuilder(verticesAndNormals, this.areGeneratedTexturesPresent(materials));
|
faceMeshBuilder = new FaceMeshBuilder(verticesAndNormals, this.areGeneratedTexturesPresent(materials));
|
||||||
faceMeshBuilder.readMesh(meshStructure, blenderContext);
|
faceMeshBuilder.readMesh(meshStructure, blenderContext);
|
||||||
lineMeshBuilder = new LineMeshBuilder(verticesAndNormals);
|
lineMeshBuilder = new LineMeshBuilder(verticesAndNormals);
|
||||||
lineMeshBuilder.readMesh(meshStructure, blenderContext);
|
lineMeshBuilder.readMesh(meshStructure);
|
||||||
pointMeshBuilder = new PointMeshBuilder(verticesAndNormals);
|
pointMeshBuilder = new PointMeshBuilder(verticesAndNormals);
|
||||||
pointMeshBuilder.readMesh(meshStructure, blenderContext);
|
pointMeshBuilder.readMesh(meshStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, List<Mesh>> buildMeshes() {
|
public Map<Integer, List<Mesh>> buildMeshes() {
|
||||||
@ -111,14 +111,12 @@ public class MeshBuilder {
|
|||||||
*
|
*
|
||||||
* @param meshStructure
|
* @param meshStructure
|
||||||
* the structure containing the mesh data
|
* the structure containing the mesh data
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @return a list of two - element arrays, the first element is the vertex and the second - its normal
|
* @return a list of two - element arrays, the first element is the vertex and the second - its normal
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* this exception is thrown when the blend file structure is somehow invalid or corrupted
|
* this exception is thrown when the blend file structure is somehow invalid or corrupted
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Vector3f[][] getVerticesAndNormals(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException {
|
private Vector3f[][] getVerticesAndNormals(Structure meshStructure) throws BlenderFileException {
|
||||||
int count = ((Number) meshStructure.getFieldValue("totvert")).intValue();
|
int count = ((Number) meshStructure.getFieldValue("totvert")).intValue();
|
||||||
Vector3f[][] result = new Vector3f[count][2];
|
Vector3f[][] result = new Vector3f[count][2];
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
@ -126,7 +124,7 @@ public class MeshBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pointer pMVert = (Pointer) meshStructure.getFieldValue("mvert");
|
Pointer pMVert = (Pointer) meshStructure.getFieldValue("mvert");
|
||||||
List<Structure> mVerts = pMVert.fetchData(blenderContext.getInputStream());
|
List<Structure> mVerts = pMVert.fetchData();
|
||||||
if (fixUpAxis) {
|
if (fixUpAxis) {
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
DynamicArray<Number> coordinates = (DynamicArray<Number>) mVerts.get(i).getFieldValue("co");
|
DynamicArray<Number> coordinates = (DynamicArray<Number>) mVerts.get(i).getFieldValue("co");
|
||||||
|
@ -15,7 +15,6 @@ import com.jme3.scene.VertexBuffer;
|
|||||||
import com.jme3.scene.VertexBuffer.Format;
|
import com.jme3.scene.VertexBuffer.Format;
|
||||||
import com.jme3.scene.VertexBuffer.Type;
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
import com.jme3.scene.VertexBuffer.Usage;
|
import com.jme3.scene.VertexBuffer.Usage;
|
||||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
|
||||||
import com.jme3.scene.plugins.blender.file.BlenderFileException;
|
import com.jme3.scene.plugins.blender.file.BlenderFileException;
|
||||||
import com.jme3.scene.plugins.blender.file.Pointer;
|
import com.jme3.scene.plugins.blender.file.Pointer;
|
||||||
import com.jme3.scene.plugins.blender.file.Structure;
|
import com.jme3.scene.plugins.blender.file.Structure;
|
||||||
@ -59,19 +58,17 @@ import com.jme3.util.BufferUtils;
|
|||||||
* anywhere or not, we need to check all vertices and use here only those that are not used.
|
* anywhere or not, we need to check all vertices and use here only those that are not used.
|
||||||
* @param meshStructure
|
* @param meshStructure
|
||||||
* the mesh structure
|
* the mesh structure
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* an exception thrown when reading from the blend file fails
|
* an exception thrown when reading from the blend file fails
|
||||||
*/
|
*/
|
||||||
public void readMesh(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException {
|
public void readMesh(Structure meshStructure) throws BlenderFileException {
|
||||||
LOGGER.fine("Reading points mesh.");
|
LOGGER.fine("Reading points mesh.");
|
||||||
Pointer pMEdge = (Pointer) meshStructure.getFieldValue("medge");
|
Pointer pMEdge = (Pointer) meshStructure.getFieldValue("medge");
|
||||||
|
|
||||||
if (pMEdge.isNotNull()) {
|
if (pMEdge.isNotNull()) {
|
||||||
int count = ((Number) meshStructure.getFieldValue("totvert")).intValue();
|
int count = ((Number) meshStructure.getFieldValue("totvert")).intValue();
|
||||||
Set<Vector3f> usedVertices = new HashSet<Vector3f>(count);
|
Set<Vector3f> usedVertices = new HashSet<Vector3f>(count);
|
||||||
List<Structure> edges = pMEdge.fetchData(blenderContext.getInputStream());
|
List<Structure> edges = pMEdge.fetchData();
|
||||||
|
|
||||||
for (Structure edge : edges) {
|
for (Structure edge : edges) {
|
||||||
int v1 = ((Number) edge.getFieldValue("v1")).intValue();
|
int v1 = ((Number) edge.getFieldValue("v1")).intValue();
|
||||||
|
@ -76,17 +76,17 @@ import com.jme3.util.TempVars;
|
|||||||
* corrupted
|
* corrupted
|
||||||
*/
|
*/
|
||||||
public ArmatureModifier(Structure objectStructure, Structure modifierStructure, BlenderContext blenderContext) throws BlenderFileException {
|
public ArmatureModifier(Structure objectStructure, Structure modifierStructure, BlenderContext blenderContext) throws BlenderFileException {
|
||||||
Structure meshStructure = ((Pointer) objectStructure.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0);
|
Structure meshStructure = ((Pointer) objectStructure.getFieldValue("data")).fetchData().get(0);
|
||||||
if (this.validate(modifierStructure, blenderContext)) {
|
if (this.validate(modifierStructure, blenderContext)) {
|
||||||
Pointer pArmatureObject = (Pointer) modifierStructure.getFieldValue("object");
|
Pointer pArmatureObject = (Pointer) modifierStructure.getFieldValue("object");
|
||||||
if (pArmatureObject.isNotNull()) {
|
if (pArmatureObject.isNotNull()) {
|
||||||
ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
|
ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
|
||||||
|
|
||||||
armatureObject = pArmatureObject.fetchData(blenderContext.getInputStream()).get(0);
|
armatureObject = pArmatureObject.fetchData().get(0);
|
||||||
|
|
||||||
// load skeleton
|
// load skeleton
|
||||||
Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0);
|
Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData().get(0);
|
||||||
List<Structure> bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase(blenderContext);
|
List<Structure> bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase();
|
||||||
List<Bone> bonesList = new ArrayList<Bone>();
|
List<Bone> bonesList = new ArrayList<Bone>();
|
||||||
for (int i = 0; i < bonebase.size(); ++i) {
|
for (int i = 0; i < bonebase.size(); ++i) {
|
||||||
armatureHelper.buildBones(armatureObject.getOldMemoryAddress(), bonebase.get(i), null, bonesList, objectStructure.getOldMemoryAddress(), blenderContext);
|
armatureHelper.buildBones(armatureObject.getOldMemoryAddress(), bonebase.get(i), null, bonesList, objectStructure.getOldMemoryAddress(), blenderContext);
|
||||||
@ -130,7 +130,7 @@ import com.jme3.util.TempVars;
|
|||||||
// fetching action defined in object
|
// fetching action defined in object
|
||||||
Pointer pAction = (Pointer) objectStructure.getFieldValue("action");
|
Pointer pAction = (Pointer) objectStructure.getFieldValue("action");
|
||||||
if (pAction.isNotNull()) {
|
if (pAction.isNotNull()) {
|
||||||
Structure actionStructure = pAction.fetchData(blenderContext.getInputStream()).get(0);
|
Structure actionStructure = pAction.fetchData().get(0);
|
||||||
String actionName = actionStructure.getName();
|
String actionName = actionStructure.getName();
|
||||||
|
|
||||||
BoneTrack[] tracks = armatureHelper.getTracks(actionStructure, skeleton, blenderContext);
|
BoneTrack[] tracks = armatureHelper.getTracks(actionStructure, skeleton, blenderContext);
|
||||||
@ -235,9 +235,9 @@ import com.jme3.util.TempVars;
|
|||||||
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
||||||
ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class);
|
ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class);
|
||||||
|
|
||||||
Structure pose = pPose.fetchData(blenderContext.getInputStream()).get(0);
|
Structure pose = pPose.fetchData().get(0);
|
||||||
Structure chanbase = (Structure) pose.getFieldValue("chanbase");
|
Structure chanbase = (Structure) pose.getFieldValue("chanbase");
|
||||||
List<Structure> chans = chanbase.evaluateListBase(blenderContext);
|
List<Structure> chans = chanbase.evaluateListBase();
|
||||||
Transform transform = new Transform();
|
Transform transform = new Transform();
|
||||||
for (Structure poseChannel : chans) {
|
for (Structure poseChannel : chans) {
|
||||||
Pointer pBone = (Pointer) poseChannel.getFieldValue("bone");
|
Pointer pBone = (Pointer) poseChannel.getFieldValue("bone");
|
||||||
@ -290,11 +290,11 @@ import com.jme3.util.TempVars;
|
|||||||
private VertexBuffer[] readVerticesWeightsData(Structure objectStructure, Structure meshStructure, Skeleton skeleton, int materialIndex, int[] bonesGroups, BlenderContext blenderContext) throws BlenderFileException {
|
private VertexBuffer[] readVerticesWeightsData(Structure objectStructure, Structure meshStructure, Skeleton skeleton, int materialIndex, int[] bonesGroups, BlenderContext blenderContext) throws BlenderFileException {
|
||||||
ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
|
ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
|
||||||
Structure defBase = (Structure) objectStructure.getFieldValue("defbase");
|
Structure defBase = (Structure) objectStructure.getFieldValue("defbase");
|
||||||
Map<Integer, Integer> groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, skeleton, blenderContext);
|
Map<Integer, Integer> groupToBoneIndexMap = armatureHelper.getGroupToBoneIndexMap(defBase, skeleton);
|
||||||
|
|
||||||
MeshContext meshContext = blenderContext.getMeshContext(meshStructure.getOldMemoryAddress());
|
MeshContext meshContext = blenderContext.getMeshContext(meshStructure.getOldMemoryAddress());
|
||||||
|
|
||||||
return this.getBoneWeightAndIndexBuffer(meshStructure, meshContext.getVertexCount(materialIndex), bonesGroups, meshContext.getVertexReferenceMap(materialIndex), groupToBoneIndexMap, blenderContext);
|
return this.getBoneWeightAndIndexBuffer(meshStructure, meshContext.getVertexCount(materialIndex), bonesGroups, meshContext.getVertexReferenceMap(materialIndex), groupToBoneIndexMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,15 +318,13 @@ import com.jme3.util.TempVars;
|
|||||||
* @param groupToBoneIndexMap
|
* @param groupToBoneIndexMap
|
||||||
* this object maps the group index (to which a vertices in
|
* this object maps the group index (to which a vertices in
|
||||||
* blender belong) to bone index of the model
|
* blender belong) to bone index of the model
|
||||||
* @param blenderContext
|
|
||||||
* the blender context
|
|
||||||
* @return arrays of vertices weights and their bone indices and (as an
|
* @return arrays of vertices weights and their bone indices and (as an
|
||||||
* output parameter) the maximum amount of weights for a vertex
|
* output parameter) the maximum amount of weights for a vertex
|
||||||
* @throws BlenderFileException
|
* @throws BlenderFileException
|
||||||
* this exception is thrown when the blend file structure is
|
* this exception is thrown when the blend file structure is
|
||||||
* somehow invalid or corrupted
|
* somehow invalid or corrupted
|
||||||
*/
|
*/
|
||||||
private VertexBuffer[] getBoneWeightAndIndexBuffer(Structure meshStructure, int vertexListSize, int[] bonesGroups, Map<Integer, List<Integer>> vertexReferenceMap, Map<Integer, Integer> groupToBoneIndexMap, BlenderContext blenderContext) throws BlenderFileException {
|
private VertexBuffer[] getBoneWeightAndIndexBuffer(Structure meshStructure, int vertexListSize, int[] bonesGroups, Map<Integer, List<Integer>> vertexReferenceMap, Map<Integer, Integer> groupToBoneIndexMap) throws BlenderFileException {
|
||||||
bonesGroups[0] = 0;
|
bonesGroups[0] = 0;
|
||||||
Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert
|
Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert
|
||||||
// =
|
// =
|
||||||
@ -337,7 +335,7 @@ import com.jme3.util.TempVars;
|
|||||||
if (pDvert.isNotNull()) {// assigning weights and bone indices
|
if (pDvert.isNotNull()) {// assigning weights and bone indices
|
||||||
boolean warnAboutTooManyVertexWeights = false;
|
boolean warnAboutTooManyVertexWeights = false;
|
||||||
// dverts.size() = verticesAmount (one dvert per vertex in blender)
|
// dverts.size() = verticesAmount (one dvert per vertex in blender)
|
||||||
List<Structure> dverts = pDvert.fetchData(blenderContext.getInputStream());
|
List<Structure> dverts = pDvert.fetchData();
|
||||||
int vertexIndex = 0;
|
int vertexIndex = 0;
|
||||||
// use tree map to sort weights from the lowest to the highest ones
|
// use tree map to sort weights from the lowest to the highest ones
|
||||||
TreeMap<Float, Integer> weightToIndexMap = new TreeMap<Float, Integer>();
|
TreeMap<Float, Integer> weightToIndexMap = new TreeMap<Float, Integer>();
|
||||||
@ -352,7 +350,7 @@ import com.jme3.util.TempVars;
|
|||||||
if (totweight > 0 && groupToBoneIndexMap != null) {
|
if (totweight > 0 && groupToBoneIndexMap != null) {
|
||||||
weightToIndexMap.clear();
|
weightToIndexMap.clear();
|
||||||
int weightIndex = 0;
|
int weightIndex = 0;
|
||||||
List<Structure> dw = pDW.fetchData(blenderContext.getInputStream());
|
List<Structure> dw = pDW.fetchData();
|
||||||
for (Structure deformWeight : dw) {
|
for (Structure deformWeight : dw) {
|
||||||
Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue());
|
Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue());
|
||||||
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue();
|
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue();
|
||||||
|
@ -67,7 +67,7 @@ import java.util.logging.Logger;
|
|||||||
Pointer pCurveOb = (Pointer) modifierStructure.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().get(0);
|
||||||
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
||||||
Node curveObject = (Node) objectHelper.toObject(curveStructure, blenderContext);
|
Node curveObject = (Node) objectHelper.toObject(curveStructure, blenderContext);
|
||||||
Set<Number> referencesToCurveLengths = new HashSet<Number>(curveObject.getChildren().size());
|
Set<Number> referencesToCurveLengths = new HashSet<Number>(curveObject.getChildren().size());
|
||||||
|
@ -91,7 +91,7 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper;
|
|||||||
if (pMirrorObject.isNotNull()) {
|
if (pMirrorObject.isNotNull()) {
|
||||||
Structure objectStructure;
|
Structure objectStructure;
|
||||||
try {
|
try {
|
||||||
objectStructure = pMirrorObject.fetchData(blenderContext.getInputStream()).get(0);
|
objectStructure = pMirrorObject.fetchData().get(0);
|
||||||
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
|
||||||
Node object = (Node) objectHelper.toObject(objectStructure, blenderContext);
|
Node object = (Node) objectHelper.toObject(objectStructure, blenderContext);
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
|
@ -84,7 +84,7 @@ public class ModifierHelper extends AbstractBlenderHelper {
|
|||||||
Set<String> alreadyReadModifiers = new HashSet<String>();
|
Set<String> alreadyReadModifiers = new HashSet<String>();
|
||||||
Collection<Modifier> result = new ArrayList<Modifier>();
|
Collection<Modifier> result = new ArrayList<Modifier>();
|
||||||
Structure modifiersListBase = (Structure) objectStructure.getFieldValue("modifiers");
|
Structure modifiersListBase = (Structure) objectStructure.getFieldValue("modifiers");
|
||||||
List<Structure> modifiers = modifiersListBase.evaluateListBase(blenderContext);
|
List<Structure> modifiers = modifiersListBase.evaluateListBase();
|
||||||
for (Structure modifierStructure : modifiers) {
|
for (Structure modifierStructure : modifiers) {
|
||||||
String modifierType = modifierStructure.getType();
|
String modifierType = modifierStructure.getType();
|
||||||
if (!Modifier.canBeAppliedMultipleTimes(modifierType) && alreadyReadModifiers.contains(modifierType)) {
|
if (!Modifier.canBeAppliedMultipleTimes(modifierType) && alreadyReadModifiers.contains(modifierType)) {
|
||||||
@ -146,7 +146,7 @@ public class ModifierHelper extends AbstractBlenderHelper {
|
|||||||
Pointer pIpo = (Pointer) objectStructure.getFieldValue("ipo");
|
Pointer pIpo = (Pointer) objectStructure.getFieldValue("ipo");
|
||||||
if (pIpo.isNotNull()) {
|
if (pIpo.isNotNull()) {
|
||||||
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
||||||
Structure ipoStructure = pIpo.fetchData(blenderContext.getInputStream()).get(0);
|
Structure ipoStructure = pIpo.fetchData().get(0);
|
||||||
Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext);
|
Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext);
|
||||||
if (ipo != null) {
|
if (ipo != null) {
|
||||||
result = new ObjectAnimationModifier(ipo, objectStructure.getName(), objectStructure.getOldMemoryAddress(), blenderContext);
|
result = new ObjectAnimationModifier(ipo, objectStructure.getName(), objectStructure.getOldMemoryAddress(), blenderContext);
|
||||||
@ -172,10 +172,10 @@ public class ModifierHelper extends AbstractBlenderHelper {
|
|||||||
Modifier result = null;
|
Modifier result = null;
|
||||||
Pointer pAnimData = (Pointer) objectStructure.getFieldValue("adt");
|
Pointer pAnimData = (Pointer) objectStructure.getFieldValue("adt");
|
||||||
if (pAnimData.isNotNull()) {
|
if (pAnimData.isNotNull()) {
|
||||||
Structure animData = pAnimData.fetchData(blenderContext.getInputStream()).get(0);
|
Structure animData = pAnimData.fetchData().get(0);
|
||||||
Pointer pAction = (Pointer) animData.getFieldValue("action");
|
Pointer pAction = (Pointer) animData.getFieldValue("action");
|
||||||
if (pAction.isNotNull()) {
|
if (pAction.isNotNull()) {
|
||||||
Structure actionStructure = pAction.fetchData(blenderContext.getInputStream()).get(0);
|
Structure actionStructure = pAction.fetchData().get(0);
|
||||||
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class);
|
||||||
Ipo ipo = ipoHelper.fromAction(actionStructure, blenderContext);
|
Ipo ipo = ipoHelper.fromAction(actionStructure, blenderContext);
|
||||||
if (ipo != null) {// ipo can be null if it has no curves applied, ommit such modifier then
|
if (ipo != null) {// ipo can be null if it has no curves applied, ommit such modifier then
|
||||||
|
@ -48,8 +48,8 @@ import java.util.logging.Logger;
|
|||||||
Pointer pParticleSystem = (Pointer) modifierStructure.getFieldValue("psys");
|
Pointer pParticleSystem = (Pointer) modifierStructure.getFieldValue("psys");
|
||||||
if (pParticleSystem.isNotNull()) {
|
if (pParticleSystem.isNotNull()) {
|
||||||
ParticlesHelper particlesHelper = blenderContext.getHelper(ParticlesHelper.class);
|
ParticlesHelper particlesHelper = blenderContext.getHelper(ParticlesHelper.class);
|
||||||
Structure particleSystem = pParticleSystem.fetchData(blenderContext.getInputStream()).get(0);
|
Structure particleSystem = pParticleSystem.fetchData().get(0);
|
||||||
particleEmitter = particlesHelper.toParticleEmitter(particleSystem, blenderContext);
|
particleEmitter = particlesHelper.toParticleEmitter(particleSystem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
Pointer pParent = (Pointer) objectStructure.getFieldValue("parent");
|
Pointer pParent = (Pointer) objectStructure.getFieldValue("parent");
|
||||||
Object parent = blenderContext.getLoadedFeature(pParent.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE);
|
Object parent = blenderContext.getLoadedFeature(pParent.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE);
|
||||||
if (parent == null && pParent.isNotNull()) {
|
if (parent == null && pParent.isNotNull()) {
|
||||||
Structure parentStructure = pParent.fetchData(blenderContext.getInputStream()).get(0);
|
Structure parentStructure = pParent.fetchData().get(0);
|
||||||
parent = this.toObject(parentStructure, blenderContext);
|
parent = this.toObject(parentStructure, blenderContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
result = new Node(name);
|
result = new Node(name);
|
||||||
MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class);
|
MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class);
|
||||||
Pointer pMesh = (Pointer) objectStructure.getFieldValue("data");
|
Pointer pMesh = (Pointer) objectStructure.getFieldValue("data");
|
||||||
List<Structure> meshesArray = pMesh.fetchData(blenderContext.getInputStream());
|
List<Structure> meshesArray = pMesh.fetchData();
|
||||||
List<Geometry> geometries = meshHelper.toMesh(meshesArray.get(0), blenderContext);
|
List<Geometry> geometries = meshHelper.toMesh(meshesArray.get(0), blenderContext);
|
||||||
if (geometries != null) {
|
if (geometries != null) {
|
||||||
for (Geometry geometry : geometries) {
|
for (Geometry geometry : geometries) {
|
||||||
@ -176,7 +176,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
Pointer pCurve = (Pointer) objectStructure.getFieldValue("data");
|
Pointer pCurve = (Pointer) objectStructure.getFieldValue("data");
|
||||||
if (pCurve.isNotNull()) {
|
if (pCurve.isNotNull()) {
|
||||||
CurvesHelper curvesHelper = blenderContext.getHelper(CurvesHelper.class);
|
CurvesHelper curvesHelper = blenderContext.getHelper(CurvesHelper.class);
|
||||||
Structure curveData = pCurve.fetchData(blenderContext.getInputStream()).get(0);
|
Structure curveData = pCurve.fetchData().get(0);
|
||||||
List<Geometry> curves = curvesHelper.toCurve(curveData, blenderContext);
|
List<Geometry> curves = curvesHelper.toCurve(curveData, blenderContext);
|
||||||
for (Geometry curve : curves) {
|
for (Geometry curve : curves) {
|
||||||
result.attachChild(curve);
|
result.attachChild(curve);
|
||||||
@ -187,7 +187,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
Pointer pLamp = (Pointer) objectStructure.getFieldValue("data");
|
Pointer pLamp = (Pointer) objectStructure.getFieldValue("data");
|
||||||
if (pLamp.isNotNull()) {
|
if (pLamp.isNotNull()) {
|
||||||
LightHelper lightHelper = blenderContext.getHelper(LightHelper.class);
|
LightHelper lightHelper = blenderContext.getHelper(LightHelper.class);
|
||||||
List<Structure> lampsArray = pLamp.fetchData(blenderContext.getInputStream());
|
List<Structure> lampsArray = pLamp.fetchData();
|
||||||
result = lightHelper.toLight(lampsArray.get(0), blenderContext);
|
result = lightHelper.toLight(lampsArray.get(0), blenderContext);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -195,7 +195,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
Pointer pCamera = (Pointer) objectStructure.getFieldValue("data");
|
Pointer pCamera = (Pointer) objectStructure.getFieldValue("data");
|
||||||
if (pCamera.isNotNull()) {
|
if (pCamera.isNotNull()) {
|
||||||
CameraHelper cameraHelper = blenderContext.getHelper(CameraHelper.class);
|
CameraHelper cameraHelper = blenderContext.getHelper(CameraHelper.class);
|
||||||
List<Structure> camerasArray = pCamera.fetchData(blenderContext.getInputStream());
|
List<Structure> camerasArray = pCamera.fetchData();
|
||||||
result = cameraHelper.toCamera(camerasArray.get(0), blenderContext);
|
result = cameraHelper.toCamera(camerasArray.get(0), blenderContext);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -119,7 +119,7 @@ public class Properties implements Cloneable {
|
|||||||
}
|
}
|
||||||
case IDP_GROUP:
|
case IDP_GROUP:
|
||||||
Structure group = (Structure) data.getFieldValue("group");
|
Structure group = (Structure) data.getFieldValue("group");
|
||||||
List<Structure> dataList = group.evaluateListBase(blenderContext);
|
List<Structure> dataList = group.evaluateListBase();
|
||||||
List<Properties> subProperties = new ArrayList<Properties>(len);
|
List<Properties> subProperties = new ArrayList<Properties>(len);
|
||||||
for (Structure d : dataList) {
|
for (Structure d : dataList) {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
@ -136,14 +136,14 @@ public class Properties implements Cloneable {
|
|||||||
break;
|
break;
|
||||||
case IDP_IDPARRAY: {
|
case IDP_IDPARRAY: {
|
||||||
Pointer pointer = (Pointer) data.getFieldValue("pointer");
|
Pointer pointer = (Pointer) data.getFieldValue("pointer");
|
||||||
List<Structure> arrays = pointer.fetchData(blenderContext.getInputStream());
|
List<Structure> arrays = pointer.fetchData();
|
||||||
List<Object> result = new ArrayList<Object>(arrays.size());
|
List<Object> result = new ArrayList<Object>(arrays.size());
|
||||||
Properties temp = new Properties();
|
Properties temp = new Properties();
|
||||||
for (Structure array : arrays) {
|
for (Structure array : arrays) {
|
||||||
temp.load(array, blenderContext);
|
temp.load(array, blenderContext);
|
||||||
result.add(temp.value);
|
result.add(temp.value);
|
||||||
}
|
}
|
||||||
this.value = result;
|
value = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IDP_NUMTYPES:
|
case IDP_NUMTYPES:
|
||||||
@ -180,8 +180,8 @@ public class Properties implements Cloneable {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> getSubPropertiesNames() {
|
public List<String> getSubPropertiesNames() {
|
||||||
List<String> result = null;
|
List<String> result = null;
|
||||||
if (this.type == IDP_GROUP) {
|
if (type == IDP_GROUP) {
|
||||||
List<Properties> properties = (List<Properties>) this.value;
|
List<Properties> properties = (List<Properties>) value;
|
||||||
if (properties != null && properties.size() > 0) {
|
if (properties != null && properties.size() > 0) {
|
||||||
result = new ArrayList<String>(properties.size());
|
result = new ArrayList<String>(properties.size());
|
||||||
for (Properties property : properties) {
|
for (Properties property : properties) {
|
||||||
@ -272,8 +272,8 @@ public class Properties implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void completeLoading() {
|
protected void completeLoading() {
|
||||||
if (this.type == IDP_GROUP) {
|
if (type == IDP_GROUP) {
|
||||||
List<Properties> groupProperties = (List<Properties>) this.value;
|
List<Properties> groupProperties = (List<Properties>) value;
|
||||||
Properties rnaUI = null;
|
Properties rnaUI = null;
|
||||||
for (Properties properties : groupProperties) {
|
for (Properties properties : groupProperties) {
|
||||||
if (properties.name.equals(RNA_PROPERTY_NAME) && properties.type == IDP_GROUP) {
|
if (properties.name.equals(RNA_PROPERTY_NAME) && properties.type == IDP_GROUP) {
|
||||||
|
@ -95,11 +95,11 @@ public class ParticlesHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ParticleEmitter toParticleEmitter(Structure particleSystem, BlenderContext blenderContext) throws BlenderFileException {
|
public ParticleEmitter toParticleEmitter(Structure particleSystem) throws BlenderFileException {
|
||||||
ParticleEmitter result = null;
|
ParticleEmitter result = null;
|
||||||
Pointer pParticleSettings = (Pointer) particleSystem.getFieldValue("part");
|
Pointer pParticleSettings = (Pointer) particleSystem.getFieldValue("part");
|
||||||
if (pParticleSettings.isNotNull()) {
|
if (pParticleSettings.isNotNull()) {
|
||||||
Structure particleSettings = pParticleSettings.fetchData(blenderContext.getInputStream()).get(0);
|
Structure particleSettings = pParticleSettings.fetchData().get(0);
|
||||||
|
|
||||||
int totPart = ((Number) particleSettings.getFieldValue("totpart")).intValue();
|
int totPart = ((Number) particleSettings.getFieldValue("totpart")).intValue();
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class ColorBand {
|
|||||||
cursorsAmount = colors.size();
|
cursorsAmount = colors.size();
|
||||||
this.ipoType = ipoType;
|
this.ipoType = ipoType;
|
||||||
this.resultSize = resultSize;
|
this.resultSize = resultSize;
|
||||||
data = new ColorBandData[this.cursorsAmount];
|
data = new ColorBandData[cursorsAmount];
|
||||||
for (int i = 0; i < cursorsAmount; ++i) {
|
for (int i = 0; i < cursorsAmount; ++i) {
|
||||||
data[i] = new ColorBandData(colors.get(i), positions.get(i));
|
data[i] = new ColorBandData(colors.get(i), positions.get(i));
|
||||||
}
|
}
|
||||||
@ -112,12 +112,12 @@ public class ColorBand {
|
|||||||
if ((flag & GeneratedTexture.TEX_COLORBAND) != 0) {
|
if ((flag & GeneratedTexture.TEX_COLORBAND) != 0) {
|
||||||
Pointer pColorband = (Pointer) tex.getFieldValue("coba");
|
Pointer pColorband = (Pointer) tex.getFieldValue("coba");
|
||||||
try {
|
try {
|
||||||
Structure colorbandStructure = pColorband.fetchData(blenderContext.getInputStream()).get(0);
|
Structure colorbandStructure = pColorband.fetchData().get(0);
|
||||||
this.cursorsAmount = ((Number) colorbandStructure.getFieldValue("tot")).intValue();
|
cursorsAmount = ((Number) colorbandStructure.getFieldValue("tot")).intValue();
|
||||||
this.ipoType = ((Number) colorbandStructure.getFieldValue("ipotype")).intValue();
|
ipoType = ((Number) colorbandStructure.getFieldValue("ipotype")).intValue();
|
||||||
this.data = new ColorBandData[this.cursorsAmount];
|
data = new ColorBandData[cursorsAmount];
|
||||||
DynamicArray<Structure> data = (DynamicArray<Structure>) colorbandStructure.getFieldValue("data");
|
DynamicArray<Structure> data = (DynamicArray<Structure>) colorbandStructure.getFieldValue("data");
|
||||||
for (int i = 0; i < this.cursorsAmount; ++i) {
|
for (int i = 0; i < cursorsAmount; ++i) {
|
||||||
this.data[i] = new ColorBandData(data.get(i));
|
this.data[i] = new ColorBandData(data.get(i));
|
||||||
}
|
}
|
||||||
} catch (BlenderFileException e) {
|
} catch (BlenderFileException e) {
|
||||||
@ -372,11 +372,11 @@ public class ColorBand {
|
|||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
private ColorBandData(ColorBandData data) {
|
private ColorBandData(ColorBandData data) {
|
||||||
this.r = data.r;
|
r = data.r;
|
||||||
this.g = data.g;
|
g = data.g;
|
||||||
this.b = data.b;
|
b = data.b;
|
||||||
this.a = data.a;
|
a = data.a;
|
||||||
this.pos = data.pos;
|
pos = data.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -386,16 +386,16 @@ public class ColorBand {
|
|||||||
* the structure containing the CBData object
|
* the structure containing the CBData object
|
||||||
*/
|
*/
|
||||||
public ColorBandData(Structure cbdataStructure) {
|
public ColorBandData(Structure cbdataStructure) {
|
||||||
this.r = ((Number) cbdataStructure.getFieldValue("r")).floatValue();
|
r = ((Number) cbdataStructure.getFieldValue("r")).floatValue();
|
||||||
this.g = ((Number) cbdataStructure.getFieldValue("g")).floatValue();
|
g = ((Number) cbdataStructure.getFieldValue("g")).floatValue();
|
||||||
this.b = ((Number) cbdataStructure.getFieldValue("b")).floatValue();
|
b = ((Number) cbdataStructure.getFieldValue("b")).floatValue();
|
||||||
this.a = ((Number) cbdataStructure.getFieldValue("a")).floatValue();
|
a = ((Number) cbdataStructure.getFieldValue("a")).floatValue();
|
||||||
this.pos = (int) (((Number) cbdataStructure.getFieldValue("pos")).floatValue() * 1000.0f);
|
pos = (int) (((Number) cbdataStructure.getFieldValue("pos")).floatValue() * 1000.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "P: " + this.pos + " [" + this.r + ", " + this.g + ", " + this.b + ", " + this.a + "]";
|
return "P: " + pos + " [" + r + ", " + g + ", " + b + ", " + a + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ public class TextureHelper extends AbstractBlenderHelper {
|
|||||||
case TEX_IMAGE:// (it is first because probably this will be most commonly used)
|
case TEX_IMAGE:// (it is first because probably this will be most commonly used)
|
||||||
Pointer pImage = (Pointer) tex.getFieldValue("ima");
|
Pointer pImage = (Pointer) tex.getFieldValue("ima");
|
||||||
if (pImage.isNotNull()) {
|
if (pImage.isNotNull()) {
|
||||||
Structure image = pImage.fetchData(blenderContext.getInputStream()).get(0);
|
Structure image = pImage.fetchData().get(0);
|
||||||
Texture loadedTexture = this.loadTexture(image, imaflag, blenderContext);
|
Texture loadedTexture = this.loadTexture(image, imaflag, blenderContext);
|
||||||
if (loadedTexture != null) {
|
if (loadedTexture != null) {
|
||||||
result = loadedTexture;
|
result = loadedTexture;
|
||||||
@ -232,7 +232,7 @@ public class TextureHelper extends AbstractBlenderHelper {
|
|||||||
result = this.loadImageFromFile(texturePath, imaflag, blenderContext);
|
result = this.loadImageFromFile(texturePath, imaflag, blenderContext);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.fine("Packed texture. Reading directly from the blend file!");
|
LOGGER.fine("Packed texture. Reading directly from the blend file!");
|
||||||
Structure packedFile = pPackedFile.fetchData(blenderContext.getInputStream()).get(0);
|
Structure packedFile = pPackedFile.fetchData().get(0);
|
||||||
Pointer pData = (Pointer) packedFile.getFieldValue("data");
|
Pointer pData = (Pointer) packedFile.getFieldValue("data");
|
||||||
FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pData.getOldMemoryAddress());
|
FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pData.getOldMemoryAddress());
|
||||||
blenderContext.getInputStream().setPosition(dataFileBlock.getBlockPosition());
|
blenderContext.getInputStream().setPosition(dataFileBlock.getBlockPosition());
|
||||||
@ -533,7 +533,7 @@ public class TextureHelper extends AbstractBlenderHelper {
|
|||||||
Pointer p = mtexsArray.get(i);
|
Pointer p = mtexsArray.get(i);
|
||||||
if (p.isNotNull() && (separatedTextures & 1 << i) == 0) {
|
if (p.isNotNull() && (separatedTextures & 1 << i) == 0) {
|
||||||
TextureData textureData = new TextureData();
|
TextureData textureData = new TextureData();
|
||||||
textureData.mtex = p.fetchData(blenderContext.getInputStream()).get(0);
|
textureData.mtex = p.fetchData().get(0);
|
||||||
textureData.uvCoordinatesType = skyTexture ? UVCoordinatesType.TEXCO_ORCO.blenderValue : ((Number) textureData.mtex.getFieldValue("texco")).intValue();
|
textureData.uvCoordinatesType = skyTexture ? UVCoordinatesType.TEXCO_ORCO.blenderValue : ((Number) textureData.mtex.getFieldValue("texco")).intValue();
|
||||||
textureData.projectionType = ((Number) textureData.mtex.getFieldValue("mapping")).intValue();
|
textureData.projectionType = ((Number) textureData.mtex.getFieldValue("mapping")).intValue();
|
||||||
textureData.uvCoordinatesName = textureData.mtex.getFieldValue("uvName").toString();
|
textureData.uvCoordinatesName = textureData.mtex.getFieldValue("uvName").toString();
|
||||||
@ -543,7 +543,7 @@ public class TextureHelper extends AbstractBlenderHelper {
|
|||||||
|
|
||||||
Pointer pTex = (Pointer) textureData.mtex.getFieldValue("tex");
|
Pointer pTex = (Pointer) textureData.mtex.getFieldValue("tex");
|
||||||
if (pTex.isNotNull()) {
|
if (pTex.isNotNull()) {
|
||||||
Structure tex = pTex.fetchData(blenderContext.getInputStream()).get(0);
|
Structure tex = pTex.fetchData().get(0);
|
||||||
textureData.textureStructure = tex;
|
textureData.textureStructure = tex;
|
||||||
texturesList.add(textureData);
|
texturesList.add(textureData);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user