Files
RCBASIC4/doc/bu/files/createslideconstraintex.txt

25 lines
1.5 KiB
Plaintext

#title createSlideConstraintEx [RCBasic Doc]
#header function createSlideConstraintEx( actorA, actorB, frameInA_matrix, frameInB_matrix, useLinearReferenceFrameA)
A type of constraint that restricts the motion between two actors (or between an actor and the world) in such a way that they can slide along a specific axis and rotate around the same axis, while limiting or allowing movement along other axes. This constraint is similar to a prismatic joint with added rotational freedom, making it useful for simulating objects like pistons, sliding doors, or rail systems.
#code
actorA = CreateCubeActor(100) 'Creates a cube actor
frameA = DimMatrix(4, 4) 'A transform matrix must be a 4x4 matrix
SetIdentityMatrix(frameA, 4) 'Sets frameB to a 4x4 identity matrix
SetMatrixTranslation(frameA, 0, 0, 0) 'Sets the attach point of the constraint to center of the cube
SetMatrixRotation(frameA, 0, 90, 0) 'Rotates the constraint axis by 90 degrees around y
actorB = CreateCubeActor(100) 'Creates a cube actor
frameB = DimMatrix(4, 4) 'A transform matrix must be a 4x4 matrix
SetIdentityMatrix(frameB, 4) 'Sets frameB to a 4x4 identity matrix
SetMatrixTranslation(frameB, 0, 50, 0) 'Sets the attach point of the constraint to the top of the cube
SetMatrixRotation(frameB, 0, 90, 0) 'Rotates the constraint axis by 90 degrees around y
slide = CreateSlideConstraintEx(actorA, actorB, frameA, frameB, true)
#/code
Note: It is recommended to use CreateSlideConstraintEx() in most cases
#ref CreateSlideConstraint SetIdentityMatrix SetMatrixTranslation SetMatrixRotation