OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Zoom in to special area and special object


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Daven Hem (Daven Hem)
Newbie


Joined: 08 Jul 2016
Posts: 11
Location: Phnom Penh

PostPosted: Wed Feb 22, 2017 2:35 am    Post subject:
Zoom in to special area and special object
Reply with quote

Hello, everyone!
I hope you are doing well.
Using osgEarth, I think that mouse interface is very good.
While mouse right dragging, we can zoom in or zoom out smoothly.
If we double click on terrain, camera will move smoothly as flying and zoom in.

1. I’m trying to zoom in to special rectangle area by mouse right drag & drop.
- Dash lined rectangle should be drawn while mouse right dragging
- When mouse right drop, the rectangle area of the scene should be done zoom in
Please find my attached image. You can understand at first sight.

2. I’m trying to zoom in to terrain and to special object (such as box, sphere, polygon, line, 3ds, obj...) by mouse left double click.

I have just read about 800 posts about camera zoom on forum.osgearth.org but I have not found a solution.
How can I do that? Please teach me.
Thanks for your time.
Back to top
View user's profile Send private message Send e-mail
Steal
User


Joined: 26 Jan 2017
Posts: 60

PostPosted: Wed Feb 22, 2017 8:50 am    Post subject:
Reply with quote

Hi,

I'm not sure how redundant it is to say this, but you could use a field-of-view zoom. This would be closest to a camera zoom that I can think of.

I am a beginner with the library and this is probably not the neatest way to do it, but here's a snippet.
Code:

double fovy, aspectRatio, zNear, zFar;

camera->getProjectionMatrix().getPerspective(fov, aspectRatio, zNear, zFar);
fov = 45;
camera->getProjectionMatrix().makePerspective(fov, aspect, zNear, zFar);


You may just want to move the camera closer though, a field-of-view zoom is kind of dingy.

Also I wouldn't get too frustrated with how OSG hides itself behind mandatory callbacks and the like. I believe it also does this for its threading model. Not using pre/post callbacks is a potential crash when (viewer) threading is on.

Thank you!

Cheers,
Johny
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 796

PostPosted: Wed Feb 22, 2017 9:19 am    Post subject:
Zoom in to special area and special object
Reply with quote

Hi Daven
Quote:
Hello, everyone!
I hope you are doing well.
Using osgEarth, I think that mouse interface is very good.
While mouse right dragging, we can zoom in or zoom out smoothly.
If we double click on terrain, camera will move smoothly as flying and zoom in.

1. I’m trying to zoom in to special rectangle area by mouse right drag & drop.
- Dash lined rectangle should be drawn while mouse right dragging
- When mouse right drop, the rectangle area of the scene should be done zoom in
Please find my attached image. You can understand at first sight.

2. I’m trying to zoom in to terrain and to special object (such as box, sphere, polygon, line, 3ds, obj...) by mouse left double click.

You need to calculate the FoV angles in both cases based on your camera
position and the size of the object in both cases*. If you need to
combine it with flying there I'd interpolate between the current FoV and
the new one while moving towards the object.

*Basically you can think of a triangle with the height being your
distance to the object and the base length being on of your object's
dimensions in the projection. Use trigonometry and figure out the angles
you need to put in to your projection.

Cheers
Sebastian
Quote:

I have just read about 800 posts about camera zoom on forum.osgearth.org but I have not found a solution.
How can I do that? Please teach me.
Thanks for your time.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70304#70304








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts scene object not receiving/casting sh... Meldryt General 0 Thu May 11, 2017 8:01 am View latest post
No new posts Scale problem while transforming obje... YuraIU02 General 1 Sat Apr 15, 2017 4:26 pm View latest post
No new posts How to get Node object from PositionA... nghien_rbc General 1 Sat Apr 15, 2017 3:05 am View latest post
No new posts How to get the orientation of 3d object? Jiechang Guo General 2 Mon Apr 10, 2017 2:14 pm View latest post
No new posts How to use frame buffer object in exi... saedrna1 General 2 Sat Feb 18, 2017 3:54 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP