Difference between revisions of "LlDetectedTouchNormal"

From Second Life Wiki
Jump to navigation Jump to search
m
m (Added caveat for legacy sphere prims.)
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{LSL_Function/detected|index|TouchNormal|simple=*}}{{LSL_Function
{{LSL_Function
|inject-2={{LSL_Function/detected|index|touchNormal|simple=*}}
|func_id=340|func_sleep=0.0|func_energy=10.0
|func_id=340|func_sleep=0.0|func_energy=10.0
|func=llDetectedTouchNormal
|func=llDetectedTouchNormal
|return_type=vector|return_text=that is the surface normal (perpendicular to the surface) where the touch event was triggered.
|return_type=vector|return_text=that is the surface normal (perpendicular to the surface) where the touch event was triggered.  Along with [[llDetectedTouchBinormal]], this information can be used to find the [http://en.wikipedia.org/wiki/Tangent_space tangent space] at the touch location.
|p1_type=integer|p1_name=index
|p1_type=integer|p1_name=index
|func_footnote=For the {{LSLGC|Touch|touch}} category of events only. The prim that was touched may not be the prim receiving the event, use [[llDetectedLinkNumber]] to check for this; likewise you can use [[llDetectedTouchFace]] to determine which face was touched.
|func_footnote=For the {{LSLGC|Touch|touch}} category of events only. The prim that was touched may not be the prim receiving the event, use [[llDetectedLinkNumber]] to check for this; likewise you can use [[llDetectedTouchFace]] to determine which face was touched.{{PBR}}To find the third tangent vector, [[LSL Cross Product|cross]] the [[llDetectedTouchBinormal|binormal]] with this vector.
|func_desc
|func_desc
|spec
|spec
|caveats=
|caveats=
*{{LSL Const|TOUCH_INVALID_VECTOR|vecter|{{LSL_VR|0.0|0.0|0.0}}|c=same as ZERO_VECTOR}} is returned when...
*{{LSL Const|TOUCH_INVALID_VECTOR|vector|{{LSL_VR|0.0|0.0|0.0}}|c=same as ZERO_VECTOR}} is returned when...
** The avatar's viewer does not support face touch detection.
** The avatar's viewer does not support face touch detection.
*** To check if face touch detection is supported check the return of [[llDetectedTouchFace]].
*** To check if face touch detection is supported check the return of [[llDetectedTouchFace]].
** The touch has moved off the surface of the prim.
** The touch has moved off the surface of the prim.
** The event triggered is not a {{LSLGC|Touch|touch}} event.
** The event triggered is not a {{LSLGC|Touch|touch}} event.
|examples
* The rotation of a legacy sphere prim does not influence touch normal like it does with other legacy prims.
|helpers
|examples=<source lang="lsl2">
default
{
    touch_start(integer total_num)
    {
        llOwnerSay((string)llDetectedTouchNormal(0)); //Says the vector where the touched face is pointing to.
    }
}
</source>
|helpers=
<source lang="lsl2">touch_start(integer total_number){
    // rotates the prim, so the touched position points upwards
    llSetRot(llGetRot()*llRotBetween(llDetectedTouchNormal(0),<0,0,1>));
}</source>
|related
|related
|also_functions=
|also_functions=
Line 31: Line 45:
|history=* Introduced in Viewer {{SVN|870|rev=92872|branch=Release|anchor=file14|date=Wednesday, 23 July 2008}}, no server support, no viewer binary released.
|history=* Introduced in Viewer {{SVN|870|rev=92872|branch=Release|anchor=file14|date=Wednesday, 23 July 2008}}, no server support, no viewer binary released.
*Server support available on preview grid in Second Life Beta Server 1.24, client support in Preview Grid viewer 1.20.15 (93532)  
*Server support available on preview grid in Second Life Beta Server 1.24, client support in Preview Grid viewer 1.20.15 (93532)  
*Date of Release Server [[ Release_Notes/Second_Life_Beta_Server/1.24#Release_Notes_for_Second_Life_Beta_Server_1.24.3_.28August_29th.2C_2008.29 | 29-08-2008 ]]
*Date of Release Client  [[ Release_Notes/Second_Life_Release/1.21 | 16-10-2008 ]]
|cat1=Touch
|cat1=Touch
|cat2
|cat2

Latest revision as of 17:16, 30 November 2021

Summary

Function: vector llDetectedTouchNormal( integer index );
0.0 Forced Delay
10.0 Energy

Returns a vector that is the surface normal (perpendicular to the surface) where the touch event was triggered. Along with llDetectedTouchBinormal, this information can be used to find the tangent space at the touch location.

• integer index Index of detection information

index does not support negative indexes. For the touch category of events only. The prim that was touched may not be the prim receiving the event, use llDetectedLinkNumber to check for this; likewise you can use llDetectedTouchFace to determine which face was touched.To find the third tangent vector, cross the binormal with this vector.

Caveats

  • If index is out of bounds the script continues to execute without an error message.
  • TOUCH_INVALID_VECTOR is returned when...
    • The avatar's viewer does not support face touch detection.
    • The touch has moved off the surface of the prim.
    • The event triggered is not a touch event.
  • The rotation of a legacy sphere prim does not influence touch normal like it does with other legacy prims.

Examples

default
{
    touch_start(integer total_num)
    {
        llOwnerSay((string)llDetectedTouchNormal(0)); //Says the vector where the touched face is pointing to.
    }
}

Useful Snippets

touch_start(integer total_number){
    // rotates the prim, so the touched position points upwards
    llSetRot(llGetRot()*llRotBetween(llDetectedTouchNormal(0),<0,0,1>));
}

See Also

Deep Notes

History

Signature

function vector llDetectedTouchNormal( integer index );