iOS Guides | Samples

MonoTouch.SceneKit Namespace

The SceneKit namespace provides high-level, scene-graph-based 3D graphics.

Remarks

Scene Kit is a framework for 3D graphics, based on hierarchical scene-graphs.

The fundamental classes in Scene Kit are SCNScene, which holds all content, and SCNView, a UIView that renders an SCNScene.

An SCNScene has a SCNScene.RootNode property of type SCNNode. SCNNode's have SCNNode.ChildNodes and implement System.Collections.Generic.IEnumerable`1<class MonoTouch.SceneKit.SCNNode>. Properties of SCNNode include SCNNode.Camera, of type SCNCamera, SCNNode.Geometry, of type SCNGeometry, and SCNNode.Light, of type SCNLight.

Additionally, every SCNNode has a SCNNode.Position property that defines a location in space relative to the SCNNode's SCNNode.ParentNode and SCNNode.FirstMaterial and SCNNode.Materials that create the SCNNode's appearance.

The following example shows a minimal Scene Kit view:

C# Example

public MySceneView (RectangleF frame) : base(frame)
{
	BackgroundColor = UIColor.Blue;
	this.Scene = new SCNScene ();

	var material = new SCNMaterial ();
	material.Diffuse.Contents = UIImage.FromFile("textureX.png");
	material.Specular.Contents = UIColor.Gray;
	material.LocksAmbientWithDiffuse = true;

	Scene.RootNode.Geometry = new SCNBox {
		Width = 1,
		Height = 1,
		Length = 1,
		ChamferRadius = 0.2f,
		FirstMaterial = material
	};

	Scene.RootNode.Light = new SCNLight {
		LightType = SCNLightType.Ambient,
		Color = UIColor.Gray,
	};

	var camera = new SCNCamera ();
	var cameraNode = new SCNNode () {
		Camera = camera,
		Position = new SCNVector3 (3, 3, 3),
		Constraints = new SCNConstraint[] { SCNLookAtConstraint.Create(Scene.RootNode) }
	};
	Scene.RootNode.AddChildNode (cameraNode);
}

Geometry

All geometry in SceneKit is described by subclasses of SCNGeometry:

SCNCapsule A pill-shaped capsule with adjustable end caps

SCNCone A cone whose top can be truncated

SCNCube A rectangular box.

SCNCylinder A cylinder.

SCNFloor An infinite plane with the ability to reflect the geometry above it.

SCNPlane A one-sided rectangle.

SCNPyramid A tetrahedron.

SCNShape A 2D shape that has been extruded into the 3rd dimension.

SCNSphere A ball.

SCNText Extruded text.

SCNTorus A donut shape.

SCNTube An uncapped cylinder.

In addition, SceneKit can load entire scenes from .DAE files with the FromFile method.

Finally, developers can create custom geometry using the SCNGeometry.Create(SCNGeometrySource[],SCNGeometryElement[]) method with arrays of appropriate SCNGeometrySource and SCNGeometryElement objects. The following shows the creation of a custom pyramid:

C# Example

//Lower-left
var a = new SCNVector3(-1, -1, 0);
//Upper-right
var b = new SCNVector3(1, 1, 0);

var halfX = (c.X + a.X) / 2;
var halfY = (c.Y + a.Y) / 2;
var halfZ = (c.Z + a.Z) / 2;

var b = new SCNVector3(a.X, c.Y, halfZ);
var d = new SCNVector3(c.X, a.Y, halfZ);
//Elevate the midpoint so that it's clearly a pyramid
var midPoint = new SCNVector3(halfX, halfY, halfZ + 1.0);

//The vertices of the geometry
var locs = new [] {
	a, b, c, d, midPoint
};
var locSource = SCNGeometrySource.FromVertices(locs);

//Note that this relies on the ordering of locs above
//and it defines triangles (could be triangle strips, etc.)
var indices = new [] {
	//Triangles are defined counter-clockwise!
	4, 1, 0,
	1, 4, 2,
	2, 4, 3,
	3, 4, 0
};


var idxArray = new byte[indices.Length][];
for(int i = 0; i < idxArray.Length; i++)
{
	idxArray[i] = BitConverter.GetBytes(indices[i]);
}
var idxData = NSData.FromArray(idxArray.SelectMany(id => id).ToArray());

//Note that this relies on indices defining triangles
var element = SCNGeometryElement.FromData(idxData, SCNGeometryPrimitiveType.Triangles, indices.Length / 3, sizeof(int));

//Normals are relative to geometry
var normals = new [] {
	new SCNVector3(0, 0, 1),
	new SCNVector3(0, 0, 1),
	new SCNVector3(0, 0, 1),
	new SCNVector3(0, 0, 1),
	new SCNVector3(0, 0, 1),
};;
var normSource = SCNGeometrySource.FromNormals(normals);

//These texture coords will cause the texture to wrap 
var txCoords = new [] {
	new CGPoint(-1, -1),
	new CGPoint(-1, 1),
	new CGPoint(1, 1),
	new CGPoint(1, -1)
};

var txCoordsSource = SCNGeometrySource.FromTextureCoordinates(txCoords);

var geometry = SCNGeometry.Create(new [] { locSource, normSource, txCoordsSource }, new [] { element });

Classes

TypeReason
_SCNShaderModifiersA dictionary of shader snippets.
ISCNActionableInterface representing the required methods (if any) of the protocol SCNActionable.
ISCNAnimatableInterface representing the required methods (if any) of the protocol SCNAnimatable.
ISCNAnimationProtocol
ISCNBoundingVolumeInterface representing the required methods (if any) of the protocol SCNBoundingVolume.
ISCNBufferStreamInterface for managing a custom shader's Metal buffer.
ISCNCameraControlConfiguration
ISCNCameraControllerDelegateInterface representing the required methods (if any) of the protocol SCNCameraControllerDelegate.
ISCNNodeRendererDelegateInterface representing the required methods (if any) of the protocol SCNNodeRendererDelegate.
ISCNPhysicsContactDelegateInterface representing the required methods (if any) of the protocol SCNPhysicsContactDelegate.
ISCNProgramDelegateInterface representing the required methods (if any) of the protocol SCNProgramDelegate.
ISCNSceneExportDelegateInterface representing the required methods (if any) of the protocol SCNSceneExportDelegate.
ISCNSceneRendererInterface representing the required methods (if any) of the protocol SCNSceneRenderer.
ISCNSceneRendererDelegateInterface representing the required methods (if any) of the protocol SCNSceneRendererDelegate.
ISCNShadableInterface representing the required methods (if any) of the protocol SCNShadable.
ISCNTechniqueSupportInterface representing the required methods (if any) of the protocol SCNTechniqueSupport.
SCNActionPerforms actions on a SCNNode, including changes to appearance, geometry, animations, or arbitrary functions.
SCNActionableAllows actions to be applied.
SCNActionable_ExtensionsExtension methods to the ISCNActionable interface to support all the methods from the SCNActionable protocol.
SCNActionNodeWithElapsedTimeHandlerCompletion handler used with SCNAction.CustomAction.
SCNActionTimingModeEnumerates rate curves for use with SCNAction objects.
SCNAnimatableAllows animations to be applied.
SCNAnimatable_ExtensionsExtension methods to the ISCNAnimatable interface to support all the methods from the SCNAnimatable protocol.
SCNAnimation
SCNAnimationDidStartHandler
SCNAnimationDidStopHandler
SCNAnimationEventPerforms a function at a specific time during an animation.
SCNAnimationEventHandlerCompletion handler for use with SCNAnimationEvent.Create.
SCNAnimationImportPolicyEnumerates animation import policies.
SCNAnimationPlayer
SCNAntialiasingModeEnumerates values that control antialiasing behavior.
SCNAudioPlayerHolds a SCNAudioSource or AVAudioNode for use with positional audio.
SCNAudioSourceA reusable audio source for positional audio in SceneKit scenes.
SCNBillboardAxisEnumeration of axes' locks available to nodes constrained by SCNBillboardConstraint.
SCNBillboardConstraintAutomatically constrains a SCNNode so that it always points to the current rendering node.
SCNBindingHandlerCompletion handler used with SCNShadable.HandleBinding.
SCNBlendModeEnumeration of the ways SceneKit can blend colors from a material with colors that already exist in the render target.
SCNBoundingVolumeFunctions that define a volume in 3D space.
SCNBoxAn SCNGeometry whose faces are all rectangles.
SCNBufferBindingHandler
SCNBufferFrequencyEnumerates values that control whether handlers are invoked per frame, per node per frame, or per node per frame per shaded renderable.
SCNCameraSpecifies a camera, with attributes such as field-of-view and depth-of-view.
SCNCameraController
SCNCameraControllerDelegate
SCNCameraControllerDelegate_ExtensionsExtension methods to the ISCNCameraControllerDelegate interface to support all the methods from the SCNCameraControllerDelegate protocol.
SCNCameraProjectionDirection
SCNCapsuleAn SCNGeometry that is a cylinder with capped ends.
SCNChamferModeEnumerates the ways a SCNShape can be chamfered; on its front, back, or both sides.
SCNColorMask
SCNConeAn SCNGeometry that is a circular frustum. Or, a party hat.
SCNConstraintAutomatically adjusts the transformation of a node.
SCNCullModeEnumeration determining which faces of a surface SCNMaterial are rendered.
SCNCylinderAn SCNGeometry that is a right circular cylinder.
SCNDebugOptionsEnumerates debug overlay options.
SCNErrorCode
SCNErrorCodeExtensionsExtension methods for the MonoTouch.SceneKit.SCNErrorCode enumeration.
SCNFieldForceEvaluatorDelegate for the SCNPhysicsField.CustomField method.
SCNFillMode
SCNFilterModeEnumeration of texture filtering modes.
SCNFloorAn SCNGeometry that is an infinite plane.
SCNGeometryBase class for SceneKit geometry objects
SCNGeometryElementCombines information about vertices and a drawing primitive. Maps to a single drawing command sent to the GPU.
SCNGeometryPrimitiveTypeEnumeration of 2D geometry primitives.
SCNGeometrySourceProvides vertex data that, in conjunction with SCNGeometryElements, define a 3D object.
SCNGeometrySourceSemanticEnumerates vertex mode attributes.
SCNGeometrySourceSemanticsEnumerates semantics for geometry data.
SCNGeometryTessellator
SCNHitTestConstants for use with the options argument in SCNNode.HitTest.
SCNHitTestOptionsConfiguration options for hit-testing in SCNNode and SCNSceneRenderer
SCNHitTestResultInformation about the SCNNode (if any) located at a specific point or along a ray.
SCNHitTestSearchMode
SCNIKConstraintAn SCNConstraint that applies inverse kinematics.
SCNInteractionMode
SCNJavaScriptStatic class that contains a method to export JavaScript modules.
SCNLevelOfDetailControls alternate geometries rendered at thresholds in either world-space or screen-space.
SCNLightA light source, used for all SCNLightTypes.
SCNLightingModelConstants for use with the SCHMaterial.LightingModel property, which defines the way lights and materials combine to produce a particular rendered color.
SCNLightTypeEnumerates the types of SCNLight.
SCNLookAtConstraintAn SCNConstraint that orients a node to point towards another node.
SCNMaterialSpecifies the lighting and shading characteristics of the surface of an SCNGeometry.
SCNMaterialPropertyConfigures the various properties (such as color and texture) of a SCNMaterial.
SCNMatrix4A 4x4 matrix.
SCNMorpherAn animated transformation of an SCNGeometry into one or more target SCNGeometry objects.
SCNMorpherCalculationModeEnumeration of valid interpolation formulae for SCNMorpher.CalculationMode.
SCNMovabilityHintEnumerates values that tell SceneKit whether nodes are expected to move over time.
SCNNodeA node in the scene graph.
SCNNodeFocusBehavior
SCNNodeHandler
SCNNodePredicateDelegate for use with SCNNode.EnumerateChildNodes.
SCNNodeRendererDelegateInterface defining delegate object functions for adding custom OpenGL drawing code.
SCNNodeRendererDelegate_ExtensionsExtension methods to the ISCNNodeRendererDelegate interface to support all the methods from the SCNNodeRendererDelegate protocol.
SCNParticleBirthDirectionEnumerates the initial direction of particles emitted by a SCNParticleSystem.
SCNParticleBirthLocationEnumeration of the initial location of particles emitted by a SCNParticleSystem.
SCNParticleBlendModeEnumeration of the ways in which overlapping particles emitted by a SCNParticleSystem will be rendered.
SCNParticleEventEnumeration of lifecycle events for particles emitted by a SCNParticleSystem. Used with SCNParticleSystem.HandleEvent.
SCNParticleEventHandlerCompletion handler for use with SCNParticleSystem.HandleEvent.
SCNParticleImageSequenceAnimationModeEnumeration of playing modes for SCNParticleSystem's whose particles are rendered as a sequence of images.
SCNParticleInputModeEnumerates how a particle property is animated (over the lifetime of the particle, as the particle travels over a distance, or based on another property). Used with SCNParticlePropertyController.InputMode.
SCNParticleModifierHandlerDelegate used as the handler in SCNParticleSystem.AddModifier.
SCNParticleModifierStageEnumerates moments when the modifier specified in SCNParticleSystem.AddModifier should be applied.
SCNParticleOrientationModeEnumerates the alignment of particles emitted by a SCNParticleSystem. Used with SCNParticleSystem.OrientationMode.
SCNParticleProperty
SCNParticlePropertyControllerAnimates a property of the particles emitted by a SCNParticleSystem.
SCNParticleSortingModeEnumeration specifying the order in which particles emitted by a SCNParticleScene are rendered.
SCNParticleSystemEmits small sprites whose behaviors are developer-specified.
SCNPhysicsBallSocketJointAn SCNPhysicsBehavior that allows two SCNPhysicsBody objects to pivot around each other.
SCNPhysicsBehaviorControls the behavior of one or more SCNPhysicsBody objects.
SCNPhysicsBodyAdds physics simulation to an SCNNode.
SCNPhysicsBodyTypeAn enumeration specifying whether the SCNPhysicsBody is dynamic, kinematic, or static. Used with SCNPhysicsBody.CreateBody.
SCNPhysicsCollisionCategoryDefaults for the collision properties of a SCNPhysicsBody.
SCNPhysicsContactHow two SCNPhysicsBody objects are in contact with each other.
SCNPhysicsContactDelegateDelegate object functions responding to touches between SCNPhysicsBody objects..
SCNPhysicsContactDelegate_ExtensionsExtension methods to the ISCNPhysicsContactDelegate interface to support all the methods from the SCNPhysicsContactDelegate protocol.
SCNPhysicsContactEventArgsProvides data for the SCNPhysicsContactEventArgs.DidBeginContact, SCNPhysicsContactEventArgs.DidEndContact and SCNPhysicsContactEventArgs.DidUpdateContact events.
SCNPhysicsFieldApplies forces to all SCNPhysicsBody objects in a given volume.
SCNPhysicsFieldScopeEnumerates values specifying whether an SCNPhysicsField affects objects inside or outside its border.
SCNPhysicsHingeJointAn SCNPhysicsBehavior that attaches two SCNPhysicsBody objects along a single axis.
SCNPhysicsSearchModeEnumerates values that control which physics search results are returned.
SCNPhysicsShapeA solid volume for a SCNPhysicsBody. Used in collision detection.
SCNPhysicsShapeOptionsValid keys for the options dictionary used with SCNPhysicsShape.Create.
SCNPhysicsShapeOptionsKeysDefines valid keys for use with the options dictionary passed to SCNPhysicsShape.Create.
SCNPhysicsShapeOptionsTypesGeometrical type associated with SCNPhysicsShapes.
SCNPhysicsShapeTypeEnumeration of categories for SCNPhysicsShapes.
SCNPhysicsSliderJointAn SCNPhysicsBehavior that connects two SCNPhysicsBody objects, allowing them to slide and rotate around their connecting points.
SCNPhysicsTestValid options for use with SCNPhysicsWorld.ContactTest.
SCNPhysicsTestKeysContains values that control searching, backface culling, and collision testing.
SCNPhysicsTestSearchModeKeysEnumerates values that control which collision search results are returned.
SCNPhysicsVehicleAn SCNPhysicsBehavior that simulates the physics of a wheeled vehicle.
SCNPhysicsVehicleWheelThe appearance and physical characteristics of a wheel on a SCNPhysicsVehicle.
SCNPhysicsWorldA physics simulation that models collisions and other physics-related properties in an SCNScene.
SCNPlaneAn SCNGeometry that is a rectangular single-sided finite plane.
SCNProgramPerforms custom rendering using shaders written in OpenGL Shading Language.
SCNProgramDelegateDelegate object for SCNProgram objects.
SCNProgramDelegate_ExtensionsExtension methods to the ISCNProgramDelegate interface to support all the methods from the SCNProgramDelegate protocol.
SCNProgramSemanticOptionsDefines the SCNProgramSemanticOptions.MappingChannel for use with SCNProgram.SetSemantic.
SCNPropertyControllers
SCNPyramidAn SCNGeometry that is a right rectangular pyramid.
SCNQuaternionRepresents a quaternion and contains methods that operate on them.
SCNReferenceLoadingPolicyEnumerates possible loading policies for SCNReferenceNode objects.
SCNReferenceNodeA SCNNode that loads its content from a scene file.
SCNRendererRenders an SCNScene into an OpenGL context.
SCNRenderingApiEnumerates values that signify the Metal or OpenGLES2 APIs.
SCNRenderingArgumentsDefines keys for use with SCNNodeRendererDelegate.Render and SCNProgram.SetSemantic.
SCNRenderingOptionsA DictionaryContainer that defines options when instantiating a SCNView.
SCNSceneThe highest-level description of a 3D scene.
SCNSceneExportDelegateProtocol that defines methods to handle exporting a scene to a file.
SCNSceneExportDelegate_ExtensionsExtension methods to the ISCNSceneExportDelegate interface to support all the methods from the SCNSceneExportDelegate protocol.
SCNSceneExportProgressHandlerContinuation handler that SceneKit repeatedly calls when exporting a scene.
SCNSceneLoadingOptionsOptions for scene loading.
SCNSceneRendererImplementation class of the MonoTouch.SceneKit.ISCNSceneRenderer interface.
SCNSceneRenderer_ExtensionsExtension methods to the ISCNSceneRenderer interface to support all the methods from the SCNSceneRenderer protocol.
SCNSceneRendererDelegateDelegate object for the SCNRenderer class, defines methods reflects rendering events.
SCNSceneRendererDelegate_ExtensionsExtension methods to the ISCNSceneRendererDelegate interface to support all the methods from the SCNSceneRendererDelegate protocol.
SCNSceneSourceReads scene-defining data from a file or NSData object.
SCNSceneSourceFilterDelegate that tests objects in the scene for inclusion.
SCNSceneSourceLoadErrorsEnumerates error types that can occur while loading SCNSceneSources.
SCNSceneSourceLoadingOptions for creating and loading SCNScene objects.
SCNSceneSourcePropertiesMetadata keys associated with a scene file. Used with SCNSceneSource.GetProperty.
SCNSceneSourceStatusEnumerates the states of an SCNSceneSource.
SCNSceneSourceStatusHandlerCallback used to reflect progress during execution of SCNSceneSource.SceneFromOptions.
SCNShadableImplementation of SceneKit.ISCNShadable.
SCNShadable_ExtensionsExtension methods to the ISCNShadable interface to support all the methods from the SCNShadable protocol.
SCNShaderModifiersA DictionaryContainer containing options for shaders.
SCNShadowModeEnumeration controlling when shadows are calculated.
SCNShapeAn SCNGeometry created from a 2D path, optionally extruded into three dimensions.
SCNSkinnerAccesses the scene graph in support of skeletal animation.
SCNSphereAn SCNGeometry that is a sphere.
SCNTechniqueProvides additional drawing passes, each of which applies a shader.
SCNTechniqueSupportImplementation of ISCNTechniqueSupport that simply holds a reference to the SCNTechnique.
SCNTessellationSmoothingMode
SCNTextAn SCNGeometry based on a string, optionally extruded into three dimensions.
SCNTimingFunction
SCNTorusAn SCNGeometry that is a ring-shaped solid.
SCNTransactionAllows a set of modifications to be applied atomically.
SCNTransformConstraintAn SCNConstraint that executes a function specifying a change in transformation (position, rotation, and scale) to a node or nodes.
SCNTransformConstraintHandlerDelegate used in calls to SCNTransformConstraint.Create.
SCNTransparencyModeEnumerates techniques for calculating transparency.
SCNTubeAn SCNGeometry that is a cylinder with a hole along its central axis.
SCNVector3A 3-component vector.
SCNVector4A 4-component vector.
SCNViewA UIView that renders SCNScenes.
SCNView+SCNViewAppearanceAppearance class for objects of type SCNView.
SCNWrapModeEnumerates texture-wrapping techniques.