SceneKit修改3D对象并导出文件

在我的应用程序中,我使用SceneKit框架在SCNView中显示3D对象,并导出修改后的文件,如颜色,温度等一些小的变化。但是我将原始文件导出到文档文件夹后。

在这里,我可以显示和做一些3D对象的修改,这看起来不错,我可以看到模拟器中SCNView的变化。

sceneView = [[SCNView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 100)]; [sceneView setBackgroundColor:[UIColor orangeColor]]; [self.view addSubview:sceneView]; sceneView.allowsCameraControl = true ; // Load 3D object NSString *path = [[NSBundle mainBundle] pathForResource:@“test” ofType:@"obj"]; NSURL * url = [NSURL fileURLWithPath:path]; scene = [SCNScene sceneWithURL:url options:nil error:nil]; sceneView.scene = scene ; // Processing--- SCNLight *light =[[SCNLight alloc] init]; light.type = SCNLightTypeAmbient; SCNNode *lightNode = [[SCNNode alloc] init]; lightNode.light = light ; // Camera node SCNCamera *camera = [[SCNCamera alloc] init]; SCNNode * Cameranode = [[SCNNode alloc]init]; camera.saturation = 0.5 ; [scene.rootNode addChildNode:Cameranode]; Cameranode.position = SCNVector3Make(0.0, 0.0, 30.0); sceneToExport = sceneView.scene ; // Rotation - SCNNode *cubeNode = [[SCNNode alloc] init]; cubeNode.rotation = SCNVector4Make(1000.0, 0.0, 30.0 , 40.0); [scene.rootNode addChildNode:cubeNode]; 

现在我试图导出我已经修改的3D(.obj)文件。

 - (IBAction)saveAction:(id)sender { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory NSString *exportPath = [documentsPath stringByAppendingPathComponent:@"sceneAssets.obj"]; //NSLog(@"Saved %d",[sceneView.scene writeToURL:[NSURL URLWithString:exportPath] options:nil delegate:nil progressHandler:nil]); NSLog(@"%d",[assetsToExport exportAssetToURL:[NSURL URLWithString:exportPath]]); } 

在这里我已经尝试了这种方式(MDLAssets和SCNKit)通过使用这个.obj文件保存在两个方法的文档目录,但我得到原始文件,而不是修改后的对象。

我也尝试使用SCNScene创buildMDLAsset对象,但获得相同的结果。