Difference between revisions of "Joint"
(→Reason for Removal: Add screenshot of one way joints could catastrophicly fail to function) |
m (→Scripting Alternatives: Replaced obsolete <lsl> tag with <syntaxhighlight> and changed some wikisyntax (now it's uglier but more automated!)) |
||
Line 22: | Line 22: | ||
In certain constrained conditions it is still possible to do what was possible with hinge joints but instead through LSL scripting. While joints allowed an object to be constrained along an arbitrary angle of rotation, this method allows constraining only along the three cardinal axis of X, Y, and Z. | In certain constrained conditions it is still possible to do what was possible with hinge joints but instead through LSL scripting. While joints allowed an object to be constrained along an arbitrary angle of rotation, this method allows constraining only along the three cardinal axis of X, Y, and Z. | ||
# Place object in world where it is desired to freely rotate, but do not set physical. | |||
# Create a new script in the object and edit it to look like this: | |||
#:<syntaxhighlight lang="lsl2">default | |||
< | |||
{ | { | ||
state_entry() | state_entry() | ||
Line 38: | Line 36: | ||
llSetStatus(STATUS_ROTATE_Z, TRUE); | llSetStatus(STATUS_ROTATE_Z, TRUE); | ||
} | } | ||
}</ | }</syntaxhighlight> | ||
# When the script saves, it will auto-activate and do the following: | |||
#* It finds the current location of the object, uses [[llMoveToTarget]]() to tell the physics engine to make the object hover in mid-air at that location, and sets the object to be physical. | |||
#* It then constrains rotation on the X and Y axis, permitting only rotation around the Z axis. | |||
It finds the current location of the object, uses llMoveToTarget() to tell the physics engine to make the object hover in | #* By using a timer and [[llPushObject]], the object can be made to spin continuously in mid-air without the use of joints. | ||
It then constrains rotation on the X and Y axis, permitting only rotation around the Z axis. | |||
By using a timer and llPushObject, the object can be made to spin |
Latest revision as of 15:56, 2 May 2024
Joints are an obsolete technology that are no longer a part of the Second Life experience.
Work on reimplementing joints is not likely to occur until after the main grid has been fully upgraded to the new Havok 4 engine.
Definition of a Joint
A joint is a free-moving rotational axis formed between two primitives, and is a function of the phyics engine. The two basic joint types are:
- Hinge Joint, with rotation constrained along a single axis
- Point-to-Point, allowing free rotation in any direction on the three different axis
! Constraining an object on two axis does not work, because it is possible to move through the third axis through special compounded rotations of just two axis.
Reason for Removal
Joints suffered from a number of serious internal bugs, which would result in objects shooting apart across the simulator at high speed, if the "wrong" object was edited. When jointed, only the parent object could be moved and the child would immediately jump to align on the new location with the parent. In certain conditions edited joints would seem to disappear, but were in fact suddenly moving to coordinates <0,0,0> and out of editing range of the avatar.
Joints were a component of the original Havok I physics engine but were implemented in a manner that resulted in a mess of sphagetti programming code that was extremely difficult to manage. For a long time joints were one of the primary obstacles in the path of upgrading the Havok engine. A decision had to be made to remove them to ease the upgrade process.
Scripting Alternatives
In certain constrained conditions it is still possible to do what was possible with hinge joints but instead through LSL scripting. While joints allowed an object to be constrained along an arbitrary angle of rotation, this method allows constraining only along the three cardinal axis of X, Y, and Z.
- Place object in world where it is desired to freely rotate, but do not set physical.
- Create a new script in the object and edit it to look like this:
default { state_entry() { vector here; here = llGetPos(); llMoveToTarget(here,0.2); llSetStatus(STATUS_PHYSICS, TRUE); llSetStatus(STATUS_ROTATE_X, FALSE); llSetStatus(STATUS_ROTATE_Y, FALSE); llSetStatus(STATUS_ROTATE_Z, TRUE); } }
- When the script saves, it will auto-activate and do the following:
- It finds the current location of the object, uses llMoveToTarget() to tell the physics engine to make the object hover in mid-air at that location, and sets the object to be physical.
- It then constrains rotation on the X and Y axis, permitting only rotation around the Z axis.
- By using a timer and llPushObject, the object can be made to spin continuously in mid-air without the use of joints.