Specifying a point in 3D using the mouse.
Specifying a point in 3D using the mouse Preliminiary object to specify a 3D point within a given bounding box via mouse movement. The object makes use of the VInteractionEvent type that is provided by a MetaViewer object. This interaction event is grabbed from a Camera object.
#include <ocean/plankton/VInputCreator.hpp>
#include <ocean/shrimp/VInteractionEvent.hpp>
#include <ocean/shrimp/PhysicalSpace.hpp>
#include <ocean/shrimp/VObjectStatus.hpp>
#include <ocean/shrimp/VEnum.hpp>
#include <ocean/shrimp/VCamera.hpp>
#include <ocean/shrimp/BoundingBox.hpp>
#include <ocean/plankton/VPipeline.hpp>
namespace
{
{
public:
, GrabMouse(this, "mouse", false)
, thePoint(
this,
"point",
point(0,0,0) )
{
attachUniqueObject(MyCamera);
attachUniqueObject(Interaction);
}
bool update(
VRequest&R,
double precision)
override;
};
{
bool GrabTheMouse = false;
GrabMouse << Context >> GrabTheMouse;
if (!Interaction->getSource())
{
{
if (CameraInteractionInput && CameraInteractionInput->getParameter() )
{
if (!attachParameter(CameraInteractionInput->getParameter(),
Interaction, "" ) )
{
puts("Hm??? could not grab camera mouse input?");
}
assert( CameraInteractionInput->getParameter() == Interaction->getParameter() );
}
}
}
MyCamera << Context >> theCamera;
Interaction << Context >> mp;
if (!GrabTheMouse )
{
return ConnectionsHaveChanged(
Context );
}
{
return true;
}
if ((mp.
state & VInteractionEvent::LeftButton)==0 )
{
return true;
}
{
thePoint << Context >> P;
double Pdist= norm(Pdir);
point Pshift = ViewCenter - (x-0.5)*Right - (y-0.5)*Up;
if (norm2(newP-P)>1E-8)
{
return setStatusInfo(
Context,
"Point: " + String(P) );
}
}
return true;
}
}
namespace
{
MyCreator(
Category(
"Create" ) + VIdentifier(
"InteractivePoint" ) +
Application(
"Interaction" ) +
Description(
"Create a point via mouse interaction." ) +
ObjectQuality::OUTDATED );
My2ndCreator(
Category(
"Utility" ) + VIdentifier(
"InteractivePoint" ) +
Application(
"Interaction" ) +
Description(
"Create a point via mouse interaction." ) +
Help(
"Navigate a point in 3D space using the cursor in the rendering window, once activated" ),
ObjectQuality::BETA );
}
A set of variable names, with indices associated to each type.
Definition Context.hpp:18
A point in physical 3D space.
Definition elementary/eagle/PhysicalSpace.hpp:106
3-dimensional vector.
Definition elementary/eagle/PhysicalSpace.hpp:170
vector unit() const
Return the unit vector of this vector.
Definition elementary/eagle/PhysicalSpace.hpp:339
A reference counting pointer class which keeps objects alive as long as strong pointers to these obje...
Definition RefPtr.hpp:405
An input slot for VObjects, bound to a specific type.
Definition TypedSlot.hpp:57
A set of property elements for VCreator objects.
Definition VCreatorProperties.hpp:258
Communication type for mouse and keyboard interactions.
Definition VInteractionEvent.hpp:58
double PosX
Scaled position [0,1]x[0,1] of the mouse relative to the current input device.
Definition VInteractionEvent.hpp:68
void ungrab(const WeakPtr< VObject > &)
Ungrab this interaction event.
Definition VInteractionEvent.cpp:79
bool mayuse(const WeakPtr< VObject > &) const
May the specified object make use of this interaction event or is it supposed to ignore it?
Definition VInteractionEvent.cpp:216
GrabReason * grab(const WeakPtr< VObject > &, GrabReason::Type=GrabReason::Select, int CursorShapeWidth=0, const RefPtr< ChunkBase > &CursorShape=nullptr)
Grab this interaction event exclusively to be interpreted by this object only.
Definition VInteractionEvent.cpp:43
Generic base class for all VObjects.
Definition VObject.hpp:186
Output properties of an object.
Definition VSlotContainerIO.hpp:222
Request structure.
Definition VRequest.hpp:24
Geometric algebra of the physical 3D-space, by which we mean the Clifford algebara over Euclidean,...
Definition AnalyticFunction.hpp:31
Gather general basic mathematic functions which are not available in cmath here.
Definition Context.cpp:7
The Panthalassa namespace allows to conveniently specify the properties of a VCreator object during c...
Definition VCreatorProperties.hpp:385
The Vish namespace.
Definition Anemone.cpp:17
Base class for convenient messing around with the status to be displayed for a certain object.
Definition VObjectStatus.hpp:109
The Camera object for OpenGL operations in VISH.
Definition VCamera.hpp:26
bivector_t Up
The horizontal plane, a bi-vector, whose dual is the up-direction.
Definition VCamera.hpp:38
tvector3 viewdir() const
The view direction.
Definition VCamera.hpp:46
point_t Observer
Location of the observer.
Definition VCamera.hpp:33
Implements a data filter, or computational object in general.
Definition VPipeline.hpp:52