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: 11154

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 CompositeViewer:: checkNeedToDoFrame(... makulis General 3 Sun Sep 24, 2017 9:26 pm View latest post
No new posts ViewerBase::frame() method slow after... gambr General 8 Fri Jul 21, 2017 9:11 am View latest post
No new posts How to color each character of an osg... lq37 General 0 Thu Jun 22, 2017 1:31 pm View latest post
No new posts background color for osgWidget::Input Meldryt General 0 Tue Jun 20, 2017 12:36 pm View latest post
No new posts wireframe darker wrt the surface color gambr General 10 Tue Mar 21, 2017 4:00 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