Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCNGeometry / SCNCylinder render edges / border only (Store color, clear content)

I'm trying to figure out how to have an SCNScylinder on sceen with only a border / stroke / edge visible. Everything in my scene is working fine and i was thinking of just applying a clear color to specular.contents

is the use of a SCNNode delegate / Metal code required (i'm not using opengl on my scene)

Any pointers? help is appreciated

like image 971
David Homes Avatar asked Mar 07 '16 16:03

David Homes


1 Answers

The WWDC 2014 presentation showed orbiting cubes that had only wireframes. The technique was to use an image with green edges but transparent interior as the material. From AAPLSlideScenegraphSummary.m:

        // A node that will help visualize the position of the stars
        _wireframeBoxNode = [SCNNode node];
        _wireframeBoxNode.rotation = SCNVector4Make(0, 1, 0, M_PI_4);
        _wireframeBoxNode.geometry = [SCNBox boxWithWidth:1 height:1 length:1 chamferRadius:0];
        _wireframeBoxNode.geometry.firstMaterial.diffuse.contents = [NSImage imageNamed:@"box_wireframe"];
        _wireframeBoxNode.geometry.firstMaterial.lightingModelName = SCNLightingModelConstant; // no lighting
        _wireframeBoxNode.geometry.firstMaterial.doubleSided = YES; // double sided

enter image description here

For a similar effect with SCNCylinder, you might need to pass an array of materials, some with border and some without.

Edit

For High Sierra/iOS 11 and higher, the answer by @mnuages is a simpler/better approach.

like image 168
Hal Mueller Avatar answered Sep 30 '22 21:09

Hal Mueller