com.threed.jpct
Class Interact2D

java.lang.Object
  extended by com.threed.jpct.Interact2D

public final class Interact2D
extends java.lang.Object

Interact2D offers some static methods for interacting with objects in camera-space. Its main purpose is to allow object-picking with the mouse (or with whatever). Everything within here has to be called after calling World.renderScene(...), because the current visibility list is required.


Method Summary
static SimpleVector project3D2D(Camera camera, FrameBuffer buffer, SimpleVector vertex)
          Projects a vertex from world space into screen space.
static SimpleVector project3D2D(Camera camera, FrameBuffer buffer, SimpleVector vertex, SimpleVector toFill)
          Projects a vertex from world space into screen space.
static SimpleVector projectCenter3D2D(Camera camera, FrameBuffer buffer, Object3D obj)
          Gets the center of the object in screen-coordinates (2D) by transforming and projecting it from 3D objectspace into 2D screenspace.
static SimpleVector projectCenter3D2D(FrameBuffer buffer, Object3D obj)
          Gets the center of the object in screen-coordinates (2D) by transforming and projecting it from 3D objectspace into 2D screenspace.
static SimpleVector reproject2D3D(Camera camera, FrameBuffer buffer, int x, int y)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D.
static SimpleVector reproject2D3D(Camera camera, FrameBuffer buffer, int x, int y, float z)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D with a given z (in 3D).
static SimpleVector reproject2D3D(Camera camera, FrameBuffer buffer, int x, int y, float z, SimpleVector toFill)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D with a given z (in 3D).
static SimpleVector reproject2D3D(Camera camera, FrameBuffer buffer, int x, int y, SimpleVector toFill)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D.
static SimpleVector reproject2D3DWS(Camera camera, FrameBuffer buffer, int x, int y)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space).
static SimpleVector reproject2D3DWS(Camera camera, FrameBuffer buffer, int x, int y, float z)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space).
static SimpleVector reproject2D3DWS(Camera camera, FrameBuffer buffer, int x, int y, float z, SimpleVector toFill)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space).
static SimpleVector reproject2D3DWS(Camera camera, FrameBuffer buffer, int x, int y, SimpleVector toFill)
          Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

reproject2D3D

public static SimpleVector reproject2D3D(Camera camera,
                                         FrameBuffer buffer,
                                         int x,
                                         int y)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D. The Z-value is assumed to be 1.

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
Returns:
the reprojected vector in camera space

reproject2D3D

public static SimpleVector reproject2D3D(Camera camera,
                                         FrameBuffer buffer,
                                         int x,
                                         int y,
                                         SimpleVector toFill)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D. The Z-value is assumed to be 1.

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
toFill - a SimpleVector that will be filled with the result
Returns:
the reprojected vector in camera space

reproject2D3DWS

public static SimpleVector reproject2D3DWS(Camera camera,
                                           FrameBuffer buffer,
                                           int x,
                                           int y)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space). The Z-value is assumed to be 1.

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
Returns:
the direction vector from the camera to the position in world space

reproject2D3DWS

public static SimpleVector reproject2D3DWS(Camera camera,
                                           FrameBuffer buffer,
                                           int x,
                                           int y,
                                           SimpleVector toFill)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space). The Z-value is assumed to be 1.

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
toFill - a SimpleVector that will be filled with the result
Returns:
the direction vector from the camera to the position in world space

reproject2D3DWS

public static SimpleVector reproject2D3DWS(Camera camera,
                                           FrameBuffer buffer,
                                           int x,
                                           int y,
                                           float z)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space).

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
z - the z position in camera space
Returns:
the direction vector from the camera to the position in world space

reproject2D3DWS

public static SimpleVector reproject2D3DWS(Camera camera,
                                           FrameBuffer buffer,
                                           int x,
                                           int y,
                                           float z,
                                           SimpleVector toFill)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D (world space).

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
z - the z position in camera space
toFill - a SimpleVector that will be filled with the result
Returns:
the direction vector from the camera to the position in world space

