Difference between revisions of "Talk:LlCastRay"
Jack Abraham (talk | contribs) |
Jack Abraham (talk | contribs) |
||
Line 12: | Line 12: | ||
<lsl>key camPing() { | <lsl>key camPing() { | ||
// End points at the camera and 20m in front of it | |||
vector camPos = llGetCameraPos(); | vector camPos = llGetCameraPos(); | ||
vector endPos = camPos + ( <20.0, 0., 0.> * llGetCameraRot() ); | vector endPos = camPos + ( <20.0, 0., 0.> * llGetCameraRot() ); | ||
// Clamp the end position to within the sim | |||
if ( endPos.x > 255.0 ) endPos.x = 255.0; | if ( endPos.x > 255.0 ) endPos.x = 255.0; | ||
else if ( endPos.x < 0.0 ) endPos.x = 0.0; | else if ( endPos.x < 0.0 ) endPos.x = 0.0; | ||
if ( endPos.y > 255.0 ) endPos.y = 255.0; | if ( endPos.y > 255.0 ) endPos.y = 255.0; | ||
else if ( endPos.y < 0.0 ) endPos.y = 0.0; | else if ( endPos.y < 0.0 ) endPos.y = 0.0; | ||
// Cast the ray; ignore hits on land, otherwise get the root key | |||
list contacts = llCastRay( camPos, endPos, | list contacts = llCastRay( camPos, endPos, | ||
RC_REJECT_LAND, | RC_REJECT_LAND, | ||
RC_GET_ROOT_KEY ); | RC_GET_ROOT_KEY ); | ||
// Return values | |||
if ( llList2Integer( contacts, -1 ) > 0 ) { // Got a return | if ( llList2Integer( contacts, -1 ) > 0 ) { // Got a return | ||
return llList2Key( contacts, 0 ); | return llList2Key( contacts, 0 ); |
Revision as of 20:51, 2 July 2010
llSonar please?
I would appreciate if you took in consideration my suggestions at http://jira.secondlife.com/browse/SVC-2486 please; any feedback is more than welcome.
ps:llCastRay is already awesome, you rock! Please try the hardest you can to figure out how to get this to come to the maingrid with the least crippling as possible.
--TigroSpottystripes Katsu 03:01, 3 July 2010 (UTC)
What am I looking at?
A function I just threw in to replace phantom bullets for quickly acquiring a point of interest -- whatever your camera's focused on (in this sim, within 20m) is returned, allowing quicker, more intuitive targeting of other objects. PERMISSION_TRACK_CAMERA must be previously set.
<lsl>key camPing() {
// End points at the camera and 20m in front of it vector camPos = llGetCameraPos(); vector endPos = camPos + ( <20.0, 0., 0.> * llGetCameraRot() );
// Clamp the end position to within the sim if ( endPos.x > 255.0 ) endPos.x = 255.0; else if ( endPos.x < 0.0 ) endPos.x = 0.0; if ( endPos.y > 255.0 ) endPos.y = 255.0; else if ( endPos.y < 0.0 ) endPos.y = 0.0;
// Cast the ray; ignore hits on land, otherwise get the root key list contacts = llCastRay( camPos, endPos, RC_REJECT_LAND, RC_GET_ROOT_KEY );
// Return values if ( llList2Integer( contacts, -1 ) > 0 ) { // Got a return return llList2Key( contacts, 0 ); } return NULL_KEY;
} </lsl>
Jack Abraham 04:42, 3 July 2010 (UTC)
RC_GET_LINK_NUM? Not RC_GET_LINK_KEY?
I can't think of a circumstance where knowing the link number of the return would be useful. UUID of the prim hit would be far more useful; is that within the realm of possibility? Jack Abraham 04:47, 3 July 2010 (UTC)