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 

scene snapshot


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Trajce Nikolov NICK
Guest





PostPosted: Wed Aug 30, 2017 6:39 am    Post subject:
scene snapshot
Reply with quote

Hi community,


this is easy but I am struggling with. Here is the story:


I have scene (terrain tile) and I want to take a snapshot in ortho (to make a texture out of the scene snapshot). I have RTT camera and an image as an attachment. The scene is added as a child to this camera. What would be the settings for the Projection and the View matrix for the RTT camera?


Thanks a bunch as always
--

trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11152

PostPosted: Wed Aug 30, 2017 8:00 am    Post subject:
scene snapshot
Reply with quote

Hi Nick,

On 30 August 2017 at 07:38, Trajce Nikolov NICK < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
I have scene (terrain tile) and I want to take a snapshot in ortho (to make a texture out of the scene snapshot). I have RTT camera and an image as an attachment. The scene is added as a child to this camera. What would be the settings for the Projection and the View matrix for the RTT camera?


Just have a look at the osg::Camera header for the setViewMatrixAs*() and setProjectionMatrix*() methods, they all have GL/GLU counterparts so general OpenGL documentation on view and projection matrices apply (it's why I chose to use exactly the same naming).


Exactly what the settings should be will depend upon your application needs, it's not something we know so can't can't provide specific guidance on, you'll need to work these out.


As a general comment, to help debug the settings I would recommend creating a osg::Camera that renders on top of the main window, like a traditonal map view, and once you are confident that the view and projection matrix settings make sense you can then just change the Camera to be an offscreen one.



Robert.

 

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


Joined: 22 Jun 2010
Posts: 355

PostPosted: Wed Aug 30, 2017 9:57 am    Post subject:
Reply with quote

Hi Nick,
I'm not sure my scenario is like mine but hope this code snippet may help:

Code:

void setViewTowardsXMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(nodeTrackerManipulator->getDistance(), 0.0, 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsXPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(-nodeTrackerManipulator->getDistance(), 0.0, 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsYMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, nodeTrackerManipulator->getDistance(), 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsYPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, -nodeTrackerManipulator->getDistance(), 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsZMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, 0.0, nodeTrackerManipulator->getDistance())), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsZPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3(0.0f, 0.0f, -nodeTrackerManipulator->getDistance())), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

osg::Vec3d computeEye(const osg::Vec3d& iEye)
{
   osg::Vec3d eye = iEye;
   ...
   double psi, theta, phi;
   graphicObject->getInitialRotation(psi, theta, phi);
   osg::Quat initAttitude = viosg::quatFromBody313(psi, theta, phi);
   eye = initAttitude * graphicObject->getTransformNode()->getAttitude() * eye;
   return eye;
}


Cheers,
Gianni
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Wed Aug 30, 2017 11:07 am    Post subject:
scene snapshot
Reply with quote

Hi Gianni, Robert,


yes, this will be like map view. I am familiar with the Camera interface and the GL/GLU counterparts. The projection matrix should for sure be ortho2D, just struggling with the view matrix how to set it up to have the scene to fit exactly in ... thinking ... 


Thanks for any hint


On Wed, Aug 30, 2017 at 11:57 AM, Gianni Ambrosio <g.ambrosio+ ([email]g.ambrosio+[/email])> wrote:
Quote:
Hi Nick,
I'm not sure my scenario is like mine but hope this code snippet may help:


Code:

void setViewTowardsXMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(nodeTrackerManipulator->getDistance(), 0.0, 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsXPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(-nodeTrackerManipulator->getDistance(), 0.0, 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsYMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, nodeTrackerManipulator->getDistance(), 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsYPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, -nodeTrackerManipulator->getDistance(), 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsZMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, 0.0, nodeTrackerManipulator->getDistance())), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsZPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3(0.0f, 0.0f, -nodeTrackerManipulator->getDistance())), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

osg::Vec3d computeEye(const osg::Vec3d& iEye)
{
   osg::Vec3d eye = iEye;
   ...
   double psi, theta, phi;
   graphicObject->getInitialRotation(psi, theta, phi);
   osg::Quat initAttitude = viosg::quatFromBody313(psi, theta, phi);
   eye = initAttitude * graphicObject->getTransformNode()->getAttitude() * eye;
   return eye;
}




Cheers,
Gianni

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
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 Display one scene, pick from another one arennuit General 8 Fri Sep 08, 2017 11:50 am View latest post
No new posts MFC mdi child windows show the scene ... rposg General 1 Fri May 26, 2017 6:37 pm View latest post
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 Recommended way to render a scene fro... Hannes Naude General 6 Tue Apr 11, 2017 11:12 am View latest post
No new posts Covert and use 3ds Max scene to OpenS... lucia General 0 Mon Mar 06, 2017 9:19 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