Search in sources :

Example 1 with FbxElement

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];
    }
}
Also used : FbxElement(com.jme3.scene.plugins.fbx.file.FbxElement)

Example 2 with FbxElement

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);
        }
    }
}
Also used : FbxElement(com.jme3.scene.plugins.fbx.file.FbxElement)

Example 3 with FbxElement

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);
        }
    }
}
Also used : FbxElement(com.jme3.scene.plugins.fbx.file.FbxElement) Matrix4f(com.jme3.math.Matrix4f) FbxId(com.jme3.scene.plugins.fbx.file.FbxId)

Example 4 with FbxElement

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);
    }
}
Also used : FbxElement(com.jme3.scene.plugins.fbx.file.FbxElement) FbxObject(com.jme3.scene.plugins.fbx.objects.FbxObject) FbxNode(com.jme3.scene.plugins.fbx.objects.FbxNode) FbxAnimCurve(com.jme3.scene.plugins.fbx.objects.FbxAnimCurve) FbxTexture(com.jme3.scene.plugins.fbx.objects.FbxTexture) FbxMesh(com.jme3.scene.plugins.fbx.objects.FbxMesh) FbxBindPose(com.jme3.scene.plugins.fbx.objects.FbxBindPose) FbxAnimNode(com.jme3.scene.plugins.fbx.objects.FbxAnimNode) FbxMaterial(com.jme3.scene.plugins.fbx.objects.FbxMaterial) FbxImage(com.jme3.scene.plugins.fbx.objects.FbxImage)

Example 5 with FbxElement

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);
    }
}
Also used : FbxElement(com.jme3.scene.plugins.fbx.file.FbxElement)

Aggregations

FbxElement (com.jme3.scene.plugins.fbx.file.FbxElement)14 FbxFile (com.jme3.scene.plugins.fbx.file.FbxFile)2 FbxId (com.jme3.scene.plugins.fbx.file.FbxId)2 FbxObject (com.jme3.scene.plugins.fbx.obj.FbxObject)2 FbxObject (com.jme3.scene.plugins.fbx.objects.FbxObject)2 ColorRGBA (com.jme3.math.ColorRGBA)1 Matrix4f (com.jme3.math.Matrix4f)1 Quaternion (com.jme3.math.Quaternion)1 Vector3f (com.jme3.math.Vector3f)1 CullHint (com.jme3.scene.Spatial.CullHint)1 FbxMesh (com.jme3.scene.plugins.fbx.mesh.FbxMesh)1 FbxGlobalSettings (com.jme3.scene.plugins.fbx.misc.FbxGlobalSettings)1 FbxAnimCurve (com.jme3.scene.plugins.fbx.objects.FbxAnimCurve)1 FbxAnimNode (com.jme3.scene.plugins.fbx.objects.FbxAnimNode)1 FbxBindPose (com.jme3.scene.plugins.fbx.objects.FbxBindPose)1 FbxCluster (com.jme3.scene.plugins.fbx.objects.FbxCluster)1 FbxImage (com.jme3.scene.plugins.fbx.objects.FbxImage)1 FbxMaterial (com.jme3.scene.plugins.fbx.objects.FbxMaterial)1 FbxMesh (com.jme3.scene.plugins.fbx.objects.FbxMesh)1 FbxNode (com.jme3.scene.plugins.fbx.objects.FbxNode)1