2016-09-09 20 views
9

我已經在XCode中導入了DAE文件並將其轉換爲SCN文件。該文件包含一些帶有動畫的3D對象。從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]; 
+1

在轉換DAE文件之前,請查看實體 - >動畫。如果它顯示多於一個動畫鍵[0]將只是動畫的一部分。如果出現這種情況,您甚至可能會看到您的物體抽搐或輕微移動。我有一個下載文件,將所有動畫關鍵字轉換爲一個。這必須在轉換爲SCN文件之前完成。 – FlippinFun

回答

1

這是將多張關鍵動畫轉換成一個DAE文件

Automater collada converter download

解壓縮,並在〜/庫/ services文件夾中刪除該文件的文件。從那裏你可以右鍵點擊你的collada文件並向下滾動到ConvertToXcodeCollada和presto!完成後會彈出一個窗口(大約半秒)。

+0

工作流程不再適用。生成的文件每次都被破壞。有誰知道如何修理它? – hablema