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 ) {
std::cerr << "Requested illegal viewer for setScenePos!!" << 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;
void setSceneCenter(const ACG::Vec3d& _center, int _viewer) {
if (_viewer == ACTIVE_VIEWER) {
examiner_widgets_[activeExaminer_]->setSceneCenter(_center);
} else if (_viewer == ALL_VIEWERS) {
for (uint i = 0; i < examiner_widgets_.size(); ++i) {
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() {
......
......@@ -178,6 +178,18 @@ void setActiveExaminer( const unsigned int _id );
DLLEXPORT
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
* This picking function will pick in the last active examiner context which is automatically
* Set by mouseevents from the core
......
......@@ -51,7 +51,7 @@ void Core::resetScenegraph() {
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)
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();
coreWidget_->examiner_widgets_[i]->updateGL();
}
......
......@@ -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)
// return;
......@@ -263,10 +263,11 @@ void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root)
if ( ( bbmin[0] > bbmax[0] ) ||
( bbmin[1] > bbmax[1] ) ||
( 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
setScenePos( ( bbmin + bbmax ) * 0.5,
( bbmax - bbmin ).norm() * 0.5 );
( bbmax - bbmin ).norm() * 0.5,
_setCenter);
}
updateGL();
......@@ -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;
scene_radius_ = trackball_radius_ = _radius;
if(_setCenter) {
scene_center_ = trackball_center_ = _center;
}
orthoWidth_ = 2.0 * scene_radius_;
near_ = 0.001 * scene_radius_;
far_ = 10.0 * scene_radius_;
scene_radius_ = trackball_radius_ = _radius;
updateProjectionMatrix();
updateGL();
orthoWidth_ = 2.0 * scene_radius_;
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()
void glViewer::viewAll()
{
makeCurrent();
makeCurrent();
// move center (in camera coords) to origin and translate in -z dir
translate(-(glstate_->modelview().transform_point(scene_center_))
- ACG::Vec3d(0.0, 0.0, 3.0*scene_radius_ ));
// update scene graph (get new bounding box and set projection right, including near and far plane)
properties_.lockUpdate();
orthoWidth_ = 1.1*scene_radius_;
double aspect = (double) glWidth() / (double) glHeight();
if (aspect > 1.0) orthoWidth_ *= aspect;
updateProjectionMatrix();
updateGL();
// move center (in camera coords) to origin and translate in -z dir
translate(-(glstate_->modelview().transform_point(scene_center_))
- ACG::Vec3d(0.0, 0.0, 3.0 * scene_radius_));
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:
The \c sceneGraphToched() signal will be emitted (even if
\c _root does not actually change).
*/
void sceneGraph(ACG::SceneGraph::BaseNode* _root);
void sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _setCenter = false);
/// projection mode
......@@ -197,7 +197,13 @@ public:
used as fixpoint for rotations and to set the eye point far
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
\see setScenePos()
*/
......
......@@ -454,11 +454,6 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE
int objectId = _node->getIdentifier();
if (objectId == -1){
OpenFlipper::Options::redrawDisabled( false );
return;
}
ACG::Matrix4x4d mat;
mat.identity();
mat = _node->matrix();
......@@ -487,6 +482,8 @@ void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseE
}
}
PluginFunctions::setSceneCenter(_node->center(), PluginFunctions::ALL_VIEWERS );
lastActiveManipulator_ = objectId;
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