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 

Efficient way to swap colors


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


Joined: 06 Dec 2013
Posts: 45

PostPosted: Tue Sep 05, 2017 4:31 pm    Post subject:
Efficient way to swap colors
Reply with quote

Hello all

I have a mesh (a osg::Geometry) which I would like to change color depending on the mode it s in:

  • osg::Geometry all white by default
  • osg::Geometry all blue when selected


In order to achieve this I thought of using the BIND_OVERALL mode with 2 Vec3Arrays (one array for the white color and the other one for the blue color) and simply swapping arrays to change the color (with osg::Geometry::setColorArray()), and calling dirtyDisplayList() to update.

Is this the most efficient way of changing the osg::Geometry color?

Thanks a lot,

Antoine.
Back to top
View user's profile Send private message
tianzjyh
Guest





PostPosted: Wed Sep 06, 2017 1:34 am    Post subject:
Efficient way to swap colors
Reply with quote

Hi, Antoine,
I think changing the material of the geometry will be more efficient. Have a look at examples about osg::Material Smile




--
Cheers,
TianZJ




Quote:
At 2017-09-06 00:31:11, "Antoine Rennuit" <> wrote:
Quote:
In order to achieve this I thought of using the BIND_OVERALL mode with 2 Vec3Arrays (one array for the white color and the other one for the blue color) and simply swapping arrays to change the color (with osg::Geometry::setColorArray()), and calling dirtyDisplayList() to update.

Is this the most efficient way of changing the osg::Geometry color?
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71629#71629



------------------
Post generated by Mail2Forum
Back to top
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 789

PostPosted: Wed Sep 06, 2017 7:24 am    Post subject:
Efficient way to swap colors
Reply with quote

Hi Antoine,
Quote:
Hello all

I have a mesh (a osg::Geometry) which I would like to change color depending on the mode it s in:

osg::Geometry all white by default

osg::Geometry all blue when selected



In order to achieve this I thought of using the BIND_OVERALL mode with 2 Vec3Arrays (one array for the white color and the other one for the blue color) and simply swapping arrays to change the color (with osg::Geometry::setColorArray()), and calling dirtyDisplayList() to update.

Don't use display lists if you're planning on updating geometry on a
regular base (since rebuilding a display list can be a rather costly
operation). Use vertex buffer objects instead. In case you're modifying
the complete geometry but no individual faces, you might consider using
osg::Material or if you're using shaders anyways, simply set a uniform
describing your color and specify it in the geometries state set.



Quote:

Is this the most efficient way of changing the osg::Geometry color?
Depends ;-)

There usually isn't one most efficient way. In your case, swapping might
be efficient, but you simply need to benchmark and decide for yourself
which fits the bill.

Cheers
Sebastian
Quote:

Thanks a lot,

Antoine[/list][/list]

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









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


Joined: 06 Dec 2013
Posts: 45

PostPosted: Wed Sep 06, 2017 8:29 am    Post subject:
Reply with quote

Sebastien, TianZJ,

Thanks a lot for your relevant answers!

Antoine
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 Select StateSet subset to render basi... chunyanggou General 0 Wed Jul 26, 2017 9:17 am View latest post
No new posts Text colors in shaders wernerM General 5 Fri Feb 24, 2017 12:00 pm View latest post
No new posts Most efficient way to get the gl_Mode... mille25 General 1 Tue Jun 21, 2016 12:20 pm View latest post
No new posts reset root color to original colors Bruno Oliveira General 4 Tue May 24, 2016 10:25 pm View latest post
No new posts Seeking advice: Efficient method for ... AffineMess General 5 Tue Sep 08, 2015 10:35 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