“LlCastRay”的版本间的差异

来自人工智能助力教育知识百科
跳转至: 导航搜索
Ty讨论 | 贡献
 
(未显示同一用户的2个中间版本)
第3行: 第3行:
 
{{函数详情
 
{{函数详情
 
|函数名 = Function:list llCastRay(vector start,vector end,list options );
 
|函数名 = Function:list llCastRay(vector start,vector end,list options );
|参数 = 参数:vector start -starting location;vector end -ending location; list options -can consists of any number of option flags and their parameters.
+
|参数 = 参数:向量起始位置; 向量结束位置; 列表选项-可以包含任意数量的选项标志及其参数。
|返回值 = 返回值:Returns a list of strided values with an additional integer status code on the end.Each stride consists of two mandatory values {key uuid,vector position}and possibly some optional values {integer link_number,vector normal}see RC DATA FLAGS for details.The status_code if it is negative is an error code,otherwise it is the number of hits (and strides)returned.
+
|返回值 = 返回值:返回一个带条纹的值列表,其末尾附加一个整数状态码。
  
  
|注意事项=Depending upon the value of flags(providing via RC DATA FLAGS),the number and types of values in the strides will vary.See RC DATA FLAGS for details. llGetrot will not return an avatar's exact visual rotation because the viewer doesn't update the avatar's rotation under a threshold (see VWR-1331).To get an avatar's exact looking direction while in mouselook,use llGetCameraRot instead. llCastRay will not detect prims having no physics shape (PRIM PHYSICS SHAPE TYPE=PRIM PHYSICS SHAPRE NONE).  llCastRay will not detect a prim if the line starts inside the prim.This makes it safe to use the prim position as the start location.  llCastRay can detect the prim the script is in,if the start location is outside the prim.
+
|注意事项=根据标志的值(通过 rc 数据标志提供) ,strides 中的值的数量和类型将随之变化,详情请参阅 rc 数据标志。 Llgetrot 不会返回阿凡达的精确视觉旋转,因为观看者不会更新阿凡达的旋转在阈值之下(见 vwr-1331)。 想要得到阿凡达在 mouselook 的精确视角,用 llgetcamerarot 代替。 光谱检测不会检测到没有物理形状的原始物质(原始物理形状类型原始物理形状)。 如果线路从 prim 内部开始,lcastray 不会检测到 prim,这使得使用 prim 位置作为起始位置是安全的。 如果起始位置在 prim 之外,lcastray 可以检测到脚本所在的 prim。
 
 
  
  
第15行: 第14行:
 
示例1
 
示例1
 
<pre>
 
<pre>
integer filter;//default is()
+
integer filter;// default is 0
 
+
 
default
 
default
 
{
 
{
  state_entry()
+
    state_entry()
 
     {
 
     {
      string ownerName = llKey2Name(llGetOwner());
+
        string ownerName = llKey2Name(llGetOwner());
      llOwnerSay("hello,"+ownerName + "!");
+
        llOwnerSay("Hello, " + ownerName + "!");
 
     }
 
     }
 +
 
     touch_start(integer total_number)
 
     touch_start(integer total_number)
 
     {
 
     {
      vector start = llGetPos();
+
        vector start = llGetPos();
      vector end = start - <0.0,-25.0,0.0>;
+
        vector end = start - <0.0, -25.0, 0.0>;
 
+
      if( filter>8)
+
        if ( filter > 8 )
        filter = 0;
+
            filter = 0;
 
+
      llOwnerSay("Filter"+(string)filter);
+
        llOwnerSay("Filter " + (string)filter);
 
+
      list results = llCastRay(start,end,[RC_REJECT_TYPES,filter,RC_MAX_HTTS,4});
+
        list results = llCastRay(start, end, [RC_REJECT_TYPES, filter, RC_MAX_HITS, 4] );
      integer hitNum = 0;
+
      //Handle error condition here by checking llList2Integer(resules,-1)>=0
+
        integer hitNum = 0;
      while (hitNum<llList2Integer(results,-1))
+
        // Handle error conditions here by checking llList2Integer(results, -1) >= 0
      {
+
        while (hitNum < llList2Integer(results, -1))
        //Stride is 2 because wedidn't request normals or link numbers
+
        {
        key uuid = llList2Key(results,2*hitNum);
+
            // Stride is 2 because we didn't request normals or link numbers
       
+
            key uuid = llList2Key(results, 2*hitNum);
        string name = "Land",7;//if (uuid == NULL_KEY)
+
 
+
            string name = "Land"; // if (uuid == NULL_KEY)
        if(uuid != NUML_KEY)
+
          name = llKey2Name(uuid);
+
            if (uuid != NULL_KEY)
     
+
                name = llKey2Name(uuid);
        llOwnerSay("Hit"+name+".");
+
   
+
            llOwnerSay("Hit " + name + ".");
        ++hitNum;
+
      }
+
            ++hitNum;
      ++filter;
+
        }
 +
 +
        ++filter;
 
     }
 
     }
  }
+
}
 
          
 
          
 
</pre>
 
</pre>
第59行: 第61行:
 
示例2
 
示例2
 
<pre>
 
<pre>
//Fire a weapon at a target,report a hit
+
// Fire a weapon at a target, report a hit
 
+
 
integer gTargetChan = -9934917;
 
integer gTargetChan = -9934917;
 
+
 
default
 
default
 
{
 
{
attach(key id)
+
    attach(key id)
{
+
    {
  if(id!= NULL_KEY)
+
        if (id != NULL_KEY)
  {
+
        {  
  llRequestPermissions(id,PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA);
+
            llRequestPermissions(id,PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA);
  }
+
        }
}
+
    }
  run_time_permissions(integer perm)
+
   
{
+
    run_time_permissions (integer perm)
  if(perm&PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA)
+
    {
  {
+
        if (perm & PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA)  
  llTakeControls(CONTROL_LBUTTON|CONTROL_ML_LBUTTON,TRUE,FALSE);
+
        {
  }
+
            llTakeControls(CONTROL_LBUTTON|CONTROL_ML_LBUTTON,TRUE,FALSE);
}
+
        }
 +
    }
 
   
 
   
control(key id,integer level,integer edge)
+
    control (key id, integer level, integer edge)
{
+
    {
  //User must be in mouselook to aim the weapon
+
        // User must be in mouselook to aim the weapon
  if (level & edge & CONTROL_LBUTTON)
+
        if (level & edge & CONTROL_LBUTTON)
  {
+
        {
  llSay(0,"You must be in Mouselook to shoot.Type\"CTRL+M\"or type \"Esc\"and scroll your mouse wheel forward to enter Mouselook.");
+
            llSay(0,"You must be in Mouselook to shoot. Type \"CTRL + M\" or type \"Esc\" and scroll your mouse wheel forward to enter Mouselook.");
  }
+
        }
  //User IS in mouselook
+
        // User IS in mouselook      
  if (level & edge & CONTROL_ML_LBUTTON)
+
        if (level & edge & CONTROL_ML_LBUTTON)
  {
+
        {
  vector start = llGetCameraPos();
+
            vector start = llGetCameraPos();
  //Detect only a non-physical,non-phantom object,Report its root prim's UUID.
+
            // Detect only a non-physical, non-phantom object. Report its root prim's UUID.
  list results = llCastRay(start,start+<60.0 ,0.0,0.0>*llGetCameraRot(),[RC_REJECT_TYPES,RC_REJECT_PHYSICAL|RC_REJECT_AGENTS|RC_REJECT_LAND,RC_DETECT_PHANTOM,FALSE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,1]);
+
            list results = llCastRay(start, start+<60.0,0.0,0.0>*llGetCameraRot(),[RC_REJECT_TYPES,RC_REJECT_PHYSICAL|RC_REJECT_AGENTS|RC_REJECT_LAND,RC_DETECT_PHANTOM,FALSE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,1]);
  llTriggerSound(llGetInventoryName(INVENTORY_SOUND,0),1.0);
+
            llTriggerSound(llGetInventoryName(INVENTORY_SOUND,0),1.0);
  llSleep(0.03);
+
            llSleep(0.03);
  key target = llList2Key(results,0);
+
            key target = llList2Key(results,0);
  //Tell target that it has been hit.
+
            // Tell target that it has been hit.  
  llRegionSayTo(target,gTargetChan,"HIT");
+
            llRegionSayTo(target,gTargetChan,"HIT");
  //Target,scripted to listen on gTargetChan,can explode,change color,fall over.....
+
            // Target, scripted to listen on gTargetChan, can explode, change color, fall over .....
  }
+
        }
}
+
    }          
 
}
 
}
 
</pre>
 
</pre>

2020年4月19日 (日) 14:14的最新版本

Template:Needs Translation/

函数名
Function:list llCastRay(vector start,vector end,list options );
参数:向量起始位置; 向量结束位置; 列表选项-可以包含任意数量的选项标志及其参数。
返回值:返回一个带条纹的值列表,其末尾附加一个整数状态码。
注意事项
根据标志的值(通过 rc 数据标志提供) ,strides 中的值的数量和类型将随之变化,详情请参阅 rc 数据标志。 Llgetrot 不会返回阿凡达的精确视觉旋转,因为观看者不会更新阿凡达的旋转在阈值之下(见 vwr-1331)。 想要得到阿凡达在 mouselook 的精确视角,用 llgetcamerarot 代替。 光谱检测不会检测到没有物理形状的原始物质(原始物理形状类型原始物理形状)。 如果线路从 prim 内部开始,lcastray 不会检测到 prim,这使得使用 prim 位置作为起始位置是安全的。 如果起始位置在 prim 之外,lcastray 可以检测到脚本所在的 prim。
示例
示例1
integer filter;// default is 0
 
default
{
    state_entry()
    {
        string ownerName = llKey2Name(llGetOwner());
        llOwnerSay("Hello, " + ownerName + "!");
    }
 
    touch_start(integer total_number)
    {
        vector start = llGetPos();
        vector end = start - <0.0, -25.0, 0.0>;
 
        if ( filter > 8 )
            filter = 0;
 
        llOwnerSay("Filter " + (string)filter);
 
        list results = llCastRay(start, end, [RC_REJECT_TYPES, filter, RC_MAX_HITS, 4] );
 
        integer hitNum = 0;
        // Handle error conditions here by checking llList2Integer(results, -1) >= 0
        while (hitNum < llList2Integer(results, -1))
        {
            // Stride is 2 because we didn't request normals or link numbers
            key uuid = llList2Key(results, 2*hitNum);
 
            string name = "Land"; // if (uuid == NULL_KEY)
 
            if (uuid != NULL_KEY)
                name = llKey2Name(uuid);
 
            llOwnerSay("Hit " + name + ".");
 
            ++hitNum;
        }
 
        ++filter;
    }
}
        

示例2

// Fire a weapon at a target, report a hit
 
integer gTargetChan = -9934917;
 
default
{
    attach(key id)
    {
        if (id != NULL_KEY)
        { 
            llRequestPermissions(id,PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA);
        }
    }
 
    run_time_permissions (integer perm)
    {
        if (perm & PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA) 
        {
            llTakeControls(CONTROL_LBUTTON|CONTROL_ML_LBUTTON,TRUE,FALSE);
        }
    }
 
    control (key id, integer level, integer edge)
    {
        // User must be in mouselook to aim the weapon
        if (level & edge & CONTROL_LBUTTON)
        {
            llSay(0,"You must be in Mouselook to shoot.  Type \"CTRL + M\" or type \"Esc\" and scroll your mouse wheel forward to enter Mouselook.");
        }
        // User IS in mouselook        
        if (level & edge & CONTROL_ML_LBUTTON)
        {
            vector start = llGetCameraPos();
            // Detect only a non-physical, non-phantom object. Report its root prim's UUID.
            list results = llCastRay(start, start+<60.0,0.0,0.0>*llGetCameraRot(),[RC_REJECT_TYPES,RC_REJECT_PHYSICAL|RC_REJECT_AGENTS|RC_REJECT_LAND,RC_DETECT_PHANTOM,FALSE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,1]);
            llTriggerSound(llGetInventoryName(INVENTORY_SOUND,0),1.0);
            llSleep(0.03);
            key target = llList2Key(results,0);
            // Tell target that it has been hit. 
            llRegionSayTo(target,gTargetChan,"HIT");
            // Target, scripted to listen on gTargetChan, can explode, change color, fall over .....
        }
    }            
}
相关函数
相关事件