AppleSCNPhysicsField - UBogun/Xojo-iosLib GitHub Wiki

Inherits from AppleObject
Memory leak check: not yet done.
Status: complete.

An SCNPhysicsField object applies forces to objects in an area of effect within a scene. You can create many types of field effects, such as gravitation, electromagnetism, and turbulence. To add a field effect to a scene, you create a physics field of the type you want to use and then attach it to the physicsField property of a node in the scene.

Physics fields can affect both SCNPhysicsBody objects and the particles spawned by SCNParticleSystem objects.

Constructors

Constructor (Block as AppleBlock): Creates a custom field that runs the specified block to determine the force a field applies to each object in its area of effect. See the SCNForceEvaluatorTemplate method for its structure.

The other constructors are available as class (shared) methods:

Dragfield(): Creates a field that slows any object in its area of effect with a force proportional to the object’s velocity.

ElectricField(): Creates a field that attracts or repels objects based on their electrical charge and on their distance from the field’s center.

LinearGravityField(): Creates a field that accelerates objects in a specific direction.

MagneticField(): Creates a field that attracts or repels objects based on their electrical charge, velocity, and distance from the field’s axis.

NoiseField (Smoothness as Double, AnimationSpeed as Double): Creates a field that applies random forces to objects in its area of effect.
A Smoothness value of 0.0 specifies maximum noise, and a value of 1.0 specifies no noise at all. An animationSpeed of 0.0 means a static field.

RadialGravityField(): Creates a field that accelerates objects toward its center.

SpringField(): Creates a field that pulls objects toward its center with a spring-like force.

TurbulenceField (Smoothness as Double, AnimationSpeed as Double): Creates a field that applies random forces to objects in its area of effect, with magnitudes proportional to those objects’ velocities.
A Smoothness value of 0.0 specifies maximum noise, and a value of 1.0 specifies no noise at all. An animationSpeed of 0.0 means a static field.

VortexField(): Creates a field whose forces circulate around an axis.

Properties

Active As Boolean: Whether the field’s effect is enabled. Default True.

CategoryBitMask As UInteger: A mask that defines which categories this physics field belongs to.

Direction As SCNVector3: The field’s directional axis.

Exclusive As Boolean: Whether the field overrides other fields whose areas of effect it overlaps.

FallOffExponent As Double: An exponent that determines how the field’s strength diminishes with distance.

HalfExtent As SCNVector3: A location marking the end of the field’s area of effect. To define a field’s area of effect, use the position property of the node that contains the field and the field’s halfExtent property. The center of the area of effect is the node’s position. The half-extent, a position vector in the local coordinate space of the node containing the field, marks one corner of a box, and the negative of the half-extent vector marks the opposite corner of the box. For example, if a node’s position is the vector {2.0, 2.0, 2.0} and it contains a physics field whose half-extent is the vector {0.5, 0.5, 0.5}, the field’s area of effect is the box extending from 1.5 to 2.5 along each axis of the scene’s coordinate system.

By default, a field’s area of effect is the interior of this box shape. Use the usesEllipsoidalExtent property to instead make the area of effect an ellipsoid bounded by this box. Use the scope property to choose whether the area of effect is the interior or exterior of the box (or ellipsoid).

The default half-extent is the vector {INFINITY, INFINITY, INFINITY}, specifying that the field affects bodies located anywhere in the scene.

Offset As SCNVector3: The offset of the field’s center within its area of effect.

Scope As SCNPhysicsFieldScope: The area affected by the field, either inside or outside its region.

SCNPhysicsFieldScope Definition
InsideExtent The area inside the field is affected.
OutsideExtent The area outside the field is affected.

Strength As Double: A multiplier for the force that the field applies to objects in its area of effect.

UsesEllipsoidalExtent As Boolean: Whether the field’s area of effect is shaped like a box or ellipsoid. Default False.