Quad Mesh question

Quad Mesh question

On a quad mesh you setup a table of M by N vectors describing the verticies of a quadrangles. No problem here.
The question is on the Color Source. When I create a table for color source is it also M by N or is it M-1 by N-1?
My suspicion is that this depends on if Surface Flat Shading is enabled or disabled. i.e Flat Shading checked is M-1 by N-1. When not Flat Shading then use M by N.
Is this correct? Or with Flat Shading do you supply M by N but use M-1 by N-1 as a protective measure against the user flipping the Flat Shading check box.
Your comments will be appreciated.
Jim Dempsey

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The quadmesh will look for MxN colors if FlatShading is false, or (M-1)x(N-1) if FlatShading is true. Nothing too bad will happen if the color array is not of sufficient size. For example if you supply a (M-1)X(N-1) array and then turn off FlatShading, when the AV code tries to get color values forelements such as (M,N)0 will be returned (i.e. totally transparent). This may not be exactly what you want, but at least there's no danger of the app crashing due to an invalid array access.

Thanks, I was concerned about crashing AV.

On the same subject I would like to have FlatShading Off but yet have crisp edges. I've tried placing a narrow quadmesh band aroung the object I am trying to draw (e.g. a continent on a sphere depicting Earth). I seem to get a bleed across the band. I will need to do some more experimentation to confirm this though.

And with quadmesh what would be wrong with specifying the mesh (the physical geometry) with M x N vectors and the ColorPlot with M*4 x N*4 colors. i.e. more than one color per quadrangle. It probably does not work that way but why not? Realize that the ColorPlot is an array of integer(4) or even an array of integer(1) but the mesh is typicaly real(4) or real(8) vectors. With this feature at an extream you could plot 4 points to provide a plane and then plot 1024x768 PlotColors to print a picture in the plane. If you draw more vectors (e.g. a sphere of 30x30 vectors) but put on 1000 x 1000 color patches you would then have a reasonably good looking picture of Earth without the computation overhead of a quadmesh of 1000x1000 vectors.

Jim Dempsey

Your idea of being able to have additional color data certainly makes sense. 30x30 quads will give a good geometric representation of a sphere while you'd like to have something like 512x512 for the image data of the earth.

We've actually had a simlar request to be able to layer image data ontop of Height plots.

I'll look into this some more.

Then the question to answer is how it would be implimented.

a) linearly interpolate a new mesh from the edges.

b) require a fixed ratio of map to plot e.g. 2x, 3x, x/2, x/3, ... in which each quadrangle gets wacked up with lineal interpolation.

Maybe this would be an option

In the case of a globe (Earth) it would be useful to enter a Mercator projection at a higher res. It could possibly be done by scanning to .BMP. And... As a feature you could permit the color path to point to C:/MyStuff/Picture.BMP and where the size (extents)of the color plot are taked from the .BMP file itself. If that doesn't work then perhaps avWatch can be modified to obtain the C:/MyStuff/Picture.BMP file.

What could be easier than that.

Jim Dempsey

Doing a linear interpolation should be fairly easy. The graphics hardware actually has support for this operation, so it will run fast on most systems. I'll add a property to indicate if the color data should be scaled to geometry or not.

Keep in mind that if you take a flat image and map it to a warped surface you'll get some distortion. In the case Mercator projection, this should work out OK since the distortion will just cancel out the original projection!

It only is a linear interpolation when the QuadMesh plots rectangles. As you point out the Mercator projection warps as it wraps over the globe. QuadMesh can also plot out other shapes than rectangles (e.g. a segment on a sphere). And the quadrangular shapes need not be consistantly (predictably) different.

Recall that Surface Flat Shading looks too chunky and Non-Flat Shading has too much "blead" when the quadrangles are few in number. One solution is to configure the quadrangles such that an edge of adjacent quadrangles follow the shape of the item being drawn (contenent for Earth) and you can use an extra set of quadrangles to have the edge line closely follow the first edge line that draws the contenent. In this manner the color transition occures over a short distance at the edge line of thefeature being drawn yet you can have fairly large distances across sections where the color is unchanged. This makes for greatly reducing the number of facits to be drawn.

Jim Dempsey

Leave a Comment

Please sign in to add a comment. Not a member? Join today