Search in sources :

Example 6 with ModelKey

use of com.jme3.asset.ModelKey in project jmonkeyengine by jMonkeyEngine.

the class FbxLoader method load.

@Override
public Object load(AssetInfo assetInfo) throws IOException {
    this.assetManager = assetInfo.getManager();
    AssetKey<?> assetKey = assetInfo.getKey();
    if (!(assetKey instanceof ModelKey)) {
        throw new AssetLoadException("Invalid asset key");
    }
    InputStream stream = assetInfo.openStream();
    try {
        sceneFilename = assetKey.getName();
        sceneFolderName = assetKey.getFolder();
        String ext = assetKey.getExtension();
        sceneName = sceneFilename.substring(0, sceneFilename.length() - ext.length() - 1);
        if (sceneFolderName != null && sceneFolderName.length() > 0) {
            sceneName = sceneName.substring(sceneFolderName.length());
        }
        reset();
        // Load the data from the stream.
        loadData(stream);
        // Bind poses are needed to compute world transforms.
        applyBindPoses();
        // Need world transforms for skeleton creation.
        updateWorldTransforms();
        // Need skeletons for meshs to be created in scene graph construction.
        // Mesh bone indices require skeletons to determine bone index.
        constructSkeletons();
        // Create the jME3 scene graph from the FBX scene graph.
        // Also creates SkeletonControls based on the constructed skeletons.
        Spatial scene = constructSceneGraph();
        // Load animations into AnimControls
        constructAnimations();
        return scene;
    } finally {
        releaseObjects();
        if (stream != null) {
            stream.close();
        }
    }
}
Also used : ModelKey(com.jme3.asset.ModelKey) Spatial(com.jme3.scene.Spatial) InputStream(java.io.InputStream) AssetLoadException(com.jme3.asset.AssetLoadException)

Aggregations

ModelKey (com.jme3.asset.ModelKey)6 AssetLoadException (com.jme3.asset.AssetLoadException)2 BinaryImporter (com.jme3.export.binary.BinaryImporter)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 AssetInfo (com.jme3.asset.AssetInfo)1 AssetKey (com.jme3.asset.AssetKey)1 AssetManager (com.jme3.asset.AssetManager)1 BlenderKey (com.jme3.asset.BlenderKey)1 InputCapsule (com.jme3.export.InputCapsule)1 DirectionalLight (com.jme3.light.DirectionalLight)1 PointLight (com.jme3.light.PointLight)1 ColorRGBA (com.jme3.math.ColorRGBA)1 Vector3f (com.jme3.math.Vector3f)1 AssetLinkNode (com.jme3.scene.AssetLinkNode)1 Geometry (com.jme3.scene.Geometry)1 Node (com.jme3.scene.Node)1 Spatial (com.jme3.scene.Spatial)1 AnimationHelper (com.jme3.scene.plugins.blender.animations.AnimationHelper)1 CameraHelper (com.jme3.scene.plugins.blender.cameras.CameraHelper)1