Open Inventor Reference
SoSpotLightDragger Class Reference

Spotlight shaped dragger that allows you to change position, direction, and width of the beam. More...

#include <Inventor/draggers/SoSpotLightDragger.h>

Inheritance diagram for SoSpotLightDragger:
SoDragger SoInteractionKit SoBaseKit SoNode SoFieldContainer SoBase

List of all members.

Public Member Functions

 SoSpotLightDragger ()
 Constructor.

Static Public Member Functions

static void initClass ()
 Initialize the class.

Public Attributes

SoSFRotation rotation
SoSFVec3f translation
SoSFFloat angle

Protected Member Functions

void dragStart ()
void drag ()
void dragFinish ()
void setBeamScaleFromAngle (float beamAngle)
 Returns scaleFactor for beamScale part to display beamAngle.
virtual SbBool setUpConnections (SbBool onOff, SbBool doItAlways=FALSE)
 detach/attach any sensors, callbacks, and/or field connections.
virtual void setDefaultOnNonWritingFields ()
 Called by the SoBaseKit::write() method.
virtual ~SoSpotLightDragger ()

Static Protected Member Functions

static void startCB (void *, SoDragger *)
static void motionCB (void *, SoDragger *)
static void doneCB (void *, SoDragger *)
static void fieldSensorCB (void *, SoSensor *)
static void valueChangedCB (void *, SoDragger *)

Protected Attributes

SbPlaneProjectorplaneProj
 used during interaciton with beam
SoFieldSensorrotFieldSensor
SoFieldSensortranslFieldSensor
SoFieldSensorangleFieldSensor

Detailed Description

SoSpotLightDragger is a composite dragger. It is shaped like a beam of light emanating from a sun-like ball. An arrow runs along the axis of the beam and extends past the end of the beam.

When you click and drag the beam, it opens and closes with an umbrella-like motion. The angle between the center and edge of the beam is stored in the angle field of this dragger; setting the angle field causes the beam to widen or narrow in response. The spotlight dragger does not use a standard dragger class to execute this motion. More details are given later in this section.

Dragging the arrow rotates it arount the sun, and the beam moves with it. The arrow is an SoRotateSphericalDragger that controls the rotation field. See the reference page for SoDirectionalLightDragger, which works the same way, for details.

The sun-shape can be dragged to translate all three pieces together through 3-space. Its movement controls the translation field and works exactly as described in the reference pages for SoDirectionalLightDragger and SoPointLightDragger (which goes into more detail).

Remember: This is not a light source! It just looks like one. If you want to move a light with this dragger, you can do the following:

[a] Use an SoSpotLightManip, which is subclassed from SoLight. It creates an SoSpotLightDragger and uses it as the interface to change the location , direction , and cutOffAngle of its light source (see the SoSpotLightManip man page). The manip also edits the material part of this dragger to match the color of light the manip is producing.

[b] Connect the angle field of this dragger to the cutOffAngle field of an SoSpotLight with a field-to-field connection.

See the SoPointLightDragger and SoDirectionalLightDragger man pages for other ways to control light parameters with the rotation and translation fields.

This class creates its own projector and handles mouse events to do it's own dragging of the beam angle. When the mouse picks a point on the beam, that point is dragged in a circle just like in an SoRotateDiscDragger, but the plane of the disc is re-defined every time a drag is initiated. Imagine placing the metal tip of a compass at the apex of the cone and the pencil tip at the picked point. If you swing an arc through the central axis of the cone, you will be drawing the arc used to drag the beam open and closed.

The beam is opened and closed not by rotating, but by scaling. The dragger scales the beam-cone so that the height and radius change to move the picked point along the circle. Then the angle field is calculated from the height and radius.

You can change the geometry of parts in any instance of this dragger using setPart(). The default part geometries are defined as resources for this SoSpotLightDragger class. They are detailed below in the DRAGGER RESOURCE section. You can make your program use different default resources for the parts by copying the file /usr/share/data/draggerDefaults/spotLightDragger.iv into your own directory, editing the file, and then setting the environment variable SO_DRAGGER_DIR to be a path to that directory.

File Format/Default
See Also
SoInteractionKit, SoDragger, SoCenterballDragger, SoDirectionalLightDragger, SoDragPointDragger, SoHandleBoxDragger, SoJackDragger, SoPointLightDragger, SoRotateCylindricalDragger, SoRotateDiscDragger, SoRotateSphericalDragger, SoScale1Dragger, SoScale2Dragger, SoScale2UniformDragger, SoScaleUniformDragger, SoTabBoxDragger, SoTabPlaneDragger, SoTrackballDragger, SoTransformBoxDragger, SoTransformerDragger, SoTranslate1Dragger, SoTranslate2Dragger

Definition at line 225 of file SoSpotLightDragger.h.


Constructor & Destructor Documentation

SoSpotLightDragger::SoSpotLightDragger ( )
virtual SoSpotLightDragger::~SoSpotLightDragger ( ) [protected, virtual]

Member Function Documentation

static void SoSpotLightDragger::doneCB ( void *  ,
SoDragger  
) [static, protected]
void SoSpotLightDragger::drag ( ) [protected]
void SoSpotLightDragger::dragFinish ( ) [protected]
void SoSpotLightDragger::dragStart ( ) [protected]
static void SoSpotLightDragger::fieldSensorCB ( void *  ,
SoSensor  
) [static, protected]

Reimplemented from SoInteractionKit.

static void SoSpotLightDragger::initClass ( ) [static]

Reimplemented from SoDragger.

static void SoSpotLightDragger::motionCB ( void *  ,
SoDragger  
) [static, protected]
void SoSpotLightDragger::setBeamScaleFromAngle ( float  beamAngle) [protected]
virtual void SoSpotLightDragger::setDefaultOnNonWritingFields ( ) [protected, virtual]

Draggers don't want to write out fields if they have default vals.

sets isActive to default if default and not connected.

Looks for fields named: 'rotation' with value SbRotation::identity() 'translation' with value (0,0,0) 'center' with value (0,0,0) 'scaleFactor' with value (1,1,1) and sets them to default if they are not connected from a field. (most draggers are missing at least some of these, but thats okay)

Then calls the method for SoInteractionKit.

NOTE: Parts which are set to default may still wind up writing to file if, for example, they lie on a path.

Reimplemented from SoDragger.

virtual SbBool SoSpotLightDragger::setUpConnections ( SbBool  onOff,
SbBool  doItAlways = FALSE 
) [protected, virtual]

Also set geometry of childDraggers to be our default instead of their regular default, using our resources. Called by: start/end of SoBaseKit::readInstance and on new copy by: start/end of SoBaseKit::copy. Classes that redefine must call setUpConnections(TRUE,TRUE) at end of constructor. Returns the state of the node when this was called.

Reimplemented from SoInteractionKit.

static void SoSpotLightDragger::startCB ( void *  ,
SoDragger  
) [static, protected]
static void SoSpotLightDragger::valueChangedCB ( void *  ,
SoDragger  
) [static, protected]

Member Data Documentation

Definition at line 266 of file SoSpotLightDragger.h.


The documentation for this class was generated from the following file: