Archived

This topic is now archived and is closed to further replies.

NewbieA

3D colour graph?

Recommended Posts

NewbieA    122
Hello, I''m making a 3D graph, in OpenGL. I got the data ploted. But couldn''t get the colour right. You know, a curve in a 3D graph. They have white/light colour for the peak, and some dark colour for the valley. How do i do that? Thanks for any help

Share this post


Link to post
Share on other sites
The graph is something like z = x*x/9+y*y/8 or something right? So the graph changes along the z axis. Just find the max z value you ever plot, and the min z value you ever plot and change the color accordingly.
Like is max is the max z value and min is the min z value and z is the current z value,
c = (z-min)/(max-min)
Then, assuming you use floats for colors, set the color to c,c,c. Then graph will be brighter closer to the max values and darker towards the min values.
Changing to 0-255 is easy, if you need that.

--------------------------------------------------------
Life would be so much easier if we could just get the source code.

Share this post


Link to post
Share on other sites
NewbieA    122
Yes, that''s exactly what i''m trying to do. I got this bit right [ c = (z-min)/(max-min) ]. But then the colour thing came...
Oh, is there any way to add more colour to the graph?
Thanks

Share this post


Link to post
Share on other sites