- The Call-Back Function
- Specification
- CBFnPick2D()

** br_pick2d_cbfn**

`BrScenePick2D()`

. It is called for each model actor in an actor hierarchy that is beneath a particular screen pixel (corresponding to a particular camera). It's typically used to implement picking functions for user interfaces.

`typedef`

`fwproto.h `

for a precise declaration)
**int br_pick2d_cbfn(br_actor*, const br_model*, const br_material*, const br_vector3*, const br_vector3*, br_scalar, br_scalar, void*) 2D pick call-back**

`BrScenePick2D()`

.
For a function that calls a call-back for each model actor whose bounds intersect a specific bounds, see `BrScenePick3D()`

*82*`.`

`br_pick3d_cbfn`

for a similar 3D call-back.
See `br_model_custom_cbfn`

*247*` for details of functions (used from within rendering call-backs) that can convert model co-ordinates into screen co-ordinates, e.g. `

`BrPointToScreenXY()`

*251*`.`

**CBFnPick2D()**

`BrScenePick2D()`

. It is called for each model actor whose bounds intersect the ray passing from a camera through a particular screen pixel (see `BrScenePick2D()`

).Declaration:

**int BR_CALLBACK CBFnPick2D(br_actor* a, const br_model* model, const br_material* material, const br_vector3* ray_pos, const br_vector3* ray_dir, br_scalar t_near, br_scalar t_far, void* arg)**

Arguments:

**br_actor * a**

Pointer to model actor whose model bounds intersect the pick ray.

**const br_model * model**

Pointer to the model attributed to the model actor whose bounds intersect the pick ray (may be an inherited model).

**const br_material * material**

Pointer to the default material attributed to the model actor that may be used by the model (may be an inherited material).

**const br_vector3 * ray_pos**

Pointer to a 3D vector giving a starting position of the pick ray in the model's co-ordinate space. This position has no special significance, i.e. it is not necessarily the position of the view-point.

**const br_vector3 * ray_dir**

Pointer to a 3D vector giving direction of ray from view-point through pixel in the model's co-ordinate space. The magnitude has no special significance, i.e. it is not necessarily the position of the model.

**br_scalar t_near**

The co-efficient giving the position of the entry point of the pick ray into the bounds of the intersecting model, in the model's co-ordinate space. To obtain this position refer to the following formula.

**br_scalar t_far**

The co-efficient giving the position of the exit point of the pick ray out of the bounds of the intersecting model, in the model's co-ordinate space. To obtain this position refer to the following formula.

**void * arg**

The corresponding value specified in the call of `BrScenePick2D()`

*84*` `

that invoked this call-back.

Preconditions: BRender has completed initialisation. A model's bounds intersect the pick ray. The order in which intersections are computed is undefined.

Effects: Behaviour is up to the application.

Result:

**int**

Return zero continue the search for intersecting model actors, non-zero to terminate. A non-zero value will be returned by `BrScenePick2D()`

*84*`.`

Remarks: For borderline cases, the pick ray is defined to be such that if a model's rendering would appear in the pixel then the model's bounds will intersect the ray. The precise sub-pixel position of the ray is consistent, but undefined.

Example: Possible uses include:

- Selection
- Manipulation

`br_model_custom_cbfn`

, `br_renderbounds_cbfn`

, `br_pick3d_cbfn`

.

Generated with CERN WebMaker