Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

SphereSensor Class Reference

The SphereSensor node is a simple manipulator that maps mouse movement onto a sphere or sphere-like projection, specified by the 'sphere' field. More...

Inheritance diagram for SphereSensor:

Node EventHandler Object List of all members.

Public Member Functions

virtual bool handleEvent (const Event &event)
 Callback function that is implemented by the callee.

Detailed Description

The SphereSensor node is a simple manipulator that maps mouse movement onto a sphere or sphere-like projection, specified by the 'sphere' field.

Input is in normalized device coordinates (NDC), or {x,y} = {[0..1],[0..1]}. Output is a 3D point in world space.

Authoring Interface:

        SphereSensor {
            field SFString type "SHEET"
            field SFVec4f sphere 0 0 0 1
            eventIn SFVec2f ndcIn
            eventIn SFVec2f startPosIn
            eventOut SFVec3f worldOut
            eventOut SFVec3f rotOut
        }

Parameters:
sphere 4-vector defining a sphere: first three vector elements is the sphere center, the fourth element is the radius
ndcIn input mouse movement in Normalized Device Coordinates. You can use a WindowSensor and a ValueSensor in tandem to get NDC. Example:
        DEF V ValueSensor { valueOfInterest [ "MOUSEX", "MOUSEY" ] }
        DEF W WindowSensor {}
        function _getMousePos() {
           return SFVec2f( V.value[0] / W.size[0], ( W.size[1] - V.value[1] ) / W.size[1]);
        }
startPosIn send an NDC to this eventIn when you want to reset the SphereSensor to start at a particular point. Typically this is done at mouse-down: Example:
        DEF MyShape Shape {
           ...
           pickEvent  DO { 
             if ( self.pickEvent == "OVERBUTTONDOWN" ) then
                MySphereSensor.startPosIn = self:_getMousePos();
             end
           }
        }
worldOut 3D point projection of ndcIn
rotOut Rotation vector relative to the projected point startPosIn suitable for sending to the rotation field of a node Example:
        DEF MySphereSensor SphereSensor {
           sphere 0 0 0 1
           rotOut DO { 
              MyShape.rotation = self.rotOut;
           } 
        }
type type of sphere projection to use. One of:
"SHEET" A projector that is a sphere with a hyperbolic sheet draped over it. As the mouse moves away from the sphere, rotation gradually turns into pure roll. This projector is good for trackballs that want to do a continuous roll. It allows pure roll as you move away from the sphere. Warning: This projector tends to become very unstable when the mouse position is beyond about 2*radius from the center of the sphere. Therefore, it is best to use this as a large, window-sized trackball.
"SECTION" This projector projects the mouse position onto the section of a sphere that has been sliced by a plane. The tolerance slice can be specified as a fraction of the radius of the sphere. The projection point will not extend beyond the sliced portion of the sphere. This projector is good for trackballs that only do pure roll when the mouse is off the sliced portion of the sphere.
"PLANE" This projector projects the mouse position onto a sphere with a plane cutting through it. When the mouse position projects on to the plane, the rotations will be as if the plane is being dragged, causing the sphere to rotate beneath it.
Author:
Rick Pasetto
Date:
10/7/2005


Member Function Documentation

virtual bool handleEvent const Event event  )  [virtual]
 

Callback function that is implemented by the callee.

Parameters:
event specifies the time of the event. Event time will be the same for events occurring in the same render phase For example, PREUPDATE, POSTUPDATE, PRERENDER and POSTRENDER event callbacks will all pass the same event time for the same frame. Returning stop Emma from calling the rest of the handlers for this event If you return true, Emma will keep on calling rest of the handlers for this event

Implements EventHandler.


Generated on Sat Apr 1 06:08:09 2006 for Emma Content Development Kit by  doxygen 1.4.3