에서 재생되지 않습니다 내가 완전히 OS X에서 근무 애니메이션의 예를 가지고SceneKit 애니메이션은 아이폰 OS
가 지금은 아이폰 OS이 포팅 시작 등의 일시 정지, 변화 속도를 시작하고 심지어 애니메이션을 시작할 수 없습니다 . 코드를 최소로 단순화했습니다. OS X에서는 작동하지만 iOS에서는 작동하지 않습니다. 내가 무엇
는
- 가에서 (애니메이션) 문자 (유휴 애니메이션)로 장면을보기입니다 - OS X 및 iOS
- 시작 문자에 실행 애니메이션에서 모두 작동합니다. 이것은 OS X에서 작동하고 애니메이션 시작 및 루프를 실행합니다. iOS에서는 캐릭터가 애니메이션 시작시에 배치됩니다. 하지만 실행되지 않습니다 ...
유휴 상태가 아닌 장면을 실행하면 작동 - 문자가 실행됩니다. 문제는 장면을로드 한 후 애니메이션을 시작하는 것입니다. 애니메이션과 함께 모델을로드하지만 재생되지 않습니다.
는 OS X와 iOS 버전 간의 자세한 비교하면 나는 아마 관련이 차이를 발견하지만 난 그 해결 방법을 알아낼 수 없습니다 : 문자가되지 않습니다 OS X의 버전에서
을 애니메이션을 시작할 때까지 움직입니다. iOS 버전에서는 유휴 (또는 다른 어떤 장면) 루트에서 노드를 연결하면 애니메이션이 적용됩니다. 나는 이것을 어떻게 바꿀 지 모른다.
OS X 버전에는 스토리 보드의 장면보기에 첨부 된 scene.dae가 있습니다. 이는 iOS에서도 마찬가지입니다. 하지만 iOS에서 어떤 이유로이 첨부 파일이 작동하지 않습니다, 자기야 .scene'nil입니다. 이것이 장면을 프로그래밍 방식으로 인스턴스화하고 지정해야하는 이유입니다. 나는 그것을 고칠 수 등 스토리 보드를 사용하여 추가
장면 키트보기 콘센트를 할당 장면 뷰를 다시 추가했습니다. 유휴 및 실행은 .dae 파일입니다. 각각은 캐릭터 및 애니메이션이있는 전체 모델을 포함합니다. 애니메이션 식별자가 .dae 파일과 동일한 지 확인했습니다.
보기 컨트롤러 :
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)viewDidAppear:(BOOL)animated {
[self.sceneView loadScene];
}
@end
장면 키트보기 헤더 :
모델은이
코드입니다 ... 실제로 애플의 예에 제공 및 OS X에 완벽하게 작동된다// ASCView.h
#import <UIKit/UIKit.h>
#import <SceneKit/SceneKit.h>
@interface ASCView : SCNView
- (void)loadScene;
@end
장면 키트보기 구현 :
//
// ASCView.m
// anim_test
//
//
#import "ASCView.h"
@implementation ASCView
- (void)loadScene {
self.backgroundColor = [UIColor blueColor];
self.allowsCameraControl = YES;
[self loadSceneAndAnimations];
}
#pragma mark - Animation loading
- (void)loadSceneAndAnimations {
// Load the character from one of our dae documents, for instance "idle.dae"
NSURL *idleURL = [[NSBundle mainBundle] URLForResource:@"idle" withExtension:@"dae"];
SCNScene *idleScene = [SCNScene sceneWithURL:idleURL options:nil error:nil];
SCNScene *scene = [SCNScene sceneNamed:@"scene.dae"];
self.scene = scene;
NSLog(@"scene: %@", self.scene);
// Merge the loaded scene into our main scene in order to
// place the character in our own scene
for (SCNNode *child in idleScene.rootNode.childNodes)
[self.scene.rootNode addChildNode:child];
// Load and start run animation
// The animation identifier can be found in the Node Properties inspector of the Scene Kit editor integrated into Xcode
[self loadAndStartAnimation:@"run" withIdentifier:@"RunID"];
}
- (void)loadAndStartAnimation:(NSString *)sceneName withIdentifier:(NSString *)animationIdentifier {
NSURL *sceneURL = [[NSBundle mainBundle] URLForResource:sceneName withExtension:@"dae"];
SCNSceneSource *sceneSource = [SCNSceneSource sceneSourceWithURL:sceneURL options:nil];
CAAnimation *animationObject = [sceneSource entryWithIdentifier:animationIdentifier withClass:[CAAnimation class]];
NSLog(@"duration: %f", [animationObject duration]); //0.9
animationObject.duration = 1.0;
animationObject.repeatCount = INFINITY;
[self.scene.rootNode addAnimation:animationObject forKey:@"foofoofoo"];
NSLog(@"animation: %@",[self.scene.rootNode animationForKey: @"foofoofoo"]);
NSLog(@"is paused: %@",[self.scene.rootNode isAnimationForKeyPaused: @"foofoofoo"] ? @"yes" : @"no"); //NO
}
@end
,