我是新来的.我的第一个问题出现了.
我用SceneKit构建了一个对象加载器.我得到了路径,对象可用,但我不知道如何为显示的对象着色.
ScnScene *testScene = [SCNScene sceneWithURL:url options:nil error:NULL];
testScene.background.contents = [UIImage imageWithName:@"color.png"];
[self.mainView.scene.rootnode addChildNode:testScene.rootNode];
Run Code Online (Sandbox Code Playgroud)
这没用.我也尝试过:
SCNMaterialProperty *testColor = [SCNMaterialProperty materialPropertyWithContents [UIImage imageNamed:@"color.png"]];
testScene.rootnode.geometry.materials = testcolor;
Run Code Online (Sandbox Code Playgroud)
要么:
SCNMaterial *testColor = [SCNMaterial material];
testColor.diffuse.contesnts = [UIColor redColor];
testScene.rootnode.geometry.firstMaterial = testColor;
Run Code Online (Sandbox Code Playgroud)
什么都行不通.当我启动应用程序时,会显示每个对象.到目前为止,OBJ-Loader工作得非常好.但一切仍然是灰色的.我完全不知道如何为显示的对象着色.有没有人给我提示/想法/解决方案?
顺便说一句.我想避免我必须手动从OBJ信息构建几何.所以我试着通过SCNScene来解决这个问题.