【问题标题】:Import 3D object with animation from scn从 scn 导入带有动画的 3D 对象
【发布时间】:2017-01-17 09:32:35
【问题描述】:

我在 XCode 中导入了一个 DAE 文件并将其转换为 SCN 文件。该文件包含一些带有动画的 3D 对象。

我正在尝试导入所有节点及其动画并在场景中播放它们。节点已导入,但我无法播放动画。

NSURL    *idleURL   = [[NSBundle mainBundle] URLForResource:model.model3D 
                        withExtension:@"scn" subdirectory:@"3d.scnassets"];
SCNScene *idleScene = [SCNScene sceneWithURL:idleURL 
                      options:@{
SCNSceneSourceAnimationImportPolicyKey:SCNSceneSourceAnimationImportPolicyPlayRepeatedly} 
error:nil];

// Merge the loaded scene into our main scene in order to
//   place the object in our own scene
for (SCNNode *child in idleScene.rootNode.childNodes){

    [_sceneView.scene.rootNode addChildNode:child];

    if (child.animationKeys.count > 0) {
        CAAnimation *animation = [child animationForKey:child.animationKeys[0]];
        animation.repeatCount = INFINITY;
        child.paused = NO;
        [_sceneView.scene.rootNode addAnimation:animation forKey:child.animationKeys[0]];
    }       

}

[_sceneView setPlaying:YES];

【问题讨论】:

  • 在转换 DAE 文件之前,请查看实体 -> 动画。如果它显示多个,则一个动画键[0] 将只是动画的一部分。如果是这种情况,您甚至可能会看到您的对象在一个地方抽搐或轻微移动。我有一个文件可供下载,它将所有动画键转换为一个。这必须在转换为 SCN 文件之前完成。

标签: ios xcode animation scenekit scnnode


【解决方案1】:

这是一个将多个关键动画转换为一个用于 DAE 文件的文件

Automater collada converter download

解压缩文件并将其放到您的 ~/Library/services 文件夹中。从那里您只需右键单击您的 collada 文件并向下滚动到 ConvertToXcodeCollada 和 presto!完成后(大约半秒)会弹出一个窗口。

【讨论】:

  • 工作流不再起作用。生成的文件每次都损坏。有人知道怎么解决吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-01
  • 2018-05-20
  • 2017-04-29
  • 1970-01-01
  • 1970-01-01
  • 2020-12-13
相关资源
最近更新 更多