Class PhysicsBeamSample
Example component using Frozen World to facilitate physics simulation.
Implements
Namespace: Microsoft.MixedReality.WorldLocking.Examples
Assembly: cs.temp.dll.dll
Syntax
public class PhysicsBeamSample : InputSystemGlobalHandlerListener
Remarks
This MRTK based component uses MRTK for inputs to abstract out device.
In all modes, the ray cast intersection as reported by MRTK is further filtered to specifically exclude UI elements. Along with collidable objects in the scene, a collidable spatial map is also included as ray cast target. The "hit point" is the intersection of the currently active pointer ray with those collidables, along with information about that object and the intersection (e.g. surface normal at hit point). If there is no current hit point, after excluding UI elements, no operation is performed.
The component itself has 5 modes of operation:
- Idle - ignore inputs, do nothing
- Throw darts - compute and display an ballistic arc to toss a physics rigid body at the current hit point.
- Place pillar - Place an upright pillar at hit point. If the hit object is not a beam or pillar (e.g. is the spatial map), then a static pillar is added, else a physically simulated pillar.
- Place beam - A two part operation. The first select of a hit point establishes the first end point of a beam, and the second hit point the other beam's end point. A physically simulated beam stretched to have those two endpoints is generated and added to the scene.
- Remove object - Clicking on an object added to the scene in one of the above modes will remove it from the scene.
Mode selection is done via the MRTK radio buttons (see Microsoft.MixedReality.Toolkit.UI.InteractableToggleCollection) included in the scene as an addition to the dashboard.
Properties
AttachRoot
The subroot to attach created objects to.
Declaration
public Transform AttachRoot { get; }
Property Value
Type | Description |
---|---|
Transform |
LineMaterial
Material to use when rendering line for beam placement.
Declaration
public Material LineMaterial { get; }
Property Value
Type | Description |
---|---|
Material |
PrefabBeam
The prefab of the beam to place in the world at gaze position on air taps.
Declaration
public GameObject PrefabBeam { get; }
Property Value
Type | Description |
---|---|
GameObject |
PrefabDart
The prefab of the dart to place in the world at gaze position on air taps.
Declaration
public GameObject PrefabDart { get; }
Property Value
Type | Description |
---|---|
GameObject |
PrefabHybridLockedSphere
The prefab of the hybrid-locked 'sphere' to place in the world at gaze position on air taps in Pin Sphere Mode.
Declaration
public GameObject PrefabHybridLockedSphere { get; }
Property Value
Type | Description |
---|---|
GameObject |
PrefabPillarDynamic
The prefab of dynamic pillars to place in the world at gaze position on air taps.
Declaration
public GameObject PrefabPillarDynamic { get; }
Property Value
Type | Description |
---|---|
GameObject |
PrefabPillarFixed
The prefab of fixed pillars to place in the world at gaze position on air taps.
Declaration
public GameObject PrefabPillarFixed { get; }
Property Value
Type | Description |
---|---|
GameObject |
PrefabUnlockedSphere
The prefab of the non-locked 'sphere' to place in the world at gaze position on air taps in Pin Sphere Mode.
Declaration
public GameObject PrefabUnlockedSphere { get; }
Property Value
Type | Description |
---|---|
GameObject |
PrefabWorldLockedSphere
The prefab of the world-locked 'sphere' to place in the world at gaze position on air taps in Pin Sphere Mode.
Declaration
public GameObject PrefabWorldLockedSphere { get; }
Property Value
Type | Description |
---|---|
GameObject |
Methods
EnterBeamMode()
Switch into cross-beam placement mode.
Declaration
public void EnterBeamMode()
EnterDartMode()
Switch into dart tossing mode.
Declaration
public void EnterDartMode()
EnterIdleMode()
Switch into idle mode.
Declaration
public void EnterIdleMode()
EnterPillarMode()
Switch into pillar placement mode.
Declaration
public void EnterPillarMode()
EnterPinSphereMode()
Declaration
public void EnterPinSphereMode()
EnterRemoveMode()
Switch into object removal mode.
Declaration
public void EnterRemoveMode()
EnterWorldLockHybridLocked()
Declaration
public void EnterWorldLockHybridLocked()
EnterWorldLockUnlocked()
Declaration
public void EnterWorldLockUnlocked()
EnterWorldLockWorldLocked()
Declaration
public void EnterWorldLockWorldLocked()
OnPointerClicked(MixedRealityPointerEventData)
Process pointer clicked event if ray cast has result.
Declaration
public void OnPointerClicked(MixedRealityPointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityPointerEventData | eventData |
OnPointerDown(MixedRealityPointerEventData)
No-op on pointer down.
Declaration
public void OnPointerDown(MixedRealityPointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityPointerEventData | eventData |
OnPointerDragged(MixedRealityPointerEventData)
No-op on pointer drag.
Declaration
public void OnPointerDragged(MixedRealityPointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityPointerEventData | eventData |
OnPointerUp(MixedRealityPointerEventData)
No-op on pointer up.
Declaration
public void OnPointerUp(MixedRealityPointerEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityPointerEventData | eventData |
RegisterHandlers()
Declaration
protected override void RegisterHandlers()
Start()
Override InputSystemGlobalListener Start() method for additional one-time setup.
Declaration
protected override void Start()
UnregisterHandlers()
Declaration
protected override void UnregisterHandlers()