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 

Scale object based on camera distance


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Moohasha
Newbie


Joined: 04 Jan 2019
Posts: 2

PostPosted: Fri Jan 04, 2019 4:57 pm    Post subject:
Scale object based on camera distance
Reply with quote

I have certain nodes/objects in my scene that I always want to be the same size regardless of their distance from the camera and I'm trying to figure out the best way to go about doing this. My first thought is to create a custom NodeCallback to add to the node as a cull callback and then get the distance from the node to the camera and apply the appropriate scale to the node (as a MatrixTransform). Is that a reasonable approach?

The other thing I'm struggling with is how to calculate the proper scale. What I'd like is for the object's geometry to translate to pixel units, meaning if the vertices range from (-10, -10, -10) to (10, 10, 10), then it would take up roughly 20x20 pixels on the screen when scaled. Rather than fumbling around with different matrices and transforms trying to get this to work, I thought I'd try asking first.
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Mon Jan 07, 2019 6:22 am    Post subject:
Scale object based on camera distance
Reply with quote

Hi David,


have a look at osg::AutoTransform



On Mon, Jan 7, 2019 at 1:41 AM David Mitchell < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
I have certain nodes/objects in my scene that I always want to be the same size regardless of their distance from the camera and I'm trying to figure out the best way to go about doing this.  My first thought is to create a custom NodeCallback to add to the node as a cull callback and then get the distance from the node to the camera and apply the appropriate scale to the node (as a MatrixTransform).  Is that a reasonable approach?

The other thing I'm struggling with is how to calculate the proper scale.  What I'd like is for the object's geometry to translate to pixel units, meaning if the vertices range from (-10, -10, -10) to (10, 10, 10), then it would take up roughly 20x20 pixels on the screen when scaled.  Rather than fumbling around with different matrices and transforms trying to get this to work, I thought I'd try asking first.

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





_______________________________________________
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
Moohasha
Newbie


Joined: 04 Jan 2019
Posts: 2

PostPosted: Mon Jan 07, 2019 2:38 pm    Post subject:
Reply with quote

Thanks, Trajce. That looks like it will do what I need. Since this was my first post to the forums, apparently it wouldn't show up until an admin approved it and during that time I was able to modify the GeoPositionNodeAutoScaler class from osgEarth to do what I need it to. Looking at osg::AutoTransform, it looks like it's doing more or less the same thing, but is more involved. My solution ended up being a little more specialized for my use case.
Back to top
View user's profile Send private message
Chris Hanson
Guest





PostPosted: Mon Jan 07, 2019 3:23 pm    Post subject:
Scale object based on camera distance
Reply with quote

Are you using osgEarth?

On Mon, Jan 7, 2019 at 3:38 PM David Mitchell < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Thanks, Trajce.  That looks like it will do what I need.  Since this was my first post to the forums, apparently it wouldn't show up until an admin approved it and during that time I was able to modify the GeoPositionNodeAutoScaler class from osgEarth to do what I need it to.  Looking at osg::AutoTransform, it looks like it's doing more or less the same thing, but is more involved.  My solution ended up being a little more specialized for my use case.

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





_______________________________________________
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



--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
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 Projection matrix with camera looking... AlexSavo General 0 Thu Jul 25, 2019 2:34 am View latest post
No new posts osgVIEWER problem camera skehal General 1 Tue Jul 23, 2019 9:17 am View latest post
No new posts Keeping camera fixed alasca General 3 Fri May 31, 2019 10:08 am View latest post
No new posts Implementation of movement, rotation ... arfaa General 2 Thu May 30, 2019 10:32 am View latest post
No new posts adding object models in osgEarth best... Db80 General 10 Tue Apr 30, 2019 6:12 pm 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