The designer provided three files:
- picture. Jpg
- something. MTL
- anything. Obj
I can successfully load the .obj file into my scene, for example:
SCNView * sceneView = [SCNView new];
sceneView.frame = view.bounds;
[view addSubview:sceneView];
SCNScene * scene = [SCNScene sceneNamed:@"models.scnassets/whatever.obj"];
[sceneView setScene:scene];
What I'm struggling with is applying the .jpg and .mtl files in the .obj file. I tried applying the image with the following code, but don't like it:
SCNMaterial * material = [SCNMaterial material];
material.diffuse.contents = [UIImage imageNamed:@"image.jpg"];
SCNNode * materialNode = [SCNNode node];
materialNode.geometry.firstMaterial = material;
[scene.rootNode addChildNode:materialNode];
source
share