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 

ScalarsToColors returns a wrong color in case a value larger max is passed to getColor


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


Joined: 20 Mar 2009
Posts: 86

PostPosted: Sun Nov 20, 2016 4:40 pm    Post subject:
ScalarsToColors returns a wrong color in case a value larger max is passed to getColor
Reply with quote

Hi,

ScalarsToColors should return values from black to white. But if the passed value to getColor is larger than max also black is returned (see code below).

Code:

osg::Vec4 ScalarsToColors::getColor(float scalar) const
{
    if(scalar<_min) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);
    if(scalar>_max) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);

    float c = (_min+scalar)/(_max-_min);
    return osg::Vec4(c,c,c,1.0);
}


This code should be corrected to
Code:

osg::Vec4 ScalarsToColors::getColor(float scalar) const
{
    if(scalar<_min) return osg::Vec4(0.0f,0.0f,0.0f,1.0f);
    if(scalar>_max) return osg::Vec4(1.0f,1.0f,1.0f,1.0f);

    float c = (_min+scalar)/(_max-_min);
    return osg::Vec4(c,c,c,1.0);
}


Thank you!

Cheers,
Hartwig
Back to top
View user's profile Send private message
Michal Ďurkovič
Guest





PostPosted: Sun Nov 20, 2016 6:52 pm    Post subject:
ScalarsToColors returns a wrong color in case a value larger max is passed to getColor
Reply with quote

---------- Forwarded message ----------
From: "Hartwig Wiesmann" < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Date: kkomkmzmo m m zmcd dažde na Nov 2016 5:40 pm
Subject: ScalarsToColors returns a wrong color in case a value larger max is passed to getColor
To: <éferehlhleehehxwzwXs cd xwse rez ffflwzzaanscenegraph.org>
Cc:
Quote:
Hi,

ScalarsToColors should return values from black to white. But if the passed value to getColor is larger than max also black is returned (see code below).


Code:

osg::Vec4 ScalarsToColors::getColor(float scalar) const
{
    if(scalar<_min) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);
    if(scalar>_max) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);

    float c = (_min+scalar)/(_max-_min);
    return osg::Vec4(c,c,c,1.0);
}




This code should be corrected to

Code:

osg::Vec4 ScalarsToColors::getColor(float scalar) const
{
    if(scalar<_min) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);
    if(scalar>_max) return osg::Vec4(1.0f,1.0f,1.0f,1.0f);

    float c = (_min+scalar)/(_max-_min);
    return osg::Vec4(c,c,c,1.0);
}




Thank you!

Cheers,
Hartwig

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





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


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


Joined: 18 Mar 2009
Posts: 10799

PostPosted: Fri Dec 23, 2016 5:21 pm    Post subject:
ScalarsToColors returns a wrong color in case a value larger max is passed to getColor
Reply with quote

Thanks Harwig, I've applied the change to git master, 3.2 and 3.4
branches. In future could post a git pull request or the whole
modified file as these approaches are far more reliable. Cheers
Rober6

On 20 November 2016 at 16:40, Hartwig Wiesmann
<> wrote:
Quote:
Hi,

ScalarsToColors should return values from black to white. But if the passed value to getColor is larger than max also black is returned (see code below).


Code:

osg::Vec4 ScalarsToColors::getColor(float scalar) const
{
if(scalar<_min) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);
if(scalar>_max) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);

float c = (_min+scalar)/(_max-_min);
return osg::Vec4(c,c,c,1.0);
}




This code should be corrected to

Code:

osg::Vec4 ScalarsToColors::getColor(float scalar) const
{
if(scalar<_min) return osg::Vec4(0.0f,0.0f,0.0f,0.0f);
if(scalar>_max) return osg::Vec4(1.0f,1.0f,1.0f,1.0f);

float c = (_min+scalar)/(_max-_min);
return osg::Vec4(c,c,c,1.0);
}




Thank you!

Cheers,
Hartwig

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








------------------
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 -> Submission 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 wireframe darker wrt the surface color gambr General 5 Tue Mar 21, 2017 4:00 pm View latest post
No new posts using ref_ptr in any case Meldryt General 2 Mon Mar 20, 2017 1:41 pm View latest post
No new posts Matrices interpreted wrong in AC load... freqfly Plugins [osgPlugins] 7 Sun Mar 12, 2017 4:37 am View latest post
No new posts Secondary Color not working? umesh General 0 Tue Feb 14, 2017 10:37 am View latest post
No new posts Version 3.5.6 osgText::Text bounding ... dcfennell General 0 Tue Jan 31, 2017 5:40 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