Commit 9d50f975 authored by Mike Kremer's avatar Mike Kremer

Started new attempt to fix rotation center issue.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6294 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3d33f45e
...@@ -425,17 +425,39 @@ void setScenePos(const ACG::Vec3d& _center, int _viewer ) { ...@@ -425,17 +425,39 @@ void setScenePos(const ACG::Vec3d& _center, int _viewer ) {
std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl; std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
} }
const ACG::Vec3d& sceneCenter( int _viewer ) { void setSceneCenter(const ACG::Vec3d& _center, int _viewer) {
if ( _viewer == ACTIVE_VIEWER ) {
return examiner_widgets_[activeExaminer_]->scene_center(); if (_viewer == ACTIVE_VIEWER) {
} else if ( _viewer == ALL_VIEWERS )
std::cerr << "Please select viewer to get viewing direction!" << std::endl; examiner_widgets_[activeExaminer_]->setSceneCenter(_center);
else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() ) } else if (_viewer == ALL_VIEWERS) {
return examiner_widgets_[_viewer]->scene_center();
else for (uint i = 0; i < examiner_widgets_.size(); ++i) {
std::cerr << "Requested illegal viewer for sceneCenter!!" << std::endl;
examiner_widgets_[i]->setSceneCenter(_center);
}
} else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size()) {
examiner_widgets_[_viewer]->setSceneCenter(_center);
} else {
std::cerr << "Requested illegal viewer for setSceneCenter!!"
<< std::endl;
}
}
const ACG::Vec3d& sceneCenter(int _viewer) {
if (_viewer == ACTIVE_VIEWER) {
return examiner_widgets_[activeExaminer_]->scene_center();
} else if (_viewer == ALL_VIEWERS)
std::cerr << "Please select viewer to get viewing direction!"
<< std::endl;
else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size())
return examiner_widgets_[_viewer]->scene_center();
else
std::cerr << "Requested illegal viewer for sceneCenter!!" << std::endl;
return examiner_widgets_[activeExaminer_]->scene_center(); return examiner_widgets_[activeExaminer_]->scene_center();
} }
double sceneRadius() { double sceneRadius() {
......
...@@ -178,6 +178,18 @@ void setActiveExaminer( const unsigned int _id ); ...@@ -178,6 +178,18 @@ void setActiveExaminer( const unsigned int _id );
DLLEXPORT DLLEXPORT
unsigned int activeExaminer(); unsigned int activeExaminer();
/**
* Set center of scene
*/
DLLEXPORT
void setSceneCenter(const ACG::Vec3d& _center, int _viewer );
/**
* Get scene center
*/
DLLEXPORT
const ACG::Vec3d& sceneCenter( int _viewer );
/** Execute picking operation on scenegraph /** Execute picking operation on scenegraph
* This picking function will pick in the last active examiner context which is automatically * This picking function will pick in the last active examiner context which is automatically
* Set by mouseevents from the core * Set by mouseevents from the core
......
...@@ -51,7 +51,7 @@ void Core::resetScenegraph() { ...@@ -51,7 +51,7 @@ void Core::resetScenegraph() {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
// update scene graph (get new bounding box and set projection right, including near and far plane) // update scene graph (get new bounding box and set projection right, including near and far plane)
PluginFunctions::viewerProperties(i).lockUpdate(); PluginFunctions::viewerProperties(i).lockUpdate();
coreWidget_->examiner_widgets_[i]->sceneGraph(root_node_scenegraph_); coreWidget_->examiner_widgets_[i]->sceneGraph(root_node_scenegraph_, true);
PluginFunctions::viewerProperties(i).unLockUpdate(); PluginFunctions::viewerProperties(i).unLockUpdate();
coreWidget_->examiner_widgets_[i]->updateGL(); coreWidget_->examiner_widgets_[i]->updateGL();
} }
......
...@@ -244,7 +244,7 @@ void glViewer::swapBuffers() { ...@@ -244,7 +244,7 @@ void glViewer::swapBuffers() {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root) void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _setCenter)
{ {
// if (sceneGraphRoot_ == _root) // if (sceneGraphRoot_ == _root)
// return; // return;
...@@ -263,10 +263,11 @@ void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root) ...@@ -263,10 +263,11 @@ void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root)
if ( ( bbmin[0] > bbmax[0] ) || if ( ( bbmin[0] > bbmax[0] ) ||
( bbmin[1] > bbmax[1] ) || ( bbmin[1] > bbmax[1] ) ||
( bbmin[2] > bbmax[2] ) ) ( bbmin[2] > bbmax[2] ) )
setScenePos( ACG::Vec3d( 0.0,0.0,0.0 ) , 1.0 ); setScenePos( ACG::Vec3d( 0.0,0.0,0.0 ) , 1.0, _setCenter );
else else
setScenePos( ( bbmin + bbmax ) * 0.5, setScenePos( ( bbmin + bbmax ) * 0.5,
( bbmax - bbmin ).norm() * 0.5 ); ( bbmax - bbmin ).norm() * 0.5,
_setCenter);
} }
updateGL(); updateGL();
...@@ -362,19 +363,28 @@ void glViewer::updateProjectionMatrix() ...@@ -362,19 +363,28 @@ void glViewer::updateProjectionMatrix()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::setScenePos(const ACG::Vec3d& _center, double _radius) void glViewer::setScenePos(const ACG::Vec3d& _center, double _radius, const bool _setCenter)
{ {
scene_center_ = trackball_center_ = _center; if(_setCenter) {
scene_radius_ = trackball_radius_ = _radius; scene_center_ = trackball_center_ = _center;
}
orthoWidth_ = 2.0 * scene_radius_; scene_radius_ = trackball_radius_ = _radius;
near_ = 0.001 * scene_radius_;
far_ = 10.0 * scene_radius_;
updateProjectionMatrix(); orthoWidth_ = 2.0 * scene_radius_;
updateGL(); near_ = 0.001 * scene_radius_;
far_ = 10.0 * scene_radius_;
updateProjectionMatrix();
updateGL();
} }
//-----------------------------------------------------------------------------
void glViewer::setSceneCenter( const ACG::Vec3d& _center ) {
scene_center_ = trackball_center_ = _center;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -587,17 +597,25 @@ void glViewer::home() ...@@ -587,17 +597,25 @@ void glViewer::home()
void glViewer::viewAll() void glViewer::viewAll()
{ {
makeCurrent(); makeCurrent();
// move center (in camera coords) to origin and translate in -z dir // update scene graph (get new bounding box and set projection right, including near and far plane)
translate(-(glstate_->modelview().transform_point(scene_center_)) properties_.lockUpdate();
- ACG::Vec3d(0.0, 0.0, 3.0*scene_radius_ ));
orthoWidth_ = 1.1*scene_radius_; // move center (in camera coords) to origin and translate in -z dir
double aspect = (double) glWidth() / (double) glHeight(); translate(-(glstate_->modelview().transform_point(scene_center_))
if (aspect > 1.0) orthoWidth_ *= aspect; - ACG::Vec3d(0.0, 0.0, 3.0 * scene_radius_));
updateProjectionMatrix();
updateGL(); orthoWidth_ = 1.1 * scene_radius_;
double aspect = (double) glWidth() / (double) glHeight();
if (aspect > 1.0)
orthoWidth_ *= aspect;
sceneGraph(PluginFunctions::getSceneGraphRootNode(), true);
properties_.unLockUpdate();
updateProjectionMatrix();
updateGL();
} }
......
...@@ -178,7 +178,7 @@ public: ...@@ -178,7 +178,7 @@ public:
The \c sceneGraphToched() signal will be emitted (even if The \c sceneGraphToched() signal will be emitted (even if
\c _root does not actually change). \c _root does not actually change).
*/ */
void sceneGraph(ACG::SceneGraph::BaseNode* _root); void sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _setCenter = false);
/// projection mode /// projection mode
...@@ -197,7 +197,13 @@ public: ...@@ -197,7 +197,13 @@ public:
used as fixpoint for rotations and to set the eye point far used as fixpoint for rotations and to set the eye point far
enough from the scene so that the whole scene is visible. enough from the scene so that the whole scene is visible.
*/ */
void setScenePos( const ACG::Vec3d& _center, double _radius ); void setScenePos( const ACG::Vec3d& _center, double _radius, const bool _setCenter = false );
/**
* Set new center point of scene
*/
void setSceneCenter( const ACG::Vec3d& _center );
/** Get scene's center /** Get scene's center
\see setScenePos() \see setScenePos()
*/ */
......
...@@ -454,11 +454,6 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE ...@@ -454,11 +454,6 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE
int objectId = _node->getIdentifier(); int objectId = _node->getIdentifier();
if (objectId == -1){
OpenFlipper::Options::redrawDisabled( false );
return;
}
ACG::Matrix4x4d mat; ACG::Matrix4x4d mat;
mat.identity(); mat.identity();
mat = _node->matrix(); mat = _node->matrix();
...@@ -487,6 +482,8 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE ...@@ -487,6 +482,8 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE
} }
} }
PluginFunctions::setSceneCenter(_node->center(), PluginFunctions::ALL_VIEWERS );
lastActiveManipulator_ = objectId; lastActiveManipulator_ = objectId;
updateManipulatorDialog(); updateManipulatorDialog();
} }
......
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