SCNGeometrySource Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides vertex data that, in conjunction with SCNGeometryElements, define a 3D object.
[Foundation.Register("SCNGeometrySource", true)]
public class SCNGeometrySource : Foundation.NSObject, Foundation.INSSecureCoding, IDisposable
[<Foundation.Register("SCNGeometrySource", true)>]
type SCNGeometrySource = class
inherit NSObject
interface INSCoding
interface INativeObject
interface IDisposable
interface INSSecureCoding
- Inheritance
- Attributes
- Implements
Remarks
Developers who wish to programmatically generate custom SCNGeometry objects use the Create(SCNGeometrySource[], SCNGeometryElement[]) method. The form and number of the SCNGeometrySource objects varies based on the manner in which the developer is describing the geometry (for instance, whether vertex data comes as a series of triplets describing triangles or a moving series that describes a triangle strip) and whether the geometry will simply be colored or have a texture map.
The following code demonstrates the custom code to create a custom four-sided pyramid. This example shows the use of vertices, defining triangles, on which a single texture is mapped. Note how specific index values within locs are used to define indices and how the ordering within locs affects normals and txCoords. Also, notice how the triplets in indices are linked to SCNGeometryPrimitiveType.Triangles.
//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(0, 0),
new CGPoint(0, 1),
new CGPoint(1, 1),
new CGPoint(1, 0),
new CGPoint(0.5, 0.5)
};
var txCoordsSource = SCNGeometrySource.FromTextureCoordinates(txCoords);
var geometry = SCNGeometry.Create(new [] { locSource, normSource, txCoordsSource }, new [] { element });
Constructors
| Name | Description |
|---|---|
| SCNGeometrySource() |
Creates a new SCNGeometrySource with default values. |
| SCNGeometrySource(NativeHandle) |
A constructor used when creating managed representations of unmanaged objects. Called by the runtime. |
| SCNGeometrySource(NSCoder) |
A constructor that initializes the object from the data stored in the unarchiver object. |
| SCNGeometrySource(NSObjectFlag) |
Constructor to call on derived classes to skip initialization and merely allocate the object. |
Properties
| Name | Description |
|---|---|
| AccessibilityAttributedUserInputLabels | (Inherited from NSObject) |
| AccessibilityRespondsToUserInteraction | (Inherited from NSObject) |
| AccessibilityTextualContext | (Inherited from NSObject) |
| AccessibilityUserInputLabels | (Inherited from NSObject) |
| BytesPerComponent | |
| Class | (Inherited from NSObject) |
| ClassHandle |
The Objective-C class handle for this class. |
| ComponentsPerVector | |
| Data | |
| DataOffset | |
| DataStride | |
| DebugDescription | (Inherited from NSObject) |
| Description | (Inherited from NSObject) |
| ExposedBindings | (Inherited from NSObject) |
| FloatComponents | |
| Handle |
Handle (pointer) to the unmanaged object representation. (Inherited from NSObject) |
| IsDirectBinding | (Inherited from NSObject) |
| IsProxy | (Inherited from NSObject) |
| RetainCount | (Inherited from NSObject) |
| Self | (Inherited from NSObject) |
| Semantic | |
| Superclass | (Inherited from NSObject) |
| SuperHandle |
Handle used to represent the methods in the base class for this NSObject. (Inherited from NSObject) |
| VectorCount | |
| Zone | (Inherited from NSObject) |