reproject2D3D

public static SimpleVector reproject2D3D(Camera camera,
                                         FrameBuffer buffer,
                                         int x,
                                         int y,
                                         float z)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D with a given z (in 3D).

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
z - the z position of the "picking plane" (in camera space)
Returns:
the reprojected vector in camera space

reproject2D3D

public static SimpleVector reproject2D3D(Camera camera,
                                         FrameBuffer buffer,
                                         int x,
                                         int y,
                                         float z,
                                         SimpleVector toFill)
Reprojects a 2D vector (a screen/framebuffer coordinate in most cases) back into 3D with a given z (in 3D).

Parameters:
camera - the camera used to render the scene
buffer - the framebuffer containing the rendered image
x - the x position in 2D
y - the y position in 2D
z - the z position of the "picking plane" (in in camera space)
toFill - a SimpleVector that will be filled with the result
Returns:
the reprojected vector in camera space

project3D2D

public static SimpleVector project3D2D(Camera camera,
                                       FrameBuffer buffer,
                                       SimpleVector vertex)
Projects a vertex from world space into screen space.

Parameters:
camera - the Camera used for the projection
buffer - the Framebuffer
vertex - the vertex in world space
Returns:
a SimpleVector containing the x- and y-coordinates in screenspace in the x and y components and the (rather uninteresting) w-coordinate in the z component of the SimpleVector. All coordinates are returned as floats to allow for the higher accuracy when post-processing them. Returns null if the transformation can't be done (i.e. the center is behind the viewplane). Negative values are possible.

project3D2D

public static SimpleVector project3D2D(Camera camera,
                                       FrameBuffer buffer,
                                       SimpleVector vertex,
                                       SimpleVector toFill)
Projects a vertex from world space into screen space. This variant takes a SimpleVector to fill instead of creating a new one for each call.

Parameters:
camera - the Camera used for the projection
buffer - the Framebuffer
vertex - the vertex in world space
toFill - the SimpleVector that will be filled with the result
Returns:
a SimpleVector containing the x- and y-coordinates in screenspace in the x and y components and the (rather uninteresting) w-coordinate in the z component of the SimpleVector. All coordinates are returned as floats to allow for the higher accuracy when post-processing them. Returns null if the transformation can't be done (i.e. the vertex is behind the viewplane). Negative values are possible.

projectCenter3D2D

public static SimpleVector projectCenter3D2D(FrameBuffer buffer,
                                             Object3D obj)
Gets the center of the object in screen-coordinates (2D) by transforming and projecting it from 3D objectspace into 2D screenspace. Useful to "attach" bitmaps to objects for example. This method uses the current camera of the World the object has been assigned to.

Parameters:
buffer - the framebuffer the object will be (or has been) rendered into
obj - the object itself
Returns:
a SimpleVector containing the x- and y-coordinates in screenspace in the x and y components and the (rather uninteresting) w-coordinate in the z component of the SimpleVector. All coordinates are returned as floats to allow for the higher accuracy when post-processing them. Returns null if the transformation can't be done (i.e. the vertex is behind the viewplane). Negative values are possible.

projectCenter3D2D

public static SimpleVector projectCenter3D2D(Camera camera,
                                             FrameBuffer buffer,
                                             Object3D obj)
Gets the center of the object in screen-coordinates (2D) by transforming and projecting it from 3D objectspace into 2D screenspace. Useful to "attach" bitmaps to objects for example.

Parameters:
camera - the camera that represents the worldspace->cameraspace transformation. The frontbuffer matrix of the camera will be used. If the camera is null, the one from the object's World will be used instead.
buffer - the framebuffer the object will be (or has been) rendered into
obj - the object itself
Returns:
a SimpleVector containing the x- and y-coordinates in screenspace in the x and y components and the (rather uninteresting) w-coordinate in the z component of the SimpleVector. All coordinates are returned as floats to allow for the higher accuracy when post-processing them. Returns null if the transformation can't be done (i.e. the center is behind the viewplane). Negative values are possible.