I need to create a hemisphere (dome) Shape in ARKit
/SceneKit
scene, we have SCNSphere basic shape in SceneKit, but not sure how to create hemisphere (dome).
Immediate reply will be appreciated.
I need to create a hemisphere (dome) Shape in ARKit
/SceneKit
scene, we have SCNSphere basic shape in SceneKit, but not sure how to create hemisphere (dome).
Immediate reply will be appreciated.
Thanks Andy. Following is coded on basis of ur suggestion which create dome
import ModelIO
func adddome() {
let mesh = MDLMesh.newEllipsoid(withRadii: vector_float3(0.1, 0.1, 0.1), radialSegments: 100, verticalSegments: 50, geometryType: MDLGeometryType.lines, inwardNormals: false, hemisphere: true, allocator: nil)
let node = SCNNode()
node.geometry = MeshToGeometry.convert(mesh)
node.geometry?.firstMaterial?.diffuse.contents = UIColor.blue
node.geometry?.firstMaterial?.specular.contents = UIColor.orange
node.position = SCNVector3(0, 0, 0)
sceneView.scene.rootNode.addChildNode(node)
}
#import <Foundation/Foundation.h>
#import <ModelIO/MDLMesh.h>
#import <SceneKit/SceneKit.h>
#import <SceneKit/ModelIO.h>
@interface MeshToGeometry : NSObject
+ (SCNGeometry*) convert:(MDLMesh*)mesh;
@end
#import "MESHToGEO.h"
@implementation MeshToGeometry
+ (SCNGeometry*) convert:(MDLMesh*)mesh {
return [SCNGeometry geometryWithMDLMesh:mesh];
}
@end
SceneKit has no ready-to-use hemisphere primitive as well as SceneKit isn't a 3D editing tool like Maya or 3dsMax. But you can generate a hemisphere using ModelIO framework:
When argument
hemisphere = true
it allows us generate only the upper half of the ellipsoid or sphere (a dome). Ifhemisphere = false
you can generate a complete ellipsoid or sphere.