Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
physics [2020/05/24 13:17] – [Colliders] adminphysics [2020/05/24 13:28] – [Remote-Control] admin
Line 20: Line 20:
 </file> </file>
  
 +
 +==== Start ====
 +
 +To enable physics computation you have to enable the controller, by simply activating it.
 +
 +<file pascal>
 +GorillaPhysicsSystem1.Active := true;
 +</file>
  
 ==== Iterations ==== ==== Iterations ====
Line 84: Line 92:
 Even though you link visual components like TGorillaCube or TGorillaSphere, __those are just links__ and __are not utilized for computation__. Even though you link visual components like TGorillaCube or TGorillaSphere, __those are just links__ and __are not utilized for computation__.
  
-You push starting transformation and body data by adding a collider+On collider registration you push starting transformation information and shape data to the physics world
-  * AddBoxCollider +  * AddBoxCollider() 
-  * AddSphereCollider +  * AddSphereCollider() 
-  * AddCapsuleCollider +  * AddCapsuleCollider() 
-  * AddParticleCollider +  * AddParticleCollider() 
-  * AddTerrainCollider +  * AddTerrainCollider() 
-  * AddMeshCollider+  * AddMeshCollider()
  
 From there on the physics controller will compute transformation based on its own universe. From there on the physics controller will compute transformation based on its own universe.
Line 99: Line 107:
 [[#Remote-Control|Remote-Control]] [[#Remote-Control|Remote-Control]]
  
-Derived components of TCustomMesh and TGorillaMesh are supported for colliders.+Derived components of **TCustomMesh** and **TGorillaMesh** are supported for colliders.
 ===== Threading ===== ===== Threading =====
  
Line 198: Line 206:
 Those callbacks will give you the both colliding elements at this moment of TQ3Body type (Gorilla.Physics.Q3.Body). 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 "UserData", which contains the linked visual component. The type of that link you can request with the property "UserDataType". Each body has an untyped pointer property "UserData", which contains the linked visual component. The type of that link you can request with the property "UserDataType".
 +
 +<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('Cube1') and TComponent(ABodyB.UserData).Name.Equals('Sphere2') then
 +    begin
 +      FMX.Types.Log.D('expected collision between %s <=> %s', 
 +        [TComponent(ABodyA.UserData).Name, TComponent(ABodyB.UserData).Name]);
 +    end
 +    else
 +    begin
 +      FMX.Types.Log.D('<ERROR> unexpected collision between %s <=> %s', 
 +        [ABodyA.UserDataType^.Name, ABodyB.UserDataType^.Name]);
 +    end;
 + end;
 +</file>
 ===== Remote-Control ===== ===== Remote-Control =====
  
Line 211: Line 240:
  
 **__CAUTION:__ By this methods you can influence physical mechanics so heavily, that overstep bounds / limits, which may lead to unexpected behaviour.** **__CAUTION:__ By this methods you can influence physical mechanics so heavily, that overstep bounds / limits, which may lead to unexpected behaviour.**
 +
 +<file pascal>
 +GorillaPhysicsSystem1.RemoteBodyImpulse(GorillaCube1, Point3D(0, -1, 0));
 +</file>
  
 Next step: [[fmodaudio|FMOD Audio]] Next step: [[fmodaudio|FMOD Audio]]