SCNGeometry.Create Metodo

Definizione

Overload

Create()

Crea un nuovo elemento geometry.

Create(SCNGeometrySource[], SCNGeometryElement[])

Crea un nuovo oggetto geometry dalle matrici specificate di sources e elements.

Create()

Crea un nuovo elemento geometry.

[Foundation.Export("geometry")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.MacOSX, 10, 9, ObjCRuntime.PlatformArchitecture.All, null)]
public static SceneKit.SCNGeometry Create ();
static member Create : unit -> SceneKit.SCNGeometry

Restituisce

Attributi

Si applica a

Create(SCNGeometrySource[], SCNGeometryElement[])

Crea un nuovo oggetto geometry dalle matrici specificate di sources e elements.

[Foundation.Export("geometryWithSources:elements:")]
public static SceneKit.SCNGeometry Create (SceneKit.SCNGeometrySource[] sources, SceneKit.SCNGeometryElement[] elements);
static member Create : SceneKit.SCNGeometrySource[] * SceneKit.SCNGeometryElement[] -> SceneKit.SCNGeometry

Parametri

sources
SCNGeometrySource[]

Matrice di oggetti SCNGeometrySource.

elements
SCNGeometryElement[]

Matrice di oggetti SCNGeometryElement.

Questo parametro può essere null.

Restituisce

Attributi

Commenti

Usato per creare geometria personalizzata. A seconda delle esigenze dello sviluppatore, il numero e i tipi di sources matrici e elements possono essere altamente variabili. Nell'esempio seguente viene illustrato l'uso di vertici, definizione di triangoli, su cui viene mappata una singola trama. Si noti come vengono usati valori di indice specifici all'interno locs per definire indices e come l'ordinamento all'interno locs di influisce normals e txCoords. Si noti anche come i tripletti in indices sono collegati a 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);

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 });

Si applica a