📄 rayintersection.html
字号:
<DD><p>Retrieves the picked Mesh or Sprite3D object. Other types of Nodes are not pickable and hence can not be returned by this method.</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the picked Mesh or Sprite3D object</DL>
</DD>
</DL>
<HR>
<A NAME="getRay(float[])"><!-- --></A><H3>
getRay</H3>
<PRE>
public void <B>getRay</B>(float[] ray)</PRE>
<DL>
<DD><p>Retrieves the origin (ox oy oz) and direction (dx dy dz) of the pick ray, in that order. The ray origin and direction vector are specified in the coordinate system of the Group node where the <code>pick</code> method was called from. The returned direction vector is the same that is used to compute the distance measure from the pick point to the object in <code>getDistance</code>.</p> <p>Note that if the application itself provides the pick ray origin and direction to the <code>pick</code> method, this method simply returns the same information; in particular, the direction vector is returned as is, not normalized. On the other hand, if the application uses the other <code>pick</code> method, where only a Camera and a point on the viewing plane are specified, the ray origin and direction would not otherwise be readily available.</p> <p>This method together with <code>getDistance</code> enables the point of intersection to be computed conveniently, as shown in the example below.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>ray</CODE> - a float array to fill in with the pick ray origin and direction, in that order<DT><B>Throws:</B><DD><CODE>java.lang.NullPointerException</CODE> - if <code>ray</code> is null<DD><CODE>java.lang.IllegalArgumentException</CODE> - if <code>ray.length < 6</code><DT><b>Example:</b><DD><div class="example_title">Computing the ray intersection point. </div><pre class="example"> <span class="example_type">float</span> x, y, z; <span class="example_comment">// the intersection point</span> <span class="example_type">float</span> [] ray = <span class="example_reserved">new</span> <span class="example_type">float</span>[6]; <span class="example_comment">// ray origin and direction</span> <span class="example_class">RayIntersection</span> ri = <span class="example_reserved">new</span> <span class="example_class">RayIntersection</span>(); <span class="example_comment">// Pick through the center of the viewport</span> <span class="example_control">if</span> (myGroup.pick(-1, 0.5f, 0.5f, myCamera, ri) == <span class="example_literal">true</span>) { ri.getRay(ray); x = ray[0] + ray[3] * ri.getDistance(); y = ray[1] + ray[4] * ri.getDistance(); z = ray[2] + ray[5] * ri.getDistance(); }</pre></DD></DD></DL>
</DD>
</DL>
<HR>
<A NAME="getDistance()"><!-- --></A><H3>
getDistance</H3>
<PRE>
public float <B>getDistance</B>()</PRE>
<DL>
<DD><p>Retrieves the distance from the pick ray origin to the intersection point. The distance is normalized to the length of the given pick ray (1.0 = ray length). The length of the pick ray is defined as sqrt(dx<sup>2</sup> + dy<sup>2</sup> + dz<sup>2</sup>), where (dx dy dz) is the direction vector of the ray. The direction vector itself can be obtained using <code>getRay</code>.</p> <p>The normalized distance is convenient, because it is independent of the transformations of the intersected Node and its ancestors, including any non-uniform scales and other non-length preserving transformations. The distance to the intersection point can be used for simple collision detection, for instance.</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>normalized distance from the pick ray origin to the intersection point</DL>
</DD>
</DL>
<HR>
<A NAME="getSubmeshIndex()"><!-- --></A><H3>
getSubmeshIndex</H3>
<PRE>
public int <B>getSubmeshIndex</B>()</PRE>
<DL>
<DD><p>Retrieves the index of the submesh where the intersection point is located within the intersected Mesh. This allows the application to identify, for example, the texture image that is displayed at the intersection point. The submesh index is only applicable to Meshes; its value is always set to zero if the picked object is a Sprite3D.</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>index of the intersected submesh (always 0 for sprites)</DL>
</DD>
</DL>
<HR>
<A NAME="getTextureS(int)"><!-- --></A><H3>
getTextureS</H3>
<PRE>
public float <B>getTextureS</B>(int index)</PRE>
<DL>
<DD><p>Retrieves the S texture coordinate at the intersection point on the picked Mesh or Sprite3D. For meshes, there can be between zero and N texture coordinates, where N is the number of texturing units supported by the implementation. If a texturing unit is disabled, the corresponding texture coordinates are undefined. For sprites, there is always exactly one pair of valid texture coordinates (at index zero); the rest of the coordinates are undefined.</p> <p>If the picked object is a Mesh, the returned coordinates represent the texture coordinates <i>after</i> applying the texture transformation and projection, but <i>before</i> possible clamping. In the case of a Sprite3D, the returned coordinates are always between [0, 1], where (0, 0) is the upper left corner of the sprite image. Note that the sprite crop rectangle has no effect on the returned values.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>index</CODE> - index of the texturing unit to get the texture coordinate of<DT><B>Returns:</B><DD>the S texcoord of the specified texturing unit at the intersection point<DT><B>Throws:</B><DD><CODE>java.lang.IndexOutOfBoundsException</CODE> - if <code>index != [0, N]</code> where <code>N</code> is the implementation specific maximum texturing unit index</DL>
</DD>
</DL>
<HR>
<A NAME="getTextureT(int)"><!-- --></A><H3>
getTextureT</H3>
<PRE>
public float <B>getTextureT</B>(int index)</PRE>
<DL>
<DD><p>Retrieves the T texture coordinate at the intersection point on the picked Mesh or Sprite3D. See <A HREF="../../../javax/microedition/m3g/RayIntersection.html#getTextureS(int)"><CODE>getTextureS</CODE></A> for more information.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>index</CODE> - index of the texturing unit to get the texture coordinate of<DT><B>Returns:</B><DD>the T texcoord of the specified texturing unit at the intersection point<DT><B>Throws:</B><DD><CODE>java.lang.IndexOutOfBoundsException</CODE> - if <code>index != [0, N]</code> where <code>N</code> is the implementation specific maximum texturing unit index</DL>
</DD>
</DL>
<HR>
<A NAME="getNormalX()"><!-- --></A><H3>
getNormalX</H3>
<PRE>
public float <B>getNormalX</B>()</PRE>
<DL>
<DD><p>Retrieves the X component of the surface normal at the intersection point. The normal is specified in the coordinate system of the intersected Node, and is always unit length. If the picked object is a Sprite3D, the normal vector is always (0 0 1). If the object is a Mesh with no vertex normals, the returned normal is undefined.</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the X component of the surface normal at the intersection point</DL>
</DD>
</DL>
<HR>
<A NAME="getNormalY()"><!-- --></A><H3>
getNormalY</H3>
<PRE>
public float <B>getNormalY</B>()</PRE>
<DL>
<DD><p>Retrieves the Y component of the surface normal at the intersection point. See <A HREF="../../../javax/microedition/m3g/RayIntersection.html#getNormalX()"><CODE>getNormalX</CODE></A> for more information.</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the Y component of the surface normal at the intersection point</DL>
</DD>
</DL>
<HR>
<A NAME="getNormalZ()"><!-- --></A><H3>
getNormalZ</H3>
<PRE>
public float <B>getNormalZ</B>()</PRE>
<DL>
<DD><p>Retrieves the Z component of the surface normal at the intersection point. See <A HREF="../../../javax/microedition/m3g/RayIntersection.html#getNormalX()"><CODE>getNormalX</CODE></A> for more information.</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the Z component of the surface normal at the intersection point</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/RayIntersection.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<EM><B>Nov 19, 2003</B></EM></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/microedition/m3g/PolygonMode.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/m3g/SkinnedMesh.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="RayIntersection.html" TARGET="_top"><B>NO FRAMES</B></A>
<SCRIPT> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT><A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A></NOSCRIPT></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<EM>Copyright © 2003 Nokia Corporation. See the <a href="../../../overview-summary.html#Copyright">Copyright Notice</a> for details.</EM>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -