Difference between revisions of "LlSetPhysicsMaterial"

From Second Life Wiki
Jump to navigation Jump to search
(Add second Example)
(Add caveat noting this function does nothing if called from an attachment.)
 
(5 intermediate revisions by 3 users not shown)
Line 10: Line 10:
{{!}}}
{{!}}}
|examples=*Basic Example
|examples=*Basic Example
<lsl>
<syntaxhighlight lang="lsl2">
     llSetPhysicsMaterial(FRICTION, 1.0,0.9,0.1,0.5); // Sets FRICTION to 0.1
     llSetPhysicsMaterial(FRICTION, 1.0,0.9,0.1,0.5); // Sets FRICTION to 0.1
</lsl>
</syntaxhighlight>
*Multiple Settings
*Multiple Settings
<lsl>
<syntaxhighlight lang="lsl2">
     llSetPhysicsMaterial(GRAVITY_MULTIPLIER | RESTITUTION | FRICTION | DENSITY, 0.5,0.9,0.1,1.0);
     llSetPhysicsMaterial(GRAVITY_MULTIPLIER | RESTITUTION | FRICTION | DENSITY, 0.5,0.9,0.1,1.0);
</lsl>
</syntaxhighlight>
*Defined Materials
|caveats=*Using [[PRIM_MATERIAL]] to set the material type will reset the values for {{LSLP|friction}} and {{LSLP|restitution}} to that material's defaults.
<lsl>
*[[llSetPhysicsMaterial]] silently fails if called from an attachment.
    llSetPhysicsMaterial(PRIM_MATERIAL_STONE, 0.0,0.0,0.0,0.0);
|p1_type=integer|p1_name={{#var:material_mask}}
</lsl>
|caveats=*Setting [[PRIM_MATERIAL]] will reset the values for {{LSLP|friction}} and {{LSLP|restitution}} back to the material defaults.
|p1_type=integer|p1_name=material_bits
|p2_type=float|p2_name=gravity_multiplier
|p2_type=float|p2_name=gravity_multiplier
|p3_type=float|p3_name=restitution
|p3_type=float|p3_name=restitution
Line 29: Line 26:
|also_functions=
|also_functions=
{{LSL DefineRow||[[llGetPhysicsMaterial]]}}
{{LSL DefineRow||[[llGetPhysicsMaterial]]}}
{{LSL DefineRow||[[llSetBuoyancy]]|Set how gravity interacts with an object. Works in attachments (changes are applied to the avatar).}}
|also_constants=
|also_constants=
{{LSL DefineRow||[[PRIM_MATERIAL]]}}
{{LSL DefineRow||[[PRIM_MATERIAL]]}}
Line 38: Line 36:
|deepnotes=
|deepnotes=
<h3>Material Defaults</h3>
<h3>Material Defaults</h3>
Using [[PRIM_MATERIAL]] changes the the values for friction and restitution to the values listed for the material type.
{{LSL_Constants/PrimitiveParams/materials|table=*|sortable=*}}
{{LSL_Constants/PrimitiveParams/materials|table=*|sortable=*}}
<font style="font-size:75%">llSetPhysicsMaterial cannot use these flags.</font>
|signature=
|signature=
{{LSL Const/Signature|DENSITY|integer|1|c={{#var:p_density_hover}}}}
{{LSL Const/Signature|DENSITY|integer|1|c={{#var:p_density_hover}}}}
Line 44: Line 44:
{{LSL Const/Signature|RESTITUTION|integer|4|c={{#var:p_restitution_hover}}}}
{{LSL Const/Signature|RESTITUTION|integer|4|c={{#var:p_restitution_hover}}}}
{{LSL Const/Signature|GRAVITY_MULTIPLIER|integer|8|c={{#var:p_gravity_multiplier_hover}}}}
{{LSL Const/Signature|GRAVITY_MULTIPLIER|integer|8|c={{#var:p_gravity_multiplier_hover}}}}
|history = Date of Release  [[ Release_Notes/Second_Life_Server/11#11.09.23.241511 | 23/09/2011 ]]
}}
}}

Latest revision as of 12:28, 10 July 2022

Summary

Function: llSetPhysicsMaterial( integer mask, float gravity_multiplier, float restitution, float friction, float density );

Used to set the physical characteristics of an object.

• integer mask bitwise combination of DENSITY, FRICTION, RESTITUTION, and GRAVITY_MULTIPLIER and specifies which floats to actually apply
• float gravity_multiplier range [-1.0, +28.0], default: 1.0
• float restitution range [0.0, 1.0], default: [0.3, 0.9] [1]
• float friction range [0.0, 255.0], default: [0.2, 0.9][1]
• float density range [1.0, 22587.0] kg/m^3, default: 1000.0

The default values for friction and restitution depend upon the material type.

mask Flags V Description
DENSITY 1 Indicates that density parameter is enabled and will override the previous value.
FRICTION 2 Indicates that friction parameter is enabled and will override the previous value.
RESTITUTION 4 Indicates that restitution parameter is enabled and will override the previous value.
GRAVITY_MULTIPLIER 8 Indicates that gravity_multiplier parameter is enabled and will override the previous value.

Caveats

  • A collision between two objects with restitution 1.0 will still not be perfectly elastic due to damping in the physics engine.
  • Using PRIM_MATERIAL to set the material type will reset the values for friction and restitution to that material's defaults.
  • llSetPhysicsMaterial silently fails if called from an attachment.
All Issues ~ Search JIRA for related Bugs

Examples

  • Basic Example
     llSetPhysicsMaterial(FRICTION, 1.0,0.9,0.1,0.5); // Sets FRICTION to 0.1
  • Multiple Settings
     llSetPhysicsMaterial(GRAVITY_MULTIPLIER | RESTITUTION | FRICTION | DENSITY, 0.5,0.9,0.1,1.0);

See Also

Constants

•  PRIM_MATERIAL

Functions

•  llGetPhysicsMaterial
•  llSetBuoyancy Set how gravity interacts with an object. Works in attachments (changes are applied to the avatar).

Deep Notes

Material Defaults

Using PRIM_MATERIAL changes the the values for friction and restitution to the values listed for the material type.

material Flags Description Friction Restitution
PRIM_MATERIAL_STONE 0 stone 0.8 0.4
PRIM_MATERIAL_METAL 1 metal 0.3 0.4
PRIM_MATERIAL_GLASS 2 glass 0.2 0.7
PRIM_MATERIAL_WOOD 3 wood 0.6 0.5
PRIM_MATERIAL_FLESH 4 flesh 0.9 0.3
PRIM_MATERIAL_PLASTIC 5 plastic 0.4 0.7
PRIM_MATERIAL_RUBBER 6 rubber 0.9 0.9
PRIM_MATERIAL_LIGHT 7 light, DEPRECATED: Looks the same as [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ] 0.6 0.5

llSetPhysicsMaterial cannot use these flags.

History

Date of Release 23/09/2011
Search JIRA for related Issues

Tests

•  Physics Material Settings test

Footnotes

  1. ^ The default values for friction and restitution depend upon the prim's material.
  2. ^ The ranges in this article are written in Interval Notation.

Signature

function void llSetPhysicsMaterial( integer mask, float gravity_multiplier, float restitution, float friction, float density );
integer DENSITY = 1;//range 1.0 to 22587.0 (in kg/m^3), default: 1000.0
integer FRICTION = 2;//range 0.0 to 255.0, default values are in the range 0.2 to 0.9
integer RESTITUTION = 4;//range 0.0 to 1.0, default values are in the range 0.3 to 0.9 (note, a collision between two objects with restitution 1.0 will still not be perfectly elastic due to damping in the physics engine)
integer GRAVITY_MULTIPLIER = 8;//range -1.0 to +28.0, default: 1.0