-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssimpKit can not display all the animations of the FBX model #101
Comments
|
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"duilian" ofType:@"FBX"]; self.modelFilePath = filePath; SCNAssimpScene *scene = // Load the animation scene
} // retrieve the SCNView // set the scene to the view // allows the user to manipulate the camera // show statistics such as fps and timing information // configure the view scnView.scene.rootNode.position = SCNVector3Make(0, 0, -50); scnView.playing = YES; |
Thanks for providing the file. Comparing it with FBX review tool, I can see only 1 vertical block on the left is animated using AssimpKit. Btw, your code change is wrong and unnecessary. You should probably read how to load animations. The gist is: you load the model scene, then load the animations (from the scene you just loaded or another scene if they are defined externally) and add the animation to the model scene. The above docs referred to use the same scenarios. |
So AssimpKit loading FBX animation is a problem right? The correct way is as follows:
|
Yes, hence I have labeled this issue as a bug. |
Thank you @dmsurti for sharing, looking forward to your update |
Hi! |
I'm banging my head against the wall on similiar issue downstream with swift port failed attempts to get my fbx import to animate in swift. if let pathToObject = Bundle.main.path(forResource: "ely", ofType: "fbx") {
let scaleFactor:Float = 0.0025
do {
// 1. you load the model scene
let assimpScene = try SCNScene.assimpScene(filePath: pathToObject, postProcessSteps:[.defaultQuality]) //realtimeFast realtimeQuality realtimeMaxQuality [.optimizeGraph,
// ( add the model to the scene / scale it down / is this wrong?)
let modelScene = assimpScene.modelScene!
modelScene.rootNode.childNodes.forEach {
$0.position = $0.position * scaleFactor
$0.scale = $0.scale * scaleFactor
sceneView.scene.rootNode.addChildNode($0) // the robot is added - it has a root - below it fails to add animation due to no root: nil nil
self.robotNode = $0
}
// print("skeletonNode:",assimpScene.skeletonNode)
// print("animations:",assimpScene.animations)
// print("animationKeys:",assimpScene.animationScenes.allKeys)
//assimpScene.makeAnimationScenes()
// for animSceneKey in assimpScene.animations.allKeys {
// if let animSceneKey = animSceneKey as? String {
// if let assimpAnim = assimpScene.animations.value(forKey: animSceneKey) as? AssetImporterAnimation {
// let animScene = SCNScene()
// animScene.rootNode.addChildNode(assimpScene.skeletonNode.clone())
// assimpScene.addAnimation(assimpAnimation: assimpAnim,to: assimpScene.modelScene!)
// assimpScene.animationScenes.setValue( assimpScene.modelScene!,forKey: animSceneKey)
// }
// }
// }
//
// 2. then load the animations
// either these lines are wrong... OR
for (_,animScene) in assimpScene.animationScenes{
print("animScene:",animScene)
if animScene is SCNScene{
let animation = assimpScene.animations["ely-1"] as! AssetImporterAnimation
print("animation:",animation)
// 3. and add the animation to the model scene.
// assimpScene.modelScene!.rootNode.addAnimationScene(animation, forKey: "ely-1", with: settings) // FAILS
// self.robotNode?.parent?.addAnimationScene(animation, forKey: "ely-1", with: settings) // FAILS
// self.robotNode?.addAnimationScene(animation, forKey: "ely-1", with: settings) // FAILS
// sceneView.scene.rootNode.addAnimationScene(animation, forKey: "ely-1", with: settings) // FAILS
// just attempt to hijack view and coerce the animation scene to sceneView.scene
sceneView.scene = animScene as! SCNScene // FAILS
}
}
sceneView.isPlaying = true
sceneView.showsStatistics = true
}catch let error{
print("error:",error)
}
} |
UPDATE - I got the library loading fbx + animations with swift / via carthage. The eugenebokhan/AssetImportKit seems to not work. https://github.com/johndpope/swift-2 if anyone knows how to pass the flags in swift - would like to know.
|
AssimpKit can not display all the animations of the FBX model, only a portion of the animation. I would like to ask what is the reason for such a result
The text was updated successfully, but these errors were encountered: