Archived issue #0002618
Visualization - choose better center of gravity for camera rotation operations
Description
Bug from Open CASCADE community
Bug has been registered by François Lauzon
http://www.opencascade.org/forumorg/bug.php?bug_id=125&f=8
There is a bug in the method Gravity (which is used by StartRotation when we
start a rotation). If you see the whole model, the Gravity is set ok and the
rotation work ok, but if you zoom a small part of the model, the Gravity returns
0,0,0 and then the rotation is done by this new center and we "lost" the model.
This will append when all Graphic3d_Structure Bounding Box are outside the view.
Maybe use another way to compute gravity to set the center of rotation...
Bug has been registered by François Lauzon
http://www.opencascade.org/forumorg/bug.php?bug_id=125&f=8
There is a bug in the method Gravity (which is used by StartRotation when we
start a rotation). If you see the whole model, the Gravity is set ok and the
rotation work ok, but if you zoom a small part of the model, the Gravity returns
0,0,0 and then the rotation is done by this new center and we "lost" the model.
This will append when all Graphic3d_Structure Bounding Box are outside the view.
Maybe use another way to compute gravity to set the center of rotation...
Additional information
Documentation remark, added by apl 2011-07-26 11:55:53:
Improvements:
Two new approaches has been developed for rotating the model in the view. In
addition to the older algorithm when the displayed model in the view was
rotated around its gravity point, the new algorithms take for rotation more
appropriate point that provides more convenient method, similar to turning the
camera. There are two new methods: first calculates rotation point depending on
the objects displayed inside of the view that are visible, and the second
calculates rotation point in the same manner with priority of the closest
object in center of the view providing the rotation of the model around this
object. These methods calculate rotation point not the same as the gravity
point, thus the model could go out of front and back view planes (ZSize), but
this solution provides an option that enables automated recalculation of the
view planes for such rotations.
The mathematical part of solution is developed as an utility tool, which could
be reused with any viewer that could provide information on displayed objects
such as bounding boxes and its viewing volume geometrical properties.
You might need to revise code of your application to enable use of these new
approaches. The gravity point will be selected by default as point of rotating
the model when porting your application.
Changes:
Gravity point calculation has been fixed, in the case when the zoomed object
inside of the view the gravity point is taken as the object's center. Two new
approaches to calculate model rotation point has been added: these approaches
project the model on the ray that goes from the center of the view in front
direction, and find average point on it. New enumeration
Aspect_ViewRotationType has been added to define the rotation point calculation
algorithms. The rotation type and option to automatically recompute front and
back view planes (ZSize) is specified for the V3d view in the method
StartRotation that calculates the point of model rotation.
There are changes in the following packages:
Aspect package:
1) New enumeration Aspect_ViewRotationType has been added
Bnd package:
Bnd_Box class:
1) New methods has been added to Bnd_Box class: project its bounding points on
the line (Bnd_Box::ProjectedPoints (const gp_Lin& theLine)), find intersection
points of the line with bounding box (Bnd_Box::IntersectionPoints (const
gp_Lin& theLine))
TColgp package:
1) TColgp_Array1OfPln class has been defined in cdl.
V3d package:
V3d_View class:
1) Gravity method has been corrected;
2) StartRotation method now has two new arguments: theViewRotationType and
FitZSize to provide services of new approaches for calculating the rotation
point and automatically ZSize calculation;
3) FrustumPlanes method has been added, this method calculates view volume
planes of the view, normals of planes are oriented outside the viewing volume;
4) PointOfRotation method has been added, this method uses utility tool to
compute the point of model rotation depending on the bounding boxes and view
volume.
Viewer package:
Viewer_ViewRotationTool class:
1) New class Viewer_ViewRotationTool has been added, this class provides
services for interactive rotation point calculation. This class could be reused
with other viewers.
ViewerTest package:
1) ViewerTest_ViewerCommands.cxx: new command vsetrotationtype has been added
to switch between rotation point calculation methods; this command manipulates
variables that are passed to the StartRotation command on mouse move and right
button click.
Modified entities:
Aspect.cdl - New enumeration Aspect_ViewRotationType has been added.
Bnd_Box.cdl - Two methods ProjectedPoints, IntersectionPoints has been added.
TColgp.cdl - New class TColgp_Array1OfPln has been added.
V3d_View.cdl - New methods FrustumPlanes and PointOfRotation has been added.
Viewer_ViewRotationTool.cxx - new class has been added.
ViewerTest_ViewerCommands.cxx - new method VSetRotationType has been added.
Improvements:
Two new approaches has been developed for rotating the model in the view. In
addition to the older algorithm when the displayed model in the view was
rotated around its gravity point, the new algorithms take for rotation more
appropriate point that provides more convenient method, similar to turning the
camera. There are two new methods: first calculates rotation point depending on
the objects displayed inside of the view that are visible, and the second
calculates rotation point in the same manner with priority of the closest
object in center of the view providing the rotation of the model around this
object. These methods calculate rotation point not the same as the gravity
point, thus the model could go out of front and back view planes (ZSize), but
this solution provides an option that enables automated recalculation of the
view planes for such rotations.
The mathematical part of solution is developed as an utility tool, which could
be reused with any viewer that could provide information on displayed objects
such as bounding boxes and its viewing volume geometrical properties.
You might need to revise code of your application to enable use of these new
approaches. The gravity point will be selected by default as point of rotating
the model when porting your application.
Changes:
Gravity point calculation has been fixed, in the case when the zoomed object
inside of the view the gravity point is taken as the object's center. Two new
approaches to calculate model rotation point has been added: these approaches
project the model on the ray that goes from the center of the view in front
direction, and find average point on it. New enumeration
Aspect_ViewRotationType has been added to define the rotation point calculation
algorithms. The rotation type and option to automatically recompute front and
back view planes (ZSize) is specified for the V3d view in the method
StartRotation that calculates the point of model rotation.
There are changes in the following packages:
Aspect package:
1) New enumeration Aspect_ViewRotationType has been added
Bnd package:
Bnd_Box class:
1) New methods has been added to Bnd_Box class: project its bounding points on
the line (Bnd_Box::ProjectedPoints (const gp_Lin& theLine)), find intersection
points of the line with bounding box (Bnd_Box::IntersectionPoints (const
gp_Lin& theLine))
TColgp package:
1) TColgp_Array1OfPln class has been defined in cdl.
V3d package:
V3d_View class:
1) Gravity method has been corrected;
2) StartRotation method now has two new arguments: theViewRotationType and
FitZSize to provide services of new approaches for calculating the rotation
point and automatically ZSize calculation;
3) FrustumPlanes method has been added, this method calculates view volume
planes of the view, normals of planes are oriented outside the viewing volume;
4) PointOfRotation method has been added, this method uses utility tool to
compute the point of model rotation depending on the bounding boxes and view
volume.
Viewer package:
Viewer_ViewRotationTool class:
1) New class Viewer_ViewRotationTool has been added, this class provides
services for interactive rotation point calculation. This class could be reused
with other viewers.
ViewerTest package:
1) ViewerTest_ViewerCommands.cxx: new command vsetrotationtype has been added
to switch between rotation point calculation methods; this command manipulates
variables that are passed to the StartRotation command on mouse move and right
button click.
Modified entities:
Aspect.cdl - New enumeration Aspect_ViewRotationType has been added.
Bnd_Box.cdl - Two methods ProjectedPoints, IntersectionPoints has been added.
TColgp.cdl - New class TColgp_Array1OfPln has been added.
V3d_View.cdl - New methods FrustumPlanes and PointOfRotation has been added.
Viewer_ViewRotationTool.cxx - new class has been added.
ViewerTest_ViewerCommands.cxx - new method VSetRotationType has been added.
Public activity
10 archived notes
Participants are labeled by their role within this record.
Hello,
Here are some remarks concerning the source code, all of "Code style" and "Comments" type.
1. V3d_View.cdl, StartRotation() method - documentation should be updated
2. V3d_View.cxx, line 3175 - here some explanations expected to mention why the code for orthographic projection only is implemented
3. V3d_View.cxx, all changed code fragments - opening braces "{" should be on the same line as corresponding statement(if, else, for), similarly to the rest of the file.
4. Viewer_ViewRotationTool class - it has static methods only, why those methods cannot be the package methods of Viewer package and are not declared in Viewer.cdl? Do we really need a new class for that?
5. Bnd_Box.cxx, lines 1161, 1189, 1192, 1195 - opening "{" should be on the same line as "if"/"for" statements.
6. Aspect.cdl, Aspect_ViewRotationType enumeration - for me, explanation of each rotation type's meaning is not clear ("gravity" most likely means "gravity center" here, right? it is better to use clear wording to avoid questions from the community), especially for VRT_OBJECTSINCENTER.
It would be great to have an example of situation when each rotation type is suitable. Ideally, Visualization User's Guide should be also updated with some illustrations explaining different rotation types.
[signature removed]
Sergey
Here are some remarks concerning the source code, all of "Code style" and "Comments" type.
1. V3d_View.cdl, StartRotation() method - documentation should be updated
2. V3d_View.cxx, line 3175 - here some explanations expected to mention why the code for orthographic projection only is implemented
3. V3d_View.cxx, all changed code fragments - opening braces "{" should be on the same line as corresponding statement(if, else, for), similarly to the rest of the file.
4. Viewer_ViewRotationTool class - it has static methods only, why those methods cannot be the package methods of Viewer package and are not declared in Viewer.cdl? Do we really need a new class for that?
5. Bnd_Box.cxx, lines 1161, 1189, 1192, 1195 - opening "{" should be on the same line as "if"/"for" statements.
6. Aspect.cdl, Aspect_ViewRotationType enumeration - for me, explanation of each rotation type's meaning is not clear ("gravity" most likely means "gravity center" here, right? it is better to use clear wording to avoid questions from the community), especially for VRT_OBJECTSINCENTER.
It would be great to have an example of situation when each rotation type is suitable. Ideally, Visualization User's Guide should be also updated with some illustrations explaining different rotation types.
[signature removed]
Sergey
Dear Anton,
Could you please refresh the status of this fix?
Could you please refresh the status of this fix?
This bug is still assigned and needs correction of remarks
Dear apl,
please analyze workload required to re-done the progress on this issue to current master and finalize integration.
please analyze workload required to re-done the progress on this issue to current master and finalize integration.
Branch [archived branch] has been created by Participant.
[revision removed]
No new revisions were added by this update.
[revision removed]
No new revisions were added by this update.
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: duv
Date: Tue Mar 10 15:15:07 2015 +0300
0002618: Visualization - choose better center of gravity for camera rotation operations
Gravity point set to camera center.
[revision removed]
Detailed log of new commits:
Author: duv
Date: Tue Mar 10 15:15:07 2015 +0300
0002618: Visualization - choose better center of gravity for camera rotation operations
Gravity point set to camera center.
Alternative solution was implemented in advanced visualization demo. New camera concept introduced in OCCT 6.8.0 allows us to use camera "Center" point as "Gravity" point for rotation operations. Center point of camera doesn't get affected by scene contents directly. Thus we may achieve stable and predictable camera behavior.
Implementation available at branch CR2618_1.
Implementation available at branch CR2618_1.
Please switch into VERIFIED state.
Patch for #0030507 introduced AIS_RotationMode enumeration, including AIS_RotationMode_PickLast handy for rotating around picked point.
Applications may also override AIS_ViewController::GravityPoint() method to customize this behavior further in desired way, since there is no good answer to the question how to rotate camera in orbit mode within arbitrary geometry.
Patch for #0030507 introduced AIS_RotationMode enumeration, including AIS_RotationMode_PickLast handy for rotating around picked point.
Applications may also override AIS_ViewController::GravityPoint() method to customize this behavior further in desired way, since there is no good answer to the question how to rotate camera in orbit mode within arbitrary geometry.
Branch [archived branch] has been deleted by Commenter 1.
[revision removed]
[revision removed]
Related records
- #0022520 · related to · closedUpdate Visualization Users Guide
- #0030507 · related to · closedVisualization - introduce AIS_ViewController
- #0006784 · has duplicate · closedNon predicted position of rotation center in View 3d
- #0024617 · related to · closedAxial scale of view is ignored when computing rotation Gravity point
- #0025723 · related to · closedVisualization, TKV3d - the center of rotation should be calculated taking into account structure visibility and selection flags