View Full Version : Coloring mesh using color index
03-24-2005, 07:05 PM
I am working on a project that reads USGS data (NED Gridfloats) and displays the mesh as a set of triangles.
I am trying to map the height (array of floats) to a color bar (pre-set). I am basically setting arrays for r, b, g under a structure (coord.r, coord.g, coord.b).
I am, though having some problems in mapping the colors to the height.
Any ideas on how to efficiently do that?
If I understand correctly, you want to asign a color based on just the height.
Scroll down to about 80%. There's a bit about the texture matrix there.
It describes contour lines.
The difference IMO with your case is just the scale and colours of the texture you'd use.
I'm not sure if this will work with your program I havn't loaded files yet but what I do with something like this is I choose/find the maximum hight of the model and when you look for the color of all the other points just divide them by the max hight and you'l get a # between 1 and 0 and I just use that for the colors.
03-25-2005, 07:09 AM
That is a fairly naive approach. Instead, I would recommend you calculate the stdDev of the heights, select how many stdDev from mean you will consider.
Pick the min and max from the truncated distribution, then mark all heights smaller or higher that your min,max, to 1.0. Mark the rest by using the float((X[n] - min))/float((max-min)) This will allow you to see details, and variations in height "in between". You only get 256 shades in any case, so your precision is poor to begin with.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.