SCNMaterial: can't find init:mdlMaterial:

人盡茶涼 提交于 2019-12-02 08:38:23

问题


I'm trying to add a bump map to a material and since apparently there is no way to do it with a plain SCNMaterial, I just tried to use a MDLMaterial instead, and then convert it to a SCNMaterial. There is a method in the Apple documentation for this:

convenience init(MDLMaterial mdlMaterial: MDLMaterial)

But I keep getting an error:

/Users/ramy/Documents/Swift/Space Shooter/Space Shooter/Util.swift:50:26: Incorrect argument label in call (have 'MDLMaterial:', expected 'coder:')

It doesn't seem to find the method. I tried in Objective-C and it still doesn't find it.

Edit

I was already importing ModelIO:

import ModelIO

If I switch to:

import SceneKit.ModelIO

Nothing changes, I still can't find the method.


回答1:


you'll need to import the bridging header to see these methods:

// Objective-C
#import <SceneKit/ModelIO.h>

// Swift
import SceneKit.ModelIO

That said you shouldn't have to use Model I/O. Have you tried the normal material property on SCNMaterial?

Also note that Model I/O was designed as an interexchange format and not all that it can represent is supported by SceneKit. If SceneKit APIs don't expose what you're looking for, there's little to no chance that using an intermediate Model I/O object will help.



来源:https://stackoverflow.com/questions/36117614/scnmaterial-cant-find-initmdlmaterial

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!