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 

How to make isometric view


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum]
View previous topic :: View next topic  
Author Message
jgarneau
Newbie


Joined: 06 Mar 2018
Posts: 2

PostPosted: Thu Mar 08, 2018 4:33 pm    Post subject:
How to make isometric view
Reply with quote

Hi,

I'm trying to figure out how to render my scene as an isometric view.
I have not found a complete example.
I have some boxes in my scene, so I compute the bounding box of the root node an using "getCamera()->setViewMatrixAsLookAt(eye, center, up) but it is not really orthogonal.
Can someone have example to compute the eye position for isometric view?

Thank you!

Cheers,
Jean-Yves
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11622

PostPosted: Fri Mar 16, 2018 12:04 pm    Post subject:
How to make isometric view
Reply with quote

Hi Jean-Yves,

On 8 March 2018 at 16:33, Jean-Yves Garneau
<> wrote:
Quote:
I'm trying to figure out how to render my scene as an isometric view.
I have not found a complete example.
I have some boxes in my scene, so I compute the bounding box of the root node an using "getCamera()->setViewMatrixAsLookAt(eye, center, up) but it is not really orthogonal.
Can someone have example to compute the eye position for isometric view?


For a isometric view you'll need to set the view and projection
matrices. I don't have an OSG example of doing an isometric view but
it shouldn't be hard. The Camera set up for a map view will be
something like:

osg::BoundingSphere bs = scenegraph->getBound();
double r = bs.radius();
view->getCamera()->setProjectionMatrixAsOrtho(-r, r, -r, r, -r, r);
view->getCamera()->setViewMatrixAsLookAt(bs.center()+osg::Vec3d(0.0,
0.0, r), bs.center(), osg::Vec3d(0.0, 1.0, 1.0));

Cheers,
Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
jgarneau
Newbie


Joined: 06 Mar 2018
Posts: 2

PostPosted: Fri Mar 16, 2018 1:11 pm    Post subject:
Reply with quote

Thank you Robert for your answer.

Sometimes things seem to be very simple but when you are beginner, you miss details. It seem not to be enough to use the setViewMatrixAsLookAt() because I used setCameraManipulator(new osgGA::TrackballManipulator). I must used this :


Code:

viewer->setCameraManipulator(new osgGA::TrackballManipulator);
viewer->getCamera()->setProjectionMatrixAsOrtho(-1.0f, 1.0f, -1.0, 1.0f, -1.0f, 1.0f);
osg::Vec3 eye(1.0, -1.0, 1.0);
osg::Vec3 center(0.0, 0.0, 0.0);
osg::Vec3 up(0.0, 0.0, 1.0);
viewer->getCameraManipulator()->setHomePosition(eye, center, up);
viewer->setSceneData(root);



Now it's work well.

Thank you!

Regards,
Jean-Yves Garneau
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11622

PostPosted: Fri Mar 16, 2018 1:22 pm    Post subject:
How to make isometric view
Reply with quote

HI Jean-Yves,

On 16 March 2018 at 13:11, Jean-Yves Garneau
<> wrote:
Quote:
Sometimes things seem to be very simple but when you are beginner, you miss details. It seem not to be enough to use the setViewMatrixAsLookAt() because I used setCameraManipulator(new osgGA::TrackballManipulator). I must used this :

Code:

viewer->setCameraManipulator(new osgGA::TrackballManipulator);
viewer->getCamera()->setProjectionMatrixAsOrtho(-1.0f, 1.0f, -1.0, 1.0f, -1.0f, 1.0f);
osg::Vec3 eye(1.0, -1.0, 1.0);
osg::Vec3 center(0.0, 0.0, 0.0);
osg::Vec3 up(0.0, 0.0, 1.0);
viewer->getCameraManipulator()->setHomePosition(eye, center, up);
viewer->setSceneData(root);

This make sense for when you are using a Camera manipulator. I would
advise caution with using standard osgGA camera manipulators with an
orthographic view as the zooming behaviour that works well for a
perspective view won't work with an orthographic view. All of the
osgGA camera manipulators are written for perspective views. If you
do do an interactive view then I would recommend implementing your own
camera manipulator, or just managing the view yourself by setting the
view and projection matrix in the main loop.

Robert.


------------------
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 [forum] 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 View coordinates of a 3D point arennuit General 5 Fri Mar 16, 2018 12:37 pm View latest post
No new posts How OpenSource make a profit xiaoming General [forum] 2 Tue Jan 16, 2018 1:21 am View latest post
No new posts make install_ld_conf does not work n ... wartburgritter Build system [build] 1 Fri Dec 22, 2017 7:44 pm View latest post
No new posts When gets the view matrix of a camera... wernerM General 2 Sat Nov 18, 2017 4:08 pm View latest post
No new posts Make ObjOptionsStruct in obj plugin a... Ralf Habacker Submission 1 Fri Oct 20, 2017 8:31 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