Class TCastleGrabJoint
Unit
Declaration
type TCastleGrabJoint = class(TCastleAbstractOneBodyJoint)
Description
Grab joint pulls the rigid body Anchor towards a TargetWorld defined in the world coordinates. The pull is not instant, rather it works like a flexible spring / elastic rope.
Source: transform/castletransform_joints.inc (line 381).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleBehavior
- TCastleAbstractJoint
- TCastleAbstractOneBodyJoint
- TCastleGrabJoint
Overview
Constants
| Public | DefaultFrequencyHz = 5.0; |
| Public | DefaultDampingRatio = 0.7; |
Fields
| Protected | FParentRigidBody: TCastleRigidBody; |
| Protected | FBreakThresholdForce: Single; |
| Protected | FBreakThresholdTorque: Single; |
| Protected | FBreakable: Boolean; |
Methods
| Protected | function GetInternalText: String; virtual; |
| Protected | procedure SetInternalText(const Value: String); virtual; |
| Protected | procedure SetName(const Value: TComponentName); override; |
| Protected | procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual; |
| Public | destructor Destroy; override; |
| Public | procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual; |
| Public | function PropertySections(const PropertyName: String): TPropertySections; virtual; |
| Public | procedure SetTransient; |
| Public | procedure AddNonVisualComponent(const NonVisualComponent: TComponent); |
| Public | procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent); |
| Public | procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent); |
| Public | function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer; |
| Public | function NonVisualComponentsCount: Integer; |
| Public | function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator; |
| Public | function ValueIsStreamed: Boolean; virtual; |
| Public | procedure DesignerInfo(const SList: TStrings); virtual; |
| Public | procedure DesignerWarnings(const SList: TStrings); virtual; |
| Protected | procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); virtual; |
| Protected | procedure BeforeRender( const CameraView: TViewVectors; const ParentParentWorldTransformation: TTransformation); virtual; |
| Protected | procedure ParentChanged; virtual; deprecated 'Use ParentAfterAttach / ParentBeforeDetach or WorldAfterAttach / WorldBeforeDetach'; |
| Protected | procedure ParentAfterAttach; virtual; |
| Protected | procedure ParentBeforeDetach; virtual; |
| Protected | procedure WorldAfterAttach; virtual; |
| Protected | procedure WorldBeforeDetach; virtual; |
| Protected | function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; virtual; |
| Public | procedure BeforeDestruction; override; |
| Public | function World: TCastleAbstractRootTransform; |
| Protected | procedure CreateKraftJoint; virtual; abstract; |
| Protected | function GetKraftJoint: TKraftConstraintJoint; virtual; abstract; |
| Protected | procedure RecreateKraftJoint; |
| Protected | procedure InitializeKraftJoint; virtual; |
| Protected | procedure DeinitializeKraftJoint; virtual; abstract; |
| Protected | function AllNeededKraftObjectsInitialized: Boolean; virtual; |
| Protected | procedure OnParentTransformAddBehavior(const Component: TComponent); virtual; |
| Protected | procedure OnBeforeParentTransfromRemoveBehavior(const Component: TComponent); virtual; |
| Protected | procedure OnParentRigidBodyInitialized(const Component: TComponent); virtual; |
| Protected | procedure OnBeforeParentRigidBodyDeinitialized(const Component: TComponent); virtual; |
| Protected | procedure SetParentRigidBodyEvents; |
| Protected | procedure RemoveParentRigidBodyEvents; |
| Protected | procedure UpdateBreakThresholdForceInKraft; |
| Protected | procedure UpdateBreakThresholdTorqueInKraft; |
| Protected | procedure UpdateBreakableInKraft; |
| Protected | procedure SetBreakThresholdForce(const AValue: Single); |
| Protected | procedure SetBreakThresholdTorque(const AValue: Single); |
| Protected | procedure SetBreakable(const AValue: Boolean); |
| Public | destructor Destroy; override; |
| Public | procedure WorldAfterAttach; override; |
| Public | procedure WorldBeforeDetach; override; |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
| Public | procedure InternalCreateGizmos; virtual; |
| Public | procedure InternalDestroyGizmos; virtual; |
| Protected | function GetKraftJoint: TKraftConstraintJoint; override; |
| Protected | procedure CreateKraftJoint; override; |
| Protected | procedure DeinitializeKraftJoint; override; |
| Protected | procedure SetName(const Value: TComponentName); override; |
| Public | constructor Create(AOwner: TComponent); override; |
| Public | destructor Destroy; override; |
| Public | procedure WorldBeforeDetach; override; |
| Public | procedure InternalCreateGizmos; override; |
| Public | procedure InternalDestroyGizmos; override; |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
Properties
| Public | property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents; |
| Public | property IsLoading: Boolean read FIsLoading; |
| Public | property Parent: TCastleTransform read FParent; |
| Public | property ListenWorldChange: Boolean
read FListenWorldChange write SetListenWorldChange; |
| Published | property Breakable: Boolean read FBreakable write SetBreakable default false; |
| Published | property BreakThresholdForce: Single read FBreakThresholdForce write SetBreakThresholdForce default 0.0; |
| Published | property BreakThresholdTorque: Single read FBreakThresholdTorque write SetBreakThresholdTorque default 0.0; |
| Public | property Anchor: TVector3 read FAnchor write SetAnchor; |
| Public | property TargetWorld: TVector3 read FTargetWorld write SetTargetWorld; |
| Published | property FrequencyHz: Single read FFrequencyHz write SetFrequencyHz default DefaultFrequencyHz; |
| Published | property DampingRatio: Single read FDampingRatio write SetDampingRatio default DefaultDampingRatio; |
| Published | property MaxForce: Single read FMaxForce write SetMaxForce default 0.0; |
| Published | property AnchorPersistent: TCastleVector3Persistent read FAnchorPersistent ; |
| Published | property TargetWorldPersistent: TCastleVector3Persistent read FTargetWorldPersistent ; |
Description
Constants
| Public | DefaultFrequencyHz = 5.0; |
|
This item has no description. | |
| Public | DefaultDampingRatio = 0.7; |
|
This item has no description. | |
Fields
| Protected | FParentRigidBody: TCastleRigidBody; |
|
When joint is added to world we need to find parent rigid body and set callbacks for its initialize/deinitialize events. If this pointer is not nil that means that we've done that. | |
| Protected | FBreakThresholdForce: Single; |
|
This item has no description. | |
| Protected | FBreakThresholdTorque: Single; |
|
This item has no description. | |
| Protected | FBreakable: Boolean; |
|
This item has no description. | |
Methods
| Protected | function GetInternalText: String; virtual; |
|
This item has no description. | |
| Protected | procedure SetInternalText(const Value: String); virtual; |
|
This item has no description. | |
| Protected | procedure SetName(const Value: TComponentName); override; |
|
This item has no description. | |
| Protected | procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual; |
|
Enumerate all properties that are possible to translate in this component. E.g. in TCastleLabel it will return TCastleLabel.Caption, in TCastleEdit it will return TCastleEdit.Text and TCastleEdit.Placeholder. Returns only non-empty properties, thus assuming that if current (by convention, English) text is empty, then there is no point in translating it. Moreover descendants may define boolean properties to exclude particular text from translating, e.g. TCastleLabel.CaptionTranslate, TCastleEdit.TextTranslate, TCastleEdit.PlaceholderTranslate. It is not recursive (it doesn't enumerate children properties). Use global TranslateProperties procedure to call this on a hierarchy of TComponent. You usually don't want to call this method (it is called by other engine routines). But you may find it useful to override this, if you define new component. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual; |
|
Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field. | |
| Public | function PropertySections(const PropertyName: String): TPropertySections; virtual; |
|
Section where to show property in the editor. | |
| Public | procedure SetTransient; |
|
Ignore this component when serializing parent's TCastleUserInterface.Controls list or TCastleTransform.List, and do not show this component in CGE editor. This simply sets csTransient flag in ComponentStyle. This is useful for children that are automatically managed by the parent, and should not be modified by user code. For example, TCastleCheckbox is internally composed from TCastleImageControl and TCastleLabel children, but we don't want to serialize or even show these children to user. Note that if you want to prevent this component from serializing as part of TCastleUserInterface.Controls list or TCastleTransform.List, but you still want it to be visible in CGE editor, then make it a "subcomponent" instead, by Note that both csSubComponent and csTransient only disable the component serialization as part of parent's lists enumerated by CustomSerialization (see internal TCastleUserInterface.SerializeChildrenEnumerate , TCastleTransform.SerializeChildrenEnumerate, TCastleTransform.SerializeBehaviorsEnumerate). If you will make the component published in its own property (which is normal for "subcomponents") then it will be serialized anyway, just as part of it's own property (like TCastleScrollView.ScrollArea). So to really avoid serializing a children component make it csSubComponent and/or csTransient, and do not publish it. | |
| Public | procedure AddNonVisualComponent(const NonVisualComponent: TComponent); |
|
Add non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.
See also
| |
| Public | procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent); |
|
Insert non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.
See also
| |
| Public | procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent); |
|
Removes the component previously added by AddNonVisualComponent. | |
| Public | function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer; |
|
Index of the previously added non-visual component. Returns -1 if the component was not found. | |
| Public | function NonVisualComponentsCount: Integer; |
|
Count of components added by AddNonVisualComponent.
See also
| |
| Public | function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator; |
|
You can enumerate current non-visual components using loop like See also
| |
| Public | function ValueIsStreamed: Boolean; virtual; |
|
Whether the current value of this object should be written to the stream. This should be This is used by CastleComponentSerialize, which is used in Castle Game Engine for all serialization. In simple cases, this just says whether the current value of this object equals to some default value. The default implementation of this class returns Descendants that override this to sometimes return The name of this method is consistent with TPropertyEditor.ValueIsStreamed in LCL. | |
| Public | procedure DesignerInfo(const SList: TStrings); virtual; |
|
Override to add information that should be visible at design-time. Call | |
| Public | procedure DesignerWarnings(const SList: TStrings); virtual; |
|
Override to add warnings that should be visible at design-time. Call | |
| Protected | procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); virtual; |
|
Continuously occuring event, for various tasks. Parameters
| |
| Protected | procedure BeforeRender( const CameraView: TViewVectors; const ParentParentWorldTransformation: TTransformation); virtual; |
|
Event called right before rendering the parent TCastleTransform. Override this if you have to adjust the parent transformation strictly before the rendering. Compared to adjusting the parent transformation in e.g. Update, adjusting the parent transformation here has advantages:
For example, adjusting the TCastleTransform done by the TCastleBillboard is done using this method. The transformation in this case is determined by the camera and parent's parent transformation. The transformation has to be applied without any delay (even a 1-frame delay would be visible, as artifacts caused by billboard not perfectly aligned with the camera would be visible – blending sort along camera direction in sort3D is not perfect if billboard doesn't exactly match camera direction). And the transformation with billboard may be present in multiple viewports and/or multiple times in the same viewport tree.
Parameters
| |
| Protected | procedure ParentChanged; virtual; deprecated 'Use ParentAfterAttach / ParentBeforeDetach or WorldAfterAttach / WorldBeforeDetach'; |
|
Warning: this symbol is deprecated: Use ParentAfterAttach / ParentBeforeDetach or WorldAfterAttach / WorldBeforeDetach Called after Parent changed, at the end of TCastleTransform.AddBehavior, TCastleTransform.RemoveBehavior. | |
| Protected | procedure ParentAfterAttach; virtual; |
|
Called after Parent changed, e.g. at the end of TCastleTransform.AddBehavior. | |
| Protected | procedure ParentBeforeDetach; virtual; |
|
Called before Parent changed, e.g. at the beginning of TCastleTransform.RemoveBehavior. This is also called at the destruction of behavior (more precisely from BeforeDestruction now). Even in this case, we guarantee that Parent is still valid during this call, and not in half-destroyed state. Before the actual destructor of TCastleBehavior we do BeforeParentDetach and BeforeWorldDetach and set Parent to | |
| Protected | procedure WorldAfterAttach; virtual; |
|
Called after Parent became part of World. Called only if ListenWorldChange is | |
| Protected | procedure WorldBeforeDetach; virtual; |
|
Called before Parent stops being part of World. Called only if ListenWorldChange is This is also called at the destruction of behavior (more precisely from BeforeDestruction now). Even in this case, we guarantee that Parent is still valid during this call, and not in half-destroyed state. Before the actual destructor of TCastleBehavior we do BeforeParentDetach and BeforeWorldDetach and set Parent to | |
| Protected | function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; virtual; |
|
Check can this behavior be added to NewParent. When this returns function TCastleBillboard.CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; begin Result := inherited; if not Result then Exit; if NewParent.FindBehavior(TCastleBillboard) <> nil then begin ReasonWhyCannot := 'Only one TCastleBillboard behavior can be added to a given TCastleTransform'; Result := false; end; end; | |
| Public | procedure BeforeDestruction; override; |
|
This item has no description. | |
| Public | function World: TCastleAbstractRootTransform; |
|
Reference to the root transformation (typically matching the TCastleViewport.Items value) corresponding to the parent of this behavior. May be | |
| Protected | procedure CreateKraftJoint; virtual; abstract; |
|
Create physics engine (Kraft) joint and set its specialized properties. | |
| Protected | function GetKraftJoint: TKraftConstraintJoint; virtual; abstract; |
|
Get physics engine (Kraft) joint instance. | |
| Protected | procedure RecreateKraftJoint; |
|
This item has no description. | |
| Protected | procedure InitializeKraftJoint; virtual; |
|
This item has no description. | |
| Protected | procedure DeinitializeKraftJoint; virtual; abstract; |
|
This item has no description. | |
| Protected | function AllNeededKraftObjectsInitialized: Boolean; virtual; |
|
Can we create joint object. | |
| Protected | procedure OnParentTransformAddBehavior(const Component: TComponent); virtual; |
|
Event callback when TCastleRigidBody is added to the parent transform. | |
| Protected | procedure OnBeforeParentTransfromRemoveBehavior(const Component: TComponent); virtual; |
|
Event callback when TCastleRigidBody is removed from the parent transform. | |
| Protected | procedure OnParentRigidBodyInitialized(const Component: TComponent); virtual; |
|
Event callback when TCastleRigidBody behavior is initialized. | |
| Protected | procedure OnBeforeParentRigidBodyDeinitialized(const Component: TComponent); virtual; |
|
Event callback when TCastleRigidBody behavior is deinitialized. | |
| Protected | procedure SetParentRigidBodyEvents; |
|
Sets TCastleRigidBody behavior initialize/deinitialize callbacks. | |
| Protected | procedure RemoveParentRigidBodyEvents; |
|
Removes TCastleRigidBody behavior initialize/deinitialize callbacks. | |
| Protected | procedure UpdateBreakThresholdForceInKraft; |
|
This item has no description. | |
| Protected | procedure UpdateBreakThresholdTorqueInKraft; |
|
This item has no description. | |
| Protected | procedure UpdateBreakableInKraft; |
|
This item has no description. | |
| Protected | procedure SetBreakThresholdForce(const AValue: Single); |
|
This item has no description. | |
| Protected | procedure SetBreakThresholdTorque(const AValue: Single); |
|
This item has no description. | |
| Protected | procedure SetBreakable(const AValue: Boolean); |
|
This item has no description. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | procedure WorldAfterAttach; override; |
|
This item has no description. Showing description inherited from TCastleBehavior.WorldAfterAttach.
Called after Parent became part of World. Called only if ListenWorldChange is | |
| Public | procedure WorldBeforeDetach; override; |
|
This item has no description. Showing description inherited from TCastleBehavior.WorldBeforeDetach.
Called before Parent stops being part of World. Called only if ListenWorldChange is This is also called at the destruction of behavior (more precisely from BeforeDestruction now). Even in this case, we guarantee that Parent is still valid during this call, and not in half-destroyed state. Before the actual destructor of TCastleBehavior we do BeforeParentDetach and BeforeWorldDetach and set Parent to | |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. | |
| Public | procedure InternalCreateGizmos; virtual; |
|
Create design-time transformations that are displayed in the hierarchy to visualize physics joints 3D points. If you want to visualize the behavior using a visible TCastleTransform, then create and add to Parent a descendant of TCastleJointTool, and set InternalCastleDesignInvalidate to | |
| Public | procedure InternalDestroyGizmos; virtual; |
|
Destroy design-time stuff. You can destroy any component, just be sure to set InternalCastleDesignInvalidate to | |
| Protected | function GetKraftJoint: TKraftConstraintJoint; override; |
|
This item has no description. Showing description inherited from TCastleAbstractJoint.GetKraftJoint. Get physics engine (Kraft) joint instance. | |
| Protected | procedure CreateKraftJoint; override; |
|
This item has no description. Showing description inherited from TCastleAbstractJoint.CreateKraftJoint. Create physics engine (Kraft) joint and set its specialized properties. | |
| Protected | procedure DeinitializeKraftJoint; override; |
|
This item has no description. | |
| Protected | procedure SetName(const Value: TComponentName); override; |
|
This item has no description. | |
| Public | constructor Create(AOwner: TComponent); override; |
|
This item has no description. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | procedure WorldBeforeDetach; override; |
|
This item has no description. Showing description inherited from TCastleBehavior.WorldBeforeDetach.
Called before Parent stops being part of World. Called only if ListenWorldChange is This is also called at the destruction of behavior (more precisely from BeforeDestruction now). Even in this case, we guarantee that Parent is still valid during this call, and not in half-destroyed state. Before the actual destructor of TCastleBehavior we do BeforeParentDetach and BeforeWorldDetach and set Parent to | |
| Public | procedure InternalCreateGizmos; override; |
|
This item has no description. Showing description inherited from TCastleAbstractJoint.InternalCreateGizmos.
Create design-time transformations that are displayed in the hierarchy to visualize physics joints 3D points. If you want to visualize the behavior using a visible TCastleTransform, then create and add to Parent a descendant of TCastleJointTool, and set InternalCastleDesignInvalidate to | |
| Public | procedure InternalDestroyGizmos; override; |
|
This item has no description. Showing description inherited from TCastleAbstractJoint.InternalDestroyGizmos.
Destroy design-time stuff. You can destroy any component, just be sure to set InternalCastleDesignInvalidate to | |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. | |
Properties
| Public | property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents; |
|
Components added by AddNonVisualComponent. | |
| Public | property IsLoading: Boolean read FIsLoading; |
|
Is the component during deserialization now. Note: We can't use | |
| Public | property Parent: TCastleTransform read FParent; |
|
Parent TCastleTransform of this behavior. Change it by doing TCastleTransform.AddBehavior, TCastleTransform.RemoveBehavior.
| |
| Public | property ListenWorldChange: Boolean
read FListenWorldChange write SetListenWorldChange; |
|
Set this to | |
| Published | property Breakable: Boolean read FBreakable write SetBreakable default false; |
|
Makes the joint breakable when force is greater than BreakThresholdForce or torque is greater than BreakThresholdTorque. | |
| Published | property BreakThresholdForce: Single read FBreakThresholdForce write SetBreakThresholdForce default 0.0; |
|
Force threshold to break joint. | |
| Published | property BreakThresholdTorque: Single read FBreakThresholdTorque write SetBreakThresholdTorque default 0.0; |
|
Torque threshold to break joint. | |
| Public | property Anchor: TVector3 read FAnchor write SetAnchor; |
|
Point, in local coordinates, that will be pulled to TargetWorld. | |
| Public | property TargetWorld: TVector3 read FTargetWorld write SetTargetWorld; |
|
Point, in world coordinates, that pulls Anchor. With time, Anchor (in local coords) will match TargetWorld (in world coords). | |
| Published | property FrequencyHz: Single read FFrequencyHz write SetFrequencyHz default DefaultFrequencyHz; |
|
Frequency controls how fast the oscillations occur. The smaller the value, the longer the oscillation movement. This may not seem intuitive, but a higher value causes the oscillation in specified time to be faster and therefore the movement is shorter. So if you want longer movement make this value smaller. See live example: https://gamedev.stackexchange.com/questions/98772/b2distancejoint-with-frequency-equal-to-0-vs-b2weldjoint | |
| Published | property DampingRatio: Single read FDampingRatio write SetDampingRatio default DefaultDampingRatio; |
|
How fast the oscillations are damped, large values can cause the body will not do even one oscillation. | |
| Published | property MaxForce: Single read FMaxForce write SetMaxForce default 0.0; |
|
Maximal force that will be aplied to the body to move it. Zero (default) means "unlimited". | |
| Published | property AnchorPersistent: TCastleVector3Persistent read FAnchorPersistent ; |
|
Anchor that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Anchor directly. See also
| |
| Published | property TargetWorldPersistent: TCastleVector3Persistent read FTargetWorldPersistent ; |
|
TargetWorld that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write TargetWorld directly. See also
| |
Generated by PasDoc 0.17.0.snapshot.