use of com.jme3.scene.plugins.fbx.file.FbxElement in project jmonkeyengine by jMonkeyEngine.
the class FbxAnimCurve method fromElement.
@Override
public void fromElement(FbxElement element) {
super.fromElement(element);
for (FbxElement e : element.children) {
if (e.id.equals("KeyTime")) {
keyTimes = (long[]) e.properties.get(0);
} else if (e.id.equals("KeyValueFloat")) {
keyValues = (float[]) e.properties.get(0);
}
}
long time = -1;
for (int i = 0; i < keyTimes.length; i++) {
if (time >= keyTimes[i]) {
throw new UnsupportedOperationException("Keyframe times must be sequential, but they are not.");
}
time = keyTimes[i];
}
}
use of com.jme3.scene.plugins.fbx.file.FbxElement in project jmonkeyengine by jMonkeyEngine.
the class FbxAnimStack method fromElement.
@Override
public void fromElement(FbxElement element) {
super.fromElement(element);
for (FbxElement child : element.getFbxProperties()) {
String propName = (String) child.properties.get(0);
if (propName.equals("LocalStop")) {
long durationLong = (Long) child.properties.get(4);
duration = (float) (durationLong * FbxAnimUtil.SECONDS_PER_UNIT);
}
}
}
use of com.jme3.scene.plugins.fbx.file.FbxElement in project jmonkeyengine by jMonkeyEngine.
the class FbxBindPose method fromElement.
@Override
public void fromElement(FbxElement element) {
super.fromElement(element);
for (FbxElement child : element.children) {
if (!child.id.equals("PoseNode")) {
continue;
}
FbxId node = null;
float[] matData = null;
for (FbxElement e : child.children) {
if (e.id.equals("Node")) {
node = FbxId.create(e.properties.get(0));
} else if (e.id.equals("Matrix")) {
double[] matDataDoubles = (double[]) e.properties.get(0);
if (matDataDoubles.length != 16) {
// corrupt
throw new UnsupportedOperationException("Bind pose matrix " + "must have 16 doubles, but it has " + matDataDoubles.length + ". Data is corrupt");
}
matData = new float[16];
for (int i = 0; i < matDataDoubles.length; i++) {
matData[i] = (float) matDataDoubles[i];
}
}
}
if (node != null && matData != null) {
Matrix4f matrix = new Matrix4f(matData);
bindPose.put(node, matrix);
}
}
}
use of com.jme3.scene.plugins.fbx.file.FbxElement in project jmonkeyengine by jMonkeyEngine.
the class SceneLoader method loadObjects.
private void loadObjects(FbxElement element) throws IOException {
FbxObject obj = null;
for (FbxElement e : element.children) {
switch(e.id) {
case "Geometry":
FbxMesh mesh = new FbxMesh(this, e);
obj = mesh;
if (mesh.geometries != null)
geomMap.put(mesh.id, mesh);
break;
case "Material":
obj = new FbxMaterial(this, e);
break;
case "Model":
FbxNode node = new FbxNode(this, e);
obj = node;
modelMap.put(node.id, node);
if (node.isLimb())
limbMap.put(node.id, node);
break;
case "Pose":
FbxBindPose pose = new FbxBindPose(this, e);
obj = pose;
bindMap.put(pose.id, pose);
break;
case "Texture":
obj = new FbxTexture(this, e);
break;
case "Video":
obj = new FbxImage(this, e);
break;
case "Deformer":
obj = loadDeformer(e);
break;
case "AnimationLayer":
FbxObject layer = new FbxObject(this, e);
obj = layer;
alayerMap.put(layer.id, layer);
break;
case "AnimationCurve":
obj = new FbxAnimCurve(this, e);
break;
case "AnimationCurveNode":
obj = new FbxAnimNode(this, e);
break;
default:
obj = null;
}
if (obj != null)
allObjects.put(obj.id, obj);
}
}
use of com.jme3.scene.plugins.fbx.file.FbxElement in project jmonkeyengine by jMonkeyEngine.
the class FbxMaterial method fromElement.
@Override
public void fromElement(FbxElement element) {
super.fromElement(element);
if (!getSubclassName().equals("")) {
return;
}
FbxElement shadingModelEl = element.getChildById("ShadingModel");
if (shadingModelEl != null) {
shadingModel = (String) shadingModelEl.properties.get(0);
if (!shadingModel.equals("")) {
if (!shadingModel.equalsIgnoreCase("phong") && !shadingModel.equalsIgnoreCase("lambert")) {
logger.log(Level.WARNING, "FBX material uses unknown shading model: {0}. " + "Material may display incorrectly.", shadingModel);
}
}
}
for (FbxElement child : element.getFbxProperties()) {
properties.setPropertyFromElement(child);
}
}
Aggregations