JSR-184 Public Review Draft - Apr. 30, 2003.

javax.microedition.m3d
Class RayIntersection

java.lang.Object
  |
  +--javax.microedition.m3d.RayIntersection

public class RayIntersection
extends java.lang.Object

A RayIntersection object is filled in by the pick methods in Group and Camera. RayIntersection stores a reference to the intersected Mesh or Sprite and information about the intersection point. RayIntersection is a strictly run-time object; it cannot be loaded from a file by Loader.


Constructor Summary
RayIntersection()
          Constructs a new RayIntersection object with default values.
 
Method Summary
 float getDistance()
          Retrieves the distance from the pick ray origin to the intersection point.
 Node getIntersected()
          Retrieves the picked Mesh or Sprite object.
 int getSubmeshIndex()
          Retrieves the index of the submesh where the intersection point is located within the intersected Mesh.
 float getTextureS(int index)
          Retrieves the S texture coordinate at the intersection point on the picked Mesh or Sprite.
 float getTextureT(int index)
          Retrieves the T texture coordinate at the intersection point on the picked Mesh or Sprite.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RayIntersection

public RayIntersection()

Constructs a new RayIntersection object with default values. The default values are as follows:

Method Detail

getIntersected

public Node getIntersected()

Retrieves the picked Mesh or Sprite object. Other types of Nodes are not pickable and hence can not be returned by this method.

Returns:
the picked Mesh or Sprite object

getDistance

public float getDistance()

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(dx2 + dy2 + dz2), where (dx dy dz) is the direction vector given at the pick method. The normalized distance is independent of the transformations of the intersected Node and its ancestors, including any non-uniform scales and other non-length preserving transformations. Distance to the intersection point can be used for simple collision detection, for instance.

Returns:
normalized distance from the pick ray origin to the intersection point

getSubmeshIndex

public int getSubmeshIndex()

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 present on the intersection point. The submesh index is only applicable to Meshes; its value is always set to zero if the picked object is a Sprite.

Returns:
index of the intersected submesh (always 0 for Sprites)

getTextureS

public float getTextureS(int index)

Retrieves the S texture coordinate at the intersection point on the picked Mesh or Sprite. 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.

If the picked object is a Mesh, the returned coordinates are after texture transformation, but before possible clamping. In the case of a Sprite object, the returned coordinates are always between [0, 1], where (0, 0) is the upper left corner of the Sprite's Image2D. Note that the Sprite crop rectangle has no effect on the returned values.

Parameters:
index - index of the texturing unit to get the texture coordinate of
Returns:
the S texcoord of the specified texturing unit at the intersection point
Throws:
java.lang.IndexOutOfBoundsException - if index != [0, N] where N is the implementation specific maximum texture unit index (typically 1)

getTextureT

public float getTextureT(int index)

Retrieves the T texture coordinate at the intersection point on the picked Mesh or Sprite. See getTextureS(int) for more information.

Parameters:
index - index of the texturing unit to get the texture coordinate of
Returns:
the T texcoord of the specified texturing unit at the intersection point
Throws:
java.lang.IndexOutOfBoundsException - if index != [0, N] where N is the implementation specific maximum texture unit index (typically 1)

JSR-184 Public Review Draft - Apr. 30, 2003.

Copyright © 2003 Nokia Corporation. See the Copyright Notice for details.