Difference between revisions of "LlGetPhysicsMaterial"

From Second Life Wiki
Jump to navigation Jump to search
m (This is how DefineRow is supposed to be used... sorta)
(")
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{LSL Function
{{LSL Function
|inject-2=
|inject-2={{LSL Function/physics materials}}
<!-- caveats & parameter descriptions imported from PRIM_PHYSICS_MATERIAL article -->
{{:PRIM_PHYSICS_MATERIAL}}
|func=llGetPhysicsMaterial
|func=llGetPhysicsMaterial
|func_id=?
|func_id=?
|func_desc=Used to get the physical characteristics of an object.
|func_desc=Used to get the physical characteristics of an object.
|return_type=list
|return_type=list
|return_text=in the form [&nbsp;[[float]] {{LSL Param|gravity_multiplier}}, [[float]] {{LSL Param|restitution}}, [[float]] {{LSL Param|friction}}, [[float]] {{LSL Param|density}}&nbsp;]
|return_text=in the form <code>[&nbsp;[[float]]&nbsp;{{LSLPT|gravity_multiplier}}, [[float]]&nbsp;{{LSLPT|restitution}}, [[float]]&nbsp;{{LSLPT|friction}}, [[float]]&nbsp;{{LSLPT|density}}&nbsp;]</code>
{{{!}}
{{{!}}
{{LSL DefineRow|float|gravity_multiplier|{{#var:p_gravity_multiplier_desc}}}}
{{LSL DefineRow|float|gravity_multiplier|{{#var:p_gravity_multiplier_desc}}}}
Line 14: Line 12:
{{LSL DefineRow|float|density|{{#var:p_density_desc}}}}
{{LSL DefineRow|float|density|{{#var:p_density_desc}}}}
{{!}}}
{{!}}}
|history=Content taken from [[Release Notes/Second Life Server/11#11.09.23.241511]]''
|also_functions=
{{LSL DefineRow||[[llSetPhysicsMaterial]]}}
|also_constants=
{{LSL DefineRow||[[PRIM_MATERIAL]]}}
|also_tests=
{{LSL DefineRow||[[Physics Material Settings test]]}}
|deepnotes=
<h3>Material Defaults</h3>
{{LSL_Constants/PrimitiveParams/materials|table=*|sortable=*}}
|examples=<source lang="lsl2">default
{
    touch_start(integer total_number)
    {
        list params = llGetPhysicsMaterial();
        llOwnerSay(
            "\nGravity multiplier: " + (string)llList2Float(params, 0) +
            "\nRestitution: " + (string)llList2Float(params, 1) +
            "\nFriction: " + (string)llList2Float(params, 2) +
            "\nDensity: " + (string)llList2Float(params, 3) + "kg/m^3"
        );
    }
}</source>
|cat1=Physics
|cat1=Physics
|cat2=Physics/Material
|history = Date of Release  [[ Release_Notes/Second_Life_Server/11#11.09.23.241511 | 23/09/2011 ]]
}}
}}

Latest revision as of 09:11, 8 September 2024

Summary

Function: list llGetPhysicsMaterial( );

Used to get the physical characteristics of an object.
Returns a list in the form float gravity_multiplier, float restitution, float friction, float density ]

• 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.

Caveats

  • A collision between two objects with restitution 1.0 will still not be perfectly elastic due to damping in the physics engine.

Examples

default
{
    touch_start(integer total_number)
    {
        list params = llGetPhysicsMaterial();
        llOwnerSay(
            "\nGravity multiplier: " + (string)llList2Float(params, 0) +
            "\nRestitution: " + (string)llList2Float(params, 1) +
            "\nFriction: " + (string)llList2Float(params, 2) +
            "\nDensity: " + (string)llList2Float(params, 3) + "kg/m^3"
        );
    }
}

See Also

Constants

•  PRIM_MATERIAL

Functions

•  llSetPhysicsMaterial

Deep Notes

Material Defaults

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

History

Date of Release 23/09/2011

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 list llGetPhysicsMaterial();