Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
physics [2020/05/24 13:29] – [Remote-Control] admin | physics [2020/05/24 13:30] – [Remote-Control] admin | ||
---|---|---|---|
Line 131: | Line 131: | ||
</ | </ | ||
(available since v0.8.2.1600+) | (available since v0.8.2.1600+) | ||
+ | |||
+ | ===== Callbacks ===== | ||
+ | |||
+ | The physics controller provides 2 callback events to interact with the physics world. | ||
+ | * OnBeginContact | ||
+ | * OnEndContact | ||
+ | |||
+ | Those callbacks will give you the both colliding elements at this moment of TQ3Body type (Gorilla.Physics.Q3.Body). | ||
+ | Each body has an untyped pointer property " | ||
+ | |||
+ | <file pascal> | ||
+ | procedure TUIMainWin.doOnBeginContact(const ABodyA, ABodyB : TQ3Body); | ||
+ | begin | ||
+ | if not Assigned(ABodyA.UserDataType) then | ||
+ | Exit; | ||
+ | if not Assigned(ABodyB.UserDataType) then | ||
+ | Exit; | ||
+ | | ||
+ | if TComponent(ABodyA.UserData).Name.Equals(' | ||
+ | begin | ||
+ | FMX.Types.Log.D(' | ||
+ | [TComponent(ABodyA.UserData).Name, | ||
+ | end | ||
+ | else | ||
+ | begin | ||
+ | FMX.Types.Log.D('< | ||
+ | [ABodyA.UserDataType^.Name, | ||
+ | end; | ||
+ | end; | ||
+ | </ | ||
+ | ===== Remote-Control ===== | ||
+ | |||
+ | As you read above, the physics controller universe is separated from scene universe. | ||
+ | But sometimes you need to control elements in physics world. | ||
+ | Therefore we've implemented some helper methods. | ||
+ | * RemoteMeshTransform | ||
+ | * RemoteBodyTransform | ||
+ | * RemoteBodyImpulse | ||
+ | * RemoteBodyForce | ||
+ | |||
+ | <file pascal> | ||
+ | // move cube upwards by impulse | ||
+ | GorillaPhysicsSystem1.RemoteBodyImpulse(GorillaCube1, | ||
+ | </ | ||
+ | |||
+ | By the methods above you're able to set a position and/or rotation explicitly, or to apply a force / impulse on a specific element. | ||
+ | |||
+ | **__CAUTION: | ||
+ | |||
+ | |||
===== Example ===== | ===== Example ===== | ||
For a working physics system you need a TGorillaPhysicsSystem component on your form. | For a working physics system you need a TGorillaPhysicsSystem component on your form. | ||
Line 198: | Line 248: | ||
</ | </ | ||
- | ===== Callbacks ===== | ||
- | |||
- | The physics controller provides 2 callback events to interact with the physics world. | ||
- | * OnBeginContact | ||
- | * OnEndContact | ||
- | |||
- | Those callbacks will give you the both colliding elements at this moment of TQ3Body type (Gorilla.Physics.Q3.Body). | ||
- | Each body has an untyped pointer property " | ||
- | |||
- | <file pascal> | ||
- | procedure TUIMainWin.doOnBeginContact(const ABodyA, ABodyB : TQ3Body); | ||
- | begin | ||
- | if not Assigned(ABodyA.UserDataType) then | ||
- | Exit; | ||
- | if not Assigned(ABodyB.UserDataType) then | ||
- | Exit; | ||
- | | ||
- | if TComponent(ABodyA.UserData).Name.Equals(' | ||
- | begin | ||
- | FMX.Types.Log.D(' | ||
- | [TComponent(ABodyA.UserData).Name, | ||
- | end | ||
- | else | ||
- | begin | ||
- | FMX.Types.Log.D('< | ||
- | [ABodyA.UserDataType^.Name, | ||
- | end; | ||
- | end; | ||
- | </ | ||
- | ===== Remote-Control ===== | ||
- | |||
- | As you read above, the physics controller universe is separated from scene universe. | ||
- | But sometimes you need to control elements in physics world. | ||
- | Therefore we've implemented some helper methods. | ||
- | * RemoteMeshTransform | ||
- | * RemoteBodyTransform | ||
- | * RemoteBodyImpulse | ||
- | * RemoteBodyForce | ||
- | |||
- | <file pascal> | ||
- | // move cube upwards by impulse | ||
- | GorillaPhysicsSystem1.RemoteBodyImpulse(GorillaCube1, | ||
- | </ | ||
- | |||
- | By the methods above you're able to set a position and/or rotation explicitly, or to apply a force / impulse on a specific element. | ||
- | |||
- | **__CAUTION: | ||
Next step: [[fmodaudio|FMOD Audio]] | Next step: [[fmodaudio|FMOD Audio]] |