Commit 0bc9541c authored by Jan Möbius's avatar Jan Möbius

Added interfaces and functions for refine picking functionality

refs #1908

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20422 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a5919f0e
......@@ -128,7 +128,7 @@ class MetadataInterface {
};
/** \page MetaDataInterfacePage MetaData Interface
/** \page metaDataInterfacePage MetaData Interface
\n
\image html metaDataInterface.png
\n
......
......@@ -458,11 +458,13 @@ ACG::SceneGraph::DrawModes::DrawMode drawMode( int _viewer ) {
return viewerProperties(activeExaminer()).drawMode();
}
// Pick returning node index
bool scenegraphPick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) {
return examiner_widgets_[activeExaminer_]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
}
// Pick returning node index
bool scenegraphPick( const unsigned int _examiner, ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) {
if ( _examiner >= examiner_widgets_.size() ) {
......@@ -472,6 +474,59 @@ bool scenegraphPick( const unsigned int _examiner, ACG::SceneGraph::PickTarget _
return examiner_widgets_[_examiner]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
}
// Pick returning object and calling refine
bool scenegraphPick( const unsigned int _examiner ,
ACG::SceneGraph::PickTarget _pickTarget,
const QPoint & _mousePos,
BaseObjectData*& _object,
unsigned int & _targetIdx,
const bool _refine,
ACG::Vec3d * _hitPointPtr ) {
unsigned int nodeIdx = 0;
bool ok = scenegraphPick(_examiner,_pickTarget,_mousePos,nodeIdx,_targetIdx,_hitPointPtr);
// If successfully picked and object is found
if ( ok && PluginFunctions::getPickedObject(nodeIdx, _object) ) {
if ( _refine && (_hitPointPtr != 0) ) {
// Map to correct coordinates in OpenGL
double x = _mousePos.x() - examiner_widgets_[_examiner]->scenePos().x();
double y = examiner_widgets_[_examiner]->glHeight() - (_mousePos.y() - examiner_widgets_[_examiner]->scenePos().y());
std::cerr << "x " << x << " y " << y << std::endl;
ACG::Vec3d mousePoint3d = examiner_widgets_[_examiner]->unproject( ACG::Vec3d(x,y,-1.0 ) );
ACG::Vec3d direction = (mousePoint3d - eyePos(_examiner)).normalized();
*_hitPointPtr = _object->refinePick(_pickTarget,*_hitPointPtr, mousePoint3d , direction , _targetIdx );
}
}
return ok;
}
// Pick returning object and calling refine
bool scenegraphPick( ACG::SceneGraph::PickTarget _pickTarget,
const QPoint & _mousePos,
BaseObjectData*& _object,
unsigned int & _targetIdx,
const bool _refine,
ACG::Vec3d * _hitPointPtr ) {
return scenegraphPick(activeExaminer_,_pickTarget,_mousePos, _object,_targetIdx,_refine,_hitPointPtr );
}
bool scenegraphRegionPick( ACG::SceneGraph::PickTarget _pickTarget,
const QRegion& _region,
QList<QPair<unsigned int, unsigned int> >& _list,
......
......@@ -237,19 +237,41 @@ void setEncodedExaminerView(int _viewerId , QString _view );
DLLEXPORT
void setSceneCenter(const ACG::Vec3d& _center, int _viewer );
/** Execute picking operation on scenegraph
/** \brief Execute picking operation on scenegraph
*
* This picking function will pick in the last active examiner context which is automatically
* Set by mouseevents from the core
* set by the last mouse event from the core
*/
DLLEXPORT
bool scenegraphPick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr );
/** Execute picking operation on scenegraph
/** \brief Execute picking operation on scenegraph
*
* This picking function will pick in the specified examiner context
*/
DLLEXPORT
bool scenegraphPick( const unsigned int _examiner ,ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr );
/** \brief Execute picking operation on scenegraph and return object
*
* This picking function will pick in the specified examiner context and
* will return a pointer to the picked object. Furthermore, the refine picking of
* the picked object will be called in order to achieve higher picking accuracy
*/
DLLEXPORT
bool scenegraphPick( const unsigned int _examiner ,ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, BaseObjectData*& _object, unsigned int &_targetIdx, const bool _refine ,ACG::Vec3d *_hitPointPtr );
/** \brief Execute picking operation on scenegraph and return object
*
* This picking function will pick in the examiner context of the last mouse event and
* will return a pointer to the picked object. Furthermore, the refine picking of
* the picked object will be called in order to achieve higher picking accuracy
*/
DLLEXPORT
bool scenegraphPick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, BaseObjectData*& _object, unsigned int &_targetIdx, const bool _refine, ACG::Vec3d *_hitPointPtr );
/** Execute picking operation on scenegraph
* This picking function will pick in the last active examiner context which is automatically
* Set by mouseevents from the core
......
......@@ -314,6 +314,10 @@ bool BaseObjectData::pickingEnabled() {
return true;
}
ACG::Vec3d BaseObjectData::refinePick(const ACG::SceneGraph::PickTarget _pickTarget, const ACG::Vec3d _hitPoint, const ACG::Vec3d _start , const ACG::Vec3d _dir, const unsigned int _targetIdx ) {
return _hitPoint;
}
// ===============================================================================
// Content Nodes
// ===============================================================================
......
......@@ -252,6 +252,26 @@ class DLLEXPORT BaseObjectData : public BaseObject
*/
virtual bool pickingEnabled();
/** \brief Refine picking
*
* Reimplement this function, if the object type can refine picking. E.g.
* the standard picking will rely on the z-buffer resolution, while a mesh
* can intersect a ray with the triangle and refine the depth via
* the exact intersection point.
*
* @param _pickTarget Current picking target (Faces, all,...)
* @param _original hitpoint
* @param _eyePos current picking ray start position
* @param _dir Ray direction when picking
* @param _targetIdx Entity id hit (e.g. face index for meshes
*
*/
virtual ACG::Vec3d refinePick(ACG::SceneGraph::PickTarget _pickTarget,
const ACG::Vec3d _hitPoint,
const ACG::Vec3d _start ,
const ACG::Vec3d _dir,
const unsigned int _targetIdx );
/** @} */
//===========================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment